From 4c02d3a0ce08aab4e4b89b4eee7a72145e66c33a Mon Sep 17 00:00:00 2001 From: Javier Date: Thu, 22 May 2014 22:54:11 +0200 Subject: additional gtk2 fixes --- libtopmenu-client/topmenu-client.c | 10 +++++----- libtopmenu-client/topmenu-monitor.c | 4 ++-- mate-applet/Makefile.am | 2 +- module/menuitem-proxy.c | 32 +++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/libtopmenu-client/topmenu-client.c b/libtopmenu-client/topmenu-client.c index cbc2d20..a84cdf9 100644 --- a/libtopmenu-client/topmenu-client.c +++ b/libtopmenu-client/topmenu-client.c @@ -30,8 +30,8 @@ static gboolean handle_widget_button_event(GtkWidget *widget, GdkEvent *event, G GdkDisplay * display = gdk_window_get_display(socket); GdkScreen *screen = gdk_window_get_screen(socket); GdkWindow *root = gdk_screen_get_root_window(screen); - Display *dpy = gdk_x11_display_get_xdisplay(display); - Window xwin = gdk_x11_window_get_xid(socket); + Display *dpy = GDK_DISPLAY_XDISPLAY(display); + Window xwin = GDK_WINDOW_XID(socket); if (event->type == GDK_BUTTON_PRESS) { gdk_display_pointer_ungrab(gtk_widget_get_display(widget), @@ -43,7 +43,7 @@ static gboolean handle_widget_button_event(GtkWidget *widget, GdkEvent *event, G e.type = event->type == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease; e.xbutton.window = xwin; e.xbutton.display = dpy; - e.xbutton.root = gdk_x11_window_get_xid(root); + e.xbutton.root = GDK_WINDOW_XID(root); e.xbutton.time = event->button.time; e.xbutton.button = event->button.button; e.xbutton.state = event->button.state; @@ -76,7 +76,7 @@ void topmenu_client_connect_window_widget(GdkWindow *window, GtkWidget *widget) topmenu_client_disconnect_window(window); } - Window xwin = gdk_x11_window_get_xid(window); + Window xwin = GDK_WINDOW_XID(window); GtkPlug *plug = GTK_PLUG(gtk_plug_new(0)); gtk_container_add(GTK_CONTAINER(plug), widget); g_signal_connect_object(plug, "delete-event", @@ -110,7 +110,7 @@ void topmenu_client_disconnect_window(GdkWindow *window) gpointer window_data = g_object_steal_data(G_OBJECT(window), OBJECT_DATA_KEY_PLUG); g_return_if_fail(window_data); - Window xwin = gdk_x11_window_get_xid(window); + Window xwin = GDK_WINDOW_XID(window); GtkPlug *plug = GTK_PLUG(window_data); g_return_if_fail(plug); diff --git a/libtopmenu-client/topmenu-monitor.c b/libtopmenu-client/topmenu-monitor.c index 94302ef..8532047 100644 --- a/libtopmenu-client/topmenu-monitor.c +++ b/libtopmenu-client/topmenu-monitor.c @@ -39,7 +39,7 @@ static GdkFilterReturn handle_cur_server_event(GdkXEvent *xevent, GdkEvent *even g_debug("Current server has been destroyed"); TopMenuMonitor *self = TOPMENU_MONITOR(data); if (self->priv->cur_server && - gdk_x11_window_get_xid(self->priv->cur_server) == e->xdestroywindow.window) { + GDK_WINDOW_XID(self->priv->cur_server) == e->xdestroywindow.window) { topmenu_monitor_update(self); } } @@ -52,7 +52,7 @@ static void topmenu_monitor_set_cur_server(TopMenuMonitor *self, GdkWindow *wind // Nothing to do return; } - g_debug("Setting current server to 0x%lx", gdk_x11_window_get_xid(window)); + g_debug("Setting current server to 0x%lx", GDK_WINDOW_XID(window)); if (self->priv->cur_server) { gdk_window_remove_filter(window, handle_cur_server_event, self); g_object_unref(self->priv->cur_server); diff --git a/mate-applet/Makefile.am b/mate-applet/Makefile.am index dcebc77..6877eff 100644 --- a/mate-applet/Makefile.am +++ b/mate-applet/Makefile.am @@ -4,7 +4,7 @@ libexec_PROGRAMS = topmenu-mate-panel-applet topmenu_mate_panel_applet_SOURCES = main.c topmenu-mate-panel-applet.c topmenu-mate-panel-applet.h topmenu_mate_panel_applet_CPPFLAGS = $(GTK_CFLAGS) $(MATEPANELAPPLET_CFLAGS) -DG_LOG_DOMAIN=\"topmenu-mate-panel-applet\" -topmenu_mate_panel_applet_LDADD = $(GTK_LIBS) $(MATEPANELAPPLET_LIBS) ../libtopmenu-server/libtopmenu-server.la +topmenu_mate_panel_applet_LDADD = $(GTK_LIBS) $(MATEPANELAPPLET_LIBS) ../libtopmenu-server/libtopmenu-server-gtk$(GTK_VERSION).la appletdir = $(datadir)/mate-panel/applets applet_DATA = com.javispedro.topmenu.MatePanelApplet.mate-panel-applet diff --git a/module/menuitem-proxy.c b/module/menuitem-proxy.c index fbab6f1..935c29a 100644 --- a/module/menuitem-proxy.c +++ b/module/menuitem-proxy.c @@ -185,6 +185,26 @@ struct _GtkMenuItemPrivate }; #endif +static gboolean +menu_shell_is_active(GtkMenuShell *shell) +{ +#if GTK_MAJOR_VERSION == 3 + return shell->priv->active; +#else + return shell->active; +#endif +} + +static void +menu_shell_set_active(GtkMenuShell *shell, gboolean active) +{ +#if GTK_MAJOR_VERSION == 3 + shell->priv->active = active; +#else + shell->active = active; +#endif +} + static void free_timeval (GTimeVal *val) { @@ -563,7 +583,8 @@ static gboolean handle_menuitem_mnemonic_activate(GtkMenuItem *item, gboolean cy if (parent && monitor->available) { GtkMenuShell *parent_shell = GTK_MENU_SHELL(parent); - if (GTK_IS_MENU_BAR(parent_shell) || parent_shell->priv->active) { + + if (GTK_IS_MENU_BAR(parent_shell) || menu_shell_is_active(parent_shell)) { gtk_widget_mnemonic_activate(GTK_WIDGET(proxy), cycling); return TRUE; } @@ -599,7 +620,7 @@ static void handle_proxy_select(GtkMenuItem *proxy, GtkMenuItem *item) GtkMenuShell *parent_shell = GTK_MENU_SHELL(parent); GTimeVal *popup_time = g_slice_new0(GTimeVal); - g_get_current_time(popup_time); + g_get_current_time(popup_time); g_object_set_data_full(G_OBJECT(submenu), "gtk-menu-exact-popup-time", popup_time, (GDestroyNotify) free_timeval); @@ -615,7 +636,11 @@ static void handle_proxy_select(GtkMenuItem *proxy, GtkMenuItem *item) GTK_WIDGET(proxy), menu_item_position_menu, proxy, +#if GTK_MAJOR_VERSION == 3 parent_shell->priv->button, +#else + parent_shell->button, +#endif 0); } } @@ -650,7 +675,8 @@ static void handle_proxy_activate_item(GtkMenuItem *proxy, GtkMenuItem *item) if (submenu) { GtkMenuShell *parent = GTK_MENU_SHELL(gtk_widget_get_parent(GTK_WIDGET(proxy))); if (parent) { - parent->priv->active = TRUE; + menu_shell_set_active(parent, TRUE); + // We do not add grabs here, like Gtk+ does, because they are already done. gtk_menu_shell_select_item(parent, GTK_WIDGET(proxy)); gtk_menu_shell_select_first(GTK_MENU_SHELL(submenu), TRUE); -- cgit v1.2.3