make sure window is subscribed to mandatory event-masks

TODO: we should do this with xlib.
This commit is contained in:
foudfou 2012-04-18 00:51:50 +02:00
parent 229fd20b5e
commit 31881fa3f5
3 changed files with 38 additions and 29 deletions

View File

@ -117,6 +117,29 @@ function gdk_defines(lib) {
this.GDK_SCROLL_DOWN = 1;
this.GDK_SCROLL_LEFT = 2;
this.GDK_SCROLL_RIGHT = 3;
this.GdkEventMask = ctypes.int; // enum
this.GDK_EXPOSURE_MASK = 1 << 1,
this.GDK_POINTER_MOTION_MASK = 1 << 2,
this.GDK_POINTER_MOTION_HINT_MASK = 1 << 3,
this.GDK_BUTTON_MOTION_MASK = 1 << 4,
this.GDK_BUTTON1_MOTION_MASK = 1 << 5,
this.GDK_BUTTON2_MOTION_MASK = 1 << 6,
this.GDK_BUTTON3_MOTION_MASK = 1 << 7,
this.GDK_BUTTON_PRESS_MASK = 1 << 8,
this.GDK_BUTTON_RELEASE_MASK = 1 << 9,
this.GDK_KEY_PRESS_MASK = 1 << 10,
this.GDK_KEY_RELEASE_MASK = 1 << 11,
this.GDK_ENTER_NOTIFY_MASK = 1 << 12,
this.GDK_LEAVE_NOTIFY_MASK = 1 << 13,
this.GDK_FOCUS_CHANGE_MASK = 1 << 14,
this.GDK_STRUCTURE_MASK = 1 << 15,
this.GDK_PROPERTY_CHANGE_MASK = 1 << 16,
this.GDK_VISIBILITY_NOTIFY_MASK = 1 << 17,
this.GDK_PROXIMITY_IN_MASK = 1 << 18,
this.GDK_PROXIMITY_OUT_MASK = 1 << 19,
this.GDK_SUBSTRUCTURE_MASK = 1 << 20,
this.GDK_SCROLL_MASK = 1 << 21,
this.GDK_ALL_EVENTS_MASK = 0x3FFFFE
this.GdkWindow = ctypes.StructType("GdkWindow");
this.GdkByteOrder = ctypes.int; // enum
@ -240,6 +263,8 @@ function gdk_defines(lib) {
lib.lazy_bind("gdk_window_beep", ctypes.void_t, this.GdkWindow.ptr);
lib.lazy_bind("gdk_window_get_width", ctypes.int, this.GdkWindow.ptr);
lib.lazy_bind("gdk_window_get_events", this.GdkEventMask, this.GdkWindow.ptr);
lib.lazy_bind("gdk_window_set_events", ctypes.void_t, this.GdkWindow.ptr, this.GdkEventMask);
lib.lazy_bind("gdk_window_add_filter", ctypes.void_t, this.GdkWindow.ptr, this.GdkFilterFunc, gobject.gpointer);
lib.lazy_bind("gdk_display_get_default", this.GdkDisplay.ptr);
lib.lazy_bind("gdk_x11_display_get_xdisplay", x11.Display.ptr, this.GdkDisplay.ptr);
@ -253,7 +278,6 @@ function gdk_defines(lib) {
lib.lazy_bind("gdk_display_get_n_screens", gobject.gint, this.GdkDisplay.ptr);
lib.lazy_bind("gdk_display_get_screen", this.GdkScreen.ptr, this.GdkDisplay.ptr, gobject.gint);
}
new ctypes_library(GDK_LIBNAME, GDK_ABIS, gdk_defines, this);

View File

@ -117,8 +117,11 @@ function x11_defines(lib) {
this.XA_ATOM = 4;
this.XA_CARDINAL = 6;
// Input Event Masks
this.VisibilityChangeMask = 1<<16
this.StructureNotifyMask = 1<<17
this.SubstructureNotifyMask = 1<<19;
this.SubstructureRedirectMask = 1<<20;
this.PropertyChangeMask = 1<<22
this.Bool = ctypes.int;
this.Status = ctypes.int;
@ -154,29 +157,6 @@ 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
@ -185,9 +165,6 @@ 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);
}
new ctypes_library(X11_LIBNAME, X11_ABIS, x11_defines, this);

View File

@ -285,10 +285,12 @@ firetray.Window = {
F.LOG("restored WindowStates: " + winStates);
if (winStates & FIRETRAY_XWINDOW_MAXIMIZED) {
firetray.Handler.windows[xid].chromeWin.maximize();
F.LOG("restored maximized");
}
let hides_on_minimize = firetray.Utils.prefService.getBoolPref('hides_on_minimize');
if (!hides_on_minimize && (winStates & FIRETRAY_XWINDOW_HIDDEN)) {
firetray.Handler.windows[xid].chromeWin.minimize();
F.LOG("restored minimized");
}
delete firetray.Handler.windows[xid].savedStates;
@ -464,8 +466,6 @@ 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;
@ -538,6 +538,14 @@ firetray.Handler.registerWindow = function(win) {
// register
let [gtkWin, gdkWin, xid] = firetray.Window.getWindowsFromChromeWindow(win);
let eventMask = gdk.gdk_window_get_events(gdkWin);
F.LOG(eventMask);
let eventMaskNeeded = gdk.GDK_STRUCTURE_MASK|gdk.GDK_PROPERTY_CHANGE_MASK|gdk.GDK_VISIBILITY_NOTIFY_MASK;
F.LOG(eventMaskNeeded);
if ((eventMask & eventMaskNeeded) !== eventMaskNeeded) {
F.WARN("subscribing window to missing mandatory event-masks");
gdk.gdk_window_set_events(gdkWin, eventMask|eventMaskNeeded);
}
this.windows[xid] = {};
this.windows[xid].chromeWin = win;
this.windows[xid].baseWin = firetray.Handler.getWindowInterface(win, "nsIBaseWindow");