[hackers] [surf] Get rid of getkbdevice || Quentin Rameau

From: <git_AT_suckless.org>
Date: Tue, 5 Jul 2016 13:02:32 +0200 (CEST)

commit f9714ab838e362a74e02916317cf22ef0ebdcdb6
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Tue Jul 5 12:33:23 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Tue Jul 5 13:01:56 2016 +0200

    Get rid of getkbdevice
    
    The GTK guys nicely took in account our request and pushed in a
    convenience function to get default keyboard device.

diff --git a/surf.c b/surf.c
index 9851bba..f6b5a47 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -170,7 +170,6 @@ static void destroyclient(Client *c);
 static void cleanup(void);
 
 /* GTK/WebKit */
-static GdkDevice *getkbdevice(void);
 static WebKitWebView *newview(Client *c, WebKitWebView *rv);
 static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a,
                              Client *c);
_AT_@ -259,13 +258,14 @@ die(const char *errstr, ...)
 void
 setup(void)
 {
+ GdkDisplay *gdpy = gdk_display_get_default();
         int i, j;
 
         /* clean up any zombies immediately */
         sigchld(0);
         gtk_init(NULL, NULL);
 
- dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
+ dpy = GDK_DISPLAY_XDISPLAY(gdpy);
 
         curconfig = defconfig;
 
_AT_@ -279,7 +279,7 @@ setup(void)
         scriptfile = buildfile(scriptfile);
         cachedir = buildpath(cachedir);
 
- gdkkb = getkbdevice();
+ gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
 
         if (!stylefile) {
                 styledir = buildpath(styledir);
_AT_@ -875,22 +875,6 @@ cleanup(void)
         g_free(cachedir);
 }
 
-static GdkDevice *
-getkbdevice(void)
-{
- GList *l, *gdl = gdk_device_manager_list_devices(
- gdk_display_get_device_manager(gdk_display_get_default()),
- GDK_DEVICE_TYPE_MASTER);
- GdkDevice *gd = NULL;
-
- for (l = gdl; l != NULL; l = l->next)
- if (gdk_device_get_source(l->data) == GDK_SOURCE_KEYBOARD)
- gd = l->data;
-
- g_list_free(gdl);
- return gd;
-}
-
 WebKitWebView *
 newview(Client *c, WebKitWebView *rv)
 {
Received on Tue Jul 05 2016 - 13:02:32 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 05 2016 - 13:12:56 CEST