[Xfce4-commits] <xfce4-panel:master> Fix activating the panel when a plugin asks for focus.
Nick Schermer
noreply at xfce.org
Sat Sep 4 21:16:01 CEST 2010
Updating branch refs/heads/master
to 9caf913d26b96ca657df8c43ef401a3db5ef588f (commit)
from b72a2ad68a8303c9d8c0efa25177412ac055e47b (commit)
commit 9caf913d26b96ca657df8c43ef401a3db5ef588f
Author: Nick Schermer <nick at xfce.org>
Date: Sat Sep 4 21:12:52 2010 +0200
Fix activating the panel when a plugin asks for focus.
This should fix focusing of entries in the panel like the
ones provided by the dict and verve plugins.
panel/Makefile.am | 2 ++
panel/panel-application.c | 2 +-
panel/panel-window.c | 40 ++++++++++++++++++++++++++++++++++++++++
panel/panel-window.h | 2 ++
4 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/panel/Makefile.am b/panel/Makefile.am
index 60f3a9d..ef2b8ab 100644
--- a/panel/Makefile.am
+++ b/panel/Makefile.am
@@ -61,6 +61,7 @@ xfce4_panel_CFLAGS = \
$(LIBXFCE4UI_CFLAGS) \
$(DBUS_CFLAGS) \
$(XFCONF_CFLAGS) \
+ $(LIBX11_CFLAGS) \
$(PLATFORM_CFLAGS)
xfce4_panel_LDFLAGS = \
@@ -77,6 +78,7 @@ xfce4_panel_LDADD = \
$(LIBXFCE4UI_LIBS) \
$(XFCONF_LIBS) \
$(DBUS_LIBS) \
+ $(LIBX11_LIBS) \
-lm
xfce4_panel_DEPENDENCIES = \
diff --git a/panel/panel-application.c b/panel/panel-application.c
index f264a24..1f1e0d1 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -567,7 +567,7 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
case PROVIDER_SIGNAL_FOCUS_PLUGIN:
/* focus the panel window (as part of focusing a widget within the plugin) */
- gtk_window_present_with_time (GTK_WINDOW (window), GDK_CURRENT_TIME);
+ panel_window_focus (window);
break;
case PROVIDER_SIGNAL_SHOW_CONFIGURE:
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 28b5ef7..8da1efb 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -27,6 +27,11 @@
#include <math.h>
#endif
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+#endif
+
#include <exo/exo.h>
#include <common/panel-private.h>
#include <common/panel-debug.h>
@@ -2434,3 +2439,38 @@ panel_window_get_locked (PanelWindow *window)
return window->locked;
}
+
+
+
+void
+panel_window_focus (PanelWindow *window)
+{
+#ifdef GDK_WINDOWING_X11
+ XClientMessageEvent event;
+
+ panel_return_if_fail (PANEL_IS_WINDOW (window));
+ panel_return_if_fail (GTK_WIDGET_REALIZED (window));
+
+ /* we need a slightly custom version of the call through Gtk+ to
+ * properly focus the panel when a plugin calls
+ * xfce_panel_plugin_focus_widget() */
+ event.type = ClientMessage;
+ event.window = GDK_WINDOW_XID (GTK_WIDGET (window)->window);
+ event.message_type = gdk_x11_get_xatom_by_name ("_NET_ACTIVE_WINDOW");
+ event.format = 32;
+ event.data.l[0] = 0;
+
+ gdk_error_trap_push ();
+
+ XSendEvent (GDK_DISPLAY (), GDK_ROOT_WINDOW (), False,
+ StructureNotifyMask, (XEvent *) &event);
+
+ gdk_flush ();
+
+ if (gdk_error_trap_pop () != 0)
+ g_critical ("Failed to focus panel window");
+#else
+ /* our best guess on non-x11 clients */
+ gtk_window_present (GTK_WINDOW (window));
+#endif
+}
diff --git a/panel/panel-window.h b/panel/panel-window.h
index 5150c74..f4e592b 100644
--- a/panel/panel-window.h
+++ b/panel/panel-window.h
@@ -49,6 +49,8 @@ void panel_window_set_locked (PanelWindow *window,
gboolean panel_window_get_locked (PanelWindow *window);
+void panel_window_focus (PanelWindow *window);
+
G_END_DECLS
#endif /* !__PANEL_WINDOW_H__ */
More information about the Xfce4-commits
mailing list