[Pkg-mozext-commits] [firetray] 226/399: catch minimize event with PropertyNotify also.

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:23:48 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch dfsg-clean
in repository firetray.

commit 229fd20b5e37b8ae0b6d559ecb702f93a70e1102
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Wed Apr 11 13:45:45 2012 +0200

    catch minimize event with PropertyNotify also.
    
    TODO: maybe this is not needed, and we just need to be sure windows are
    subscribed to StructureNotifyMask (UnmapNotify)
---
 src/modules/FiretrayHandler.jsm      |    4 ++--
 src/modules/ctypes/linux/x11.jsm     |   25 +++++++++++++++++++++
 src/modules/linux/FiretrayWindow.jsm |   41 +++++++++++++++++++---------------
 3 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/src/modules/FiretrayHandler.jsm b/src/modules/FiretrayHandler.jsm
index 04e76f3..b82e2a1 100644
--- a/src/modules/FiretrayHandler.jsm
+++ b/src/modules/FiretrayHandler.jsm
@@ -188,14 +188,14 @@ firetray.Handler = {
   showAllWindows: function() {
     F.LOG("showAllWindows");
     for (let winId in firetray.Handler.windows) {
-      if (!firetray.Handler.windows[winId].visibility)
+      if (!firetray.Handler.windows[winId].visible)
         firetray.Handler.showSingleWindow(winId);
     }
   },
   hideAllWindows: function() {
     F.LOG("hideAllWindows");
     for (let winId in firetray.Handler.windows) {
-      if (firetray.Handler.windows[winId].visibility)
+      if (firetray.Handler.windows[winId].visible)
         firetray.Handler.hideSingleWindow(winId);
     }
   },
diff --git a/src/modules/ctypes/linux/x11.jsm b/src/modules/ctypes/linux/x11.jsm
index 2962c92..449f8e1 100644
--- a/src/modules/ctypes/linux/x11.jsm
+++ b/src/modules/ctypes/linux/x11.jsm
@@ -154,6 +154,29 @@ function x11_defines(lib) {
     { "time": this.Time },
     { "state": ctypes.int }     /* NewValue or Deleted */
   ]);
+  // typedef struct {
+  //      int x, y;                /* location of window */
+  //      int width, height;       /* width and height of window */
+  //      int border_width;        /* border width of window */
+  //      int depth;               /* depth of window */
+  //      Visual *visual;          /* the associated visual structure */
+  //      Window root;             /* root of screen containing window */
+  //      int class;               /* InputOutput, InputOnly*/
+  //      int bit_gravity;         /* one of the bit gravity values */
+  //      int win_gravity;         /* one of the window gravity values */
+  //      int backing_store;       /* NotUseful, WhenMapped, Always */
+  //      unsigned long backing_planes;/* planes to be preserved if possible */
+  //      unsigned long backing_pixel;/* value to be used when restoring planes */
+  //      Bool save_under;         /* boolean, should bits under be saved? */
+  //      Colormap colormap;       /* color map to be associated with window */
+  //      Bool map_installed;      /* boolean, is color map currently installed*/
+  //      int map_state;           /* IsUnmapped, IsUnviewable, IsViewable */
+  //      long all_event_masks;    /* set of events all people have interest in*/
+  //      long your_event_mask;    /* my event mask */
+  //      long do_not_propagate_mask;/* set of events that should not propagate */
+  //      Bool override_redirect;  /* boolean value for override-redirect */
+  //      Screen *screen;          /* back pointer to correct screen */
+  // } XWindowAttributes;
 
   lib.lazy_bind("XFree", ctypes.int, ctypes.void_t.ptr);
   lib.lazy_bind("XInternAtom", this.Atom, this.Display.ptr, ctypes.char.ptr, this.Bool); // only_if_exsits
@@ -162,6 +185,8 @@ function x11_defines(lib) {
   lib.lazy_bind("XDefaultRootWindow", this.Window, this.Display.ptr);
   lib.lazy_bind("XSendEvent", this.Status, this.Display.ptr, this.Window, this.Bool, ctypes.long, this.XEvent.ptr);
   lib.lazy_bind("XRaiseWindow", ctypes.int, this.Display.ptr, this.Window);
+  // Status XGetWindowAttributes(Display *display, Window w, XWindowAttributes *window_attributes_return);
+  // int XChangeWindowAttributes(Display *display, Window w, unsigned long valuemask, XSetWindowAttributes *attributes);
 
 }
 
