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)
This commit is contained in:
foudfou 2012-04-11 13:45:45 +02:00
parent b2f270687d
commit 229fd20b5e
3 changed files with 50 additions and 20 deletions

View File

@ -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);
}
},

View File

@ -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);
}

View File

@ -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);