summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2020-03-26 13:45:20 +0100
committerQuentin Glidic <sardemff7+git@sardemff7.net>2020-11-27 07:26:16 +0100
commit627bd435103462bd08337754c13990270fa428b3 (patch)
tree87dd068a011162e07f3e4c4cc0ac402aafae59e3
parent94bd12e478f93985e661378fc7ae593bedc3e4d2 (diff)
xcb: Ask for focus where possible
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r--include/xcb.h1
-rw-r--r--source/view.c5
-rw-r--r--source/xcb.c12
3 files changed, 18 insertions, 0 deletions
diff --git a/include/xcb.h b/include/xcb.h
index 9feac25d..d811a2c7 100644
--- a/include/xcb.h
+++ b/include/xcb.h
@@ -84,6 +84,7 @@ void window_set_atom_prop ( xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms,
X ( WM_WINDOW_ROLE ), \
X ( _XROOTPMAP_ID ), \
X ( _MOTIF_WM_HINTS ), \
+ X ( WM_TAKE_FOCUS ), \
X ( ESETROOT_PMAP_ID )
/** enumeration of the atoms. */
diff --git a/source/view.c b/source/view.c
index d28dea75..0ebcd4bd 100644
--- a/source/view.c
+++ b/source/view.c
@@ -846,6 +846,11 @@ void __create_window ( MenuFlags menu_flags )
window_set_atom_prop ( box_window, xcb->ewmh._NET_WM_STATE, atoms, sizeof ( atoms ) / sizeof ( xcb_atom_t ) );
}
+ xcb_atom_t protocols[] = {
+ netatoms[WM_TAKE_FOCUS]
+ };
+ xcb_icccm_set_wm_protocols ( xcb->connection, box_window, xcb->ewmh.WM_PROTOCOLS, G_N_ELEMENTS ( protocols ), protocols );
+
TICK_N ( "setup window fullscreen" );
// Set the WM_NAME
rofi_view_set_window_title ( "rofi" );
diff --git a/source/xcb.c b/source/xcb.c
index c07fb38d..3ad31a92 100644
--- a/source/xcb.c
+++ b/source/xcb.c
@@ -891,6 +891,18 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event )
switch ( event->response_type & ~0x80 )
{
+ case XCB_CLIENT_MESSAGE:
+ {
+ xcb_client_message_event_t *cme = (xcb_client_message_event_t *) event;
+ xcb_atom_t atom = cme->data.data32[0];
+ xcb_timestamp_t time = cme->data.data32[1];
+ if ( atom == netatoms[WM_TAKE_FOCUS] )
+ {
+ xcb_set_input_focus ( xcb->connection, XCB_INPUT_FOCUS_NONE, cme->window, time );
+ xcb_flush ( xcb->connection );
+ }
+ break;
+ }
case XCB_EXPOSE:
rofi_view_frame_callback ();
break;