mirror of
https://github.com/tiyn/dwl.git
synced 2026-01-11 17:39:45 +01:00
Compare commits
2 Commits
xwayland-h
...
warpcursor
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e9c5a374f | |||
| 9c78e36a36 |
9
client.h
9
client.h
@@ -94,12 +94,9 @@ client_activate_surface(struct wlr_surface *s, int activated)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
struct wlr_xwayland_surface *surface;
|
||||
if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
if (activated && surface->minimized)
|
||||
wlr_xwayland_surface_set_minimized(surface, false);
|
||||
|
||||
wlr_xwayland_surface_activate(surface, activated);
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
wlr_xwayland_surface_activate(xsurface, activated);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
46
dwl.c
46
dwl.c
@@ -131,7 +131,6 @@ typedef struct {
|
||||
#ifdef XWAYLAND
|
||||
struct wl_listener activate;
|
||||
struct wl_listener associate;
|
||||
struct wl_listener minimize;
|
||||
struct wl_listener dissociate;
|
||||
struct wl_listener configure;
|
||||
struct wl_listener set_hints;
|
||||
@@ -348,6 +347,7 @@ static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
||||
static void virtualpointer(struct wl_listener *listener, void *data);
|
||||
static void warpcursor(const Client *c);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
@@ -443,7 +443,6 @@ static void associatex11(struct wl_listener *listener, void *data);
|
||||
static void configurex11(struct wl_listener *listener, void *data);
|
||||
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||
static void dissociatex11(struct wl_listener *listener, void *data);
|
||||
static void minimizenotify(struct wl_listener *listener, void *data);
|
||||
static void sethints(struct wl_listener *listener, void *data);
|
||||
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
|
||||
@@ -542,6 +541,7 @@ arrange(Monitor *m)
|
||||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
warpcursor(focustop(selmon));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1336,7 +1336,6 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->activate.link);
|
||||
wl_list_remove(&c->associate.link);
|
||||
wl_list_remove(&c->configure.link);
|
||||
wl_list_remove(&c->minimize.link);
|
||||
wl_list_remove(&c->dissociate.link);
|
||||
wl_list_remove(&c->set_hints.link);
|
||||
} else
|
||||
@@ -1410,6 +1409,10 @@ focusclient(Client *c, int lift)
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
/* Warp cursor to center of client if it is outside */
|
||||
if (lift)
|
||||
warpcursor(c);
|
||||
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
@@ -3002,6 +3005,27 @@ virtualpointer(struct wl_listener *listener, void *data)
|
||||
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
|
||||
}
|
||||
|
||||
void
|
||||
warpcursor(const Client *c) {
|
||||
if (cursor_mode != CurNormal) {
|
||||
return;
|
||||
}
|
||||
if (!c && selmon) {
|
||||
wlr_cursor_warp_closest(cursor,
|
||||
NULL,
|
||||
selmon->w.x + selmon->w.width / 2.0 ,
|
||||
selmon->w.y + selmon->w.height / 2.0);
|
||||
}
|
||||
else if ( c && (cursor->x < c->geom.x ||
|
||||
cursor->x > c->geom.x + c->geom.width ||
|
||||
cursor->y < c->geom.y ||
|
||||
cursor->y > c->geom.y + c->geom.height))
|
||||
wlr_cursor_warp_closest(cursor,
|
||||
NULL,
|
||||
c->geom.x + c->geom.width / 2.0,
|
||||
c->geom.y + c->geom.height / 2.0);
|
||||
}
|
||||
|
||||
Monitor *
|
||||
xytomon(double x, double y)
|
||||
{
|
||||
@@ -3135,7 +3159,6 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
||||
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
||||
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
||||
LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
|
||||
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
||||
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
||||
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
||||
@@ -3150,21 +3173,6 @@ dissociatex11(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->unmap.link);
|
||||
}
|
||||
|
||||
void
|
||||
minimizenotify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
Client *c = wl_container_of(listener, c, minimize);
|
||||
struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
|
||||
struct wlr_xwayland_minimize_event *e = data;
|
||||
int focused;
|
||||
|
||||
if (xsurface->surface == NULL || !xsurface->surface->mapped)
|
||||
return;
|
||||
|
||||
focused = seat->keyboard_state.focused_surface == xsurface->surface;
|
||||
wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
|
||||
}
|
||||
|
||||
void
|
||||
sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
||||
71
warpcursor.patch
Normal file
71
warpcursor.patch
Normal file
@@ -0,0 +1,71 @@
|
||||
From 4951ccc89dac2b557994b2f6c3aacb2398e2d1b1 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Thu, 4 Jan 2024 20:30:01 +1000
|
||||
Subject: [PATCH] warpcursor
|
||||
|
||||
---
|
||||
dwl.c | 27 +++++++++++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 145fd018..f7ad6c13 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -347,6 +347,7 @@ static void urgent(struct wl_listener *listener, void *data);
|
||||
static void view(const Arg *arg);
|
||||
static void virtualkeyboard(struct wl_listener *listener, void *data);
|
||||
static void virtualpointer(struct wl_listener *listener, void *data);
|
||||
+static void warpcursor(const Client *c);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
@@ -514,6 +515,7 @@ arrange(Monitor *m)
|
||||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
+ warpcursor(focustop(selmon));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1323,6 +1325,10 @@ focusclient(Client *c, int lift)
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
+ /* Warp cursor to center of client if it is outside */
|
||||
+ if (lift)
|
||||
+ warpcursor(c);
|
||||
+
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
@@ -2927,6 +2933,27 @@ virtualpointer(struct wl_listener *listener, void *data)
|
||||
wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output);
|
||||
}
|
||||
|
||||
+void
|
||||
+warpcursor(const Client *c) {
|
||||
+ if (cursor_mode != CurNormal) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!c && selmon) {
|
||||
+ wlr_cursor_warp_closest(cursor,
|
||||
+ NULL,
|
||||
+ selmon->w.x + selmon->w.width / 2.0 ,
|
||||
+ selmon->w.y + selmon->w.height / 2.0);
|
||||
+ }
|
||||
+ else if ( c && (cursor->x < c->geom.x ||
|
||||
+ cursor->x > c->geom.x + c->geom.width ||
|
||||
+ cursor->y < c->geom.y ||
|
||||
+ cursor->y > c->geom.y + c->geom.height))
|
||||
+ wlr_cursor_warp_closest(cursor,
|
||||
+ NULL,
|
||||
+ c->geom.x + c->geom.width / 2.0,
|
||||
+ c->geom.y + c->geom.height / 2.0);
|
||||
+}
|
||||
+
|
||||
Monitor *
|
||||
xytomon(double x, double y)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
From 7277f668f19f5a7fcfbbc96e80cb2829487848ca Mon Sep 17 00:00:00 2001
|
||||
From: korei999 <ju7t1xe@gmail.com>
|
||||
Date: Mon, 1 Apr 2024 15:13:11 +0300
|
||||
Subject: [PATCH] handle minimize request for xwayland clients
|
||||
|
||||
---
|
||||
client.h | 9 ++++++---
|
||||
dwl.c | 19 +++++++++++++++++++
|
||||
2 files changed, 25 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/client.h b/client.h
|
||||
index 800b867..c46cfb2 100644
|
||||
--- a/client.h
|
||||
+++ b/client.h
|
||||
@@ -94,9 +94,12 @@ client_activate_surface(struct wlr_surface *s, int activated)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
- struct wlr_xwayland_surface *xsurface;
|
||||
- if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
- wlr_xwayland_surface_activate(xsurface, activated);
|
||||
+ struct wlr_xwayland_surface *surface;
|
||||
+ if ((surface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
||||
+ if (activated && surface->minimized)
|
||||
+ wlr_xwayland_surface_set_minimized(surface, false);
|
||||
+
|
||||
+ wlr_xwayland_surface_activate(surface, activated);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 39ce68c..b49f57b 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -131,6 +131,7 @@ typedef struct {
|
||||
#ifdef XWAYLAND
|
||||
struct wl_listener activate;
|
||||
struct wl_listener associate;
|
||||
+ struct wl_listener minimize;
|
||||
struct wl_listener dissociate;
|
||||
struct wl_listener configure;
|
||||
struct wl_listener set_hints;
|
||||
@@ -412,6 +413,7 @@ static void configurex11(struct wl_listener *listener, void *data);
|
||||
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||
static void dissociatex11(struct wl_listener *listener, void *data);
|
||||
static xcb_atom_t getatom(xcb_connection_t *xc, const char *name);
|
||||
+static void minimizenotify(struct wl_listener *listener, void *data);
|
||||
static void sethints(struct wl_listener *listener, void *data);
|
||||
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||
static struct wlr_xwayland *xwayland;
|
||||
@@ -1177,6 +1179,7 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&c->activate.link);
|
||||
wl_list_remove(&c->associate.link);
|
||||
wl_list_remove(&c->configure.link);
|
||||
+ wl_list_remove(&c->minimize.link);
|
||||
wl_list_remove(&c->dissociate.link);
|
||||
wl_list_remove(&c->set_hints.link);
|
||||
} else
|
||||
@@ -2984,6 +2987,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
||||
LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);
|
||||
LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11);
|
||||
LISTEN(&xsurface->events.request_activate, &c->activate, activatex11);
|
||||
+ LISTEN(&xsurface->events.request_minimize, &c->minimize, minimizenotify);
|
||||
LISTEN(&xsurface->events.request_configure, &c->configure, configurex11);
|
||||
LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
||||
LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints);
|
||||
@@ -3011,6 +3015,21 @@ getatom(xcb_connection_t *xc, const char *name)
|
||||
return atom;
|
||||
}
|
||||
|
||||
+void
|
||||
+minimizenotify(struct wl_listener *listener, void *data)
|
||||
+{
|
||||
+ Client *c = wl_container_of(listener, c, minimize);
|
||||
+ struct wlr_xwayland_surface *xsurface = c->surface.xwayland;
|
||||
+ struct wlr_xwayland_minimize_event *e = data;
|
||||
+ int focused;
|
||||
+
|
||||
+ if (xsurface->surface == NULL || !xsurface->surface->mapped)
|
||||
+ return;
|
||||
+
|
||||
+ focused = seat->keyboard_state.focused_surface == xsurface->surface;
|
||||
+ wlr_xwayland_surface_set_minimized(xsurface, !focused && e->minimize);
|
||||
+}
|
||||
+
|
||||
void
|
||||
sethints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
--
|
||||
2.44.0
|
||||
|
||||
Reference in New Issue
Block a user