diff --git a/src/modules/linux/FiretrayWindow.jsm b/src/modules/linux/FiretrayWindow.jsm
index eb4ef69..0d842b0 100644
--- a/src/modules/linux/FiretrayWindow.jsm
+++ b/src/modules/linux/FiretrayWindow.jsm
@@ -173,7 +173,7 @@ firetray.Window = {
 
   unregisterWindowByXID: function(xid) {
     firetray.Handler.windowsCount -= 1;
-    if (firetray.Handler.windows[xid].visibility) firetray.Handler.visibleWindowsCount -= 1;
+    if (firetray.Handler.windows[xid].visible) firetray.Handler.visibleWindowsCount -= 1;
     if (firetray.Handler.windows.hasOwnProperty(xid)) {
       if (!delete firetray.Handler.windows[xid])
         throw new DeleteError();
@@ -321,7 +321,7 @@ firetray.Window = {
 
   setVisibility: function(xid, visibility) {
     firetray.Handler.windows[xid].baseWin.visibility = visibility;
-    firetray.Handler.windows[xid].visibility = visibility;
+    firetray.Handler.windows[xid].visible = visibility;
     firetray.Handler.visibleWindowsCount = visibility ?
       firetray.Handler.visibleWindowsCount + 1 :
       firetray.Handler.visibleWindowsCount - 1 ;
@@ -464,6 +464,8 @@ firetray.Window = {
       return null;
   },
 
+  // TODO: maybe we should subscribe to StructureNotifyMask (UnmapNotify),
+  // VisibilityChangeMask, PropertyChangeMask
   filterWindow: function(xev, gdkEv, data) {
     if (!xev)
       return gdk.GDK_FILTER_CONTINUE;
@@ -477,29 +479,20 @@ firetray.Window = {
 
       case x11.UnmapNotify:
         F.LOG("UnmapNotify");
-        winStates = firetray.Window.getXWindowStates(xwin);
-        isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
-        F.LOG("winStates="+winStates+", isHidden="+isHidden);
-        if (isHidden) {
-          let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize');
-          let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
-          if (hides_on_minimize) {
-            if (hides_single_window) {
-              firetray.Handler.hideSingleWindow(xwin);
-            } else
-            firetray.Handler.hideAllWindows();
-          }
+        if (firetray.Handler.windows[xwin].visible) {
+          winStates = firetray.Window.getXWindowStates(xwin);
+          isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
         }
         break;
 
       case x11.PropertyNotify:
         let xprop = ctypes.cast(xev, x11.XPropertyEvent.ptr);
-        if (firetray.js.strEquals(xprop.contents.atom, x11.current.Atoms.WM_STATE) &&
+        if (firetray.Handler.windows[xwin].visible &&
+            firetray.js.strEquals(xprop.contents.atom, x11.current.Atoms.WM_STATE) &&
             firetray.js.strEquals(xprop.contents.state, x11.PropertyNewValue)) {
-          F.LOG("PropertyNotify: "+xprop.contents.atom+" send_event: "+xprop.contents.send_event+" state: "+xprop.contents.state);
+          F.LOG("PropertyNotify: WM_STATE, send_event: "+xprop.contents.send_event+", state: "+xprop.contents.state);
           winStates = firetray.Window.getXWindowStates(xwin);
           isHidden = winStates & FIRETRAY_XWINDOW_HIDDEN;
-          if (isHidden) F.WARN("*** HIDDEN ***");
         }
         break;
 
@@ -508,6 +501,18 @@ firetray.Window = {
       //   break;
       }
 
+      if (isHidden) { // minimized
+        F.LOG("winStates="+winStates+", isHidden="+isHidden);
+        let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize');
+        let hides_single_window = firetray.Utils.prefService.getBoolPref('hides_single_window');
+        if (hides_on_minimize) {
+          if (hides_single_window) {
+            firetray.Handler.hideSingleWindow(xwin);
+          } else
+          firetray.Handler.hideAllWindows();
+        }
+      }
+
     } catch(x) {
       F.ERROR(x);
     }
@@ -549,7 +554,7 @@ firetray.Handler.registerWindow = function(win) {
   this.windowsCount += 1;
   // NOTE: no need to check for window state to set visibility because all
   // windows *are* shown at startup
-  this.windows[xid].visibility = true; // this.windows[xid].baseWin.visibility always true :-(
+  this.windows[xid].visible = true; // this.windows[xid].baseWin.visibility always true :-(
   this.visibleWindowsCount += 1;
   F.LOG("window "+xid+" registered");
   // NOTE: shouldn't be necessary to gtk_widget_add_events(gtkWin, gdk.GDK_ALL_EVENTS_MASK);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git



More information about the Pkg-mozext-commits mailing list