if all windows visible, middle click on the tray icon activates last registered

window, shows all windows otherwise.

reverts 97dcbc8c
This commit is contained in:
foudfou 2012-05-13 16:01:41 +02:00
parent 767f9487d0
commit f443116088
5 changed files with 47 additions and 6 deletions

View File

@ -184,6 +184,7 @@ firetray.Handler = {
hideSingleWindow: function(winId) {},
showSingleWindow: function(winId) {},
showHideAllWindows: function() {},
activateLastWindow: function(gtkStatusIcon, gdkEvent, userData) {},
showAllWindows: function() {
F.LOG("showAllWindows");

View File

@ -219,9 +219,24 @@ function gdk_defines(lib) {
{ "state": gobject.guint },
{ "direction": this.GdkScrollDirection },
{ "device": this.GdkDevice.ptr },
{ "x_root": gobject.gdouble }, { "y_root": gobject.gdouble }
{ "x_root": gobject.gdouble },
{ "y_root": gobject.gdouble }
]);
this.GdkAtom = ctypes.StructType("GdkAtom");
this.GdkEventButton = ctypes.StructType("GdkEventButton", [
{ "type": this.GdkEventType },
{ "window": this.GdkWindow.ptr },
{ "send_event": gobject.gint8 },
{ "time": gobject.guint32 },
{ "x": gobject.gdouble },
{ "y": gobject.gdouble },
{ "axes": gobject.gdouble.ptr },
{ "state": gobject.guint },
{ "button": gobject.guint },
{ "device": this.GdkDevice.ptr },
{ "x_root": gobject.gdouble },
{ "y_root": gobject.gdouble }
]);
this.GdkFilterFunc_t = ctypes.FunctionType(
ctypes.default_abi, this.GdkFilterReturn,

View File

@ -67,6 +67,7 @@ function gtk_defines(lib) {
this.GCallbackOnScroll_t = ctypes.FunctionType(
ctypes.default_abi, gobject.gboolean,
[this.GtkStatusIcon.ptr, gdk.GdkEvent.ptr, gobject.gpointer]).ptr;
this.GCallbackStatusIconMiddleClick_t = this.GCallbackOnScroll_t;
this.GCallbackGenericEvent_t = ctypes.FunctionType(
ctypes.default_abi, gobject.gboolean,
[this.GtkWidget.ptr, gdk.GdkEvent.ptr, gobject.gpointer]).ptr;

View File

@ -142,6 +142,12 @@ firetray.StatusIcon = {
let handlerId = gobject.g_signal_connect(firetray.StatusIcon.trayIcon,
"activate", firetray.StatusIcon.callbacks.iconActivate, null);
F.LOG("g_connect activate="+handlerId);
this.callbacks.iconMiddleClick = gtk.GCallbackStatusIconMiddleClick_t(
firetray.Handler.activateLastWindow);
handlerId = gobject.g_signal_connect(firetray.StatusIcon.trayIcon,
"button-press-event", firetray.StatusIcon.callbacks.iconMiddleClick, null);
F.LOG("g_connect middleClick="+handlerId);
},
onScroll: function(icon, event, data) {

View File

@ -581,11 +581,8 @@ firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
F.LOG("windowsCount="+firetray.Handler.windowsCount);
let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
F.LOG("visibilityRate="+visibilityRate);
if (visibilityRate === 1) {
for(var key in firetray.Handler.windows);
firetray.Window.activate(key);
} else if ((0.5 < visibilityRate) && (visibilityRate < 1)
|| visibilityRate === 0) { // TODO: should be configurable
if ((0.5 < visibilityRate) && (visibilityRate < 1)
|| visibilityRate === 0) { // TODO: should be configurable
firetray.Handler.showAllWindows();
} else {
firetray.Handler.hideAllWindows();
@ -595,6 +592,27 @@ firetray.Handler.showHideAllWindows = function(gtkStatusIcon, userData) {
return stopPropagation;
};
firetray.Handler.activateLastWindow = function(gtkStatusIcon, gdkEvent, userData) {
F.LOG("activateLastWindow");
let gdkEventButton = ctypes.cast(gdkEvent, gdk.GdkEventButton.ptr);
if (gdkEventButton.contents.button === 2 && gdkEventButton.contents.type === gdk.GDK_BUTTON_PRESS) {
F.LOG("MIDDLE CLICK");
let visibilityRate = firetray.Handler.visibleWindowsCount/firetray.Handler.windowsCount;
F.LOG("visibilityRate="+visibilityRate);
if (visibilityRate === 1) {
for(var key in firetray.Handler.windows);
firetray.Window.activate(key);
} else {
firetray.Handler.showAllWindows();
}
}
let stopPropagation = false;
return stopPropagation;
};
/**
* init X11 Display and handled XAtoms.