mirror of
https://github.com/moparisthebest/FireTray
synced 2024-11-10 19:15:08 -05:00
refactoring
This commit is contained in:
parent
0ade38b267
commit
c00d69b1ad
@ -248,24 +248,7 @@ firetray.IconLinux = {
|
||||
return null;
|
||||
},
|
||||
|
||||
filterWindow: function(xev, gdkEv, data) {
|
||||
if (!xev)
|
||||
return gdk.GDK_FILTER_CONTINUE;
|
||||
|
||||
try {
|
||||
let xany = ctypes.cast(xev, x11.XAnyEvent.ptr);
|
||||
let xwin = xany.contents.window;
|
||||
|
||||
switch (xany.contents.type) {
|
||||
|
||||
case x11.MapNotify:
|
||||
LOG("MapNotify");
|
||||
break;
|
||||
|
||||
case x11.UnmapNotify:
|
||||
LOG("UnmapNotify");
|
||||
|
||||
let prop = x11.current.Atoms._NET_WM_STATE;
|
||||
checkXWindowEWMState: function(xwin, prop) {
|
||||
LOG("prop="+prop);
|
||||
|
||||
// infos returned by XGetWindowProperty()
|
||||
@ -278,17 +261,17 @@ firetray.IconLinux = {
|
||||
let bufSize = XATOMS_EWMH_WM_STATES.length*ctypes.unsigned_long.size;
|
||||
let offset = 0;
|
||||
let res = x11.XGetWindowProperty(
|
||||
x11.current.Display, xwin, prop, offset, bufSize, 0, x11.AnyPropertyType,
|
||||
x11.current.Display, xwin, x11.current.Atoms._NET_WM_STATE, offset, bufSize, 0, x11.AnyPropertyType,
|
||||
actual_type.address(), actual_format.address(), nitems.address(), bytes_after.address(), prop_value.address());
|
||||
LOG("XGetWindowProperty res="+res+", actual_type="+actual_type.value+", actual_format="+actual_format.value+", bytes_after="+bytes_after.value+", nitems="+nitems.value);
|
||||
|
||||
if (!strEquals(res, x11.Success)) {
|
||||
ERROR("XGetWindowProperty failed");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
if (strEquals(actual_type.value, x11.None)) {
|
||||
WARN("property does not exist");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG("prop_value="+prop_value+", size="+prop_value.constructor.size);
|
||||
@ -304,25 +287,39 @@ firetray.IconLinux = {
|
||||
|
||||
for (let i=0; i<nitems.value; ++i) {
|
||||
LOG(props.contents[i]);
|
||||
if (strEquals(props.contents[i], x11.current.Atoms._NET_WM_STATE_HIDDEN))
|
||||
LOG("window hidden");
|
||||
if (strEquals(props.contents[i], prop))
|
||||
return true;
|
||||
}
|
||||
|
||||
x11.XFree(prop_value);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
filterWindow: function(xev, gdkEv, data) {
|
||||
if (!xev)
|
||||
return gdk.GDK_FILTER_CONTINUE;
|
||||
|
||||
try {
|
||||
let xany = ctypes.cast(xev, x11.XAnyEvent.ptr);
|
||||
let xwin = xany.contents.window;
|
||||
|
||||
switch (xany.contents.type) {
|
||||
|
||||
case x11.UnmapNotify:
|
||||
LOG("UnmapNotify");
|
||||
LOG("isHidden="+firetray.IconLinux.checkXWindowEWMState(xwin, x11.current.Atoms._NET_WM_STATE_HIDDEN));
|
||||
break;
|
||||
|
||||
case x11.ClientMessage:
|
||||
LOG("ClientMessage");
|
||||
let xclient = ctypes.cast(xev, x11.XClientMessageEvent.ptr);
|
||||
LOG("xclient.contents.data="+xclient.contents.data);
|
||||
// if (strEquals(xclient.contents.data[0], x11.current.Atoms.WM_DELETE_WINDOW)) {
|
||||
// LOG("Delete Window prevented");
|
||||
// return gdk.GDK_FILTER_REMOVE;
|
||||
// }
|
||||
LOG("xclient.contents.send_event="+xclient.contents.send_event);
|
||||
if (strEquals(xclient.contents.send_event, x11.current.Atoms.WM_CHANGE_STATE))
|
||||
LOG("FOUDIL");
|
||||
LOG("xclient.data="+xclient.contents.data);
|
||||
LOG("message_type="+xclient.contents.message_type+", format="+xclient.contents.format);
|
||||
if (strEquals(xclient.contents.data[0], x11.current.Atoms.WM_DELETE_WINDOW)) {
|
||||
LOG("Delete Window prevented");
|
||||
return gdk.GDK_FILTER_REMOVE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -63,6 +63,7 @@ function x11_defines(lib) {
|
||||
this.PropertyNewValue = 0;
|
||||
this.PropertyDelete = 1;
|
||||
// Event names
|
||||
this.DestroyNotify = 17;
|
||||
this.UnmapNotify = 18;
|
||||
this.MapNotify = 19;
|
||||
this.PropertyNotify = 28;
|
||||
|
Loading…
Reference in New Issue
Block a user