|
|
|
@@ -4,6 +4,7 @@
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
#include <libinput.h>
|
|
|
|
|
#include <linux/input-event-codes.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
@@ -15,6 +16,7 @@
|
|
|
|
|
#include <wlr/backend/libinput.h>
|
|
|
|
|
#include <wlr/render/allocator.h>
|
|
|
|
|
#include <wlr/render/wlr_renderer.h>
|
|
|
|
|
#include <wlr/types/wlr_alpha_modifier_v1.h>
|
|
|
|
|
#include <wlr/types/wlr_compositor.h>
|
|
|
|
|
#include <wlr/types/wlr_cursor.h>
|
|
|
|
|
#include <wlr/types/wlr_cursor_shape_v1.h>
|
|
|
|
@@ -34,6 +36,7 @@
|
|
|
|
|
#include <wlr/types/wlr_output.h>
|
|
|
|
|
#include <wlr/types/wlr_output_layout.h>
|
|
|
|
|
#include <wlr/types/wlr_output_management_v1.h>
|
|
|
|
|
#include <wlr/types/wlr_output_power_management_v1.h>
|
|
|
|
|
#include <wlr/types/wlr_pointer.h>
|
|
|
|
|
#include <wlr/types/wlr_pointer_constraints_v1.h>
|
|
|
|
|
#include <wlr/types/wlr_presentation_time.h>
|
|
|
|
@@ -69,7 +72,6 @@
|
|
|
|
|
/* macros */
|
|
|
|
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
|
|
|
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
|
|
|
|
#define ROUND(X) ((int)((X < 0) ? (X - 0.5) : (X + 0.5)))
|
|
|
|
|
#define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS)
|
|
|
|
|
#define VISIBLEON(C, M) ((M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags]))
|
|
|
|
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
|
|
|
@@ -81,7 +83,7 @@
|
|
|
|
|
/* enums */
|
|
|
|
|
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
|
|
|
|
enum { XDGShell, LayerShell, X11 }; /* client types */
|
|
|
|
|
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrFS, LyrTop, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
|
|
|
|
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
|
|
|
|
#ifdef XWAYLAND
|
|
|
|
|
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
|
|
|
|
|
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
|
|
|
|
@@ -159,6 +161,7 @@ typedef struct {
|
|
|
|
|
|
|
|
|
|
struct wl_listener modifiers;
|
|
|
|
|
struct wl_listener key;
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
} KeyboardGroup;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
@@ -174,7 +177,6 @@ typedef struct {
|
|
|
|
|
struct wlr_layer_surface_v1 *layer_surface;
|
|
|
|
|
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
struct wl_listener map;
|
|
|
|
|
struct wl_listener unmap;
|
|
|
|
|
struct wl_listener surface_commit;
|
|
|
|
|
} LayerSurface;
|
|
|
|
@@ -205,6 +207,7 @@ struct Monitor {
|
|
|
|
|
int gamma_lut_changed;
|
|
|
|
|
int nmaster;
|
|
|
|
|
char ltsymbol[16];
|
|
|
|
|
int asleep;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
@@ -255,15 +258,18 @@ static void cleanupmon(struct wl_listener *listener, void *data);
|
|
|
|
|
static void closemon(Monitor *m);
|
|
|
|
|
static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void commitnotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void commitpopup(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createdecoration(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createidleinhibitor(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createkeyboard(struct wlr_keyboard *keyboard);
|
|
|
|
|
static KeyboardGroup *createkeyboardgroup(void);
|
|
|
|
|
static void createlayersurface(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createlocksurface(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createmon(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createnotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createpointer(struct wlr_pointer *pointer);
|
|
|
|
|
static void createpointerconstraint(struct wl_listener *listener, void *data);
|
|
|
|
|
static void createpopup(struct wl_listener *listener, void *data);
|
|
|
|
|
static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
|
|
|
|
|
static void cursorframe(struct wl_listener *listener, void *data);
|
|
|
|
|
static void cursorwarptohint(void);
|
|
|
|
@@ -277,12 +283,14 @@ static void destroynotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void destroypointerconstraint(struct wl_listener *listener, void *data);
|
|
|
|
|
static void destroysessionlock(struct wl_listener *listener, void *data);
|
|
|
|
|
static void destroysessionmgr(struct wl_listener *listener, void *data);
|
|
|
|
|
static void destroykeyboardgroup(struct wl_listener *listener, void *data);
|
|
|
|
|
static Monitor *dirtomon(enum wlr_direction dir);
|
|
|
|
|
static void focusclient(Client *c, int lift);
|
|
|
|
|
static void focusmon(const Arg *arg);
|
|
|
|
|
static void focusstack(const Arg *arg);
|
|
|
|
|
static Client *focustop(Monitor *m);
|
|
|
|
|
static void fullscreennotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void gpureset(struct wl_listener *listener, void *data);
|
|
|
|
|
static void handlesig(int signo);
|
|
|
|
|
static void incnmaster(const Arg *arg);
|
|
|
|
|
static void inputdevice(struct wl_listener *listener, void *data);
|
|
|
|
@@ -292,7 +300,6 @@ static void keypressmod(struct wl_listener *listener, void *data);
|
|
|
|
|
static int keyrepeat(void *data);
|
|
|
|
|
static void killclient(const Arg *arg);
|
|
|
|
|
static void locksession(struct wl_listener *listener, void *data);
|
|
|
|
|
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void mapnotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void maximizenotify(struct wl_listener *listener, void *data);
|
|
|
|
|
static void monocle(Monitor *m);
|
|
|
|
@@ -307,6 +314,7 @@ static void outputmgrtest(struct wl_listener *listener, void *data);
|
|
|
|
|
static void pointerfocus(Client *c, struct wlr_surface *surface,
|
|
|
|
|
double sx, double sy, uint32_t time);
|
|
|
|
|
static void printstatus(void);
|
|
|
|
|
static void powermgrsetmode(struct wl_listener *listener, void *data);
|
|
|
|
|
static void quit(const Arg *arg);
|
|
|
|
|
static void rendermon(struct wl_listener *listener, void *data);
|
|
|
|
|
static void requestdecorationmode(struct wl_listener *listener, void *data);
|
|
|
|
@@ -354,6 +362,7 @@ static pid_t child_pid = -1;
|
|
|
|
|
static int locked;
|
|
|
|
|
static void *exclusive_focus;
|
|
|
|
|
static struct wl_display *dpy;
|
|
|
|
|
static struct wl_event_loop *event_loop;
|
|
|
|
|
static struct wlr_backend *backend;
|
|
|
|
|
static struct wlr_scene *scene;
|
|
|
|
|
static struct wlr_scene_tree *layers[NUM_LAYERS];
|
|
|
|
@@ -378,6 +387,7 @@ static struct wlr_gamma_control_manager_v1 *gamma_control_mgr;
|
|
|
|
|
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
|
|
|
|
|
static struct wlr_virtual_pointer_manager_v1 *virtual_pointer_mgr;
|
|
|
|
|
static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
|
|
|
|
|
static struct wlr_output_power_manager_v1 *power_mgr;
|
|
|
|
|
|
|
|
|
|
static struct wlr_pointer_constraints_v1 *pointer_constraints;
|
|
|
|
|
static struct wlr_relative_pointer_manager_v1 *relative_pointer_mgr;
|
|
|
|
@@ -393,9 +403,7 @@ static struct wlr_session_lock_v1 *cur_lock;
|
|
|
|
|
static struct wl_listener lock_listener = {.notify = locksession};
|
|
|
|
|
|
|
|
|
|
static struct wlr_seat *seat;
|
|
|
|
|
static KeyboardGroup kb_group = {0};
|
|
|
|
|
static KeyboardGroup vkb_group = {0};
|
|
|
|
|
static struct wlr_surface *held_grab;
|
|
|
|
|
static KeyboardGroup *kb_group;
|
|
|
|
|
static unsigned int cursor_mode;
|
|
|
|
|
static Client *grabc;
|
|
|
|
|
static int grabcx, grabcy; /* client-relative */
|
|
|
|
@@ -436,9 +444,9 @@ applybounds(Client *c, struct wlr_box *bbox)
|
|
|
|
|
c->geom.x = bbox->x + bbox->width - c->geom.width;
|
|
|
|
|
if (c->geom.y >= bbox->y + bbox->height)
|
|
|
|
|
c->geom.y = bbox->y + bbox->height - c->geom.height;
|
|
|
|
|
if (c->geom.x + c->geom.width + 2 * (int)c->bw <= bbox->x)
|
|
|
|
|
if (c->geom.x + c->geom.width <= bbox->x)
|
|
|
|
|
c->geom.x = bbox->x;
|
|
|
|
|
if (c->geom.y + c->geom.height + 2 * (int)c->bw <= bbox->y)
|
|
|
|
|
if (c->geom.y + c->geom.height <= bbox->y)
|
|
|
|
|
c->geom.y = bbox->y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -493,6 +501,20 @@ arrange(Monitor *m)
|
|
|
|
|
|
|
|
|
|
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, LENGTH(m->ltsymbol));
|
|
|
|
|
|
|
|
|
|
/* We move all clients (except fullscreen and unmanaged) to LyrTile while
|
|
|
|
|
* in floating layout to avoid "real" floating clients be always on top */
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
|
if (c->mon != m || c->scene->node.parent == layers[LyrFS])
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
wlr_scene_node_reparent(&c->scene->node,
|
|
|
|
|
(!m->lt[m->sellt]->arrange && c->isfloating)
|
|
|
|
|
? layers[LyrTile]
|
|
|
|
|
: (m->lt[m->sellt]->arrange && c->isfloating)
|
|
|
|
|
? layers[LyrFloat]
|
|
|
|
|
: c->scene->node.parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m->lt[m->sellt]->arrange)
|
|
|
|
|
m->lt[m->sellt]->arrange(m);
|
|
|
|
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
|
|
|
@@ -570,7 +592,7 @@ axisnotify(struct wl_listener *listener, void *data)
|
|
|
|
|
/* Notify the client with pointer focus of the axis event. */
|
|
|
|
|
wlr_seat_pointer_notify_axis(seat,
|
|
|
|
|
event->time_msec, event->orientation, event->delta,
|
|
|
|
|
event->delta_discrete, event->source);
|
|
|
|
|
event->delta_discrete, event->source, event->relative_direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@@ -585,9 +607,9 @@ buttonpress(struct wl_listener *listener, void *data)
|
|
|
|
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
|
|
|
|
|
|
|
|
|
switch (event->state) {
|
|
|
|
|
case WLR_BUTTON_PRESSED:
|
|
|
|
|
case WL_POINTER_BUTTON_STATE_PRESSED:
|
|
|
|
|
cursor_mode = CurPressed;
|
|
|
|
|
held_grab = seat->pointer_state.focused_surface;
|
|
|
|
|
selmon = xytomon(cursor->x, cursor->y);
|
|
|
|
|
if (locked)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@@ -606,8 +628,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case WLR_BUTTON_RELEASED:
|
|
|
|
|
held_grab = NULL;
|
|
|
|
|
case WL_POINTER_BUTTON_STATE_RELEASED:
|
|
|
|
|
/* If you released any buttons, we exit interactive move/resize mode. */
|
|
|
|
|
/* TODO should reset to the pointer focus's current setcursor */
|
|
|
|
|
if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) {
|
|
|
|
@@ -661,15 +682,16 @@ cleanup(void)
|
|
|
|
|
#endif
|
|
|
|
|
wl_display_destroy_clients(dpy);
|
|
|
|
|
if (child_pid > 0) {
|
|
|
|
|
kill(child_pid, SIGTERM);
|
|
|
|
|
kill(-child_pid, SIGTERM);
|
|
|
|
|
waitpid(child_pid, NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
wlr_xcursor_manager_destroy(cursor_mgr);
|
|
|
|
|
wlr_output_layout_destroy(output_layout);
|
|
|
|
|
|
|
|
|
|
/* Remove event source that use the dpy event loop before destroying dpy */
|
|
|
|
|
wl_event_source_remove(kb_group.key_repeat_source);
|
|
|
|
|
wl_event_source_remove(vkb_group.key_repeat_source);
|
|
|
|
|
destroykeyboardgroup(&kb_group->destroy, NULL);
|
|
|
|
|
|
|
|
|
|
/* If it's not destroyed manually it will cause a use-after-free of wlr_seat.
|
|
|
|
|
* Destroy it until it's fixed in the wlroots side */
|
|
|
|
|
wlr_backend_destroy(backend);
|
|
|
|
|
|
|
|
|
|
wl_display_destroy(dpy);
|
|
|
|
|
/* Destroy after the wayland display (when the monitors are already destroyed)
|
|
|
|
@@ -716,6 +738,9 @@ closemon(Monitor *m)
|
|
|
|
|
do /* don't switch to disabled mons */
|
|
|
|
|
selmon = wl_container_of(mons.next, selmon, link);
|
|
|
|
|
while (!selmon->wlr_output->enabled && i++ < nmons);
|
|
|
|
|
|
|
|
|
|
if (!selmon->wlr_output->enabled)
|
|
|
|
|
selmon = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(c, &clients, link) {
|
|
|
|
@@ -735,6 +760,17 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
|
|
|
|
LayerSurface *l = wl_container_of(listener, l, surface_commit);
|
|
|
|
|
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
|
|
|
|
struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->current.layer]];
|
|
|
|
|
struct wlr_layer_surface_v1_state old_state;
|
|
|
|
|
|
|
|
|
|
if (l->layer_surface->initial_commit) {
|
|
|
|
|
/* Temporarily set the layer's current state to pending
|
|
|
|
|
* so that we can easily arrange it */
|
|
|
|
|
old_state = l->layer_surface->current;
|
|
|
|
|
l->layer_surface->current = l->layer_surface->pending;
|
|
|
|
|
arrangelayers(l->mon);
|
|
|
|
|
l->layer_surface->current = old_state;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (layer_surface->current.committed == 0 && l->mapped == layer_surface->surface->mapped)
|
|
|
|
|
return;
|
|
|
|
@@ -756,6 +792,25 @@ commitnotify(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
Client *c = wl_container_of(listener, c, commit);
|
|
|
|
|
|
|
|
|
|
if (c->surface.xdg->initial_commit) {
|
|
|
|
|
/*
|
|
|
|
|
* Get the monitor this client will be rendered on
|
|
|
|
|
* Note that if the user set a rule in which the client is placed on
|
|
|
|
|
* a different monitor based on its title this will likely select
|
|
|
|
|
* a wrong monitor.
|
|
|
|
|
*/
|
|
|
|
|
applyrules(c);
|
|
|
|
|
wlr_surface_set_preferred_buffer_scale(client_surface(c), (int)ceilf(c->mon->wlr_output->scale));
|
|
|
|
|
wlr_fractional_scale_v1_notify_scale(client_surface(c), c->mon->wlr_output->scale);
|
|
|
|
|
setmon(c, NULL, 0); /* Make sure to reapply rules in mapnotify() */
|
|
|
|
|
|
|
|
|
|
wlr_xdg_toplevel_set_wm_capabilities(c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
|
|
|
|
|
wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
|
|
|
|
|
if (c->decoration)
|
|
|
|
|
requestdecorationmode(&c->set_decoration_mode, c->decoration);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (client_surface(c)->mapped && c->mon)
|
|
|
|
|
resize(c, c->geom, (c->isfloating && !c->isfullscreen));
|
|
|
|
|
|
|
|
|
@@ -764,6 +819,33 @@ commitnotify(struct wl_listener *listener, void *data)
|
|
|
|
|
c->resize = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
LayerSurface *l = NULL;
|
|
|
|
|
Client *c = NULL;
|
|
|
|
|
struct wlr_box box;
|
|
|
|
|
int type = -1;
|
|
|
|
|
|
|
|
|
|
if (!popup->base->initial_commit)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
type = toplevel_from_wlr_surface(popup->base->surface, &c, &l);
|
|
|
|
|
if (!popup->parent || type < 0)
|
|
|
|
|
return;
|
|
|
|
|
popup->base->surface->data = wlr_scene_xdg_surface_create(
|
|
|
|
|
popup->parent->data, popup->base);
|
|
|
|
|
if ((l && !l->mon) || (c && !c->mon))
|
|
|
|
|
return;
|
|
|
|
|
box = type == LayerShell ? l->mon->m : c->mon->w;
|
|
|
|
|
box.x -= (type == LayerShell ? l->geom.x : c->geom.x);
|
|
|
|
|
box.y -= (type == LayerShell ? l->geom.y : c->geom.y);
|
|
|
|
|
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
|
|
|
|
wl_list_remove(&listener->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
createdecoration(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
@@ -790,11 +872,47 @@ void
|
|
|
|
|
createkeyboard(struct wlr_keyboard *keyboard)
|
|
|
|
|
{
|
|
|
|
|
/* Set the keymap to match the group keymap */
|
|
|
|
|
wlr_keyboard_set_keymap(keyboard, kb_group.wlr_group->keyboard.keymap);
|
|
|
|
|
wlr_keyboard_set_repeat_info(keyboard, repeat_rate, repeat_delay);
|
|
|
|
|
wlr_keyboard_set_keymap(keyboard, kb_group->wlr_group->keyboard.keymap);
|
|
|
|
|
|
|
|
|
|
/* Add the new keyboard to the group */
|
|
|
|
|
wlr_keyboard_group_add_keyboard(kb_group.wlr_group, keyboard);
|
|
|
|
|
wlr_keyboard_group_add_keyboard(kb_group->wlr_group, keyboard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KeyboardGroup *
|
|
|
|
|
createkeyboardgroup(void)
|
|
|
|
|
{
|
|
|
|
|
KeyboardGroup *group = ecalloc(1, sizeof(*group));
|
|
|
|
|
struct xkb_context *context;
|
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
|
|
|
|
|
|
group->wlr_group = wlr_keyboard_group_create();
|
|
|
|
|
group->wlr_group->data = group;
|
|
|
|
|
|
|
|
|
|
/* Prepare an XKB keymap and assign it to the keyboard group. */
|
|
|
|
|
context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
|
|
|
|
if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules,
|
|
|
|
|
XKB_KEYMAP_COMPILE_NO_FLAGS)))
|
|
|
|
|
die("failed to compile keymap");
|
|
|
|
|
|
|
|
|
|
wlr_keyboard_set_keymap(&group->wlr_group->keyboard, keymap);
|
|
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
|
xkb_context_unref(context);
|
|
|
|
|
|
|
|
|
|
wlr_keyboard_set_repeat_info(&group->wlr_group->keyboard, repeat_rate, repeat_delay);
|
|
|
|
|
|
|
|
|
|
/* Set up listeners for keyboard events */
|
|
|
|
|
LISTEN(&group->wlr_group->keyboard.events.key, &group->key, keypress);
|
|
|
|
|
LISTEN(&group->wlr_group->keyboard.events.modifiers, &group->modifiers, keypressmod);
|
|
|
|
|
|
|
|
|
|
group->key_repeat_source = wl_event_loop_add_timer(event_loop, keyrepeat, group);
|
|
|
|
|
|
|
|
|
|
/* A seat can only have one keyboard, but this is a limitation of the
|
|
|
|
|
* Wayland protocol - not wlroots. We assign all connected keyboards to the
|
|
|
|
|
* same wlr_keyboard_group, which provides a single wlr_keyboard interface for
|
|
|
|
|
* all of them. Set this combined wlr_keyboard as the seat keyboard.
|
|
|
|
|
*/
|
|
|
|
|
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
|
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@@ -804,7 +922,6 @@ createlayersurface(struct wl_listener *listener, void *data)
|
|
|
|
|
LayerSurface *l;
|
|
|
|
|
struct wlr_surface *surface = layer_surface->surface;
|
|
|
|
|
struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->pending.layer]];
|
|
|
|
|
struct wlr_layer_surface_v1_state old_state;
|
|
|
|
|
|
|
|
|
|
if (!layer_surface->output
|
|
|
|
|
&& !(layer_surface->output = selmon ? selmon->wlr_output : NULL)) {
|
|
|
|
@@ -815,7 +932,6 @@ createlayersurface(struct wl_listener *listener, void *data)
|
|
|
|
|
l = layer_surface->data = ecalloc(1, sizeof(*l));
|
|
|
|
|
l->type = LayerShell;
|
|
|
|
|
LISTEN(&surface->events.commit, &l->surface_commit, commitlayersurfacenotify);
|
|
|
|
|
LISTEN(&surface->events.map, &l->map, maplayersurfacenotify);
|
|
|
|
|
LISTEN(&surface->events.unmap, &l->unmap, unmaplayersurfacenotify);
|
|
|
|
|
LISTEN(&layer_surface->events.destroy, &l->destroy, destroylayersurfacenotify);
|
|
|
|
|
|
|
|
|
@@ -829,15 +945,8 @@ createlayersurface(struct wl_listener *listener, void *data)
|
|
|
|
|
|
|
|
|
|
wl_list_insert(&l->mon->layers[layer_surface->pending.layer],&l->link);
|
|
|
|
|
wlr_surface_send_enter(surface, layer_surface->output);
|
|
|
|
|
|
|
|
|
|
/* Temporarily set the layer's current state to pending
|
|
|
|
|
* so that we can easily arrange it
|
|
|
|
|
*/
|
|
|
|
|
old_state = layer_surface->current;
|
|
|
|
|
layer_surface->current = layer_surface->pending;
|
|
|
|
|
l->mapped = 1;
|
|
|
|
|
arrangelayers(l->mon);
|
|
|
|
|
layer_surface->current = old_state;
|
|
|
|
|
wlr_fractional_scale_v1_notify_scale(surface, l->mon->wlr_output->scale);
|
|
|
|
|
wlr_surface_set_preferred_buffer_scale(surface, (int32_t)ceilf(l->mon->wlr_output->scale));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@@ -927,14 +1036,14 @@ createmon(struct wl_listener *listener, void *data)
|
|
|
|
|
m->fullscreen_bg = wlr_scene_rect_create(layers[LyrFS], 0, 0, fullscreen_bg);
|
|
|
|
|
wlr_scene_node_set_enabled(&m->fullscreen_bg->node, 0);
|
|
|
|
|
|
|
|
|
|
/* Adds this to the output layout in the order it was configured in.
|
|
|
|
|
/* Adds this to the output layout in the order it was configured.
|
|
|
|
|
*
|
|
|
|
|
* The output layout utility automatically adds a wl_output global to the
|
|
|
|
|
* display, which Wayland clients can see to find out information about the
|
|
|
|
|
* output (such as DPI, scale factor, manufacturer, etc).
|
|
|
|
|
*/
|
|
|
|
|
m->scene_output = wlr_scene_output_create(scene, wlr_output);
|
|
|
|
|
if (m->m.x < 0 || m->m.y < 0)
|
|
|
|
|
if (m->m.x == -1 && m->m.y == -1)
|
|
|
|
|
wlr_output_layout_add_auto(output_layout, wlr_output);
|
|
|
|
|
else
|
|
|
|
|
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
|
|
|
@@ -943,49 +1052,22 @@ createmon(struct wl_listener *listener, void *data)
|
|
|
|
|
void
|
|
|
|
|
createnotify(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
/* This event is raised when wlr_xdg_shell receives a new xdg surface from a
|
|
|
|
|
* client, either a toplevel (application window) or popup,
|
|
|
|
|
* or when wlr_layer_shell receives a new popup from a layer.
|
|
|
|
|
* If you want to do something tricky with popups you should check if
|
|
|
|
|
* its parent is wlr_xdg_shell or wlr_layer_shell */
|
|
|
|
|
struct wlr_xdg_surface *xdg_surface = data;
|
|
|
|
|
/* This event is raised when a client creates a new toplevel (application window). */
|
|
|
|
|
struct wlr_xdg_toplevel *toplevel = data;
|
|
|
|
|
Client *c = NULL;
|
|
|
|
|
LayerSurface *l = NULL;
|
|
|
|
|
|
|
|
|
|
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP) {
|
|
|
|
|
struct wlr_xdg_popup *popup = xdg_surface->popup;
|
|
|
|
|
struct wlr_box box;
|
|
|
|
|
if (toplevel_from_wlr_surface(popup->base->surface, &c, &l) < 0)
|
|
|
|
|
return;
|
|
|
|
|
popup->base->surface->data = wlr_scene_xdg_surface_create(
|
|
|
|
|
popup->parent->data, popup->base);
|
|
|
|
|
if ((l && !l->mon) || (c && !c->mon))
|
|
|
|
|
return;
|
|
|
|
|
box = l ? l->mon->m : c->mon->w;
|
|
|
|
|
box.x -= (l ? l->geom.x : c->geom.x);
|
|
|
|
|
box.y -= (l ? l->geom.y : c->geom.y);
|
|
|
|
|
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
|
|
|
|
return;
|
|
|
|
|
} else if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_NONE)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Allocate a Client for this surface */
|
|
|
|
|
c = xdg_surface->data = ecalloc(1, sizeof(*c));
|
|
|
|
|
c->surface.xdg = xdg_surface;
|
|
|
|
|
c = toplevel->base->data = ecalloc(1, sizeof(*c));
|
|
|
|
|
c->surface.xdg = toplevel->base;
|
|
|
|
|
c->bw = borderpx;
|
|
|
|
|
|
|
|
|
|
wlr_xdg_toplevel_set_wm_capabilities(xdg_surface->toplevel,
|
|
|
|
|
WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
|
|
|
|
|
|
|
|
|
|
LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify);
|
|
|
|
|
LISTEN(&xdg_surface->surface->events.commit, &c->commit, commitnotify);
|
|
|
|
|
LISTEN(&xdg_surface->surface->events.map, &c->map, mapnotify);
|
|
|
|
|
LISTEN(&xdg_surface->surface->events.unmap, &c->unmap, unmapnotify);
|
|
|
|
|
LISTEN(&xdg_surface->toplevel->events.request_fullscreen, &c->fullscreen,
|
|
|
|
|
fullscreennotify);
|
|
|
|
|
LISTEN(&xdg_surface->toplevel->events.request_maximize, &c->maximize,
|
|
|
|
|
maximizenotify);
|
|
|
|
|
LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle);
|
|
|
|
|
LISTEN(&toplevel->base->surface->events.commit, &c->commit, commitnotify);
|
|
|
|
|
LISTEN(&toplevel->base->surface->events.map, &c->map, mapnotify);
|
|
|
|
|
LISTEN(&toplevel->base->surface->events.unmap, &c->unmap, unmapnotify);
|
|
|
|
|
LISTEN(&toplevel->events.destroy, &c->destroy, destroynotify);
|
|
|
|
|
LISTEN(&toplevel->events.request_fullscreen, &c->fullscreen, fullscreennotify);
|
|
|
|
|
LISTEN(&toplevel->events.request_maximize, &c->maximize, maximizenotify);
|
|
|
|
|
LISTEN(&toplevel->events.set_title, &c->set_title, updatetitle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@@ -1041,6 +1123,15 @@ createpointerconstraint(struct wl_listener *listener, void *data)
|
|
|
|
|
&pointer_constraint->destroy, destroypointerconstraint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
cursorconstrain(struct wlr_pointer_constraint_v1 *constraint)
|
|
|
|
|
{
|
|
|
|
@@ -1073,8 +1164,7 @@ cursorwarptohint(void)
|
|
|
|
|
double sy = active_constraint->current.cursor_hint.y;
|
|
|
|
|
|
|
|
|
|
toplevel_from_wlr_surface(active_constraint->surface, &c, NULL);
|
|
|
|
|
/* TODO: wlroots 0.18: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4478 */
|
|
|
|
|
if (c && (active_constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT )) {
|
|
|
|
|
if (c && active_constraint->current.cursor_hint.enabled) {
|
|
|
|
|
wlr_cursor_warp(cursor, NULL, sx + c->geom.x + c->bw, sy + c->geom.y + c->bw);
|
|
|
|
|
wlr_seat_pointer_warp(active_constraint->seat, sx, sy);
|
|
|
|
|
}
|
|
|
|
@@ -1084,6 +1174,7 @@ void
|
|
|
|
|
destroydecoration(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
Client *c = wl_container_of(listener, c, destroy_decoration);
|
|
|
|
|
c->decoration = NULL;
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&c->destroy_decoration.link);
|
|
|
|
|
wl_list_remove(&c->set_decoration_mode.link);
|
|
|
|
@@ -1112,7 +1203,6 @@ destroylayersurfacenotify(struct wl_listener *listener, void *data)
|
|
|
|
|
|
|
|
|
|
wl_list_remove(&l->link);
|
|
|
|
|
wl_list_remove(&l->destroy.link);
|
|
|
|
|
wl_list_remove(&l->map.link);
|
|
|
|
|
wl_list_remove(&l->unmap.link);
|
|
|
|
|
wl_list_remove(&l->surface_commit.link);
|
|
|
|
|
wlr_scene_node_destroy(&l->scene->node);
|
|
|
|
@@ -1217,6 +1307,18 @@ destroysessionmgr(struct wl_listener *listener, void *data)
|
|
|
|
|
wl_list_remove(&listener->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
destroykeyboardgroup(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
KeyboardGroup *group = wl_container_of(listener, group, destroy);
|
|
|
|
|
wl_event_source_remove(group->key_repeat_source);
|
|
|
|
|
wlr_keyboard_group_destroy(group->wlr_group);
|
|
|
|
|
wl_list_remove(&group->key.link);
|
|
|
|
|
wl_list_remove(&group->modifiers.link);
|
|
|
|
|
wl_list_remove(&group->destroy.link);
|
|
|
|
|
free(group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Monitor *
|
|
|
|
|
dirtomon(enum wlr_direction dir)
|
|
|
|
|
{
|
|
|
|
@@ -1367,6 +1469,30 @@ fullscreennotify(struct wl_listener *listener, void *data)
|
|
|
|
|
setfullscreen(c, client_wants_fullscreen(c));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gpureset(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_renderer *old_drw = drw;
|
|
|
|
|
struct wlr_allocator *old_alloc = alloc;
|
|
|
|
|
struct Monitor *m;
|
|
|
|
|
if (!(drw = wlr_renderer_autocreate(backend)))
|
|
|
|
|
die("couldn't recreate renderer");
|
|
|
|
|
|
|
|
|
|
if (!(alloc = wlr_allocator_autocreate(backend, drw)))
|
|
|
|
|
die("couldn't recreate allocator");
|
|
|
|
|
|
|
|
|
|
LISTEN_STATIC(&drw->events.lost, gpureset);
|
|
|
|
|
|
|
|
|
|
wlr_compositor_set_renderer(compositor, drw);
|
|
|
|
|
|
|
|
|
|
wl_list_for_each(m, &mons, link) {
|
|
|
|
|
wlr_output_init_render(m->wlr_output, alloc, drw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wlr_allocator_destroy(old_alloc);
|
|
|
|
|
wlr_renderer_destroy(old_drw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
handlesig(int signo)
|
|
|
|
|
{
|
|
|
|
@@ -1422,7 +1548,7 @@ inputdevice(struct wl_listener *listener, void *data)
|
|
|
|
|
* there are no pointer devices, so we always include that capability. */
|
|
|
|
|
/* TODO do we actually require a cursor? */
|
|
|
|
|
caps = WL_SEAT_CAPABILITY_POINTER;
|
|
|
|
|
if (!wl_list_empty(&kb_group.wlr_group->devices))
|
|
|
|
|
if (!wl_list_empty(&kb_group->wlr_group->devices))
|
|
|
|
|
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
|
|
|
|
wlr_seat_set_capabilities(seat, caps);
|
|
|
|
|
}
|
|
|
|
@@ -1555,12 +1681,6 @@ locksession(struct wl_listener *listener, void *data)
|
|
|
|
|
wlr_session_lock_v1_send_locked(session_lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
maplayersurfacenotify(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
mapnotify(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
@@ -1584,8 +1704,7 @@ mapnotify(struct wl_listener *listener, void *data)
|
|
|
|
|
if (client_is_unmanaged(c)) {
|
|
|
|
|
/* Unmanaged clients always are floating */
|
|
|
|
|
wlr_scene_node_reparent(&c->scene->node, layers[LyrFloat]);
|
|
|
|
|
wlr_scene_node_set_position(&c->scene->node, c->geom.x + borderpx,
|
|
|
|
|
c->geom.y + borderpx);
|
|
|
|
|
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
|
|
|
|
if (client_wants_focus(c)) {
|
|
|
|
|
focusclient(c, 1);
|
|
|
|
|
exclusive_focus = c;
|
|
|
|
@@ -1640,7 +1759,8 @@ maximizenotify(struct wl_listener *listener, void *data)
|
|
|
|
|
* protocol version
|
|
|
|
|
* wlr_xdg_surface_schedule_configure() is used to send an empty reply. */
|
|
|
|
|
Client *c = wl_container_of(listener, c, maximize);
|
|
|
|
|
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
|
|
|
|
if (c->surface.xdg->initialized
|
|
|
|
|
&& wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
|
|
|
|
< XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION)
|
|
|
|
|
wlr_xdg_surface_schedule_configure(c->surface.xdg);
|
|
|
|
|
}
|
|
|
|
@@ -1688,13 +1808,24 @@ void
|
|
|
|
|
motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double dy,
|
|
|
|
|
double dx_unaccel, double dy_unaccel)
|
|
|
|
|
{
|
|
|
|
|
int nx, ny;
|
|
|
|
|
double sx = 0, sy = 0, sx_confined, sy_confined;
|
|
|
|
|
Client *c = NULL, *w = NULL;
|
|
|
|
|
LayerSurface *l = NULL;
|
|
|
|
|
struct wlr_surface *surface = NULL;
|
|
|
|
|
struct wlr_pointer_constraint_v1 *constraint;
|
|
|
|
|
|
|
|
|
|
/* Find the client under the pointer and send the event along. */
|
|
|
|
|
xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
|
|
|
|
|
|
|
|
|
|
if (cursor_mode == CurPressed && !seat->drag
|
|
|
|
|
&& surface != seat->pointer_state.focused_surface
|
|
|
|
|
&& toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &l) >= 0) {
|
|
|
|
|
c = w;
|
|
|
|
|
surface = seat->pointer_state.focused_surface;
|
|
|
|
|
sx = cursor->x - (l ? l->geom.x : w->geom.x);
|
|
|
|
|
sy = cursor->y - (l ? l->geom.y : w->geom.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* time is 0 in internal calls meant to restore pointer focus. */
|
|
|
|
|
if (time) {
|
|
|
|
|
wlr_relative_pointer_manager_v1_send_relative_motion(
|
|
|
|
@@ -1729,41 +1860,20 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update drag icon's position */
|
|
|
|
|
wlr_scene_node_set_position(&drag_icon->node, ROUND(cursor->x), ROUND(cursor->y));
|
|
|
|
|
wlr_scene_node_set_position(&drag_icon->node, (int)round(cursor->x), (int)round(cursor->y));
|
|
|
|
|
|
|
|
|
|
/* If we are currently grabbing the mouse, handle and return */
|
|
|
|
|
if (cursor_mode == CurMove) {
|
|
|
|
|
/* Move the grabbed client to the new position. */
|
|
|
|
|
nx = ROUND(cursor->x) - grabcx;
|
|
|
|
|
ny = ROUND(cursor->y) - grabcy;
|
|
|
|
|
if (abs(selmon->w.x - nx) < snap)
|
|
|
|
|
nx = selmon->w.x;
|
|
|
|
|
else if (abs((selmon->w.x + selmon->w.width) - (nx + grabc->geom.width)) < snap)
|
|
|
|
|
nx = selmon->w.x + selmon->w.width - grabc->geom.width;
|
|
|
|
|
if (abs(selmon->w.y - ny) < snap)
|
|
|
|
|
ny = selmon->w.y;
|
|
|
|
|
else if (abs((selmon->w.y + selmon->w.height) - (ny + grabc->geom.height)) < snap)
|
|
|
|
|
ny = selmon->w.y + selmon->w.height - grabc->geom.height;
|
|
|
|
|
resize(grabc, (struct wlr_box){.x = nx, .y = ny,
|
|
|
|
|
resize(grabc, (struct wlr_box){.x = (int)round(cursor->x) - grabcx, .y = (int)round(cursor->y) - grabcy,
|
|
|
|
|
.width = grabc->geom.width, .height = grabc->geom.height}, 1);
|
|
|
|
|
return;
|
|
|
|
|
} else if (cursor_mode == CurResize) {
|
|
|
|
|
resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
|
|
|
|
|
.width = ROUND(cursor->x) - grabc->geom.x, .height = ROUND(cursor->y) - grabc->geom.y}, 1);
|
|
|
|
|
.width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find the client under the pointer and send the event along. */
|
|
|
|
|
xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
|
|
|
|
|
|
|
|
|
|
if (cursor_mode == CurPressed && !seat->drag && surface != held_grab
|
|
|
|
|
&& toplevel_from_wlr_surface(held_grab, &w, &l) >= 0) {
|
|
|
|
|
c = w;
|
|
|
|
|
surface = held_grab;
|
|
|
|
|
sx = cursor->x - (l ? l->geom.x : w->geom.x);
|
|
|
|
|
sy = cursor->y - (l ? l->geom.y : w->geom.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If there's no client surface under the cursor, set the cursor image to a
|
|
|
|
|
* default. This is what makes the cursor image appear when you move it
|
|
|
|
|
* off of a client or over its border. */
|
|
|
|
@@ -1801,8 +1911,8 @@ moveresize(const Arg *arg)
|
|
|
|
|
setfloating(grabc, 1);
|
|
|
|
|
switch (cursor_mode = arg->ui) {
|
|
|
|
|
case CurMove:
|
|
|
|
|
grabcx = ROUND(cursor->x) - grabc->geom.x;
|
|
|
|
|
grabcy = ROUND(cursor->y) - grabc->geom.y;
|
|
|
|
|
grabcx = (int)round(cursor->x) - grabc->geom.x;
|
|
|
|
|
grabcy = (int)round(cursor->y) - grabc->geom.y;
|
|
|
|
|
wlr_cursor_set_xcursor(cursor, cursor_mgr, "fleur");
|
|
|
|
|
break;
|
|
|
|
|
case CurResize:
|
|
|
|
@@ -1840,6 +1950,10 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
|
|
|
|
|
Monitor *m = wlr_output->data;
|
|
|
|
|
struct wlr_output_state state;
|
|
|
|
|
|
|
|
|
|
/* Ensure displays previously disabled by wlr-output-power-management-v1
|
|
|
|
|
* are properly handled*/
|
|
|
|
|
m->asleep = 0;
|
|
|
|
|
|
|
|
|
|
wlr_output_state_init(&state);
|
|
|
|
|
wlr_output_state_set_enabled(&state, config_head->state.enabled);
|
|
|
|
|
if (!config_head->state.enabled)
|
|
|
|
@@ -1853,11 +1967,6 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
|
|
|
|
|
config_head->state.custom_mode.height,
|
|
|
|
|
config_head->state.custom_mode.refresh);
|
|
|
|
|
|
|
|
|
|
/* Don't move monitors if position wouldn't change, this to avoid
|
|
|
|
|
* wlroots marking the output as manually configured */
|
|
|
|
|
if (m->m.x != config_head->state.x || m->m.y != config_head->state.y)
|
|
|
|
|
wlr_output_layout_add(output_layout, wlr_output,
|
|
|
|
|
config_head->state.x, config_head->state.y);
|
|
|
|
|
wlr_output_state_set_transform(&state, config_head->state.transform);
|
|
|
|
|
wlr_output_state_set_scale(&state, config_head->state.scale);
|
|
|
|
|
wlr_output_state_set_adaptive_sync_enabled(&state,
|
|
|
|
@@ -1867,6 +1976,13 @@ apply_or_test:
|
|
|
|
|
ok &= test ? wlr_output_test_state(wlr_output, &state)
|
|
|
|
|
: wlr_output_commit_state(wlr_output, &state);
|
|
|
|
|
|
|
|
|
|
/* Don't move monitors if position wouldn't change, this to avoid
|
|
|
|
|
* wlroots marking the output as manually configured.
|
|
|
|
|
* wlr_output_layout_add does not like disabled outputs */
|
|
|
|
|
if (!test && wlr_output->enabled && (m->m.x != config_head->state.x || m->m.y != config_head->state.y))
|
|
|
|
|
wlr_output_layout_add(output_layout, wlr_output,
|
|
|
|
|
config_head->state.x, config_head->state.y);
|
|
|
|
|
|
|
|
|
|
wlr_output_state_finish(&state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1876,7 +1992,7 @@ apply_or_test:
|
|
|
|
|
wlr_output_configuration_v1_send_failed(config);
|
|
|
|
|
wlr_output_configuration_v1_destroy(config);
|
|
|
|
|
|
|
|
|
|
/* TODO: use a wrapper function? */
|
|
|
|
|
/* https://codeberg.org/dwl/dwl/issues/577 */
|
|
|
|
|
updatemons(NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1893,7 +2009,7 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
|
|
|
|
{
|
|
|
|
|
struct timespec now;
|
|
|
|
|
|
|
|
|
|
if ((!active_constraint || active_constraint->surface != surface) &&
|
|
|
|
|
if (surface != seat->pointer_state.focused_surface &&
|
|
|
|
|
sloppyfocus && time && c && !client_is_unmanaged(c))
|
|
|
|
|
focusclient(c, 0);
|
|
|
|
|
|
|
|
|
@@ -1956,6 +2072,23 @@ printstatus(void)
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
powermgrsetmode(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_output_power_v1_set_mode_event *event = data;
|
|
|
|
|
struct wlr_output_state state = {0};
|
|
|
|
|
Monitor *m = event->output->data;
|
|
|
|
|
|
|
|
|
|
if (!m)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m->gamma_lut_changed = 1; /* Reapply gamma LUT when re-enabling the ouput */
|
|
|
|
|
wlr_output_state_set_enabled(&state, event->mode);
|
|
|
|
|
wlr_output_commit_state(m->wlr_output, &state);
|
|
|
|
|
|
|
|
|
|
m->asleep = !event->mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
quit(const Arg *arg)
|
|
|
|
|
{
|
|
|
|
@@ -2018,6 +2151,7 @@ void
|
|
|
|
|
requestdecorationmode(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
Client *c = wl_container_of(listener, c, set_decoration_mode);
|
|
|
|
|
if (c->surface.xdg->initialized)
|
|
|
|
|
wlr_xdg_toplevel_decoration_v1_set_mode(c->decoration,
|
|
|
|
|
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
|
|
|
|
}
|
|
|
|
@@ -2045,8 +2179,14 @@ requestmonstate(struct wl_listener *listener, void *data)
|
|
|
|
|
void
|
|
|
|
|
resize(Client *c, struct wlr_box geo, int interact)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_box *bbox = interact ? &sgeom : &c->mon->w;
|
|
|
|
|
struct wlr_box *bbox;
|
|
|
|
|
struct wlr_box clip;
|
|
|
|
|
|
|
|
|
|
if (!c->mon || !c->scene)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bbox = interact ? &sgeom : &c->mon->w;
|
|
|
|
|
|
|
|
|
|
client_set_bounds(c, geo.width, geo.height);
|
|
|
|
|
c->geom = geo;
|
|
|
|
|
applybounds(c, bbox);
|
|
|
|
@@ -2091,6 +2231,7 @@ run(char *startup_cmd)
|
|
|
|
|
if ((child_pid = fork()) < 0)
|
|
|
|
|
die("startup: fork:");
|
|
|
|
|
if (child_pid == 0) {
|
|
|
|
|
setsid();
|
|
|
|
|
dup2(piperw[0], STDIN_FILENO);
|
|
|
|
|
close(piperw[0]);
|
|
|
|
|
close(piperw[1]);
|
|
|
|
@@ -2101,6 +2242,12 @@ run(char *startup_cmd)
|
|
|
|
|
close(piperw[1]);
|
|
|
|
|
close(piperw[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mark stdout as non-blocking to avoid people who does not close stdin
|
|
|
|
|
* nor consumes it in their startup script getting dwl frozen */
|
|
|
|
|
if (fd_set_nonblock(STDOUT_FILENO) < 0)
|
|
|
|
|
close(STDOUT_FILENO);
|
|
|
|
|
|
|
|
|
|
printstatus();
|
|
|
|
|
|
|
|
|
|
/* At this point the outputs are initialized, choose initial selmon based on
|
|
|
|
@@ -2160,7 +2307,8 @@ setfloating(Client *c, int floating)
|
|
|
|
|
{
|
|
|
|
|
Client *p = client_get_parent(c);
|
|
|
|
|
c->isfloating = floating;
|
|
|
|
|
if (!c->mon)
|
|
|
|
|
/* If in floating layout do not change the client's layer */
|
|
|
|
|
if (!c->mon || !client_surface(c)->mapped || !c->mon->lt[c->mon->sellt]->arrange)
|
|
|
|
|
return;
|
|
|
|
|
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
|
|
|
|
|
(p && p->isfullscreen) ? LyrFS
|
|
|
|
@@ -2173,7 +2321,7 @@ void
|
|
|
|
|
setfullscreen(Client *c, int fullscreen)
|
|
|
|
|
{
|
|
|
|
|
c->isfullscreen = fullscreen;
|
|
|
|
|
if (!c->mon)
|
|
|
|
|
if (!c->mon || !client_surface(c)->mapped)
|
|
|
|
|
return;
|
|
|
|
|
c->bw = fullscreen ? 0 : borderpx;
|
|
|
|
|
client_set_fullscreen(c, fullscreen);
|
|
|
|
@@ -2280,9 +2428,6 @@ setsel(struct wl_listener *listener, void *data)
|
|
|
|
|
void
|
|
|
|
|
setup(void)
|
|
|
|
|
{
|
|
|
|
|
struct xkb_context *context;
|
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
|
|
|
|
|
|
int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
|
|
|
|
|
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
|
|
|
|
|
sigemptyset(&sa.sa_mask);
|
|
|
|
@@ -2295,12 +2440,13 @@ setup(void)
|
|
|
|
|
/* The Wayland display is managed by libwayland. It handles accepting
|
|
|
|
|
* clients from the Unix socket, manging Wayland globals, and so on. */
|
|
|
|
|
dpy = wl_display_create();
|
|
|
|
|
event_loop = wl_display_get_event_loop(dpy);
|
|
|
|
|
|
|
|
|
|
/* The backend is a wlroots feature which abstracts the underlying input and
|
|
|
|
|
* output hardware. The autocreate option will choose the most suitable
|
|
|
|
|
* backend based on the current environment, such as opening an X11 window
|
|
|
|
|
* if an X11 server is running. */
|
|
|
|
|
if (!(backend = wlr_backend_autocreate(dpy, &session)))
|
|
|
|
|
if (!(backend = wlr_backend_autocreate(event_loop, &session)))
|
|
|
|
|
die("couldn't create backend");
|
|
|
|
|
|
|
|
|
|
/* Initialize the scene graph used to lay out windows */
|
|
|
|
@@ -2317,6 +2463,7 @@ setup(void)
|
|
|
|
|
* supports for shared memory, this configures that for clients. */
|
|
|
|
|
if (!(drw = wlr_renderer_autocreate(backend)))
|
|
|
|
|
die("couldn't create renderer");
|
|
|
|
|
LISTEN_STATIC(&drw->events.lost, gpureset);
|
|
|
|
|
|
|
|
|
|
/* Create shm, drm and linux_dmabuf interfaces by ourselves.
|
|
|
|
|
* The simplest way is call:
|
|
|
|
@@ -2325,10 +2472,10 @@ setup(void)
|
|
|
|
|
* with wlr_scene. */
|
|
|
|
|
wlr_renderer_init_wl_shm(drw, dpy);
|
|
|
|
|
|
|
|
|
|
if (wlr_renderer_get_dmabuf_texture_formats(drw)) {
|
|
|
|
|
if (wlr_renderer_get_texture_formats(drw, WLR_BUFFER_CAP_DMABUF)) {
|
|
|
|
|
wlr_drm_create(dpy, drw);
|
|
|
|
|
wlr_scene_set_linux_dmabuf_v1(scene,
|
|
|
|
|
wlr_linux_dmabuf_v1_create_with_renderer(dpy, 4, drw));
|
|
|
|
|
wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Autocreates an allocator for us.
|
|
|
|
@@ -2354,6 +2501,8 @@ setup(void)
|
|
|
|
|
wlr_viewporter_create(dpy);
|
|
|
|
|
wlr_single_pixel_buffer_manager_v1_create(dpy);
|
|
|
|
|
wlr_fractional_scale_manager_v1_create(dpy, 1);
|
|
|
|
|
wlr_presentation_create(dpy, backend);
|
|
|
|
|
wlr_alpha_modifier_v1_create(dpy);
|
|
|
|
|
|
|
|
|
|
/* Initializes the interface used to implement urgency hints */
|
|
|
|
|
activation = wlr_xdg_activation_v1_create(dpy);
|
|
|
|
@@ -2362,9 +2511,12 @@ setup(void)
|
|
|
|
|
gamma_control_mgr = wlr_gamma_control_manager_v1_create(dpy);
|
|
|
|
|
LISTEN_STATIC(&gamma_control_mgr->events.set_gamma, setgamma);
|
|
|
|
|
|
|
|
|
|
power_mgr = wlr_output_power_manager_v1_create(dpy);
|
|
|
|
|
LISTEN_STATIC(&power_mgr->events.set_mode, powermgrsetmode);
|
|
|
|
|
|
|
|
|
|
/* Creates an output layout, which a wlroots utility for working with an
|
|
|
|
|
* arrangement of screens in a physical layout. */
|
|
|
|
|
output_layout = wlr_output_layout_create();
|
|
|
|
|
output_layout = wlr_output_layout_create(dpy);
|
|
|
|
|
LISTEN_STATIC(&output_layout->events.change, updatemons);
|
|
|
|
|
wlr_xdg_output_manager_v1_create(dpy, output_layout);
|
|
|
|
|
|
|
|
|
@@ -2383,7 +2535,8 @@ setup(void)
|
|
|
|
|
wl_list_init(&fstack);
|
|
|
|
|
|
|
|
|
|
xdg_shell = wlr_xdg_shell_create(dpy, 6);
|
|
|
|
|
LISTEN_STATIC(&xdg_shell->events.new_surface, createnotify);
|
|
|
|
|
LISTEN_STATIC(&xdg_shell->events.new_toplevel, createnotify);
|
|
|
|
|
LISTEN_STATIC(&xdg_shell->events.new_popup, createpopup);
|
|
|
|
|
|
|
|
|
|
layer_shell = wlr_layer_shell_v1_create(dpy, 3);
|
|
|
|
|
LISTEN_STATIC(&layer_shell->events.new_surface, createlayersurface);
|
|
|
|
@@ -2464,59 +2617,13 @@ setup(void)
|
|
|
|
|
LISTEN_STATIC(&seat->events.request_start_drag, requeststartdrag);
|
|
|
|
|
LISTEN_STATIC(&seat->events.start_drag, startdrag);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Configures a keyboard group, which will keep track of all connected
|
|
|
|
|
* keyboards, keep their modifier and LED states in sync, and handle
|
|
|
|
|
* keypresses
|
|
|
|
|
*/
|
|
|
|
|
kb_group.wlr_group = wlr_keyboard_group_create();
|
|
|
|
|
kb_group.wlr_group->data = &kb_group;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Virtual keyboards need to be in a different group
|
|
|
|
|
* https://codeberg.org/dwl/dwl/issues/554
|
|
|
|
|
*/
|
|
|
|
|
vkb_group.wlr_group = wlr_keyboard_group_create();
|
|
|
|
|
vkb_group.wlr_group->data = &vkb_group;
|
|
|
|
|
|
|
|
|
|
/* Prepare an XKB keymap and assign it to the keyboard group. */
|
|
|
|
|
context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
|
|
|
|
if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules,
|
|
|
|
|
XKB_KEYMAP_COMPILE_NO_FLAGS)))
|
|
|
|
|
die("failed to compile keymap");
|
|
|
|
|
|
|
|
|
|
wlr_keyboard_set_keymap(&kb_group.wlr_group->keyboard, keymap);
|
|
|
|
|
wlr_keyboard_set_keymap(&vkb_group.wlr_group->keyboard, keymap);
|
|
|
|
|
xkb_keymap_unref(keymap);
|
|
|
|
|
xkb_context_unref(context);
|
|
|
|
|
|
|
|
|
|
wlr_keyboard_set_repeat_info(&kb_group.wlr_group->keyboard, repeat_rate, repeat_delay);
|
|
|
|
|
wlr_keyboard_set_repeat_info(&vkb_group.wlr_group->keyboard, repeat_rate, repeat_delay);
|
|
|
|
|
|
|
|
|
|
/* Set up listeners for keyboard events */
|
|
|
|
|
LISTEN(&kb_group.wlr_group->keyboard.events.key, &kb_group.key, keypress);
|
|
|
|
|
LISTEN(&kb_group.wlr_group->keyboard.events.modifiers, &kb_group.modifiers, keypressmod);
|
|
|
|
|
LISTEN(&vkb_group.wlr_group->keyboard.events.key, &vkb_group.key, keypress);
|
|
|
|
|
LISTEN(&vkb_group.wlr_group->keyboard.events.modifiers, &vkb_group.modifiers, keypressmod);
|
|
|
|
|
|
|
|
|
|
kb_group.key_repeat_source = wl_event_loop_add_timer(
|
|
|
|
|
wl_display_get_event_loop(dpy), keyrepeat, &kb_group);
|
|
|
|
|
vkb_group.key_repeat_source = wl_event_loop_add_timer(
|
|
|
|
|
wl_display_get_event_loop(dpy), keyrepeat, &vkb_group);
|
|
|
|
|
|
|
|
|
|
/* A seat can only have one keyboard, but this is a limitation of the
|
|
|
|
|
* Wayland protocol - not wlroots. We assign all connected keyboards to the
|
|
|
|
|
* same wlr_keyboard_group, which provides a single wlr_keyboard interface for
|
|
|
|
|
* all of them. Set this combined wlr_keyboard as the seat keyboard.
|
|
|
|
|
*/
|
|
|
|
|
wlr_seat_set_keyboard(seat, &kb_group.wlr_group->keyboard);
|
|
|
|
|
kb_group = createkeyboardgroup();
|
|
|
|
|
wl_list_init(&kb_group->destroy.link);
|
|
|
|
|
|
|
|
|
|
output_mgr = wlr_output_manager_v1_create(dpy);
|
|
|
|
|
LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply);
|
|
|
|
|
LISTEN_STATIC(&output_mgr->events.test, outputmgrtest);
|
|
|
|
|
|
|
|
|
|
wlr_scene_set_presentation(scene, wlr_presentation_create(dpy, backend));
|
|
|
|
|
|
|
|
|
|
/* Make sure XWayland clients don't connect to the parent X server,
|
|
|
|
|
* e.g when running in the x11 backend or the wayland backend and the
|
|
|
|
|
* compositor has Xwayland support */
|
|
|
|
@@ -2594,7 +2701,7 @@ tile(Monitor *m)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (n > m->nmaster)
|
|
|
|
|
mw = m->nmaster ? ROUND(m->w.width * m->mfact) : 0;
|
|
|
|
|
mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
|
|
|
|
|
else
|
|
|
|
|
mw = m->w.width;
|
|
|
|
|
i = my = ty = 0;
|
|
|
|
@@ -2725,7 +2832,7 @@ updatemons(struct wl_listener *listener, void *data)
|
|
|
|
|
|
|
|
|
|
/* First remove from the layout the disabled monitors */
|
|
|
|
|
wl_list_for_each(m, &mons, link) {
|
|
|
|
|
if (m->wlr_output->enabled)
|
|
|
|
|
if (m->wlr_output->enabled || m->asleep)
|
|
|
|
|
continue;
|
|
|
|
|
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
|
|
|
|
config_head->state.enabled = 0;
|
|
|
|
@@ -2784,6 +2891,10 @@ updatemons(struct wl_listener *listener, void *data)
|
|
|
|
|
|
|
|
|
|
config_head->state.x = m->m.x;
|
|
|
|
|
config_head->state.y = m->m.y;
|
|
|
|
|
|
|
|
|
|
if (!selmon) {
|
|
|
|
|
selmon = m;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selmon && selmon->wlr_output->enabled) {
|
|
|
|
@@ -2849,13 +2960,15 @@ view(const Arg *arg)
|
|
|
|
|
void
|
|
|
|
|
virtualkeyboard(struct wl_listener *listener, void *data)
|
|
|
|
|
{
|
|
|
|
|
struct wlr_virtual_keyboard_v1 *keyboard = data;
|
|
|
|
|
struct wlr_virtual_keyboard_v1 *kb = data;
|
|
|
|
|
/* virtual keyboards shouldn't share keyboard group */
|
|
|
|
|
KeyboardGroup *group = createkeyboardgroup();
|
|
|
|
|
/* Set the keymap to match the group keymap */
|
|
|
|
|
wlr_keyboard_set_keymap(&keyboard->keyboard, vkb_group.wlr_group->keyboard.keymap);
|
|
|
|
|
wlr_keyboard_set_repeat_info(&keyboard->keyboard, repeat_rate, repeat_delay);
|
|
|
|
|
wlr_keyboard_set_keymap(&kb->keyboard, group->wlr_group->keyboard.keymap);
|
|
|
|
|
LISTEN(&kb->keyboard.base.events.destroy, &group->destroy, destroykeyboardgroup);
|
|
|
|
|
|
|
|
|
|
/* Add the new keyboard to the group */
|
|
|
|
|
wlr_keyboard_group_add_keyboard(vkb_group.wlr_group, &keyboard->keyboard);
|
|
|
|
|
wlr_keyboard_group_add_keyboard(group->wlr_group, &kb->keyboard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@@ -2988,7 +3101,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
|
|
|
|
|
c = xsurface->data = ecalloc(1, sizeof(*c));
|
|
|
|
|
c->surface.xwayland = xsurface;
|
|
|
|
|
c->type = X11;
|
|
|
|
|
c->bw = borderpx;
|
|
|
|
|
c->bw = client_is_unmanaged(c) ? 0 : borderpx;
|
|
|
|
|
|
|
|
|
|
/* Listen to the various events it can emit */
|
|
|
|
|
LISTEN(&xsurface->events.associate, &c->associate, associatex11);
|
|
|
|
|