30#define G_LOG_DOMAIN "X11Helper"
35#include <xcb-imdkit/encoding.h>
36#include <xcb/xcb_keysyms.h>
49#include <xcb/xcb_aux.h>
50#include <xcb/xcb_cursor.h>
51#include <xcb/xcb_ewmh.h>
52#include <xcb/xinerama.h>
54#include <xcb/xproto.h>
55#include <xkbcommon/xkbcommon-x11.h>
56#include <xkbcommon/xkbcommon.h>
58#define SN_API_NOT_YET_FROZEN
61#define sn_launcher_context_set_application_id sn_launcher_set_application_id
79#define RANDR_PREF_MAJOR_VERSION 1
81#define RANDR_PREF_MINOR_VERSION 5
84#define INTERSECT(x, y, x1, y1, w1, h1) \
85 ((((x) >= (x1)) && ((x) < (x1 + w1))) && (((y) >= (y1)) && ((y) < (y1 + h1))))
110xcb_colormap_t
map = XCB_COLORMAP_NONE;
131 {
"default",
"left_ptr"}, {
"pointer",
"hand"}, {
"text",
"xterm"}};
133static xcb_visualtype_t *
lookup_visual(xcb_screen_t *s, xcb_visualid_t vis) {
134 xcb_depth_iterator_t d;
135 d = xcb_screen_allowed_depths_iterator(s);
136 for (; d.rem; xcb_depth_next(&d)) {
137 xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator(d.data);
138 for (; v.rem; xcb_visualtype_next(&v)) {
139 if (v.data->visual_id == vis) {
151static uint32_t *
create_kernel(
int radius,
double deviation, uint32_t *sum2) {
152 int size = 2 * (radius) + 1;
153 uint32_t *kernel = (uint32_t *)(g_malloc(
sizeof(uint32_t) * (size + 1)));
154 double radiusf = abs(radius) + 1.0;
155 double value = -radius;
159 if (deviation == 0.0) {
160 deviation = sqrt(-(radiusf * radiusf) / (2.0 * log(1.0 / 255.0)));
165 for (i = 0; i < size; i++) {
166 kernel[1 + i] = INT16_MAX / (2.506628275 * deviation) *
167 exp(-((value * value) / (2.0 * (deviation * deviation))));
169 sum += kernel[1 + i];
181 uint32_t *kernel = 0;
182 cairo_format_t format;
183 unsigned int channels;
185 if (cairo_surface_status(surface)) {
189 uint8_t *data = cairo_image_surface_get_data(surface);
190 format = cairo_image_surface_get_format(surface);
191 const int width = cairo_image_surface_get_width(surface);
192 const int height = cairo_image_surface_get_height(surface);
193 const int stride = cairo_image_surface_get_stride(surface);
195 if (format == CAIRO_FORMAT_ARGB32) {
201 horzBlur = (uint32_t *)(g_malloc(
sizeof(uint32_t) * height * stride));
208 uint32_t *horzBlur_ptr = horzBlur;
209 for (
int iY = 0; iY < height; iY++) {
210 const int iYs = iY * stride;
211 for (
int iX = 0; iX < width; iX++) {
216 int offset = (int)(kernel[0]) / -2;
218 for (
int i = 0; i < (int)(kernel[0]); i++) {
221 if (x < 0 || x >= width) {
226 uint8_t *dataPtr = &data[iYs + x * channels];
227 const uint32_t kernip1 = kernel[i + 1];
229 blue += kernip1 * dataPtr[0];
230 green += kernip1 * dataPtr[1];
231 red += kernip1 * dataPtr[2];
232 alpha += kernip1 * dataPtr[3];
236 *horzBlur_ptr++ = blue / sum;
237 *horzBlur_ptr++ = green / sum;
238 *horzBlur_ptr++ = red / sum;
239 *horzBlur_ptr++ = alpha / sum;
245 for (
int iY = 0; iY < height; iY++) {
246 for (
int iX = 0; iX < width; iX++) {
251 int offset = (int)(kernel[0]) / -2;
253 const int iXs = iX * channels;
254 for (
int i = 0; i < (int)(kernel[0]); i++) {
257 if (y < 0 || y >= height) {
262 uint32_t *dataPtr = &horzBlur[y * stride + iXs];
263 const uint32_t kernip1 = kernel[i + 1];
265 blue += kernip1 * dataPtr[0];
266 green += kernip1 * dataPtr[1];
267 red += kernip1 * dataPtr[2];
268 alpha += kernip1 * dataPtr[3];
273 *data++ = blue / sum;
274 *data++ = green / sum;
276 *data++ = alpha / sum;
289 xcb_get_geometry_cookie_t cookie;
290 xcb_get_geometry_reply_t *reply;
292 cookie = xcb_get_geometry(
xcb->connection, window);
293 reply = xcb_get_geometry_reply(
xcb->connection, cookie, NULL);
298 xcb_get_window_attributes_cookie_t attributesCookie =
299 xcb_get_window_attributes(
xcb->connection, window);
300 xcb_get_window_attributes_reply_t *attributes =
301 xcb_get_window_attributes_reply(
xcb->connection, attributesCookie, NULL);
302 if (attributes == NULL || (attributes->map_state != XCB_MAP_STATE_VIEWABLE)) {
313 cairo_surface_t *t = cairo_xcb_surface_create(
xcb->connection, window, vt,
314 reply->width, reply->height);
316 if (cairo_surface_status(t) != CAIRO_STATUS_SUCCESS) {
317 cairo_surface_destroy(t);
323 int max = MAX(reply->width, reply->height);
324 double scale = (double)size / max;
326 cairo_surface_t *s2 = cairo_surface_create_similar_image(
327 t, CAIRO_FORMAT_ARGB32, reply->width * scale, reply->height * scale);
330 if (cairo_surface_status(s2) != CAIRO_STATUS_SUCCESS) {
331 cairo_surface_destroy(t);
335 cairo_t *d = cairo_create(s2);
336 cairo_scale(d, scale, scale);
337 cairo_set_source_surface(d, t, 0, 0);
341 cairo_surface_destroy(t);
351 xcb->screen->height_in_pixels);
356 xcb_get_property_cookie_t cookie;
357 xcb_get_property_reply_t *reply;
358 xcb_pixmap_t rootpixmap = XCB_NONE;
360 cookie = xcb_get_property(c, 0, screen->root, atom, XCB_ATOM_PIXMAP, 0, 1);
362 reply = xcb_get_property_reply(c, cookie, NULL);
365 if (xcb_get_property_value_length(reply) ==
sizeof(xcb_pixmap_t)) {
366 memcpy(&rootpixmap, xcb_get_property_value(reply),
sizeof(xcb_pixmap_t));
377 if (pm == XCB_NONE) {
381 xcb->screen->width_in_pixels,
382 xcb->screen->height_in_pixels);
389 xcb_get_property_cookie_t c = xcb_get_property(
390 xcb->connection, 0, w, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, UINT_MAX);
391 xcb_get_property_reply_t *r =
392 xcb_get_property_reply(
xcb->connection, c, NULL);
394 if (xcb_get_property_value_length(r) > 0) {
396 if (r->type ==
netatoms[UTF8_STRING]) {
397 str = g_strndup(xcb_get_property_value(r),
398 xcb_get_property_value_length(r));
399 }
else if (r->type ==
netatoms[STRING]) {
401 xcb_get_property_value_length(r));
403 str = g_strdup(
"Invalid encoding.");
416 xcb_change_property(
xcb->connection, XCB_PROP_MODE_REPLACE, w, prop,
417 XCB_ATOM_ATOM, 32,
count, atoms);
433 while (
xcb->monitors != NULL) {
446 double ratio_res = w->
w / (double)w->
h;
447 double ratio_size = w->
mw / (double)w->
mh;
449 if ((ratio_res < 1.0 && ratio_size > 1.0) ||
450 (ratio_res > 1.0 && ratio_size < 1.0)) {
461 xcb_randr_get_output_info_reply_t *op_reply;
462 xcb_randr_get_crtc_info_reply_t *crtc_reply;
463 xcb_randr_get_output_info_cookie_t it =
464 xcb_randr_get_output_info(
xcb->connection, out, XCB_CURRENT_TIME);
465 op_reply = xcb_randr_get_output_info_reply(
xcb->connection, it, NULL);
466 if (op_reply->crtc == XCB_NONE) {
470 xcb_randr_get_crtc_info_cookie_t ct = xcb_randr_get_crtc_info(
471 xcb->connection, op_reply->crtc, XCB_CURRENT_TIME);
472 crtc_reply = xcb_randr_get_crtc_info_reply(
xcb->connection, ct, NULL);
478 retv->
x = crtc_reply->x;
479 retv->
y = crtc_reply->y;
480 retv->
w = crtc_reply->width;
481 retv->
h = crtc_reply->height;
483 retv->
mw = op_reply->mm_width;
484 retv->
mh = op_reply->mm_height;
487 char *tname = (
char *)xcb_randr_get_output_info_name(op_reply);
488 int tname_len = xcb_randr_get_output_info_name_length(op_reply);
490 retv->
name = g_malloc0((tname_len + 1) *
sizeof(
char));
491 memcpy(retv->
name, tname, tname_len);
498#if (((XCB_RANDR_MAJOR_VERSION >= RANDR_PREF_MAJOR_VERSION) && \
499 (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION)) || \
500 XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION)
509x11_get_monitor_from_randr_monitor(xcb_randr_monitor_info_t *
mon) {
511 xcb_generic_error_t *err;
512 xcb_get_atom_name_cookie_t anc =
513 xcb_get_atom_name(
xcb->connection,
mon->name);
514 xcb_get_atom_name_reply_t *atom_reply =
515 xcb_get_atom_name_reply(
xcb->connection, anc, &err);
517 g_warning(
"Could not get RandR monitor name: X11 error code %d\n",
530 retv->
w =
mon->width;
531 retv->
h =
mon->height;
534 retv->
mw =
mon->width_in_millimeters;
535 retv->
mh =
mon->height_in_millimeters;
540 g_strdup_printf(
"%.*s", xcb_get_atom_name_name_length(atom_reply),
541 xcb_get_atom_name_name(atom_reply));
551 xcb_query_extension_cookie_t randr_cookie =
552 xcb_query_extension(
xcb->connection, strlen(extension), extension);
554 xcb_query_extension_reply_t *randr_reply =
555 xcb_query_extension_reply(
xcb->connection, randr_cookie, NULL);
557 int present = randr_reply->present;
565 xcb_xinerama_query_screens_cookie_t screens_cookie =
566 xcb_xinerama_query_screens_unchecked(
xcb->connection);
568 xcb_xinerama_query_screens_reply_t *screens_reply =
569 xcb_xinerama_query_screens_reply(
xcb->connection, screens_cookie, NULL);
571 xcb_xinerama_screen_info_iterator_t screens_iterator =
572 xcb_xinerama_query_screens_screen_info_iterator(screens_reply);
574 for (; screens_iterator.rem > 0;
575 xcb_xinerama_screen_info_next(&screens_iterator)) {
578 w->
x = screens_iterator.data->x_org;
579 w->
y = screens_iterator.data->y_org;
580 w->
w = screens_iterator.data->width;
581 w->
h = screens_iterator.data->height;
588 for (
workarea *iter =
xcb->monitors; iter; iter = iter->next) {
589 iter->monitor_id = index++;
603 g_debug(
"Query XINERAMA for monitor layout.");
607 g_debug(
"No RANDR or Xinerama available for getting monitor layout.");
610 g_debug(
"Query RANDR for monitor layout.");
612 g_debug(
"Randr XCB api version: %d.%d.", XCB_RANDR_MAJOR_VERSION,
613 XCB_RANDR_MINOR_VERSION);
614#if (((XCB_RANDR_MAJOR_VERSION == RANDR_PREF_MAJOR_VERSION) && \
615 (XCB_RANDR_MINOR_VERSION >= RANDR_PREF_MINOR_VERSION)) || \
616 XCB_RANDR_MAJOR_VERSION > RANDR_PREF_MAJOR_VERSION)
617 xcb_randr_query_version_cookie_t cversion = xcb_randr_query_version(
619 xcb_randr_query_version_reply_t *rversion =
620 xcb_randr_query_version_reply(
xcb->connection, cversion, NULL);
622 g_debug(
"Found randr version: %d.%d", rversion->major_version,
623 rversion->minor_version);
628 xcb_randr_get_monitors_cookie_t t =
629 xcb_randr_get_monitors(
xcb->connection,
xcb->screen->root, 1);
630 xcb_randr_get_monitors_reply_t *mreply =
631 xcb_randr_get_monitors_reply(
xcb->connection, t, NULL);
633 xcb_randr_monitor_info_iterator_t iter =
634 xcb_randr_get_monitors_monitors_iterator(mreply);
635 while (iter.rem > 0) {
636 workarea *w = x11_get_monitor_from_randr_monitor(iter.data);
641 xcb_randr_monitor_info_next(&iter);
651 if (
xcb->monitors == NULL) {
652 xcb_randr_get_screen_resources_current_reply_t *res_reply;
653 xcb_randr_get_screen_resources_current_cookie_t src;
654 src = xcb_randr_get_screen_resources_current(
xcb->connection,
656 res_reply = xcb_randr_get_screen_resources_current_reply(
xcb->connection,
662 xcb_randr_get_screen_resources_current_outputs_length(res_reply);
663 xcb_randr_output_t *ops =
664 xcb_randr_get_screen_resources_current_outputs(res_reply);
667 xcb_randr_get_output_primary_cookie_t pc =
668 xcb_randr_get_output_primary(
xcb->connection,
xcb->screen->root);
669 xcb_randr_get_output_primary_reply_t *pc_rep =
670 xcb_randr_get_output_primary_reply(
xcb->connection, pc, NULL);
672 for (
int i = mon_num - 1; i >= 0; i--) {
677 if (pc_rep && pc_rep->output == ops[i]) {
691 for (
workarea *iter =
xcb->monitors; iter; iter = iter->next) {
692 iter->monitor_id = index++;
697 int is_term = isatty(fileno(stdout));
698 printf(
"Monitor layout:\n");
699 for (
workarea *iter =
xcb->monitors; iter; iter = iter->next) {
700 printf(
"%s ID%s: %d", (is_term) ?
color_bold :
"",
703 printf(
" (primary)");
706 printf(
"%s name%s: %s\n", (is_term) ?
color_bold :
"",
708 printf(
"%s position%s: %d,%d\n", (is_term) ?
color_bold :
"",
710 printf(
"%s size%s: %d,%d\n", (is_term) ?
color_bold :
"",
712 if (iter->mw > 0 && iter->mh > 0) {
713 printf(
"%s size%s: %dmm,%dmm dpi: %.0f,%.0f\n",
715 iter->mh, iter->w * 25.4 / (
double)iter->mw,
716 iter->h * 25.4 / (
double)iter->mh);
723 GSpawnChildSetupFunc *child_setup,
724 gpointer *user_data) {
725 if (context == NULL) {
729 SnLauncherContext *sncontext;
731 sncontext = sn_launcher_context_new(
xcb->sndisplay,
xcb->screen_nbr);
733 sn_launcher_context_set_name(sncontext, context->
name);
734 sn_launcher_context_set_description(sncontext, context->
description);
735 if (context->
binary != NULL) {
736 sn_launcher_context_set_binary_name(sncontext, context->
binary);
738 if (context->
icon != NULL) {
739 sn_launcher_context_set_icon_name(sncontext, context->
icon);
741 if (context->
app_id != NULL) {
744 if (context->
wmclass != NULL) {
745 sn_launcher_context_set_wmclass(sncontext, context->
wmclass);
748 xcb_get_property_cookie_t c;
749 unsigned int current_desktop = 0;
751 c = xcb_ewmh_get_current_desktop(&
xcb->ewmh,
xcb->screen_nbr);
752 if (xcb_ewmh_get_current_desktop_reply(&
xcb->ewmh, c, ¤t_desktop,
754 sn_launcher_context_set_workspace(sncontext, current_desktop);
757 sn_launcher_context_initiate(sncontext,
"rofi", context->
command,
758 xcb->last_timestamp);
760 *child_setup = (GSpawnChildSetupFunc)sn_launcher_context_setup_child_process;
761 *user_data = sncontext;
766 mon->w =
xcb->screen->width_in_pixels;
767 mon->h =
xcb->screen->height_in_pixels;
770 for (iter =
xcb->monitors; iter; iter = iter->
next) {
781 g_error(
"%s: mon == NULL", __func__);
785 mon->w =
xcb->screen->width_in_pixels;
786 mon->h =
xcb->screen->height_in_pixels;
788 for (
workarea *iter =
xcb->monitors; iter; iter = iter->next) {
789 if (
INTERSECT(x, y, iter->x, iter->y, iter->w, iter->h)) {
809 xcb_query_pointer_cookie_t c = xcb_query_pointer(
xcb->connection, root);
810 xcb_query_pointer_reply_t *r =
811 xcb_query_pointer_reply(
xcb->connection, c, NULL);
823 g_error(
"%s: mon == NULL", __func__);
827 xcb_get_geometry_cookie_t c = xcb_get_geometry(
xcb->connection,
id);
828 xcb_get_geometry_reply_t *r =
829 xcb_get_geometry_reply(
xcb->connection, c, NULL);
831 xcb_translate_coordinates_cookie_t ct =
832 xcb_translate_coordinates(
xcb->connection,
id, root, r->x, r->y);
833 xcb_translate_coordinates_reply_t *t =
834 xcb_translate_coordinates_reply(
xcb->connection, ct, NULL);
839 mon->x = t->dst_x - r->x;
840 mon->y = t->dst_y - r->y;
854 xcb_get_property_cookie_t awc;
856 g_error(
"%s: mon == NULL", __func__);
859 awc = xcb_ewmh_get_active_window(&
xcb->ewmh,
xcb->screen_nbr);
860 if (!xcb_ewmh_get_active_window_reply(&
xcb->ewmh, awc, &active_window,
863 "Failed to get active window, falling back to mouse location (-5).");
866 xcb_query_tree_cookie_t tree_cookie =
867 xcb_query_tree(
xcb->connection, active_window);
868 xcb_query_tree_reply_t *tree_reply =
869 xcb_query_tree_reply(
xcb->connection, tree_cookie, NULL);
872 "Failed to get parent window, falling back to mouse location (-5).");
876 xcb_get_geometry_cookie_t c =
877 xcb_get_geometry(
xcb->connection, active_window);
878 xcb_get_geometry_reply_t *r =
879 xcb_get_geometry_reply(
xcb->connection, c, NULL);
881 g_debug(
"Failed to get geometry of active window, falling back to mouse "
886 if (tree_reply->parent != r->root) {
887 xcb_translate_coordinates_cookie_t ct = xcb_translate_coordinates(
888 xcb->connection, tree_reply->parent, r->root, r->x, r->y);
889 xcb_translate_coordinates_reply_t *t =
890 xcb_translate_coordinates_reply(
xcb->connection, ct, NULL);
896 g_debug(
"Failed to get translate position of active window, falling back "
897 "to mouse location (-5).");
907 mon->x = r->x + r->border_width;
908 mon->y = r->y + r->border_width;
912 }
else if (mon_id == -4) {
913 g_debug(
"Find monitor at location: %d %d", r->x, r->y);
917 g_debug(
"mon pos: %d %d %d-%d",
mon->x,
mon->y,
mon->w,
mon->h);
926 g_error(
"%s: mon == NULL", __func__);
929 g_debug(
"Monitor id: %d", mon_id);
940 else if (mon_id == -1) {
941 g_debug(
"rofi on current monitor");
943 unsigned int current_desktop = 0;
944 xcb_get_property_cookie_t gcdc;
945 gcdc = xcb_ewmh_get_current_desktop(&
xcb->ewmh,
xcb->screen_nbr);
946 if (xcb_ewmh_get_current_desktop_reply(&
xcb->ewmh, gcdc, ¤t_desktop,
948 g_debug(
"Found current desktop: %u", current_desktop);
949 xcb_get_property_cookie_t c =
950 xcb_ewmh_get_desktop_viewport(&
xcb->ewmh,
xcb->screen_nbr);
951 xcb_ewmh_get_desktop_viewport_reply_t vp;
952 if (xcb_ewmh_get_desktop_viewport_reply(&
xcb->ewmh, c, &vp, NULL)) {
953 g_debug(
"Found %d number of desktops", vp.desktop_viewport_len);
954 if (current_desktop < vp.desktop_viewport_len) {
955 g_debug(
"Found viewport for desktop: %d %d",
956 vp.desktop_viewport[current_desktop].x,
957 vp.desktop_viewport[current_desktop].y);
959 vp.desktop_viewport[current_desktop].y,
mon);
960 g_debug(
"Found monitor @: %d %d %dx%d",
mon->x,
mon->y,
mon->w,
962 xcb_ewmh_get_desktop_viewport_reply_wipe(&vp);
965 g_debug(
"Viewport does not exist for current desktop: %d, falling "
966 "back to mouse location (-5)",
969 xcb_ewmh_get_desktop_viewport_reply_wipe(&vp);
971 g_debug(
"Failed to get viewport for current desktop: %d, falling back "
972 "to mouse location (-5).",
976 g_debug(
"Failed to get current desktop, falling back to mouse location "
979 }
else if (mon_id == -2 || mon_id == -4) {
985 else if (mon_id == -5) {
993 g_debug(
"Failed to find monitor, fall back to monitor showing mouse.");
1005 g_error(
"%s: mon == NULL", __func__);
1008 g_debug(
"Monitor active");
1013 if (
config.monitor != NULL) {
1014 g_debug(
"Monitor lookup by name : %s",
config.monitor);
1015 for (
workarea *iter =
xcb->monitors; iter; iter = iter->next) {
1016 if (g_strcmp0(
config.monitor, iter->name) == 0) {
1024 g_debug(
"Monitor lookup by name failed: %s",
config.monitor);
1026 if (g_strcmp0(
config.monitor,
"primary") == 0) {
1027 for (
workarea *iter =
xcb->monitors; iter; iter = iter->next) {
1028 if (iter->primary) {
1036 if (g_str_has_prefix(
config.monitor,
"wid:")) {
1038 xcb_drawable_t win = g_ascii_strtoll(
config.monitor + 4, &end, 0);
1039 if (end !=
config.monitor) {
1050 gint64 mon_id = g_ascii_strtoll(
config.monitor, &end, 0);
1051 if (end !=
config.monitor) {
1058 g_warning(
"Failed to find selected monitor.");
1075 xcb_get_atom_name_cookie_t cookie;
1076 xcb_get_atom_name_reply_t *reply;
1085 cookie = xcb_get_atom_name(conn, atom);
1086 reply = xcb_get_atom_name_reply(conn, cookie, NULL);
1090 length = xcb_get_atom_name_name_length(reply);
1091 name = xcb_get_atom_name_name(reply);
1093 (*out) = g_strndup(name, length);
1110 xcb_selection_notify_event_t *xse) {
1111 if (xse->property == XCB_ATOM_NONE) {
1112 g_debug(
"Failed to convert selection");
1113 }
else if (xse->property ==
xcb->ewmh.UTF8_STRING) {
1115 if (text != NULL && text[0] !=
'\0') {
1116 unsigned int dl = strlen(text);
1118 for (
unsigned int i = 0; i < dl; i++) {
1119 if (text[i] ==
'\n') {
1129 g_debug(
"rofi_view_paste: Got unknown atom: %s", out);
1132 g_debug(
"rofi_view_paste: Got unknown, unnamed: %s", out);
1139 NkBindingsMouseButton *button) {
1140 switch (x11_button) {
1142 *button = NK_BINDINGS_MOUSE_BUTTON_PRIMARY;
1145 *button = NK_BINDINGS_MOUSE_BUTTON_SECONDARY;
1148 *button = NK_BINDINGS_MOUSE_BUTTON_MIDDLE;
1151 *button = NK_BINDINGS_MOUSE_BUTTON_BACK;
1154 *button = NK_BINDINGS_MOUSE_BUTTON_FORWARD;
1162 *button = NK_BINDINGS_MOUSE_BUTTON_EXTRA + x11_button;
1168 NkBindingsScrollAxis *axis,
1171 switch (x11_button) {
1176 *axis = NK_BINDINGS_SCROLL_AXIS_VERTICAL;
1182 *axis = NK_BINDINGS_SCROLL_AXIS_HORIZONTAL;
1193 g_log(
"IMDKit", G_LOG_LEVEL_DEBUG,
"press handler %d", xkpe->detail);
1195 xcb->last_timestamp = xkpe->time;
1196 if (
config.xserver_i300_workaround) {
1197 text = nk_bindings_seat_handle_key_with_modmask(
1198 xcb->bindings_seat, NULL, xkpe->state, xkpe->detail,
1199 NK_BINDINGS_KEY_STATE_PRESS);
1201 text = nk_bindings_seat_handle_key(
xcb->bindings_seat, NULL, xkpe->detail,
1202 NK_BINDINGS_KEY_STATE_PRESS);
1212 g_log(
"IMDKit", G_LOG_LEVEL_DEBUG,
"release handler %d", xkre->detail);
1213 xcb->last_timestamp = xkre->time;
1214 nk_bindings_seat_handle_key(
xcb->bindings_seat, NULL, xkre->detail,
1215 NK_BINDINGS_KEY_STATE_RELEASE);
1223 if (state == NULL) {
1227 switch (event->response_type & ~0x80) {
1228 case XCB_CLIENT_MESSAGE: {
1229 xcb_client_message_event_t *cme = (xcb_client_message_event_t *)event;
1230 xcb_atom_t atom = cme->data.data32[0];
1232 if (atom ==
netatoms[WM_TAKE_FOCUS]) {
1233 xcb_set_input_focus(
xcb->connection, XCB_INPUT_FOCUS_NONE, cme->window,
1235 xcb_flush(
xcb->connection);
1239 case XCB_DESTROY_NOTIFY: {
1240 xcb_window_t win = ((xcb_destroy_notify_event_t *)event)->window;
1243 window_client_handle_signal(win, FALSE);
1246 g_main_loop_quit(
xcb->main_loop);
1250 case XCB_CREATE_NOTIFY: {
1251 xcb_window_t win = ((xcb_create_notify_event_t *)event)->window;
1254 window_client_handle_signal(win, TRUE);
1262 case XCB_CONFIGURE_NOTIFY: {
1267 case XCB_MOTION_NOTIFY: {
1268 xcb_motion_notify_event_t *xme = (xcb_motion_notify_event_t *)event;
1269 gboolean button_mask = xme->state & XCB_EVENT_MASK_BUTTON_1_MOTION;
1271 !button_mask &&
config.hover_select);
1274 case XCB_BUTTON_PRESS: {
1275 xcb_button_press_event_t *bpe = (xcb_button_press_event_t *)event;
1276 NkBindingsMouseButton button;
1277 NkBindingsScrollAxis axis;
1280 xcb->last_timestamp = bpe->time;
1283 nk_bindings_seat_handle_button(
xcb->bindings_seat, NULL, button,
1284 NK_BINDINGS_BUTTON_STATE_PRESS, bpe->time);
1286 nk_bindings_seat_handle_scroll(
xcb->bindings_seat, NULL, axis, steps);
1291 case XCB_SELECTION_CLEAR: {
1292 g_debug(
"Selection Clear.");
1295 case XCB_SELECTION_REQUEST: {
1296 g_debug(
"Selection Request.");
1297 xcb_selection_request_event_t *req = (xcb_selection_request_event_t *)event;
1298 if (req->selection ==
netatoms[CLIPBOARD]) {
1299 xcb_atom_t targets[2];
1300 xcb_selection_notify_event_t selection_notify = {
1301 .response_type = XCB_SELECTION_NOTIFY,
1304 .requestor = req->requestor,
1305 .selection = req->selection,
1306 .target = req->target,
1307 .property = XCB_ATOM_NONE,
1310 if (
xcb->clipboard) {
1312 if (req->target ==
netatoms[UTF8_STRING]) {
1313 g_debug(
"Selection Request UTF-8.");
1314 xcb_change_property(
xcb->connection, XCB_PROP_MODE_REPLACE,
1315 req->requestor, req->property,
1317 strlen(
xcb->clipboard) + 1,
xcb->clipboard);
1318 selection_notify.property = req->property;
1319 }
else if (req->target ==
netatoms[TARGETS]) {
1320 g_debug(
"Selection Request Targets.");
1322 targets[0] =
netatoms[UTF8_STRING];
1323 xcb_change_property(
xcb->connection, XCB_PROP_MODE_REPLACE,
1324 req->requestor, req->property, XCB_ATOM_ATOM, 32,
1326 selection_notify.property = req->property;
1330 xcb_send_event(
xcb->connection,
1332 req->requestor, XCB_EVENT_MASK_NO_EVENT,
1333 (
const char *)&selection_notify);
1334 xcb_flush(
xcb->connection);
1337 case XCB_BUTTON_RELEASE: {
1338 xcb_button_release_event_t *bre = (xcb_button_release_event_t *)event;
1339 NkBindingsMouseButton button;
1341 xcb->last_timestamp = bre->time;
1343 nk_bindings_seat_handle_button(
xcb->bindings_seat, NULL, button,
1344 NK_BINDINGS_BUTTON_STATE_RELEASE,
1347 if (
config.click_to_exit == TRUE) {
1348 if (!
xcb->mouse_seen) {
1356 case XCB_SELECTION_NOTIFY:
1359 case XCB_KEYMAP_NOTIFY: {
1360 xcb_keymap_notify_event_t *kne = (xcb_keymap_notify_event_t *)event;
1361 for (gint32 by = 0; by < 31; ++by) {
1362 for (gint8 bi = 0; bi < 7; ++bi) {
1363 if (kne->keys[by] & (1 << bi)) {
1365 nk_bindings_seat_handle_key(
xcb->bindings_seat, NULL,
1367 NK_BINDINGS_KEY_STATE_PRESSED);
1373 case XCB_KEY_PRESS: {
1374 xcb_key_press_event_t *xkpe = (xcb_key_press_event_t *)event;
1377 g_log(
"IMDKit", G_LOG_LEVEL_DEBUG,
"press key %d to xim", xkpe->detail);
1378 xcb_xim_forward_event(
xcb->im,
xcb->ic, xkpe);
1387 case XCB_KEY_RELEASE: {
1388 xcb_key_release_event_t *xkre = (xcb_key_release_event_t *)event;
1391 g_log(
"IMDKit", G_LOG_LEVEL_DEBUG,
"release key %d to xim", xkre->detail);
1397 xcb_keysym_t sym = xcb_key_press_lookup_keysym(
xcb->syms, xkre, 0);
1398 if (xcb_is_modifier_key(sym)) {
1399 struct timespec five_millis = {.tv_sec = 0, .tv_nsec = 5000000};
1400 nanosleep(&five_millis, NULL);
1402 xcb_xim_forward_event(
xcb->im,
xcb->ic, xkre);
1418void x11_event_handler_fowarding(G_GNUC_UNUSED xcb_xim_t *im,
1419 G_GNUC_UNUSED xcb_xic_t ic,
1420 xcb_key_press_event_t *event,
1421 G_GNUC_UNUSED
void *user_data) {
1423 if (state == NULL) {
1427 uint8_t type =
event->response_type & ~0x80;
1428 if (type == XCB_KEY_PRESS) {
1430 }
else if (type == XCB_KEY_RELEASE) {
1431 xcb_key_release_event_t *xkre = (xcb_key_release_event_t *)event;
1439 G_GNUC_UNUSED gpointer user_data) {
1441 int status = xcb_connection_has_error(
xcb->connection);
1443 g_warning(
"The XCB connection to X server had a fatal error: %d", status);
1444 g_main_loop_quit(
xcb->main_loop);
1445 return G_SOURCE_REMOVE;
1451 return G_SOURCE_CONTINUE;
1455 if (
config.enable_imdkit &&
xcb->im && xcb_xim_filter_event(
xcb->im, ev))
1456 return G_SOURCE_CONTINUE;
1459 uint8_t type = ev->response_type & ~0x80;
1460 if (type ==
xcb->xkb.first_event) {
1462 case XCB_XKB_MAP_NOTIFY: {
1463 struct xkb_keymap *keymap = xkb_x11_keymap_new_from_device(
1464 nk_bindings_seat_get_context(
xcb->bindings_seat),
xcb->connection,
1465 xcb->xkb.device_id, 0);
1466 struct xkb_state *state = xkb_x11_state_new_from_device(
1467 keymap,
xcb->connection,
xcb->xkb.device_id);
1468 nk_bindings_seat_update_keymap(
xcb->bindings_seat, keymap, state);
1469 xkb_keymap_unref(keymap);
1470 xkb_state_unref(state);
1473 case XCB_XKB_STATE_NOTIFY: {
1474 xcb_xkb_state_notify_event_t *ksne = (xcb_xkb_state_notify_event_t *)ev;
1475 nk_bindings_seat_update_mask(
xcb->bindings_seat, NULL, ksne->baseMods,
1476 ksne->latchedMods, ksne->lockedMods,
1477 ksne->baseGroup, ksne->latchedGroup,
1483 return G_SOURCE_CONTINUE;
1485 if (
xcb->sndisplay != NULL) {
1486 sn_xcb_display_process_event(
xcb->sndisplay, ev);
1490 return G_SOURCE_CONTINUE;
1496 if (xcb_connection_has_error(
xcb->connection)) {
1497 g_warning(
"Connection has error");
1500 xcb_grab_pointer_cookie_t cc =
1501 xcb_grab_pointer(
xcb->connection, 1, w, XCB_EVENT_MASK_BUTTON_RELEASE,
1502 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, w, XCB_NONE,
1504 xcb_grab_pointer_reply_t *r =
1505 xcb_grab_pointer_reply(
xcb->connection, cc, NULL);
1507 if (r->status == XCB_GRAB_STATUS_SUCCESS) {
1513 if ((++i) > iters) {
1516 struct timespec del = {.tv_sec = 0, .tv_nsec = 1000000};
1517 nanosleep(&del, NULL);
1525 if (xcb_connection_has_error(
xcb->connection)) {
1526 g_warning(
"Connection has error");
1529 xcb_grab_keyboard_cookie_t cc =
1530 xcb_grab_keyboard(
xcb->connection, 1, w, XCB_CURRENT_TIME,
1531 XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
1532 xcb_grab_keyboard_reply_t *r =
1533 xcb_grab_keyboard_reply(
xcb->connection, cc, NULL);
1535 if (r->status == XCB_GRAB_STATUS_SUCCESS) {
1541 if ((++i) > iters) {
1544 struct timespec del = {.tv_sec = 0, .tv_nsec = 1000000};
1545 nanosleep(&del, NULL);
1551 xcb_ungrab_keyboard(
xcb->connection, XCB_CURRENT_TIME);
1554 xcb_ungrab_pointer(
xcb->connection, XCB_CURRENT_TIME);
1560 G_GNUC_UNUSED xcb_connection_t *xdisplay) {
1565 xcb_connection_t *xdisplay) {
1567 g_warning(
"Error trap underflow!");
1571 xcb_flush(xdisplay);
1581 xcb_intern_atom_cookie_t cc = xcb_intern_atom(
1583 xcb_intern_atom_reply_t *r =
1584 xcb_intern_atom_reply(
xcb->connection, cc, NULL);
1595 xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked(
1598 if (xcb_ewmh_get_supporting_wm_check_reply(&
xcb->ewmh, cc, &wm_win, NULL)) {
1599 xcb_ewmh_get_utf8_strings_reply_t wtitle;
1600 xcb_get_property_cookie_t cookie =
1601 xcb_ewmh_get_wm_name_unchecked(&(
xcb->ewmh), wm_win);
1602 if (xcb_ewmh_get_wm_name_reply(&(
xcb->ewmh), cookie, &wtitle, (
void *)0)) {
1603 if (wtitle.strings_len > 0) {
1604 retv = g_strndup(wtitle.strings, wtitle.strings_len);
1606 xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle);
1614 xcb_get_property_cookie_t cc = xcb_ewmh_get_supporting_wm_check_unchecked(
1617 if (xcb_ewmh_get_supporting_wm_check_reply(&
xcb->ewmh, cc, &wm_win, NULL)) {
1618 xcb_ewmh_get_utf8_strings_reply_t wtitle;
1619 xcb_get_property_cookie_t cookie =
1620 xcb_ewmh_get_wm_name_unchecked(&(
xcb->ewmh), wm_win);
1621 if (xcb_ewmh_get_wm_name_reply(&(
xcb->ewmh), cookie, &wtitle, (
void *)0)) {
1622 if (wtitle.strings_len > 0) {
1624 char *str = g_strndup(wtitle.strings, wtitle.strings_len);
1625 g_debug(
"Found window manager: |%s|", str);
1626 if (g_strcmp0(str,
"i3") == 0) {
1632 xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle);
1640 char *display_str = (
char *)g_getenv(
"DISPLAY");
1645 if (
config.enable_imdkit) {
1646 xcb_compound_text_init();
1649 xcb->source = g_water_xcb_source_new(g_main_loop_get_context(
xcb->main_loop),
1650 display_str, &
xcb->screen_nbr,
1652 if (
xcb->source == NULL) {
1653 g_warning(
"Failed to open display: %s", display_str);
1656 xcb->connection = g_water_xcb_source_get_connection(
xcb->source);
1658 if (
config.enable_imdkit) {
1659 xcb->im = xcb_xim_create(
xcb->connection,
xcb->screen_nbr, NULL);
1660 xcb->syms = xcb_key_symbols_alloc(
xcb->connection);
1668#ifndef XCB_IMDKIT_1_0_3_LOWER
1669 if (
config.enable_imdkit) {
1670 xcb_xim_set_use_compound_text(
xcb->im,
true);
1671 xcb_xim_set_use_utf8_string(
xcb->im,
true);
1678 xcb->screen = xcb_aux_get_screen(
xcb->connection,
xcb->screen_nbr);
1682 xcb_intern_atom_cookie_t *ac =
1683 xcb_ewmh_init_atoms(
xcb->connection, &
xcb->ewmh);
1684 xcb_generic_error_t *errors = NULL;
1685 xcb_ewmh_init_atoms_replies(&
xcb->ewmh, ac, &errors);
1687 g_warning(
"Failed to create EWMH atoms");
1694 if (xkb_x11_setup_xkb_extension(
1695 xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION,
1696 XKB_X11_MIN_MINOR_XKB_VERSION, XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS,
1697 NULL, NULL, &
xcb->xkb.first_event, NULL) < 0) {
1698 g_warning(
"cannot setup XKB extension!");
1702 xcb->xkb.device_id = xkb_x11_get_core_keyboard_device_id(
xcb->connection);
1706 (XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY |
1707 XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_STATE_NOTIFY),
1709 required_nkn_details = (XCB_XKB_NKN_DETAIL_KEYCODES),
1711 required_map_parts =
1712 (XCB_XKB_MAP_PART_KEY_TYPES | XCB_XKB_MAP_PART_KEY_SYMS |
1713 XCB_XKB_MAP_PART_MODIFIER_MAP | XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
1714 XCB_XKB_MAP_PART_KEY_ACTIONS | XCB_XKB_MAP_PART_VIRTUAL_MODS |
1715 XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP),
1717 required_state_details =
1718 (XCB_XKB_STATE_PART_MODIFIER_BASE | XCB_XKB_STATE_PART_MODIFIER_LATCH |
1719 XCB_XKB_STATE_PART_MODIFIER_LOCK | XCB_XKB_STATE_PART_GROUP_BASE |
1720 XCB_XKB_STATE_PART_GROUP_LATCH | XCB_XKB_STATE_PART_GROUP_LOCK),
1723 static const xcb_xkb_select_events_details_t details = {
1724 .affectNewKeyboard = required_nkn_details,
1725 .newKeyboardDetails = required_nkn_details,
1726 .affectState = required_state_details,
1727 .stateDetails = required_state_details,
1729 xcb_xkb_select_events(
xcb->connection,
xcb->xkb.device_id,
1737 xcb->bindings_seat = nk_bindings_seat_new(
bindings, XKB_CONTEXT_NO_FLAGS);
1738 struct xkb_keymap *keymap = xkb_x11_keymap_new_from_device(
1739 nk_bindings_seat_get_context(
xcb->bindings_seat),
xcb->connection,
1740 xcb->xkb.device_id, XKB_KEYMAP_COMPILE_NO_FLAGS);
1741 if (keymap == NULL) {
1742 g_warning(
"Failed to get Keymap for current keyboard device.");
1745 struct xkb_state *state = xkb_x11_state_new_from_device(
1746 keymap,
xcb->connection,
xcb->xkb.device_id);
1747 if (state == NULL) {
1748 g_warning(
"Failed to get state object for current keyboard device.");
1752 nk_bindings_seat_update_keymap(
xcb->bindings_seat, keymap, state);
1753 xkb_state_unref(state);
1754 xkb_keymap_unref(keymap);
1759 if (xcb_connection_has_error(
xcb->connection)) {
1760 g_warning(
"Connection has error");
1767 if (xcb_connection_has_error(
xcb->connection)) {
1768 g_warning(
"Connection has error");
1772 if (
xcb->sndisplay != NULL) {
1773 xcb->sncontext = sn_launchee_context_new_from_environment(
xcb->sndisplay,
1776 if (xcb_connection_has_error(
xcb->connection)) {
1777 g_warning(
"Connection has error");
1785 xcb_depth_t *root_depth = NULL;
1786 xcb_depth_iterator_t depth_iter;
1787 for (depth_iter = xcb_screen_allowed_depths_iterator(
xcb->screen);
1788 depth_iter.rem; xcb_depth_next(&depth_iter)) {
1789 xcb_depth_t *d = depth_iter.data;
1791 xcb_visualtype_iterator_t visual_iter;
1792 for (visual_iter = xcb_depth_visuals_iterator(d); visual_iter.rem;
1793 xcb_visualtype_next(&visual_iter)) {
1794 xcb_visualtype_t *v = visual_iter.data;
1795 if ((v->bits_per_rgb_value == 8) && (d->depth == 32) &&
1796 (v->_class == XCB_VISUAL_CLASS_TRUE_COLOR)) {
1800 if (
xcb->screen->root_visual == v->visual_id) {
1807 xcb_void_cookie_t c;
1808 xcb_generic_error_t *e;
1809 map = xcb_generate_id(
xcb->connection);
1810 c = xcb_create_colormap_checked(
xcb->connection, XCB_COLORMAP_ALLOC_NONE,
1812 e = xcb_request_check(
xcb->connection, c);
1823 map =
xcb->screen->default_colormap;
1828 xcb_cursor_context_t *ctx;
1830 if (xcb_cursor_context_new(
xcb->connection,
xcb->screen, &ctx) < 0) {
1837 if (
cursors[i] == XCB_CURSOR_NONE) {
1843 xcb_cursor_context_free(ctx);
1853 g_warning(
"Failed to grab pointer after %u times. Giving up.",
1855 return G_SOURCE_REMOVE;
1858 return G_SOURCE_REMOVE;
1861 return G_SOURCE_CONTINUE;
1866 g_warning(
"Failed to grab keyboard after %u times. Giving up.",
1868 g_main_loop_quit(
xcb->main_loop);
1869 return G_SOURCE_REMOVE;
1872 return G_SOURCE_REMOVE;
1875 return G_SOURCE_CONTINUE;
1889 if (
find_arg(
"-normal-window") >= 0 ||
find_arg(
"-transient-window") >= 0) {
1892 if (
find_arg(
"-no-lazy-grab") >= 0) {
1894 g_warning(
"Failed to grab keyboard, even after %d uS.", 500 * 1000);
1898 g_warning(
"Failed to grab mouse pointer, even after %d uS.", 100 * 1000);
1916 xcb_flush(
xcb->connection);
1920 if (
xcb->connection == NULL) {
1924 g_debug(
"Cleaning up XCB and XKB");
1926 nk_bindings_seat_free(
xcb->bindings_seat);
1927 if (
xcb->sncontext != NULL) {
1928 sn_launchee_context_unref(
xcb->sncontext);
1929 xcb->sncontext = NULL;
1931 if (
xcb->sndisplay != NULL) {
1932 sn_display_unref(
xcb->sndisplay);
1933 xcb->sndisplay = NULL;
1936 xcb_ewmh_connection_wipe(&(
xcb->ewmh));
1937 xcb_flush(
xcb->connection);
1938 xcb_aux_sync(
xcb->connection);
1940 if (
config.enable_imdkit) {
1941 xcb_xim_close(
xcb->im);
1942 xcb_xim_destroy(
xcb->im);
1946 g_water_xcb_source_free(
xcb->source);
1948 xcb->connection = NULL;
1950 xcb->screen_nbr = 0;
1955 const uint32_t MWM_HINTS_DECORATIONS = (1 << 1);
1957 struct MotifWMHints {
1960 uint32_t decorations;
1965 struct MotifWMHints hints;
1966 hints.flags = MWM_HINTS_DECORATIONS;
1967 hints.decorations = 0;
1968 hints.functions = 0;
1969 hints.inputMode = 0;
1972 xcb_atom_t ha =
netatoms[_MOTIF_WM_HINTS];
1973 xcb_change_property(
xcb->connection, XCB_PROP_MODE_REPLACE, window, ha, ha,
1982 if (
cursors[type] == XCB_CURSOR_NONE) {
1986 xcb_change_window_attributes(
xcb->connection, window, XCB_CW_CURSOR,
1990 g_free(
xcb->clipboard);
1991 xcb->clipboard = data;
1995 if (
config.steal_focus != TRUE) {
1996 xcb->focus_revert = 0;
1999 xcb_generic_error_t *error;
2000 xcb_get_input_focus_reply_t *freply;
2001 xcb_get_input_focus_cookie_t fcookie = xcb_get_input_focus(
xcb->connection);
2002 freply = xcb_get_input_focus_reply(
xcb->connection, fcookie, &error);
2003 if (error != NULL) {
2004 g_warning(
"Could not get input focus (error %d), will revert focus to best "
2008 xcb->focus_revert = 0;
2010 xcb->focus_revert = freply->focus;
2012 xcb_set_input_focus(
xcb->connection, XCB_INPUT_FOCUS_POINTER_ROOT, w,
2014 xcb_flush(
xcb->connection);
2018 if (
xcb->focus_revert == 0) {
2022 xcb_set_input_focus(
xcb->connection, XCB_INPUT_FOCUS_POINTER_ROOT,
2023 xcb->focus_revert, XCB_CURRENT_TIME);
2024 xcb_flush(
xcb->connection);
struct _display_proxy display_proxy
struct _workarea workarea
char * rofi_latin_to_utf8_strdup(const char *input, gssize length)
int find_arg_str(const char *const key, char **val)
int find_arg(const char *const key)
xcb_window_t rofi_view_get_window(void)
RofiViewState * rofi_view_get_active(void)
void rofi_view_handle_text(RofiViewState *state, char *text)
void rofi_view_handle_mouse_motion(RofiViewState *state, gint x, gint y, gboolean find_mouse_target)
void rofi_view_temp_click_to_exit(RofiViewState *state, xcb_window_t target)
void rofi_view_temp_configure_notify(RofiViewState *state, xcb_configure_notify_event_t *xce)
void rofi_view_frame_callback(void)
void rofi_view_maybe_update(RofiViewState *state)
const view_proxy * xcb_view_proxy
const gchar * description
static display_proxy display_
int xcb_configure_notify_event_t
display_proxy *const xcb_proxy
static int xcb_display_monitor_active(workarea *mon)
static int take_pointer(xcb_window_t w, int iters)
#define RANDR_PREF_MAJOR_VERSION
const char * traditional_name
static int x11_is_extension_present(const char *extension)
static gboolean lazy_grab_pointer(G_GNUC_UNUSED gpointer data)
static void x11_workarea_fix_rotation(workarea *w)
cairo_surface_t * x11_helper_get_screenshot_surface(void)
static void x11_build_monitor_layout(void)
char * window_get_text_prop(xcb_window_t w, xcb_atom_t atom)
static gboolean xcb_display_setup(GMainLoop *main_loop, NkBindings *bindings)
const struct @324115166212050013202135155310300305243237052323 cursor_names[]
static xcb_pixmap_t get_root_pixmap(xcb_connection_t *c, xcb_screen_t *screen, xcb_atom_t atom)
static void release_pointer(void)
static void xcb_display_set_input_focus(guint w)
static bool get_atom_name(xcb_connection_t *conn, xcb_atom_t atom, char **out)
struct _xcb_stuff xcb_int
static int monitor_active_from_winid(xcb_drawable_t id, workarea *mon)
static void x11_create_visual_and_colormap(void)
static gboolean x11_button_to_nk_bindings_scroll(guint32 x11_button, NkBindingsScrollAxis *axis, gint32 *steps)
static void monitor_dimensions(int x, int y, workarea *mon)
cairo_surface_t * x11_helper_get_bg_surface(void)
static void x11_lookup_cursors(void)
static gboolean lazy_grab_keyboard(G_GNUC_UNUSED gpointer data)
#define INTERSECT(x, y, x1, y1, w1, h1)
static workarea * x11_get_monitor_from_output(xcb_randr_output_t out)
static void error_trap_pop(G_GNUC_UNUSED SnDisplay *display, xcb_connection_t *xdisplay)
void x11_set_cursor(xcb_window_t window, X11CursorType type)
static void x11_build_monitor_layout_xinerama(void)
static xcb_visualtype_t * lookup_visual(xcb_screen_t *s, xcb_visualid_t vis)
unsigned int lazy_grab_retry_count_pt
static xcb_visualtype_t * root_visual
static uint32_t * create_kernel(int radius, double deviation, uint32_t *sum2)
char * x11_helper_get_window_manager(void)
static void x11_create_frequently_used_atoms(void)
static int monitor_active_from_id_focused(int mon_id, workarea *mon)
void cairo_image_surface_blur(cairo_surface_t *surface, int radius, double deviation)
static gboolean x11_button_to_nk_bindings_button(guint32 x11_button, NkBindingsMouseButton *button)
xcb_cursor_t cursors[NUM_CURSORS]
static void x11_monitor_free(workarea *m)
static void x11_helper_discover_window_manager(void)
static const struct _view_proxy * xcb_display_view_proxy(void)
static int monitor_get_dimension(int monitor_id, workarea *mon)
static void xcb_display_dump_monitor_layout(void)
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
static void rofi_view_paste(RofiViewState *state, xcb_selection_notify_event_t *xse)
static gboolean xcb_display_late_setup(void)
void window_set_atom_prop(xcb_window_t w, xcb_atom_t prop, xcb_atom_t *atoms, int count)
static void xcb_display_startup_notification(RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data)
const char * netatom_names[]
static int monitor_active_from_id(int mon_id, workarea *mon)
static void x11_monitors_free(void)
static guint xcb_display_scale(void)
static void error_trap_push(G_GNUC_UNUSED SnDisplay *display, G_GNUC_UNUSED xcb_connection_t *xdisplay)
WindowManagerQuirk current_window_manager
static int pointer_get(xcb_window_t root, int *x, int *y)
#define RANDR_PREF_MINOR_VERSION
#define sn_launcher_context_set_application_id
static void rofi_key_press_event_handler(xcb_key_press_event_t *xkpe, RofiViewState *state)
static void rofi_key_release_event_handler(xcb_key_release_event_t *xkre, G_GNUC_UNUSED RofiViewState *state)
void xcb_stuff_set_clipboard(char *data)
static int error_trap_depth
static void release_keyboard(void)
static void xcb_display_cleanup(void)
static gboolean main_loop_x11_event_handler(xcb_generic_event_t *ev, G_GNUC_UNUSED gpointer user_data)
static void xcb_display_early_cleanup(void)
void x11_disable_decoration(xcb_window_t window)
static void main_loop_x11_event_handler_view(xcb_generic_event_t *event)
xcb_atom_t netatoms[NUM_NETATOMS]
xcb_visualtype_t * visual
static void xcb_display_revert_input_focus(void)
cairo_surface_t * x11_helper_get_screenshot_surface_window(xcb_window_t window, int size)
struct _xcb_stuff xcb_stuff
@ WM_PANGO_WORKSPACE_NAMES
@ WM_DO_NOT_CHANGE_CURRENT_DESKTOP