Updating branch refs/heads/nick/gtk3-optional to 98761eb96827354c7ce7ab75fe787dd2cc8b4edb (commit) from 562954da30fd0e4ec3f301345335e994d526b0e8 (commit)
commit 98761eb96827354c7ce7ab75fe787dd2cc8b4edb Author: Nick Schermer <n...@xfce.org> Date: Fri Sep 21 18:43:44 2012 +0200 Compile GTK3 version of kbd library. configure.ac.in | 1 + libxfce4kbd-private/Makefile.am | 66 +++++++++++++++++--- ...private-2.pc.in => libxfce4kbd-private-3.pc.in} | 6 +- libxfce4kbd-private/xfce-shortcut-dialog.c | 53 +++++++++++++++- libxfce4kbd-private/xfce-shortcuts-grabber.c | 14 +++- 5 files changed, 122 insertions(+), 18 deletions(-) diff --git a/configure.ac.in b/configure.ac.in index 676dc77..f5fcc52 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -307,6 +307,7 @@ glade/icons/22x22/Makefile icons/Makefile icons/48x48/Makefile libxfce4kbd-private/libxfce4kbd-private-2.pc +libxfce4kbd-private/libxfce4kbd-private-3.pc libxfce4kbd-private/Makefile libxfce4ui/libxfce4ui-1.pc libxfce4ui/libxfce4ui-2.pc diff --git a/libxfce4kbd-private/Makefile.am b/libxfce4kbd-private/Makefile.am index 284cf21..145d175 100644 --- a/libxfce4kbd-private/Makefile.am +++ b/libxfce4kbd-private/Makefile.am @@ -11,8 +11,6 @@ INCLUDES = \ -DPREFIX=\"$(prefix)\" \ $(PLATFORM_CPPFLAGS) -lib_LTLIBRARIES = libxfce4kbd-private-2.la - libxfce4kbd_headers = \ xfce-shortcuts-provider.h \ xfce-shortcuts-grabber.h \ @@ -23,6 +21,16 @@ libxfce4kbd_built_sources = \ xfce-shortcuts-marshal.c \ xfce-shortcuts-marshal.h +libxfce4kbd_sources = \ + $(libxfce4kbd_headers) \ + $(libxfce4kbd_built_sources) \ + xfce-shortcuts-provider.c \ + xfce-shortcuts-grabber.c \ + xfce-shortcut-dialog.c \ + xfce-shortcuts.c + +lib_LTLIBRARIES = libxfce4kbd-private-2.la + libxfce4kbd_private_includedir = \ $(includedir)/xfce4/libxfce4kbd-private-$(LIBXFCE4KBD_PRIVATE_VERSION_API)/libxfce4kbd-private @@ -30,20 +38,16 @@ libxfce4kbd_private_include_HEADERS = \ $(libxfce4kbd_headers) libxfce4kbd_private_2_la_SOURCES = \ - $(libxfce4kbd_headers) \ - $(libxfce4kbd_built_sources) \ - xfce-shortcuts-provider.c \ - xfce-shortcuts-grabber.c \ - xfce-shortcut-dialog.c \ - xfce-shortcuts.c + $(libxfce4kbd_sources) libxfce4kbd_private_2_la_CFLAGS = \ $(PLATFORM_CFLAGS) \ - $(GLIB_CFLAGS) \ + $(GLIB_CFLAGS) \ $(GTK2_CFLAGS) \ $(LIBX11_CFLAGS) \ $(LIBXFCE4UTIL_CFLAGS) \ - $(XFCONF_CFLAGS) + $(XFCONF_CFLAGS) \ + $(PLATFORM_CFLAGS) libxfce4kbd_private_2_la_LDFLAGS = \ -export-dynamic \ @@ -67,6 +71,48 @@ settings_DATA = xfce4-keyboard-shortcuts.xml pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libxfce4kbd-private-2.pc +if ENABLE_GTK3_LIBRARY + +lib_LTLIBRARIES += libxfce4kbd-private-3.la + +libxfce4kbd3_private_includedir = \ + $(includedir)/xfce4/libxfce4kbd-private-3/libxfce4kbd-private + +libxfce4kbd3_private_include_HEADERS = \ + $(libxfce4kbd_headers) + +libxfce4kbd_private_3_la_SOURCES = \ + $(libxfce4kbd_sources) + +libxfce4kbd_private_3_la_CFLAGS = \ + $(PLATFORM_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GTK3_CFLAGS) \ + $(LIBX11_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ + $(XFCONF_CFLAGS) \ + $(PLATFORM_CFLAGS) + +libxfce4kbd_private_3_la_LDFLAGS = \ + -export-dynamic \ + -version-info $(LIBXFCE4KBD_PRIVATE_VERINFO) \ + -export-symbols-regex "^[^_].*" \ + -no-undefined \ + $(LIBX11_LDFLAGS) \ + $(PLATFORM_LDFLAGS) + +libxfce4kbd_private_3_la_LIBADD = \ + $(top_builddir)/libxfce4ui/libxfce4ui-2.la \ + $(GLIB_LIBS) \ + $(GTK3_LIBS) \ + $(LIBX11_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(XFCONF_LIBS) + +pkgconfig_DATA += libxfce4kbd-private-3.pc + +endif + if MAINTAINER_MODE xfce-shortcuts-marshal.h: xfce-shortcuts-marshal.list Makefile $(AM_V_GEN) glib-genmarshal --prefix=_xfce_shortcuts_marshal --internal --header $< > $@ diff --git a/libxfce4kbd-private/libxfce4kbd-private-2.pc.in b/libxfce4kbd-private/libxfce4kbd-private-3.pc.in similarity index 59% copy from libxfce4kbd-private/libxfce4kbd-private-2.pc.in copy to libxfce4kbd-private/libxfce4kbd-private-3.pc.in index b813376..9daadc5 100644 --- a/libxfce4kbd-private/libxfce4kbd-private-2.pc.in +++ b/libxfce4kbd-private/libxfce4kbd-private-3.pc.in @@ -5,7 +5,7 @@ includedir=@includedir@ Name: libxfce4kbd-private Description: Private Xfce library for shared code between xfwm4 and xfce4-settings -Requires: gdk-2.0 gtk+-2.0 libxfce4util-1.0 libxfconf-0 libxfce4ui-1 +Requires: gdk-3.0 gtk+-3.0 libxfce4util-1.0 libxfconf-0 libxfce4ui-2 Version: @PACKAGE_VERSION@ -Libs: @LIBX11_LDFLAGS@ -L${libdir} -lxfce4kbd-private-@LIBXFCE4KBD_PRIVATE_VERSION_API@ -Cflags: @LIBX11_CFLAGS@ -I${includedir}/xfce4/libxfce4kbd-private-@LIBXFCE4KBD_PRIVATE_VERSION_API@ +Libs: @LIBX11_LDFLAGS@ -L${libdir} -lxfce4kbd-private-3 +Cflags: @LIBX11_CFLAGS@ -I${includedir}/xfce4/libxfce4kbd-private-3 diff --git a/libxfce4kbd-private/xfce-shortcut-dialog.c b/libxfce4kbd-private/xfce-shortcut-dialog.c index e16a8e8..4c7905a 100644 --- a/libxfce4kbd-private/xfce-shortcut-dialog.c +++ b/libxfce4kbd-private/xfce-shortcut-dialog.c @@ -270,15 +270,46 @@ gint xfce_shortcut_dialog_run (XfceShortcutDialog *dialog, GtkWidget *parent) { - gint response = GTK_RESPONSE_CANCEL; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkDisplay *display; + GdkDevice *device; + GdkDeviceManager *device_manager; + GList *devices, *li; + gboolean succeed = FALSE; +#endif + gint response = GTK_RESPONSE_CANCEL; g_return_val_if_fail (XFCE_IS_SHORTCUT_DIALOG (dialog), GTK_RESPONSE_CANCEL); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); +#if GTK_CHECK_VERSION (3, 0, 0) + display = gtk_widget_get_display (GTK_WIDGET (dialog)); + device_manager = gdk_display_get_device_manager (display); + devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_MASTER); + + for (li = devices; li != NULL; li =li->next) + { + device = li->data; + if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD) + continue; + + if (gdk_device_grab (device, gtk_widget_get_root_window (GTK_WIDGET (dialog)), + GDK_OWNERSHIP_WINDOW, TRUE, + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, + NULL, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS) + { + succeed = TRUE; + } + } + + /* Take control on the keyboard */ + if (succeed) +#else /* Take control on the keyboard */ if (G_LIKELY (gdk_keyboard_grab (gtk_widget_get_root_window (GTK_WIDGET (dialog)), TRUE, GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)) +#endif { /* Run the dialog and wait for the user to enter a valid shortcut */ response = gtk_dialog_run (GTK_DIALOG (dialog)); @@ -290,11 +321,27 @@ xfce_shortcut_dialog_run (XfceShortcutDialog *dialog, dialog->shortcut = g_strdup (""); } +#if GTK_CHECK_VERSION (3, 0, 0) + /* Release keyboard */ + for (li = devices; li != NULL; li =li->next) + { + device = li->data; + if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD) + gdk_device_ungrab (device, GDK_CURRENT_TIME); + } +#else /* Release keyboard */ gdk_keyboard_ungrab (GDK_CURRENT_TIME); +#endif } else - g_warning ("%s", _("Could not grab the keyboard.")); + { + g_warning (_("Could not grab the keyboard.")); + } + +#if GTK_CHECK_VERSION (3, 0, 0) + g_list_free (devices); +#endif /* Return the response ID */ return response; @@ -355,8 +402,10 @@ xfce_shortcut_dialog_key_released (XfceShortcutDialog *dialog, /* Check if the shortcut was accepted */ if (G_LIKELY (shortcut_accepted)) { +#if !GTK_CHECK_VERSION (3, 0, 0) /* Release keyboard */ gdk_keyboard_ungrab (GDK_CURRENT_TIME); +#endif /* Exit dialog with positive response */ gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); diff --git a/libxfce4kbd-private/xfce-shortcuts-grabber.c b/libxfce4kbd-private/xfce-shortcuts-grabber.c index 9faec07..b8a56e3 100644 --- a/libxfce4kbd-private/xfce-shortcuts-grabber.c +++ b/libxfce4kbd-private/xfce-shortcuts-grabber.c @@ -368,7 +368,6 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber, for (j = 0; j < screens; j++) { /* Do the grab on all screens */ - GdkScreen *screen; Window root_window; /* Ignorable modifiers */ @@ -383,9 +382,13 @@ xfce_shortcuts_grabber_grab (XfceShortcutsGrabber *grabber, GDK_MOD2_MASK | GDK_LOCK_MASK | GDK_MOD5_MASK, }; +#if GTK_CHECK_VERSION (3, 0, 0) /* Retrieve the root window of the screen */ - screen = gdk_display_get_screen (display, j); - root_window = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); + root_window = gdk_x11_get_default_root_xwindow (); +#else + /* Retrieve the root window of the screen */ + root_window = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_display_get_screen (display, j))); +#endif gdk_error_trap_push (); @@ -530,7 +533,12 @@ xfce_shortcuts_grabber_event_filter (GdkXEvent *gdk_xevent, context.result, timestamp); gdk_flush (); + +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_error_trap_pop_ignored (); +#else gdk_error_trap_pop (); +#endif return GDK_FILTER_CONTINUE; } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits