Spawn a thread to fake do our XDND polling

We cannot integrate this into our event loop like we planned, because
Wine a) grabs the mouse pointer so we cannot do that, and b) blocks the
GUI thread. So instead we will spawn our own thread and do polling based
XDND. When Wine's tracker window gets destroyed, we know that the left
mouse button has been released.
This commit is contained in:
Robbert van der Helm
2021-07-10 19:28:40 +02:00
parent 42ce69943a
commit 091ab0f0df
4 changed files with 161 additions and 30 deletions
+1 -11
View File
@@ -48,12 +48,6 @@ using namespace std::literals::chrono_literals;
*/
constexpr size_t idle_timer_id = 1337;
/**
* The most significant bit in an X11 event's response type is used to indicate
* the event source.
*/
constexpr uint8_t event_type_mask = 0b0111'1111;
/**
* The name of the X11 property on the root window used to denote the active
* window in EWMH compliant window managers.
@@ -355,15 +349,11 @@ void Editor::handle_x11_events() const noexcept {
// function calls involving it will fail. All functions called from
// here should be able to handle that cleanly.
try {
// Pump X11 events for handling XDND client messages from the
// drag-and-drop proxy
dnd_proxy_handle.handle_x11_events();
std::unique_ptr<xcb_generic_event_t> generic_event;
while (generic_event.reset(xcb_poll_for_event(x11_connection.get())),
generic_event != nullptr) {
const uint8_t event_type =
generic_event->response_type & event_type_mask;
generic_event->response_type & xcb_event_type_mask;
switch (event_type) {
// We're listening for `ConfigureNotify` events on the topmost
// window before the root window, i.e. the window that's