Skip to content

Commit

Permalink
input: fix draw-cursor not appearing over Wayland-only windows
Browse files Browse the repository at this point in the history
re #27
  • Loading branch information
bk138 committed Nov 10, 2020
1 parent c4c0ac6 commit 56a6fb6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ void setup_input_devices (GromitData *data)
void release_grab (GromitData *data,
GdkDevice *dev)
{
char *xdg_session_type = getenv("XDG_SESSION_TYPE");
if (xdg_session_type && strcmp(xdg_session_type, "wayland") == 0) {
/*
When running under Wayland (XWayland in our case),
make the whole transparent window transparent to input.
*/
cairo_region_t *r = cairo_region_create();
gtk_widget_input_shape_combine_region(data->win, r);
cairo_region_destroy(r);
}


if(!dev) /* this means release all grabs */
{
GHashTableIter it;
Expand Down Expand Up @@ -270,6 +282,18 @@ void acquire_grab (GromitData *data,
{
show_window (data);

char *xdg_session_type = getenv("XDG_SESSION_TYPE");
if (xdg_session_type && strcmp(xdg_session_type, "wayland") == 0) {
/*
When running under Wayland (XWayland in our case), make the whole transparent window react to input.
Otherwise, no draw-cursor is shown over Wayland-only windows.
*/
cairo_rectangle_int_t rect = {0, 0, data->width, data->height};
cairo_region_t *r = cairo_region_create_rectangle(&rect);
gtk_widget_input_shape_combine_region(data->win, r);
cairo_region_destroy(r);
}

if(!dev) /* this means grab all */
{
GHashTableIter it;
Expand Down

0 comments on commit 56a6fb6

Please sign in to comment.