mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-11-03 20:02:23 +00:00
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d16962424 | ||
|
|
7622bd3187 | ||
|
|
12a5856427 | ||
|
|
4ecb2a9df5 | ||
|
|
4953b7ea0c | ||
|
|
9dfaea2f79 | ||
|
|
5af5dd5e7e | ||
|
|
d3d4da3bd2 | ||
|
|
88c0c68d59 | ||
|
|
d41ecb745c | ||
|
|
52c4fb58ec | ||
|
|
38c7bd7ee8 | ||
|
|
6e1bfa86c7 | ||
|
|
e32535cf97 | ||
|
|
f4249db613 | ||
|
|
b2d2b701d7 | ||
|
|
2c9cb2af1b |
@@ -1,4 +1,4 @@
|
||||
_VERSION = 0.10-dev
|
||||
_VERSION = 0.9-dev
|
||||
VERSION = `git describe --tags --dirty 2>/dev/null || echo $(_VERSION)`
|
||||
|
||||
PKG_CONFIG = pkg-config
|
||||
@@ -8,21 +8,21 @@ PREFIX = /usr/local
|
||||
MANDIR = $(PREFIX)/share/man
|
||||
DATADIR = $(PREFIX)/share
|
||||
|
||||
WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.20`
|
||||
WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.20`
|
||||
WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.21`
|
||||
WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.21`
|
||||
|
||||
# Allow using an alternative wlroots installation
|
||||
# This has to have all the includes required by wlroots, e.g:
|
||||
# Assuming wlroots git repo is "${PWD}/wlroots" and you only ran "meson setup build && ninja -C build"
|
||||
#WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
|
||||
# -I$(PWD)/wlroots/include
|
||||
# WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
|
||||
# -I$(PWD)/wlroots/include
|
||||
# Set -rpath to avoid using the wrong library.
|
||||
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.20
|
||||
# WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/build -L$(PWD)/wlroots/build -lwlroots-0.21
|
||||
|
||||
# Assuming you ran "meson setup --prefix ${PWD}/0.20 build && ninja -C build install"
|
||||
# Assuming you ran "meson setup --prefix ${PWD}/0.21 build && ninja -C build install"
|
||||
#WLR_INCS = -I/usr/include/pixman-1 -I/usr/include/elogind -I/usr/include/libdrm \
|
||||
# -I$(PWD)/wlroots/0.20/include/wlroots-0.20
|
||||
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.20/lib64 -L$(PWD)/wlroots/0.20/lib64 -lwlroots-0.20
|
||||
# -I$(PWD)/wlroots/0.21/include/wlroots-0.21
|
||||
#WLR_LIBS = -Wl,-rpath,$(PWD)/wlroots/0.21/lib64 -L$(PWD)/wlroots/0.21/lib64 -lwlroots-0.21
|
||||
|
||||
XWAYLAND =
|
||||
XLIBS =
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
||||
#define TAGMASK ((1u << TAGCOUNT) - 1)
|
||||
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
|
||||
#define LISTEN_STATIC(E, H) do { struct wl_listener *_l = ecalloc(1, sizeof(*_l)); _l->notify = (H); wl_signal_add((E), _l); } while (0)
|
||||
#define LISTEN_STATIC(E, H, D) do { StaticListener *_l = ecalloc(1, sizeof(*_l)); _l->listener.notify = (H); _l->data = (D); wl_signal_add((E), &_l->listener); } while (0)
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
@@ -263,6 +263,12 @@ typedef struct {
|
||||
struct wl_listener destroy;
|
||||
} SessionLock;
|
||||
|
||||
typedef struct {
|
||||
/* Must keep this field first */
|
||||
struct wl_listener listener;
|
||||
void *data;
|
||||
} StaticListener;
|
||||
|
||||
/* function declarations */
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applygeom(Client *c);
|
||||
@@ -328,6 +334,7 @@ static void mapnotify(struct wl_listener *listener, void *data);
|
||||
static void maximizenotify(struct wl_listener *listener, void *data);
|
||||
static void monocle(Monitor *m);
|
||||
static void motionabsolute(struct wl_listener *listener, void *data);
|
||||
static char **monoff(struct wlr_output *wlr_output);
|
||||
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
|
||||
double sy, double sx_unaccel, double sy_unaccel);
|
||||
static void motionrelative(struct wl_listener *listener, void *data);
|
||||
@@ -353,6 +360,7 @@ static void setfullscreen(Client *c, int fullscreen);
|
||||
static void setlayout(const Arg *arg);
|
||||
static void setmfact(const Arg *arg);
|
||||
static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
||||
static void setmonoff(struct wlr_output *wlr_output, int off);
|
||||
static void setpsel(struct wl_listener *listener, void *data);
|
||||
static void setsel(struct wl_listener *listener, void *data);
|
||||
static void setup(void);
|
||||
@@ -450,6 +458,7 @@ static struct wl_event_source *transaction_idle;
|
||||
static struct wl_event_source *transaction_timer;
|
||||
static int transaction_waiting;
|
||||
static struct wl_array ghosts; /* struct wlr_scene_node *, unmapped clients */
|
||||
static struct wl_array offmons; /* char *, names of outputs turned off by clients */
|
||||
|
||||
/* global event handlers */
|
||||
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
||||
@@ -479,6 +488,7 @@ static struct wl_listener request_set_sel = {.notify = setsel};
|
||||
static struct wl_listener request_set_cursor_shape = {.notify = setcursorshape};
|
||||
static struct wl_listener request_start_drag = {.notify = requeststartdrag};
|
||||
static struct wl_listener start_drag = {.notify = startdrag};
|
||||
static struct wl_listener drag_icon_destroy = {.notify = destroydragicon};
|
||||
static struct wl_listener new_session_lock = {.notify = locksession};
|
||||
static struct wl_listener new_foreign_toplevel_capture_request = {.notify = capturerequest};
|
||||
|
||||
@@ -781,7 +791,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
void
|
||||
capturerequest(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request *request = data;
|
||||
struct wlr_ext_foreign_toplevel_image_capture_source_manager_v1_request_event *request = data;
|
||||
Client *view = request->toplevel_handle->data;
|
||||
|
||||
if (!view->image_capture_source) {
|
||||
@@ -824,6 +834,8 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
||||
void
|
||||
cleanup(void)
|
||||
{
|
||||
char **name;
|
||||
|
||||
cleanuplisteners();
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
@@ -849,6 +861,9 @@ cleanup(void)
|
||||
wl_event_source_remove(transaction_idle);
|
||||
wl_event_source_remove(transaction_timer);
|
||||
wl_array_release(&ghosts);
|
||||
wl_array_for_each(name, &offmons)
|
||||
free(*name);
|
||||
wl_array_release(&offmons);
|
||||
|
||||
wl_display_destroy(dpy);
|
||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
||||
@@ -1039,8 +1054,8 @@ commitnotify(struct wl_listener *listener, void *data)
|
||||
void
|
||||
commitpopup(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_surface *surface = data;
|
||||
struct wlr_xdg_popup *popup = wlr_xdg_popup_try_from_wlr_surface(surface);
|
||||
StaticListener *sl = wl_container_of(listener, sl, listener);
|
||||
struct wlr_xdg_popup *popup = sl->data;
|
||||
LayerSurface *l = NULL;
|
||||
Client *c = NULL;
|
||||
struct wlr_box box;
|
||||
@@ -1083,7 +1098,7 @@ void
|
||||
createidleinhibitor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_idle_inhibitor_v1 *idle_inhibitor = data;
|
||||
LISTEN_STATIC(&idle_inhibitor->events.destroy, destroyidleinhibitor);
|
||||
LISTEN_STATIC(&idle_inhibitor->events.destroy, destroyidleinhibitor, idle_inhibitor);
|
||||
|
||||
checkidleinhibitor(NULL);
|
||||
}
|
||||
@@ -1229,14 +1244,17 @@ createmon(struct wl_listener *listener, void *data)
|
||||
* monitor supports only a specific set of modes. We just pick the
|
||||
* monitor's preferred mode; a more sophisticated compositor would let
|
||||
* the user configure it. */
|
||||
wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output));
|
||||
|
||||
/* Set up event listeners */
|
||||
LISTEN(&wlr_output->events.frame, &m->frame, rendermon);
|
||||
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
|
||||
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
|
||||
|
||||
wlr_output_state_set_enabled(&state, 1);
|
||||
/* Some monitors disconnect when they are turned off and reconnect shortly
|
||||
* after, so keep outputs that were turned off disabled. */
|
||||
if (!monoff(wlr_output)) {
|
||||
wlr_output_state_set_mode(&state, wlr_output_preferred_mode(wlr_output));
|
||||
wlr_output_state_set_enabled(&state, 1);
|
||||
}
|
||||
wlr_output_commit_state(wlr_output, &state);
|
||||
wlr_output_state_finish(&state);
|
||||
|
||||
@@ -1263,8 +1281,10 @@ createmon(struct wl_listener *listener, void *data)
|
||||
*/
|
||||
m->scene_output = wlr_scene_output_create(scene, wlr_output);
|
||||
|
||||
if (!wlr_output->enabled)
|
||||
if (!wlr_output->enabled) {
|
||||
updatemons(NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m->m.x == -1 && m->m.y == -1)
|
||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||
@@ -1352,7 +1372,7 @@ createpopup(struct wl_listener *listener, void *data)
|
||||
/* This event is raised when a client (either xdg-shell or layer-shell)
|
||||
* creates a new popup. */
|
||||
struct wlr_xdg_popup *popup = data;
|
||||
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup);
|
||||
LISTEN_STATIC(&popup->base->surface->events.commit, commitpopup, popup);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1410,15 +1430,15 @@ destroydragicon(struct wl_listener *listener, void *data)
|
||||
focusclient(focustop(selmon), NULL, 1);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
wl_list_remove(&listener->link);
|
||||
free(listener);
|
||||
}
|
||||
|
||||
void
|
||||
destroyidleinhibitor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* `data` is the wlr_surface of the idle inhibitor being destroyed,
|
||||
* at this point the idle inhibitor is still in the list of the manager */
|
||||
checkidleinhibitor(wlr_surface_get_root_surface(data));
|
||||
StaticListener *sl = wl_container_of(listener, sl, listener);
|
||||
struct wlr_idle_inhibitor_v1 *idle_inhibitor = sl->data;
|
||||
/* At this point the idle inhibitor is still in the list of the manager */
|
||||
checkidleinhibitor(wlr_surface_get_root_surface(idle_inhibitor->surface));
|
||||
wl_list_remove(&listener->link);
|
||||
free(listener);
|
||||
}
|
||||
@@ -1597,7 +1617,6 @@ focusclient(Client *c, LayerSurface *l, int lift)
|
||||
/* Don't change border color if there is an exclusive focus or we are
|
||||
* handling a drag operation */
|
||||
if (!(old_l && old_l->layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
|
||||
&& !(old_c && client_wants_focus(old_c))
|
||||
&& !seat->drag)
|
||||
client_set_border_color(c, focuscolor);
|
||||
}
|
||||
@@ -2066,6 +2085,17 @@ motionabsolute(struct wl_listener *listener, void *data)
|
||||
motionnotify(event->time_msec, &event->pointer->base, dx, dy, dx, dy);
|
||||
}
|
||||
|
||||
char **
|
||||
monoff(struct wlr_output *wlr_output)
|
||||
{
|
||||
char **name;
|
||||
wl_array_for_each(name, &offmons) {
|
||||
if (!strcmp(*name, wlr_output->name))
|
||||
return name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
||||
double dx_unaccel, double dy_unaccel)
|
||||
@@ -2252,6 +2282,7 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
|
||||
/* Ensure displays previously disabled by wlr-output-power-management-v1
|
||||
* are properly handled*/
|
||||
m->asleep = 0;
|
||||
setmonoff(wlr_output, !config_head->state.enabled);
|
||||
|
||||
/* Don't move monitors if position wouldn't change. This avoids
|
||||
* wlroots marking the output as manually configured.
|
||||
@@ -2370,6 +2401,10 @@ powermgrsetmode(struct wl_listener *listener, void *data)
|
||||
|
||||
m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the output */
|
||||
wlr_output_state_set_enabled(&state, event->mode);
|
||||
/* The output was reconnected while off and was never modeset */
|
||||
if (event->mode && !m->wlr_output->current_mode)
|
||||
wlr_output_state_set_mode(&state, wlr_output_preferred_mode(m->wlr_output));
|
||||
setmonoff(m->wlr_output, !event->mode);
|
||||
wlr_output_commit_state(m->wlr_output, &state);
|
||||
|
||||
m->asleep = !event->mode;
|
||||
@@ -2645,6 +2680,22 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
focusclient(focustop(selmon), NULL, 1);
|
||||
}
|
||||
|
||||
void
|
||||
setmonoff(struct wlr_output *wlr_output, int off)
|
||||
{
|
||||
char **name = monoff(wlr_output), **last;
|
||||
|
||||
if (off && !name && (name = wl_array_add(&offmons, sizeof(*name)))) {
|
||||
if (!(*name = strdup(wlr_output->name)))
|
||||
offmons.size -= sizeof(*name);
|
||||
} else if (!off && name) {
|
||||
free(*name);
|
||||
last = (char **)((char *)offmons.data + offmons.size) - 1;
|
||||
*name = *last;
|
||||
offmons.size -= sizeof(*name);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
setpsel(struct wl_listener *listener, void *data)
|
||||
{
|
||||
@@ -2785,6 +2836,7 @@ setup(void)
|
||||
|
||||
transaction_timer = wl_event_loop_add_timer(event_loop, transactiontimeout, NULL);
|
||||
wl_array_init(&ghosts);
|
||||
wl_array_init(&offmons);
|
||||
|
||||
xdg_shell = wlr_xdg_shell_create(dpy, 6);
|
||||
wl_signal_add(&xdg_shell->events.new_toplevel, &new_xdg_toplevel);
|
||||
@@ -2807,14 +2859,14 @@ setup(void)
|
||||
foreign_toplevel_list = wlr_ext_foreign_toplevel_list_v1_create(dpy,1);
|
||||
ext_foreign_toplevel_image_capture_source_manager_v1 =
|
||||
wlr_ext_foreign_toplevel_image_capture_source_manager_v1_create(dpy, 1);
|
||||
wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.new_request,
|
||||
wl_signal_add(&ext_foreign_toplevel_image_capture_source_manager_v1->events.capture_request,
|
||||
&new_foreign_toplevel_capture_request);
|
||||
|
||||
/* Use decoration protocols to negotiate server-side decorations */
|
||||
wlr_server_decoration_manager_set_default_mode(
|
||||
wlr_server_decoration_manager_create(dpy),
|
||||
WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||
xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy);
|
||||
xdg_decoration_mgr = wlr_xdg_decoration_manager_v1_create(dpy, 2);
|
||||
wl_signal_add(&xdg_decoration_mgr->events.new_toplevel_decoration, &new_xdg_decoration);
|
||||
|
||||
pointer_constraints = wlr_pointer_constraints_v1_create(dpy);
|
||||
@@ -2977,7 +3029,7 @@ startdrag(struct wl_listener *listener, void *data)
|
||||
return;
|
||||
|
||||
drag->icon->data = &wlr_scene_drag_icon_create(drag_icon, drag->icon)->node;
|
||||
LISTEN_STATIC(&drag->icon->events.destroy, destroydragicon);
|
||||
wl_signal_add(&drag->icon->events.destroy, &drag_icon_destroy);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user