Merge remote-tracking branch 'upstream/main' into wlroots-next

Fixes: https://codeberg.org/dwl/dwl/issues/432
Fixes: https://codeberg.org/dwl/dwl/issues/547
This commit is contained in:
Leonardo Hernández Hernández 2023-12-11 00:31:17 -06:00
commit 126a333354
No known key found for this signature in database
GPG Key ID: E538897EE11B9624
3 changed files with 22 additions and 15 deletions

View File

@ -10,7 +10,7 @@ static inline int
client_is_x11(Client *c) client_is_x11(Client *c)
{ {
#ifdef XWAYLAND #ifdef XWAYLAND
return c->type == X11Managed || c->type == X11Unmanaged; return c->type == X11;
#endif #endif
return 0; return 0;
} }
@ -270,7 +270,8 @@ static inline int
client_is_unmanaged(Client *c) client_is_unmanaged(Client *c)
{ {
#ifdef XWAYLAND #ifdef XWAYLAND
return c->type == X11Unmanaged; if (client_is_x11(c))
return c->surface.xwayland->override_redirect;
#endif #endif
return 0; return 0;
} }

View File

@ -7,6 +7,7 @@
static const int sloppyfocus = 1; /* focus follows mouse */ static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */ static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int borderpx = 1; /* border pixel of windows */
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff); static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff); static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff); static const float urgentcolor[] = COLOR(0xff0000ff);

31
dwl.c
View File

