30 #define G_LOG_DOMAIN "X11Helper" 40 #include <cairo-xcb.h> 41 #include <librsvg/rsvg.h> 44 #include <xcb/xcb_aux.h> 45 #include <xcb/randr.h> 46 #include <xcb/xinerama.h> 47 #include <xcb/xcb_ewmh.h> 48 #include <xcb/xproto.h> 50 #include <xkbcommon/xkbcommon.h> 51 #include <xkbcommon/xkbcommon-x11.h> 52 #define SN_API_NOT_YET_FROZEN 54 #define sn_launcher_context_set_application_id sn_launcher_set_application_id 67 #define RANDR_PREF_MAJOR_VERSION 1 68 #define RANDR_PREF_MINOR_VERSION 5 71 #define INTERSECT( x, y, x1, y1, w1, h1 ) ( ( ( ( x ) >= ( x1 ) ) && ( ( x ) < ( x1 + w1 ) ) ) && ( ( ( y ) >= ( y1 ) ) && ( ( y ) < ( y1 + h1 ) ) ) ) 92 xcb_colormap_t
map = XCB_COLORMAP_NONE;
115 xcb_get_property_cookie_t cookie;
116 xcb_get_property_reply_t *reply;
117 xcb_pixmap_t rootpixmap = XCB_NONE;
119 cookie = xcb_get_property ( c,
127 reply = xcb_get_property_reply ( c, cookie, NULL );
130 if ( xcb_get_property_value_length ( reply ) ==
sizeof ( xcb_pixmap_t ) ) {
131 memcpy ( &rootpixmap, xcb_get_property_value ( reply ),
sizeof ( xcb_pixmap_t ) );
142 if ( pm == XCB_NONE ) {
153 xcb_get_property_cookie_t c = xcb_get_property (
xcb->
connection, 0, w, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX );
154 xcb_get_property_reply_t *r = xcb_get_property_reply (
xcb->
connection, c, NULL );
156 if ( xcb_get_property_value_length ( r ) > 0 ) {
158 if ( r->type ==
netatoms[UTF8_STRING] ) {
159 str = g_strndup ( xcb_get_property_value ( r ), xcb_get_property_value_length ( r ) );
161 else if ( r->type ==
netatoms[STRING] ) {
165 str = g_strdup (
"Invalid encoding." );
178 xcb_change_property (
xcb->
connection, XCB_PROP_MODE_REPLACE, w, prop, XCB_ATOM_ATOM, 32,
count, atoms );
208 xcb_randr_get_output_info_reply_t *op_reply;
209 xcb_randr_get_crtc_info_reply_t *crtc_reply;
210 xcb_randr_get_output_info_cookie_t it = xcb_randr_get_output_info (
xcb->
connection, out, XCB_CURRENT_TIME );
211 op_reply = xcb_randr_get_output_info_reply (
xcb->
connection, it, NULL );
212 if ( op_reply->crtc == XCB_NONE ) {
216 xcb_randr_get_crtc_info_cookie_t ct = xcb_randr_get_crtc_info (
xcb->
connection, op_reply->crtc, XCB_CURRENT_TIME );
217 crtc_reply = xcb_randr_get_crtc_info_reply (
xcb->
connection, ct, NULL );
223 retv->
x = crtc_reply->x;
224 retv->
y = crtc_reply->y;
225 retv->
w = crtc_reply->width;
226 retv->
h = crtc_reply->height;
228 retv->
mw = op_reply->mm_width;
229 retv->
mh = op_reply->mm_height;
231 char *tname = (
char *) xcb_randr_get_output_info_name ( op_reply );
232 int tname_len = xcb_randr_get_output_info_name_length ( op_reply );
234 retv->
name = g_malloc0 ( ( tname_len + 1 ) *
sizeof (
char ) );
235 memcpy ( retv->
name, tname, tname_len );
242 #if ( ( (XCB_RANDR_MAJOR_VERSION >= RANDR_PREF_MAJOR_VERSION ) && (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION ) ) \ 243 || XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION ) 251 static workarea *x11_get_monitor_from_randr_monitor ( xcb_randr_monitor_info_t *
mon )
254 xcb_generic_error_t *err;
256 xcb_get_atom_name_reply_t *atom_reply = xcb_get_atom_name_reply(
xcb->
connection, anc, &err);
258 g_warning (
"Could not get RandR monitor name: X11 error code %d\n", err->error_code);
270 retv->
w =
mon->width;
271 retv->
h =
mon->height;
274 retv->
mw =
mon->width_in_millimeters;
275 retv->
mh =
mon->height_in_millimeters;
278 retv->
name = g_strdup_printf(
"%.*s", xcb_get_atom_name_name_length(atom_reply), xcb_get_atom_name_name(atom_reply));
289 xcb_query_extension_cookie_t randr_cookie = xcb_query_extension (
xcb->
connection, strlen ( extension ), extension );
291 xcb_query_extension_reply_t *randr_reply = xcb_query_extension_reply (
xcb->
connection, randr_cookie, NULL );
293 int present = randr_reply->present;
295 free ( randr_reply );
302 xcb_xinerama_query_screens_cookie_t screens_cookie = xcb_xinerama_query_screens_unchecked (
306 xcb_xinerama_query_screens_reply_t *screens_reply = xcb_xinerama_query_screens_reply (
312 xcb_xinerama_screen_info_iterator_t screens_iterator = xcb_xinerama_query_screens_screen_info_iterator (
316 for (; screens_iterator.rem > 0; xcb_xinerama_screen_info_next ( &screens_iterator ) ) {
319 w->
x = screens_iterator.data->x_org;
320 w->
y = screens_iterator.data->y_org;
321 w->
w = screens_iterator.data->width;
322 w->
h = screens_iterator.data->height;
333 free ( screens_reply );
345 g_debug (
"Query XINERAMA for monitor layout." );
349 g_debug (
"No RANDR or Xinerama available for getting monitor layout." );
352 g_debug (
"Query RANDR for monitor layout." );
354 g_debug (
"Randr XCB api version: %d.%d.", XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION );
355 #if ( ( ( XCB_RANDR_MAJOR_VERSION == RANDR_PREF_MAJOR_VERSION ) && (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION ) ) \ 356 || XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION ) 357 xcb_randr_query_version_cookie_t cversion = xcb_randr_query_version(
xcb->
connection,
359 xcb_randr_query_version_reply_t *rversion = xcb_randr_query_version_reply(
xcb->
connection, cversion, NULL );
361 g_debug (
"Found randr version: %d.%d", rversion->major_version, rversion->minor_version );
363 if ( ( ( rversion->major_version == XCB_RANDR_MAJOR_VERSION ) && (rversion->minor_version >= XCB_RANDR_MINOR_VERSION ) ) ||
364 ( rversion->major_version > XCB_RANDR_MAJOR_VERSION ) ){
366 xcb_randr_get_monitors_reply_t *mreply = xcb_randr_get_monitors_reply (
xcb->
connection, t, NULL );
368 xcb_randr_monitor_info_iterator_t iter = xcb_randr_get_monitors_monitors_iterator ( mreply );
369 while ( iter.rem > 0 ) {
370 workarea *w = x11_get_monitor_from_randr_monitor ( iter.data );
375 xcb_randr_monitor_info_next (&iter);
386 xcb_randr_get_screen_resources_current_reply_t *res_reply;
387 xcb_randr_get_screen_resources_current_cookie_t src;
389 res_reply = xcb_randr_get_screen_resources_current_reply (
xcb->
connection, src, NULL );
393 int mon_num = xcb_randr_get_screen_resources_current_outputs_length ( res_reply );
394 xcb_randr_output_t *ops = xcb_randr_get_screen_resources_current_outputs ( res_reply );
397 xcb_randr_get_output_primary_cookie_t pc = xcb_randr_get_output_primary (
xcb->
connection,
xcb->
screen->root );
398 xcb_randr_get_output_primary_reply_t *pc_rep = xcb_randr_get_output_primary_reply (
xcb->
connection, pc, NULL );
400 for (
int i = mon_num - 1; i >= 0; i-- ) {
405 if ( pc_rep && pc_rep->output == ops[i] ) {
421 iter->monitor_id = index++;
427 int is_term = isatty ( fileno ( stdout ) );
428 printf (
"Monitor layout:\n" );
430 printf (
"%s ID%s: %d", ( is_term ) ?
color_bold :
"", is_term ?
color_reset :
"", iter->monitor_id );
431 if ( iter->primary ) {
432 printf (
" (primary)" );
436 printf (
"%s position%s: %d,%d\n", ( is_term ) ?
color_bold :
"", is_term ?
color_reset :
"", iter->x, iter->y );
437 printf (
"%s size%s: %d,%d\n", ( is_term ) ?
color_bold :
"", is_term ?
color_reset :
"", iter->w, iter->h );
438 if ( iter->mw > 0 && iter->mh > 0 ) {
439 printf (
"%s size%s: %dmm,%dmm dpi: %.0f,%.0f\n",
444 iter->w * 25.4 / (
double) iter->mw,
445 iter->h * 25.4 / (
double) iter->mh
454 if ( context == NULL ) {
464 if ( context->
binary != NULL ) {
467 if ( context->
icon != NULL ) {
468 sn_launcher_context_set_icon_name (
sncontext, context->
icon );
470 if ( context->
app_id != NULL ) {
473 if ( context->
wmclass != NULL ) {
477 xcb_get_property_cookie_t c;
478 unsigned int current_desktop = 0;
481 if ( xcb_ewmh_get_current_desktop_reply ( &
xcb->
ewmh, c, ¤t_desktop, NULL ) ) {
482 sn_launcher_context_set_workspace (
sncontext, current_desktop );
487 *child_setup = (GSpawnChildSetupFunc) sn_launcher_context_setup_child_process;
514 if (
INTERSECT ( x, y, iter->x, iter->y, iter->w, iter->h ) ) {
534 xcb_query_pointer_cookie_t c = xcb_query_pointer (
xcb->
connection, root );
535 xcb_query_pointer_reply_t *r = xcb_query_pointer_reply (
xcb->
connection, c, NULL );
548 xcb_get_geometry_cookie_t c = xcb_get_geometry (
xcb->
connection,
id );
549 xcb_get_geometry_reply_t *r = xcb_get_geometry_reply (
xcb->
connection, c, NULL );
551 xcb_translate_coordinates_cookie_t ct = xcb_translate_coordinates (
xcb->
connection,
id, root, r->x, r->y );
552 xcb_translate_coordinates_reply_t *t = xcb_translate_coordinates_reply (
xcb->
connection, ct, NULL );
557 mon->
x = t->dst_x - r->x;
558 mon->
y = t->dst_y - r->y;
572 xcb_window_t active_window;
573 xcb_get_property_cookie_t awc;
575 if ( !xcb_ewmh_get_active_window_reply ( &
xcb->
ewmh, awc, &active_window, NULL ) ) {
576 g_debug (
"Failed to get active window, falling back to mouse location (-5)." );
579 xcb_query_tree_cookie_t tree_cookie = xcb_query_tree (
xcb->
connection, active_window );
580 xcb_query_tree_reply_t *tree_reply = xcb_query_tree_reply (
xcb->
connection, tree_cookie, NULL );
582 g_debug (
"Failed to get parent window, falling back to mouse location (-5)." );
586 xcb_get_geometry_cookie_t c = xcb_get_geometry (
xcb->
connection, active_window );
587 xcb_get_geometry_reply_t *r = xcb_get_geometry_reply (
xcb->
connection, c, NULL );
589 g_debug (
"Failed to get geometry of active window, falling back to mouse location (-5)." );
593 xcb_translate_coordinates_cookie_t ct = xcb_translate_coordinates (
xcb->
connection, tree_reply->parent, r->root, r->x, r->y );
594 xcb_translate_coordinates_reply_t *t = xcb_translate_coordinates_reply (
xcb->
connection, ct, NULL );
596 if ( mon_id == -2 ) {
600 mon->
x = t->dst_x - r->x;
601 mon->
y = t->dst_y - r->y;
606 else if ( mon_id == -4 ) {
613 g_debug (
"Failed to get translate position of active window, falling back to mouse location (-5)." );
624 if ( mon_id == -3 ) {
633 else if ( mon_id == -1 ) {
635 unsigned int current_desktop = 0;
636 xcb_get_property_cookie_t gcdc;
638 if ( xcb_ewmh_get_current_desktop_reply ( &
xcb->
ewmh, gcdc, ¤t_desktop, NULL ) ) {
640 xcb_ewmh_get_desktop_viewport_reply_t vp;
641 if ( xcb_ewmh_get_desktop_viewport_reply ( &
xcb->
ewmh, c, &vp, NULL ) ) {
642 if ( current_desktop < vp.desktop_viewport_len ) {
644 vp.desktop_viewport[current_desktop].y,
mon );
645 xcb_ewmh_get_desktop_viewport_reply_wipe ( &vp );
649 g_debug (
"Viewport does not exist for current desktop: %d, falling back to mouse location (-5)", current_desktop );
651 xcb_ewmh_get_desktop_viewport_reply_wipe ( &vp );
654 g_debug (
"Failed to get viewport for current desktop: %d, falling back to mouse location (-5).", current_desktop );
658 g_debug (
"Failed to get current desktop, falling back to mouse location (-5)." );
661 else if ( mon_id == -2 || mon_id == -4 ) {
667 else if ( mon_id == -5 ) {
675 g_debug (
"Failed to find monitor, fall back to monitor showing mouse." );
693 if ( iter->primary ) {
701 xcb_drawable_t win = g_ascii_strtoll (
config.
monitor + 4, &end, 0 );
717 g_warning (
"Failed to find selected monitor." );
737 if ( xse->property == XCB_ATOM_NONE ) {
738 g_warning (
"Failed to convert selection" );
740 else if ( xse->property ==
xcb->
ewmh.UTF8_STRING ) {
742 if ( text != NULL && text[0] !=
'\0' ) {
743 unsigned int dl = strlen ( text );
745 for (
unsigned int i = 0; i < dl; i++ ) {
746 if ( text[i] ==
'\n' ) {
755 g_warning (
"Failed" );
761 switch ( x11_button )
764 *button = NK_BINDINGS_MOUSE_BUTTON_PRIMARY;
767 *button = NK_BINDINGS_MOUSE_BUTTON_SECONDARY;
770 *button = NK_BINDINGS_MOUSE_BUTTON_MIDDLE;
773 *button = NK_BINDINGS_MOUSE_BUTTON_BACK;
776 *button = NK_BINDINGS_MOUSE_BUTTON_FORWARD;
784 *button = NK_BINDINGS_MOUSE_BUTTON_EXTRA + x11_button;
792 switch ( x11_button )
798 *axis = NK_BINDINGS_SCROLL_AXIS_VERTICAL;
804 *axis = NK_BINDINGS_SCROLL_AXIS_HORIZONTAL;
818 if ( state == NULL ) {
822 switch ( event->response_type & ~0x80 )
827 case XCB_CONFIGURE_NOTIFY:
829 xcb_configure_notify_event_t *xce = (xcb_configure_notify_event_t *) event;
833 case XCB_MOTION_NOTIFY:
838 xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *) event;
842 case XCB_BUTTON_PRESS:
844 xcb_button_press_event_t *bpe = (xcb_button_press_event_t *) event;
845 NkBindingsMouseButton button;
846 NkBindingsScrollAxis axis;
852 nk_bindings_seat_handle_button (
xcb->
bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_PRESS, bpe->time );
857 case XCB_BUTTON_RELEASE:
859 xcb_button_release_event_t *bre = (xcb_button_release_event_t *) event;
860 NkBindingsMouseButton button;
864 nk_bindings_seat_handle_button (
xcb->
bindings_seat, NULL, button, NK_BINDINGS_BUTTON_STATE_RELEASE, bre->time );
874 case XCB_SELECTION_NOTIFY:
877 case XCB_KEYMAP_NOTIFY:
879 xcb_keymap_notify_event_t *kne = (xcb_keymap_notify_event_t *) event;
880 for ( gint32 by = 0; by < 31; ++by ) {
881 for ( gint8 bi = 0; bi < 7; ++bi ) {
882 if ( kne->keys[by] & ( 1 << bi ) ) {
884 nk_bindings_seat_handle_key (
xcb->
bindings_seat, NULL, ( 8 * by + bi ) + 8, NK_BINDINGS_KEY_STATE_PRESSED );
892 xcb_key_press_event_t *xkpe = (xcb_key_press_event_t *) event;
896 text = nk_bindings_seat_handle_key_with_modmask (
xcb->
bindings_seat, NULL, xkpe->state, xkpe->detail, NK_BINDINGS_KEY_STATE_PRESS );
897 if ( text != NULL ) {
902 case XCB_KEY_RELEASE:
904 xcb_key_release_event_t *xkre = (xcb_key_release_event_t *) event;
906 nk_bindings_seat_handle_key (
xcb->
bindings_seat, NULL, xkre->detail, NK_BINDINGS_KEY_STATE_RELEASE );
920 g_warning (
"The XCB connection to X server had a fatal error: %d", status );
922 return G_SOURCE_REMOVE;
925 g_warning (
"main_loop_x11_event_handler: ev == NULL, status == %d", status );
926 return G_SOURCE_CONTINUE;
929 uint8_t type = ev->response_type & ~0x80;
933 case XCB_XKB_MAP_NOTIFY:
938 xkb_keymap_unref ( keymap );
939 xkb_state_unref ( state );
942 case XCB_XKB_STATE_NOTIFY:
944 xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *) ev;
956 return G_SOURCE_CONTINUE;
962 return G_SOURCE_CONTINUE;
970 g_warning (
"Connection has error" );
971 exit ( EXIT_FAILURE );
973 xcb_grab_pointer_cookie_t cc = xcb_grab_pointer (
xcb->
connection, 1, w, XCB_EVENT_MASK_BUTTON_RELEASE,
974 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, w, XCB_NONE, XCB_CURRENT_TIME );
975 xcb_grab_pointer_reply_t *r = xcb_grab_pointer_reply (
xcb->
connection, cc, NULL );
977 if ( r->status == XCB_GRAB_STATUS_SUCCESS ) {
983 if ( ( ++i ) > iters ) {
996 g_warning (
"Connection has error" );
997 exit ( EXIT_FAILURE );
999 xcb_grab_keyboard_cookie_t cc = xcb_grab_keyboard (
xcb->
connection,
1000 1, w, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC,
1001 XCB_GRAB_MODE_ASYNC );
1002 xcb_grab_keyboard_reply_t *r = xcb_grab_keyboard_reply (
xcb->
connection, cc, NULL );
1004 if ( r->status == XCB_GRAB_STATUS_SUCCESS ) {
1010 if ( ( ++i ) > iters ) {
1029 static void error_trap_push ( G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xcb_connection_t *xdisplay )
1034 static void error_trap_pop ( G_GNUC_UNUSED SnDisplay *display, xcb_connection_t *xdisplay )
1037 g_warning (
"Error trap underflow!" );
1038 exit ( EXIT_FAILURE );
1041 xcb_flush ( xdisplay );
1053 xcb_intern_atom_reply_t *r = xcb_intern_atom_reply (
xcb->
connection, cc, NULL );
1063 xcb_window_t wm_win = 0;
1064 xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked ( &
xcb->
ewmh,
1067 if ( xcb_ewmh_get_supporting_wm_check_reply ( &
xcb->
ewmh, cc, &wm_win, NULL ) ) {
1068 xcb_ewmh_get_utf8_strings_reply_t wtitle;
1069 xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked ( &(
xcb->
ewmh ), wm_win );
1070 if ( xcb_ewmh_get_wm_name_reply ( &(
xcb->
ewmh ), cookie, &wtitle, (
void *) 0 ) ) {
1071 if ( wtitle.strings_len > 0 ) {
1072 g_debug (
"Found window manager: %s", wtitle.strings );
1073 if ( g_strcmp0 ( wtitle.strings,
"i3" ) == 0 ) {
1077 xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle );
1086 char *display_str = (
char *) g_getenv (
"DISPLAY" );
1092 g_warning (
"Failed to open display: %s", display_str );
1097 TICK_N (
"Open Display" );
1104 xcb_generic_error_t *errors = NULL;
1105 xcb_ewmh_init_atoms_replies ( &
xcb->
ewmh, ac, &errors );
1107 g_warning (
"Failed to create EWMH atoms" );
1114 if ( xkb_x11_setup_xkb_extension (
xcb->
connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
1115 XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &
xcb->
xkb.
first_event, NULL ) < 0 ) {
1116 g_warning (
"cannot setup XKB extension!" );
1125 ( XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY |
1126 XCB_XKB_EVENT_TYPE_MAP_NOTIFY |
1127 XCB_XKB_EVENT_TYPE_STATE_NOTIFY ),
1129 required_nkn_details =
1130 ( XCB_XKB_NKN_DETAIL_KEYCODES ),
1132 required_map_parts =
1133 ( XCB_XKB_MAP_PART_KEY_TYPES |
1134 XCB_XKB_MAP_PART_KEY_SYMS |
1135 XCB_XKB_MAP_PART_MODIFIER_MAP |
1136 XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
1137 XCB_XKB_MAP_PART_KEY_ACTIONS |
1138 XCB_XKB_MAP_PART_VIRTUAL_MODS |
1139 XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP ),
1141 required_state_details =
1142 ( XCB_XKB_STATE_PART_MODIFIER_BASE |
1143 XCB_XKB_STATE_PART_MODIFIER_LATCH |
1144 XCB_XKB_STATE_PART_MODIFIER_LOCK |
1145 XCB_XKB_STATE_PART_GROUP_BASE |
1146 XCB_XKB_STATE_PART_GROUP_LATCH |
1147 XCB_XKB_STATE_PART_GROUP_LOCK ),
1150 static const xcb_xkb_select_events_details_t details = {
1151 .affectNewKeyboard = required_nkn_details,
1152 .newKeyboardDetails = required_nkn_details,
1153 .affectState = required_state_details,
1154 .stateDetails = required_state_details,
1165 if ( keymap == NULL ) {
1166 g_warning (
"Failed to get Keymap for current keyboard device." );
1170 if ( state == NULL ) {
1171 g_warning (
"Failed to get state object for current keyboard device." );
1176 xkb_state_unref ( state );
1177 xkb_keymap_unref ( keymap );
1183 g_warning (
"Connection has error" );
1190 g_warning (
"Connection has error" );
1198 g_warning (
"Connection has error" );
1207 xcb_depth_t *root_depth = NULL;
1208 xcb_depth_iterator_t depth_iter;
1209 for ( depth_iter = xcb_screen_allowed_depths_iterator (
xcb->
screen ); depth_iter.rem; xcb_depth_next ( &depth_iter ) ) {
1210 xcb_depth_t *d = depth_iter.data;
1212 xcb_visualtype_iterator_t visual_iter;
1213 for ( visual_iter = xcb_depth_visuals_iterator ( d ); visual_iter.rem; xcb_visualtype_next ( &visual_iter ) ) {
1214 xcb_visualtype_t *v = visual_iter.data;
1215 if ( ( v->bits_per_rgb_value == 8 ) && ( d->depth == 32 ) && ( v->_class == XCB_VISUAL_CLASS_TRUE_COLOR ) ) {
1219 if (
xcb->
screen->root_visual == v->visual_id ) {
1226 xcb_void_cookie_t c;
1227 xcb_generic_error_t *e;
1254 return G_SOURCE_REMOVE;
1257 return G_SOURCE_REMOVE;
1260 return G_SOURCE_CONTINUE;
1268 return G_SOURCE_REMOVE;
1271 return G_SOURCE_REMOVE;
1274 return G_SOURCE_CONTINUE;
1287 if (
find_arg (
"-normal-window" ) >= 0 ) {
1290 if (
find_arg (
"-no-lazy-grab" ) >= 0 ) {
1292 g_warning (
"Failed to grab keyboard, even after %d uS.", 500 * 1000 );
1296 g_warning (
"Failed to grab mouse pointer, even after %d uS.", 100 * 1000 );
1328 g_debug (
"Cleaning up XCB and XKB" );
1340 xcb_ewmh_connection_wipe ( &(
xcb->
ewmh ) );
1343 g_water_xcb_source_free (
xcb->
source );
1353 const uint32_t MWM_HINTS_DECORATIONS = ( 1 << 1 );
1359 uint32_t decorations;
1364 struct MotifWMHints hints;
1365 hints.flags = MWM_HINTS_DECORATIONS;
1366 hints.decorations = 0;
1367 hints.functions = 0;
1368 hints.inputMode = 0;
1371 xcb_atom_t ha =
netatoms[_MOTIF_WM_HINTS];
1372 xcb_change_property (
xcb->
connection, XCB_PROP_MODE_REPLACE, window, ha, ha, 32, 5, &hints );
#define INTERSECT(x, y, x1, y1, w1, h1)
static workarea * x11_get_monitor_from_output(xcb_randr_output_t out)
void display_early_cleanup(void)
#define sn_launcher_context_set_application_id
void x11_disable_decoration(xcb_window_t window)
static void error_trap_pop(G_GNUC_UNUSED SnDisplay *display, xcb_connection_t *xdisplay)
void rofi_view_temp_configure_notify(RofiViewState *state, xcb_configure_notify_event_t *xce)
static void release_pointer(void)
static xcb_visualtype_t * root_visual
static int take_keyboard(xcb_window_t w, int iters)
xcb_window_t xcb_stuff_get_root_window(void)
unsigned int lazy_grab_retry_count_kb
void display_startup_notification(RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data)
static void x11_monitors_free(void)
static int take_pointer(xcb_window_t w, int iters)
void rofi_view_temp_click_to_exit(RofiViewState *state, xcb_window_t target)
static void release_keyboard(void)
RofiViewState * rofi_view_get_active(void)
cairo_surface_t * x11_helper_get_bg_surface(void)
unsigned int lazy_grab_retry_count_pt
int find_arg_str(const char *const key, char **val)
xcb_ewmh_connection_t ewmh
xcb_timestamp_t last_timestamp
void rofi_view_frame_callback(void)
void display_cleanup(void)
void rofi_view_handle_mouse_motion(RofiViewState *state, gint x, gint y)
static void x11_create_visual_and_colormap(void)
static gboolean lazy_grab_pointer(G_GNUC_UNUSED gpointer data)
static int error_trap_depth
static xcb_pixmap_t get_root_pixmap(xcb_connection_t *c, xcb_screen_t *screen, xcb_atom_t atom)
gboolean display_setup(GMainLoop *main_loop, NkBindings *bindings)
NkBindingsSeat * bindings_seat
static gboolean main_loop_x11_event_handler(xcb_generic_event_t *ev, G_GNUC_UNUSED gpointer user_data)
static int monitor_active_from_winid(xcb_drawable_t id, workarea *mon)
static int monitor_active_from_id_focused(int mon_id, workarea *mon)
void rofi_view_handle_text(RofiViewState *state, char *text)
#define RANDR_PREF_MAJOR_VERSION
static int x11_is_extension_present(const char *extension)
char * rofi_latin_to_utf8_strdup(const char *input, gssize length)
static void error_trap_push(G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xcb_connection_t *xdisplay)
static int pointer_get(xcb_window_t root, int *x, int *y)
static gboolean x11_button_to_nk_bindings_button(guint32 x11_button, NkBindingsMouseButton *button)
static void rofi_view_paste(RofiViewState *state, xcb_selection_notify_event_t *xse)
static void x11_create_frequently_used_atoms(void)
WindowManagerQuirk current_window_manager
static void main_loop_x11_event_handler_view(xcb_generic_event_t *event)
xcb_connection_t * connection
const gchar * description
void display_dump_monitor_layout(void)
struct _xcb_stuff xcb_int
static void x11_build_monitor_layout_xinerama()
static void x11_build_monitor_layout()
#define RANDR_PREF_MINOR_VERSION
static int monitor_get_dimension(int monitor_id, workarea *mon)
char * window_get_text_prop(xcb_window_t w, xcb_atom_t atom)
int monitor_active(workarea *mon)
xcb_visualtype_t * visual
void window_set_atom_prop(xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count)
static gboolean x11_button_to_nk_bindings_scroll(guint32 x11_button, NkBindingsScrollAxis *axis, gint32 *steps)
void rofi_view_maybe_update(RofiViewState *state)
SnLauncheeContext * sncontext
int find_arg(const char *const key)
struct _xcb_stuff::@5 xkb
static void x11_monitor_free(workarea *m)
static void monitor_dimensions(int x, int y, workarea *mon)
static gboolean lazy_grab_keyboard(G_GNUC_UNUSED gpointer data)
const char * netatom_names[]
static void x11_helper_discover_window_manager(void)
static int monitor_active_from_id(int mon_id, workarea *mon)
struct _workarea * monitors
xcb_atom_t netatoms[NUM_NETATOMS]
gboolean display_late_setup(void)
cairo_surface_t * x11_helper_get_screenshot_surface(void)