Browse Source

Stop using libxcb-property

libxcb-property will be dropped from xcb-utils in the next release, because
upstream thinks it's not really useful and well-designed.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Uli Schlachter 9 years ago
parent
commit
b64c989963
3 changed files with 83 additions and 49 deletions
  1. 0
    1
      awesomeConfig.cmake
  2. 2
    2
      objects/client.c
  3. 81
    46
      property.c

+ 0
- 1
awesomeConfig.cmake View File

@@ -147,7 +147,6 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED
147 147
     xcb-keysyms>=0.3.4
148 148
     xcb-icccm>=0.3.6
149 149
     xcb-image>=0.3.0
150
-    xcb-property>=0.3.0
151 150
     cairo-xcb
152 151
     libstartup-notification-1.0>=0.10
153 152
     xproto>=7.0.15

+ 2
- 2
objects/client.c View File

@@ -422,8 +422,8 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
422 422
      * startup id. */
423 423
     xcb_get_property_cookie_t startup_id_q = { 0 };
424 424
     if(!startup)
425
-        startup_id_q = xcb_get_any_property(globalconf.connection,
426
-                                            false, w, _NET_STARTUP_ID, UINT_MAX);
425
+        startup_id_q = xcb_get_property(globalconf.connection, false, w,
426
+                                        _NET_STARTUP_ID, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
427 427
 
428 428
     xcb_change_window_attributes(globalconf.connection, w, XCB_CW_EVENT_MASK, select_input_val);
429 429
 

+ 81
- 46
property.c View File

@@ -39,11 +39,13 @@
39 39
         bool no_reply = !reply; \
40 40
         if(no_reply) \
41 41
             reply = xcb_get_property_reply(globalconf.connection, \
42
-                                           xcb_get_any_property(globalconf.connection, \
43
-                                                                false, \
44
-                                                                c->window, \
45
-                                                                atom, \
46
-                                                                UINT_MAX), NULL); \
42
+                                           xcb_get_property(globalconf.connection, \
43
+                                                            false, \
44
+                                                            c->window, \
45
+                                                            atom, \
46
+                                                            XCB_GET_PROPERTY_TYPE_ANY, \
47
+                                                            0, \
48
+                                                            UINT_MAX), NULL); \
47 49
         luaA_object_push(globalconf.L, c); \
48 50
         setfunc(globalconf.L, -1, xutil_get_text_property_from_reply(reply)); \
49 51
         lua_pop(globalconf.L, 1); \
@@ -412,56 +414,89 @@ property_handle_net_wm_opacity(void *data __attribute__ ((unused)),
412 414
     return 0;
413 415
 }
414 416
 