@ -74,7 +74,7 @@
/* enums */ /* enums */
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */ enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11Managed, X11Unmanaged }; /* client types */ enum { XDGShell, LayerShell, X11 }; /* client types */
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrFS, LyrTop, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */ enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrFS, LyrTop, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
#ifdef XWAYLAND #ifdef XWAYLAND
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar, enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
@ -362,6 +362,7 @@ static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
static struct wlr_cursor *cursor; static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr; static struct wlr_xcursor_manager *cursor_mgr;
static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr; static struct wlr_session_lock_manager_v1 *session_lock_mgr;
static struct wlr_scene_rect *locked_bg; static struct wlr_scene_rect *locked_bg;
static struct wlr_session_lock_v1 *cur_lock; static struct wlr_session_lock_v1 *cur_lock;
@ -369,6 +370,7 @@ static struct wl_listener lock_listener = {.notify = locksession};
static struct wlr_seat *seat; static struct wlr_seat *seat;
static struct wl_list keyboards; static struct wl_list keyboards;
static struct wlr_surface *held_grab;
static unsigned int cursor_mode; static unsigned int cursor_mode;
static Client *grabc; static Client *grabc;
static int grabcx, grabcy; /* client-relative */ static int grabcx, grabcy; /* client-relative */
@ -556,6 +558,7 @@ buttonpress(struct wl_listener *listener, void *data)
switch (event->state) { switch (event->state) {
case WLR_BUTTON_PRESSED: case WLR_BUTTON_PRESSED:
cursor_mode = CurPressed; cursor_mode = CurPressed;
held_grab = seat->pointer_state.focused_surface;
if (locked) if (locked)
break; break;
@ -575,6 +578,7 @@ buttonpress(struct wl_listener *listener, void *data)
} }
break; break;
case WLR_BUTTON_RELEASED: case WLR_BUTTON_RELEASED:
held_grab = NULL;
/* If you released any buttons, we exit interactive move/resize mode. */ /* If you released any buttons, we exit interactive move/resize mode. */
/* TODO should reset to the pointer focus's current setcursor */ /* TODO should reset to the pointer focus's current setcursor */
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) { if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
@ -1615,7 +1619,6 @@ motionnotify(uint32_t time)
double sx = 0, sy = 0; double sx = 0, sy = 0;
Client *c = NULL, *w = NULL; Client *c = NULL, *w = NULL;
LayerSurface *l = NULL; LayerSurface *l = NULL;
int type;
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
/* time is 0 in internal calls meant to restore pointer focus. */ /* time is 0 in internal calls meant to restore pointer focus. */
@ -1645,14 +1648,12 @@ motionnotify(uint32_t time)
/* Find the client under the pointer and send the event along. */ /* Find the client under the pointer and send the event along. */
xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy); xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
if (cursor_mode == CurPressed && !seat->drag) { if (cursor_mode == CurPressed && !seat->drag && surface != held_grab
if ((type = toplevel_from_wlr_surface( && toplevel_from_wlr_surface(held_grab, &w, &l) >= 0) {
seat->pointer_state.focused_surface, &w, &l)) >= 0) { c = w;
c = w; surface = held_grab;
surface = seat->pointer_state.focused_surface; sx = cursor->x - (l ? l->geom.x : w->geom.x);
sx = cursor->x - (type == LayerShell ? l->geom.x : w->geom.x); sy = cursor->y - (l ? l->geom.y : w->geom.y);
sy = cursor->y - (type == LayerShell ? l->geom.y : w->geom.y);
}
} }
/* If there's no client surface under the cursor, set the cursor image to a /* If there's no client surface under the cursor, set the cursor image to a
@ -2180,6 +2181,7 @@ setup(void)
/* Initialize the scene graph used to lay out windows */ /* Initialize the scene graph used to lay out windows */
scene = wlr_scene_create(); scene = wlr_scene_create();
root_bg = wlr_scene_rect_create(&scene->tree, 0, 0, rootcolor);
for (i = 0; i < NUM_LAYERS; i++) for (i = 0; i < NUM_LAYERS; i++)
layers[i] = wlr_scene_tree_create(&scene->tree); layers[i] = wlr_scene_tree_create(&scene->tree);
drag_icon = wlr_scene_tree_create(&scene->tree); drag_icon = wlr_scene_tree_create(&scene->tree);
@ -2564,6 +2566,9 @@ updatemons(struct wl_listener *listener, void *data)
/* Now that we update the output layout we can get its box */ /* Now that we update the output layout we can get its box */
wlr_output_layout_get_box(output_layout, NULL, &sgeom); wlr_output_layout_get_box(output_layout, NULL, &sgeom);
wlr_scene_node_set_position(&root_bg->node, sgeom.x, sgeom.y);
wlr_scene_rect_set_size(root_bg, sgeom.width, sgeom.height);
/* Make sure the clients are hidden when dwl is locked */ /* Make sure the clients are hidden when dwl is locked */
wlr_scene_node_set_position(&locked_bg->node, sgeom.x, sgeom.y); wlr_scene_node_set_position(&locked_bg->node, sgeom.x, sgeom.y);
wlr_scene_rect_set_size(locked_bg, sgeom.width, sgeom.height); wlr_scene_rect_set_size(locked_bg, sgeom.width, sgeom.height);
@ -2746,7 +2751,7 @@ activatex11(struct wl_listener *listener, void *data)
Client *c = wl_container_of(listener, c, activate); Client *c = wl_container_of(listener, c, activate);
/* Only "managed" windows can be activated */ /* Only "managed" windows can be activated */
if (c->type == X11Managed) if (!client_is_unmanaged(c))
wlr_xwayland_surface_activate(c->surface.xwayland, 1); wlr_xwayland_surface_activate(c->surface.xwayland, 1);
} }
@ -2766,7 +2771,7 @@ configurex11(struct wl_listener *listener, void *data)
struct wlr_xwayland_surface_configure_event *event = data; struct wlr_xwayland_surface_configure_event *event = data;
if (!c->mon) if (!c->mon)
return; return;
if (c->isfloating || c->type == X11Unmanaged) if (c->isfloating || client_is_unmanaged(c))
resize(c, (struct wlr_box){.x = event->x, .y = event->y, resize(c, (struct wlr_box){.x = event->x, .y = event->y,
.width = event->width, .height = event->height}, 0); .width = event->width, .height = event->height}, 0);
else else
@ -2782,7 +2787,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
/* Allocate a Client for this surface */ /* Allocate a Client for this surface */
c = xsurface->data = ecalloc(1, sizeof(*c)); c = xsurface->data = ecalloc(1, sizeof(*c));
c->surface.xwayland = xsurface; c->surface.xwayland = xsurface;
c->type = xsurface->override_redirect ? X11Unmanaged : X11Managed; c->type = X11;
c->bw = borderpx; c->bw = borderpx;
/* Listen to the various events it can emit */ /* Listen to the various events it can emit */