[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] new rule: ewmhnotify



* Florian Bruhin <me _at_ the _minus_ compiler _dot_ org> [2012-11-05 17:40:25 +0100]:
> It's raining PAAATCHEEES. *clears throat*

Damn. Not again. I should stop writing patches and start thinking when
writing mails.

Well, here is the patch.

-- 
() ascii ribbon campaign - stop html mail    www.asciiribbon.org
/\ www.the-compiler.org  | I love long mails http://email.is-not-s.ms/
BOFH excuse #124: user to computer ration too low. 
>From fdbab25551348c1d2b7fee87a4c326f8b919c9f2 Mon Sep 17 00:00:00 2001
From: Florian Bruhin <git _at_ the _minus_ compiler _dot_ org>
Date: Mon, 5 Nov 2012 16:00:57 +0100
Subject: [PATCH] New rule: ewmhnotify

This rule controls whether a client may know it was fullscreened or not.
---
 NEWS                 | 1 +
 doc/herbstluftwm.txt | 6 ++++++
 src/clientlist.c     | 5 +++++
 src/clientlist.h     | 2 ++
 src/ewmh.c           | 2 +-
 src/rules.c          | 7 +++++++
 src/rules.h          | 1 +
 7 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 3d91deb..8fa921a 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Changes:
     * clear the urgent flag on window focus
     * new command: list_padding
     * new commands: getenv/setenv/unsetenv
+    * new rule: ewmhnotify
 
 Release: 0.4.1 on 2012-08-30
 ----------------------------
diff --git a/doc/herbstluftwm.txt b/doc/herbstluftwm.txt
index b74e98b..0aaddf3 100644
--- a/doc/herbstluftwm.txt
+++ b/doc/herbstluftwm.txt
@@ -881,6 +881,12 @@ Each 'CONSEQUENCE' consists of a 'NAME'='VALUE' pair. Valid 'NAMES' are:
     fullscreen state requested by the window. 'VALUE' can be *on*, *off* or
     *toggle*, it defaults to *on*.
 
++ewmhnotify+::
+    sets whether hlwm should let the client know about EMWH changes (currently
+    only the fullscreen state). If this is set, applications do not change to
+    their fullscreen-mode while still being fullscreen. 'VALUE' can be *on*,
+    *off* or *toggle*, it defaults to *on*.
+
 +fullscreen+::
     sets the fullscreen flag of the client. 'VALUE' can be *on*, *off* or
     *toggle*.
diff --git a/src/clientlist.c b/src/clientlist.c
index c69dbb0..774e965 100644
--- a/src/clientlist.c
+++ b/src/clientlist.c
@@ -55,8 +55,10 @@ static HSClient* create_client() {
     hc->title = g_string_new("");
     hc->urgent = false;
     hc->fullscreen = false;
+    hc->ewmhfullscreen = false;
     hc->pseudotile = false;
     hc->ewmhrequests = true;
+    hc->ewmhnotify = true;
     return hc;
 }
 
@@ -639,6 +641,9 @@ void client_set_fullscreen(HSClient* client, bool state) {
     }
 
     client->fullscreen = state;
+    if (client->ewmhnotify) {
+        client->ewmhfullscreen = state;
+    }
     HSStack* stack = client->tag->stack;
     if (state) {
         stack_slice_add_layer(stack, client->slice, LAYER_FULLSCREEN);
diff --git a/src/clientlist.h b/src/clientlist.h
index 05faa2c..4781216 100644
--- a/src/clientlist.h
+++ b/src/clientlist.h
@@ -26,9 +26,11 @@ typedef struct HSClient {
     GString*    title;  // or also called window title; this is never NULL
     bool        urgent;
     bool        fullscreen;
+    bool        ewmhfullscreen; // ewmh fullscreen state
     bool        pseudotile; // only move client but don't resize (if possible)
     bool        neverfocus; // do not give the focus via XSetInputFocus
     bool        ewmhrequests; // accept ewmh-requests for this client
+    bool        ewmhnotify; // send ewmh-notifications for this client
     int         pid;
     struct HSSlice* slice;
 } HSClient;
diff --git a/src/ewmh.c b/src/ewmh.c
index eb61634..7c8d72b 100644
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -362,7 +362,7 @@ void ewmh_update_window_state(struct HSClient* client) {
         int     atom_index;
         bool    enabled;
     } client_atoms[] = {
-        { NetWmStateFullscreen,         client->fullscreen      },
+        { NetWmStateFullscreen,         client->ewmhfullscreen  },
         { NetWmStateDemandsAttention,   client->urgent          },
     };
 
diff --git a/src/rules.c b/src/rules.c
index 029d7a7..94e5bd0 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -58,6 +58,7 @@ DECLARE_CONSEQUENCE(consequence_pseudotile);
 DECLARE_CONSEQUENCE(consequence_fullscreen);
 DECLARE_CONSEQUENCE(consequence_switchtag);
 DECLARE_CONSEQUENCE(consequence_ewmhrequests);
+DECLARE_CONSEQUENCE(consequence_ewmhnotify);
 
 /// GLOBALS ///
 
@@ -83,6 +84,7 @@ static HSConsequenceType g_consequence_types[] = {
     { "pseudotile",     consequence_pseudotile      },
     { "fullscreen",     consequence_fullscreen      },
     { "ewmhrequests",   consequence_ewmhrequests    },
+    { "ewmhnotify",     consequence_ewmhnotify      },
 };
 
 GQueue g_rules = G_QUEUE_INIT; // a list of HSRule* elements
@@ -626,3 +628,8 @@ void consequence_ewmhrequests(HSConsequence* cons, HSClient* client,
     client->ewmhrequests = string_to_bool(cons->value.str, client->ewmhrequests);
 }
 
+void consequence_ewmhnotify(HSConsequence* cons, HSClient* client,
+                            HSClientChanges* changes) {
+    client->ewmhnotify = string_to_bool(cons->value.str, client->ewmhnotify);
+}
+
diff --git a/src/rules.h b/src/rules.h
index 736040d..11b2cb9 100644
--- a/src/rules.h
+++ b/src/rules.h
@@ -58,6 +58,7 @@ typedef struct {
     bool            switchtag; // if the tag may be switchted for focusing it
     bool            manage; // wether we should manage it
     bool            fullscreen;
+    bool            ewmhnotify; // whether to send ewmh-notifications
 } HSClientChanges;
 
 void rules_init();
-- 
1.8.0