Browse Source

xembed: Stop using XCB_CURRENT_TIME

This changes the xembed code so that the caller passes in a timestamp
that should be used instead of XCB_CURRENT_TIME.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Uli Schlachter 2 years ago
parent
commit
148dc269a8
5 changed files with 32 additions and 23 deletions
  1. 8
    6
      common/xembed.c
  2. 18
    13
      common/xembed.h
  3. 1
    1
      event.c
  4. 2
    1
      property.c
  5. 3
    2
      systray.c

+ 8
- 6
common/xembed.c View File

@@ -37,7 +37,7 @@ void luaA_systray_invalidate(void);
37 37
  */
38 38
 void
39 39
 xembed_message_send(xcb_connection_t *connection, xcb_window_t towin,
40
-                    long message, long d1, long d2, long d3)
40
+                    xcb_timestamp_t timestamp, uint32_t message, uint32_t d1, uint32_t d2, uint32_t d3)
41 41
 {
42 42
     xcb_client_message_event_t ev;
43 43
 
@@ -45,7 +45,7 @@ xembed_message_send(xcb_connection_t *connection, xcb_window_t towin,
45 45
     ev.response_type = XCB_CLIENT_MESSAGE;
46 46
     ev.window = towin;
47 47
     ev.format = 32;
48
-    ev.data.data32[0] = XCB_CURRENT_TIME;
48
+    ev.data.data32[0] = timestamp;
49 49
     ev.data.data32[1] = message;
50 50
     ev.data.data32[2] = d1;
51 51
     ev.data.data32[3] = d2;
@@ -116,10 +116,12 @@ xembed_getbywin(xembed_window_array_t *list, xcb_window_t win)
116 116
 /** Update embedded window properties.
117 117
  * \param connection The X connection.
118 118
  * \param emwin The embedded window.
119
+ * \param timestamp The timestamp.
120
+ * \param reply The property reply to handle.
119 121
  */
120 122
 void
121 123
 xembed_property_update(xcb_connection_t *connection, xembed_window_t *emwin,
122
-                       xcb_get_property_reply_t *reply)
124
+                       xcb_timestamp_t timestamp, xcb_get_property_reply_t *reply)
123 125
 {
124 126
     int flags_changed;
125 127
     xembed_info_t info = { 0, 0 };
@@ -136,13 +138,13 @@ xembed_property_update(xcb_connection_t *connection, xembed_window_t *emwin,
136 138
         if(info.flags & XEMBED_MAPPED)
137 139
         {
138 140
             xcb_map_window(connection, emwin->win);
139
-            xembed_window_activate(connection, emwin->win);
141
+            xembed_window_activate(connection, emwin->win, timestamp);
140 142
         }
141 143
         else
142 144
         {
143 145
             xcb_unmap_window(connection, emwin->win);
144
-            xembed_window_deactivate(connection, emwin->win);
145
-            xembed_focus_out(connection, emwin->win);
146
+            xembed_window_deactivate(connection, emwin->win, timestamp);
147
+            xembed_focus_out(connection, emwin->win, timestamp);
146 148
         }
147 149
         luaA_systray_invalidate();
148 150
     }

+ 18
- 13
common/xembed.h View File

@@ -87,9 +87,9 @@ DO_ARRAY(xembed_window_t, xembed_window, DO_NOTHING)
87 87
 #define XEMBED_ACCELERATOR_OVERLOADED   (1 << 0)
88 88
 
89 89
 
90
-void xembed_message_send(xcb_connection_t *, xcb_window_t, long, long, long, long);
90
+void xembed_message_send(xcb_connection_t *, xcb_window_t, xcb_timestamp_t, uint32_t, uint32_t, uint32_t, uint32_t);
91 91
 xembed_window_t * xembed_getbywin(xembed_window_array_t *, xcb_window_t);
92
-void xembed_property_update(xcb_connection_t *, xembed_window_t *, xcb_get_property_reply_t *);
92
+void xembed_property_update(xcb_connection_t *, xembed_window_t *, xcb_timestamp_t, xcb_get_property_reply_t *);
93 93
 xcb_get_property_cookie_t xembed_info_get_unchecked(xcb_connection_t *,
94 94
                                                     xcb_window_t);
95 95
 bool xembed_info_get_reply(xcb_connection_t *connection,
@@ -100,46 +100,50 @@ bool xembed_info_get_reply(xcb_connection_t *connection,
100 100
 /** Indicate to an embedded window that it has focus.
101 101
  * \param c The X connection.
102 102
  * \param client The client.
103
+ * \param timestamp The timestamp.
103 104
  * \param focus_type The type of focus.
104 105
  */
105 106
 static inline void
106
-xembed_focus_in(xcb_connection_t *c, xcb_window_t client, long focus_type)
107
+xembed_focus_in(xcb_connection_t *c, xcb_window_t client, xcb_timestamp_t timestamp, uint32_t focus_type)
107 108
 {
108
-    xembed_message_send(c, client, XEMBED_FOCUS_IN, focus_type, 0, 0);
109
+    xembed_message_send(c, client, timestamp, XEMBED_FOCUS_IN, focus_type, 0, 0);
109 110
 }
110 111
 
111 112
 /** Notify a window that it has become active.
112 113
  * \param c The X connection.
113 114
  * \param client The window to notify.
115
+ * \param timestamp The timestamp.
114 116
  */
115 117
 static inline void
116
-xembed_window_activate(xcb_connection_t *c, xcb_window_t client)
118
+xembed_window_activate(xcb_connection_t *c, xcb_window_t client, xcb_timestamp_t timestamp)
117 119
 {
118
-    xembed_message_send(c, client, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
120
+    xembed_message_send(c, client, timestamp, XEMBED_WINDOW_ACTIVATE, 0, 0, 0);
119 121
 }
120 122
 
121 123
 /** Notify a window that it has become inactive.
122 124
  * \param c The X connection.
123 125
  * \param client The window to notify.
126
+ * \param timestamp The timestamp.
124 127
  */
125 128
 static inline
126
-void xembed_window_deactivate(xcb_connection_t *c, xcb_window_t client)
129
+void xembed_window_deactivate(xcb_connection_t *c, xcb_window_t client, xcb_timestamp_t timestamp)
127 130
 {
128
-    xembed_message_send(c, client, XEMBED_WINDOW_DEACTIVATE, 0, 0, 0);
131
+    xembed_message_send(c, client, timestamp, XEMBED_WINDOW_DEACTIVATE, 0, 0, 0);
129 132
 }
130 133
 
131 134
 /** Notify a window that its embed request has been received and accepted.
132 135
  * \param c The X connection.
133 136
  * \param client The client to send message to.
137
+ * \param timestamp The timestamp.
134 138
  * \param embedder The embedder window.
135 139
  * \param version The version.
136 140
  */
137 141
 static inline void
138 142
 xembed_embedded_notify(xcb_connection_t *c,
139
-                       xcb_window_t client, xcb_window_t embedder,
140
-                       long version)
143
+                       xcb_window_t client, xcb_timestamp_t timestamp,
144
+                       xcb_window_t embedder, uint32_t version)
141 145
 {
142
-    xembed_message_send(c, client, XEMBED_EMBEDDED_NOTIFY, 0, embedder, version);
146
+    xembed_message_send(c, client, timestamp, XEMBED_EMBEDDED_NOTIFY, 0, embedder, version);
143 147
 }
144 148
 
145 149
 /** Have the embedder end XEMBED protocol communication with a child.
@@ -156,11 +160,12 @@ xembed_window_unembed(xcb_connection_t *connection, xcb_window_t child, xcb_wind
156 160
 /** Indicate to an embedded window that it has lost focus.
157 161
  * \param c The X connection.
158 162
  * \param client The client to send message to.
163
+ * \param timestamp The timestamp.
159 164
  */
160 165
 static inline void
161
-xembed_focus_out(xcb_connection_t *c, xcb_window_t client)
166
+xembed_focus_out(xcb_connection_t *c, xcb_window_t client, xcb_timestamp_t timestamp)
162 167
 {
163
-    xembed_message_send(c, client, XEMBED_FOCUS_OUT, 0, 0, 0);
168
+    xembed_message_send(c, client, timestamp, XEMBED_FOCUS_OUT, 0, 0, 0);
164 169
 }
165 170
 
166 171
 

+ 1
- 1
event.c View File

@@ -751,7 +751,7 @@ event_handle_maprequest(xcb_map_request_event_t *ev)
751 751
     if((em = xembed_getbywin(&globalconf.embedded, ev->window)))
752 752
     {
753 753
         xcb_map_window(globalconf.connection, ev->window);
754
-        xembed_window_activate(globalconf.connection, ev->window);
754
+        xembed_window_activate(globalconf.connection, ev->window, globalconf.timestamp);
755 755
         /* The correct way to set this is via the _XEMBED_INFO property. Neither
756 756
          * of the XEMBED not the systray spec talk about mapping windows.
757 757
          * Apparently, Qt doesn't care and does not set an _XEMBED_INFO

+ 2
- 1
property.c View File

@@ -341,7 +341,8 @@ property_handle_xembed_info(uint8_t state,
341 341
                              XCB_GET_PROPERTY_TYPE_ANY, 0, 3);
342 342
         xcb_get_property_reply_t *propr =
343 343
             xcb_get_property_reply(globalconf.connection, cookie, 0);
344
-        xembed_property_update(globalconf.connection, emwin, propr);
344
+        xembed_property_update(globalconf.connection, emwin,
345
+                               globalconf.timestamp, propr);
345 346
         p_delete(&propr);
346 347
     }
347 348
 

+ 3
- 2
systray.c View File

@@ -166,7 +166,7 @@ systray_request_handle(xcb_window_t embed_win)
166 166
     }
167 167
 
168 168
     xembed_embedded_notify(globalconf.connection, em.win,
169
-                           globalconf.systray.window,
169
+                           globalconf.timestamp, globalconf.systray.window,
170 170
                            MIN(XEMBED_VERSION, em.info.version));
171 171
 
172 172
     xembed_window_array_append(&globalconf.embedded, em);
@@ -241,7 +241,8 @@ xembed_process_client_message(xcb_client_message_event_t *ev)
241 241
     switch(ev->data.data32[1])
242 242
     {
243 243
       case XEMBED_REQUEST_FOCUS:
244
-        xembed_focus_in(globalconf.connection, ev->window, XEMBED_FOCUS_CURRENT);
244
+        xembed_focus_in(globalconf.connection, ev->window,
245
+                        globalconf.timestamp, XEMBED_FOCUS_CURRENT);
245 246
         break;
246 247
     }
247 248
     return 0;

Loading…
Cancel
Save