Implement support for the WM_Sn selection (#4374)

Closes #536

When the WM_Sn selection is already owned at startup, this now either
errors out or waits for the old selection owner to exit.
This commit is contained in:
Uli Schlachter
2021-08-28 01:01:38 +02:00
committed by GitHub
parent 36ba1043d5
commit 7b6e864823
6 changed files with 157 additions and 2 deletions

View File

@ -1076,6 +1076,21 @@ static void handle_configure_notify(xcb_configure_notify_event_t *event) {
randr_query_outputs();
}
/*
* Handles SelectionClear events for the root window, which are generated when
* we lose ownership of a selection.
*/
static void handle_selection_clear(xcb_selection_clear_event_t *event) {
if (event->selection != wm_sn) {
DLOG("SelectionClear for unknown selection %d, ignoring\n", event->selection);
return;
}
LOG("Lost WM_Sn selection, exiting.\n");
exit(EXIT_SUCCESS);
/* unreachable */
}
/*
* Handles the WM_CLASS property for assignments and criteria selection.
*
@ -1428,6 +1443,10 @@ void handle_event(int type, xcb_generic_event_t *event) {
handle_configure_notify((xcb_configure_notify_event_t *)event);
break;
case XCB_SELECTION_CLEAR:
handle_selection_clear((xcb_selection_clear_event_t *)event);
break;
default:
//DLOG("Unhandled event of type %d\n", type);
break;