415
-void a_xcb_set_property_handlers(void)
417
+/** The property notify event handler.
418
+ * \param data Unused data.
419
+ * \param connection The connection to the X server.
420
+ * \param ev The event.
421
+ * \return Status code, 0 if everything's fine.
422
+ */
423
+static int
424
+handle_propertynotify(void *data,
425
+                      xcb_connection_t *c,
426
+                      xcb_property_notify_event_t *ev)
416 427
 {
417
-    static xcb_property_handlers_t prophs;
418
-
419
-    /* init */
420
-    xcb_property_handlers_init(&prophs, &globalconf.evenths);
428
+    uint32_t length;
429
+    int (*handler)(void *data,
430
+                   xcb_connection_t *connection,
431
+                   uint8_t state,
432
+                   xcb_window_t window,
433
+                   xcb_atom_t name,
434
+                   xcb_get_property_reply_t *reply) = NULL;
435
+
436
+    /* Find the correct event handler */
437
+#define HANDLE(atom_, cb, len) \
438
+    if (ev->atom == atom_) \
439
+    { \
440
+        handler = cb; \
441
+        length = len; \
442
+    } else
443
+#define HANDLE_L(atom, cb) HANDLE(atom, cb, UINT_MAX)
444
+#define HANDLE_S(atom, cb) HANDLE(atom, cb, 1)
445
+#define END return 0
421 446
 
422 447
     /* Xembed stuff */
423
-    xcb_property_set_handler(&prophs, _XEMBED_INFO, UINT_MAX,
424
-                             property_handle_xembed_info, NULL);
448
+    HANDLE_L(_XEMBED_INFO, property_handle_xembed_info)
425 449
 
426 450
     /* ICCCM stuff */
427
-    xcb_property_set_handler(&prophs, WM_TRANSIENT_FOR, UINT_MAX,
428
-                             property_handle_wm_transient_for, NULL);
429
-    xcb_property_set_handler(&prophs, WM_CLIENT_LEADER, UINT_MAX,
430
-                             property_handle_wm_client_leader, NULL);
431
-    xcb_property_set_handler(&prophs, WM_NORMAL_HINTS, UINT_MAX,
432
-                             property_handle_wm_normal_hints, NULL);
433
-    xcb_property_set_handler(&prophs, WM_HINTS, UINT_MAX,
434
-                             property_handle_wm_hints, NULL);
435
-    xcb_property_set_handler(&prophs, WM_NAME, UINT_MAX,
436
-                             property_handle_wm_name, NULL);
437
-    xcb_property_set_handler(&prophs, WM_ICON_NAME, UINT_MAX,
438
-                             property_handle_wm_icon_name, NULL);
439
-    xcb_property_set_handler(&prophs, WM_CLASS, UINT_MAX,
440
-                             property_handle_wm_class, NULL);
441
-    xcb_property_set_handler(&prophs, WM_PROTOCOLS, UINT_MAX,
442
-                             property_handle_wm_protocols, NULL);
443
-    xcb_property_set_handler(&prophs, WM_CLIENT_MACHINE, UINT_MAX,
444
-                             property_handle_wm_client_machine, NULL);
445
-    xcb_property_set_handler(&prophs, WM_WINDOW_ROLE, UINT_MAX,
446
-                             property_handle_wm_window_role, NULL);
451
+    HANDLE_L(WM_TRANSIENT_FOR, property_handle_wm_transient_for)
452
+    HANDLE_L(WM_CLIENT_LEADER, property_handle_wm_client_leader)
453
+    HANDLE_L(WM_NORMAL_HINTS, property_handle_wm_normal_hints)
454
+    HANDLE_L(WM_HINTS, property_handle_wm_hints)
455
+    HANDLE_L(WM_NAME, property_handle_wm_name)
456
+    HANDLE_L(WM_ICON_NAME, property_handle_wm_icon_name)
457
+    HANDLE_L(WM_CLASS, property_handle_wm_class)
458
+    HANDLE_L(WM_PROTOCOLS, property_handle_wm_protocols)
459
+    HANDLE_L(WM_CLIENT_MACHINE, property_handle_wm_client_machine)
460
+    HANDLE_L(WM_WINDOW_ROLE, property_handle_wm_window_role)
447 461
 
448 462
     /* EWMH stuff */
449
-    xcb_property_set_handler(&prophs, _NET_WM_NAME, UINT_MAX,
450
-                             property_handle_net_wm_name, NULL);
451
-    xcb_property_set_handler(&prophs, _NET_WM_ICON_NAME, UINT_MAX,
452
-                             property_handle_net_wm_icon_name, NULL);
453
-    xcb_property_set_handler(&prophs, _NET_WM_STRUT_PARTIAL, UINT_MAX,
454
-                             property_handle_net_wm_strut_partial, NULL);
455
-    xcb_property_set_handler(&prophs, _NET_WM_ICON, UINT_MAX,
456
-                             property_handle_net_wm_icon, NULL);
457
-    xcb_property_set_handler(&prophs, _NET_WM_PID, UINT_MAX,
458
-                             property_handle_net_wm_pid, NULL);
459
-    xcb_property_set_handler(&prophs, _NET_WM_WINDOW_OPACITY, 1,
460
-                             property_handle_net_wm_opacity, NULL);
463
+    HANDLE_L(_NET_WM_NAME, property_handle_net_wm_name)
464
+    HANDLE_L(_NET_WM_ICON_NAME, property_handle_net_wm_icon_name)
465
+    HANDLE_L(_NET_WM_STRUT_PARTIAL, property_handle_net_wm_strut_partial)
466
+    HANDLE_L(_NET_WM_ICON, property_handle_net_wm_icon)
467
+    HANDLE_L(_NET_WM_PID, property_handle_net_wm_pid)
468
+    HANDLE_S(_NET_WM_WINDOW_OPACITY, property_handle_net_wm_opacity)
461 469
 
462 470
     /* background change */
463
-    xcb_property_set_handler(&prophs, _XROOTPMAP_ID, 1,
464
-                             property_handle_xrootpmap_id, NULL);
471
+    HANDLE_S(_XROOTPMAP_ID, property_handle_xrootpmap_id)
472
+
473
+    /* If nothing was found, return */
474
+    END;
475
+
476
+#undef HANDLE_L
477
+#undef HANDLE_S
478
+#undef END
479
+
480
+    /* Get the property, if needed. */
481
+    xcb_get_property_reply_t *propr = NULL;
482
+    if(ev->state != XCB_PROPERTY_DELETE)
483
+    {
484
+        xcb_get_property_cookie_t cookie =
485
+            xcb_get_property(c, 0, ev->window, ev->atom,
486
+                             XCB_GET_PROPERTY_TYPE_ANY, 0, length);
487
+        propr = xcb_get_property_reply(c, cookie, 0);
488
+    }
489
+
490
+    int ret = (*handler)(NULL, c, ev->state, ev->window, ev->atom, propr);
491
+
492
+    p_delete(&propr);
493
+    return ret;
494
+}
495
+
496
+void a_xcb_set_property_handlers(void)
497
+{
498
+    /* Register our handler for PropertyNotify events */
499
+    xcb_event_set_property_notify_handler(&globalconf.evenths, handle_propertynotify, NULL);
465 500
 }
466 501
 
467 502
 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

Loading…
Cancel
Save