mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-05-06 23:15:18 +00:00
formatting: add .clang-format
This commit is contained in:
parent
a2d03cf618
commit
1feb41da8e
30
.clang-format
Normal file
30
.clang-format
Normal file
@ -0,0 +1,30 @@
|
||||
Language: C
|
||||
BasedOnStyle: LLVM
|
||||
ColumnLimit: 100
|
||||
IndentWidth: 8
|
||||
TabWidth: 8
|
||||
UseTab: ForIndentation
|
||||
ContinuationIndentWidth: 8
|
||||
BreakBeforeBraces: Linux
|
||||
BreakAfterReturnType: AllDefinitions
|
||||
AlwaysBreakAfterReturnType: AllDefinitions
|
||||
PointerAlignment: Right
|
||||
IndentCaseLabels: false
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
BinPackParameters: true
|
||||
BinPackArguments: true
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceAfterCStyleCast: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignTrailingComments: false
|
||||
AlignArrayOfStructures: Left
|
||||
SortIncludes: true
|
||||
IncludeBlocks: Regroup
|
||||
72
client.h
72
client.h
@ -64,10 +64,12 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
|
||||
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
||||
return -1;
|
||||
|
||||
tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
||||
tmp_xdg_surface =
|
||||
wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
||||
|
||||
if (!tmp_xdg_surface)
|
||||
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
||||
return toplevel_from_wlr_surface(
|
||||
xdg_surface->popup->parent, pc, pl);
|
||||
|
||||
xdg_surface = tmp_xdg_surface;
|
||||
break;
|
||||
@ -112,8 +114,9 @@ client_set_bounds(Client *c, int32_t width, int32_t height)
|
||||
return 0;
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0
|
||||
&& (c->bounds.width != width || c->bounds.height != height)) {
|
||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION &&
|
||||
width >= 0 && height >= 0 &&
|
||||
(c->bounds.width != width || c->bounds.height != height)) {
|
||||
c->bounds.width = width;
|
||||
c->bounds.height = height;
|
||||
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
||||
@ -177,7 +180,8 @@ client_get_parent(Client *c)
|
||||
}
|
||||
#endif
|
||||
if (c->surface.xdg->toplevel->parent)
|
||||
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
|
||||
toplevel_from_wlr_surface(
|
||||
c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -216,24 +220,28 @@ client_is_float_type(Client *c)
|
||||
if (surface->modal)
|
||||
return 1;
|
||||
|
||||
if (wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
|
||||
if (wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG) ||
|
||||
wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH) ||
|
||||
wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR) ||
|
||||
wlr_xwayland_surface_has_window_type(
|
||||
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
|
||||
&& (size_hints->max_width == size_hints->min_width
|
||||
|| size_hints->max_height == size_hints->min_height);
|
||||
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0 &&
|
||||
(size_hints->max_width == size_hints->min_width ||
|
||||
size_hints->max_height == size_hints->min_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
toplevel = c->surface.xdg->toplevel;
|
||||
state = toplevel->current;
|
||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0
|
||||
&& (state.min_width == state.max_width
|
||||
|| state.min_height == state.max_height));
|
||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0 &&
|
||||
(state.min_width == state.max_width ||
|
||||
state.min_height == state.max_height));
|
||||
}
|
||||
|
||||
static inline int
|
||||
@ -246,9 +254,8 @@ client_is_rendered_on_mon(Client *c, Monitor *m)
|
||||
int unused_lx, unused_ly;
|
||||
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
||||
return 0;
|
||||
wl_list_for_each(s, &client_surface(c)->current_outputs, link)
|
||||
if (s->output == m->wlr_output)
|
||||
return 1;
|
||||
wl_list_for_each(s, &client_surface(c)->current_outputs,
|
||||
link) if (s->output == m->wlr_output) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -263,7 +270,7 @@ client_is_stopped(Client *c)
|
||||
#endif
|
||||
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
if (waitid(P_PID, pid, &in, WNOHANG|WCONTINUED|WSTOPPED|WNOWAIT) < 0) {
|
||||
if (waitid(P_PID, pid, &in, WNOHANG | WCONTINUED | WSTOPPED | WNOWAIT) < 0) {
|
||||
/* This process is not our child process, while is very unlikely that
|
||||
* it is stopped, in order to do not skip frames, assume that it is. */
|
||||
if (errno == ECHILD)
|
||||
@ -292,8 +299,8 @@ static inline void
|
||||
client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
|
||||
{
|
||||
if (kb)
|
||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
|
||||
kb->num_keycodes, &kb->modifiers);
|
||||
wlr_seat_keyboard_notify_enter(
|
||||
seat, s, kb->keycodes, kb->num_keycodes, &kb->modifiers);
|
||||
else
|
||||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||
}
|
||||
@ -342,13 +349,13 @@ client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland,
|
||||
c->geom.x + c->bw, c->geom.y + c->bw, width, height);
|
||||
wlr_xwayland_surface_configure(
|
||||
c->surface.xwayland, c->geom.x + c->bw, c->geom.y + c->bw, width, height);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width
|
||||
&& (int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width &&
|
||||
(int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
return 0;
|
||||
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
}
|
||||
@ -358,13 +365,13 @@ client_set_tiled(Client *c, uint32_t edges)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
||||
edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
||||
wlr_xwayland_surface_set_maximized(
|
||||
c->surface.xwayland, edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
||||
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
||||
} else {
|
||||
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE);
|
||||
@ -386,9 +393,10 @@ static inline int
|
||||
client_wants_focus(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
return client_is_unmanaged(c)
|
||||
&& wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland)
|
||||
&& wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
return client_is_unmanaged(c) &&
|
||||
wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland) &&
|
||||
wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) !=
|
||||
WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
52
config.def.h
52
config.def.h
@ -1,11 +1,13 @@
|
||||
/* Taken from https://github.com/djpohly/dwl/issues/466 */
|
||||
#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \
|
||||
((hex >> 16) & 0xFF) / 255.0f, \
|
||||
((hex >> 8) & 0xFF) / 255.0f, \
|
||||
(hex & 0xFF) / 255.0f }
|
||||
#define COLOR(hex) \
|
||||
{((hex >> 24) & 0xFF) / 255.0f, ((hex >> 16) & 0xFF) / 255.0f, \
|
||||
((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f}
|
||||
|
||||
/* appearance */
|
||||
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 float rootcolor[] = COLOR(0x222222ff);
|
||||
static const float bordercolor[] = COLOR(0x444444ff);
|
||||
@ -20,13 +22,16 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
|
||||
/* logging */
|
||||
static int log_level = WLR_ERROR;
|
||||
|
||||
// clang-format off
|
||||
static const Rule rules[] = {
|
||||
/* app_id title tags mask isfloating monitor */
|
||||
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
|
||||
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
|
||||
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
/* layout(s) */
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
@ -34,7 +39,9 @@ static const Layout layouts[] = {
|
||||
{ "><>", NULL }, /* no layout function means floating behavior */
|
||||
{ "[M]", monocle },
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
/* monitors */
|
||||
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
|
||||
* WARNING: negative values other than (-1, -1) cause problems with Xwayland clients due to
|
||||
@ -46,6 +53,7 @@ static const MonitorRule monrules[] = {
|
||||
{ NULL, 0.55f, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||
/* default monitor rule: can be changed but cannot be eliminated; at least one monitor rule must exist */
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
/* keyboard */
|
||||
static const struct xkb_rule_names xkb_rules = {
|
||||
@ -80,7 +88,8 @@ LIBINPUT_CONFIG_CLICK_METHOD_NONE
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
|
||||
*/
|
||||
static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||
static const enum libinput_config_click_method click_method =
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||
|
||||
/* You can choose between:
|
||||
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
|
||||
@ -93,7 +102,8 @@ static const uint32_t send_events_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
|
||||
*/
|
||||
static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
|
||||
static const enum libinput_config_accel_profile accel_profile =
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
|
||||
static const double accel_speed = 0.0;
|
||||
|
||||
/* You can choose between:
|
||||
@ -105,19 +115,28 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
||||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
#define TAGKEYS(KEY,SKEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
|
||||
// clang-format off
|
||||
#define TAGKEYS(KEY, SKEY, TAG) \
|
||||
{MODKEY, KEY, view, {.ui = 1 << TAG}}, \
|
||||
{MODKEY | WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG}}, \
|
||||
{MODKEY | WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG}}, \
|
||||
{MODKEY | WLR_MODIFIER_CTRL | WLR_MODIFIER_SHIFT, SKEY, toggletag, {.ui = 1 << TAG}}
|
||||
// clang-format on
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
#define SHCMD(cmd) \
|
||||
{ \
|
||||
.v = (const char *[]) \
|
||||
{ \
|
||||
"/bin/sh", "-c", cmd, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
/* commands */
|
||||
static const char *termcmd[] = { "foot", NULL };
|
||||
static const char *menucmd[] = { "wmenu-run", NULL };
|
||||
static const char *termcmd[] = {"foot", NULL};
|
||||
static const char *menucmd[] = {"wmenu-run", NULL};
|
||||
|
||||
// clang-format off
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: 2 -> at, etc. */
|
||||
/* modifier key function argument */
|
||||
@ -164,9 +183,12 @@ static const Key keys[] = {
|
||||
CHVT(1), CHVT(2), CHVT(3), CHVT(4), CHVT(5), CHVT(6),
|
||||
CHVT(7), CHVT(8), CHVT(9), CHVT(10), CHVT(11), CHVT(12),
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// clang-format off
|
||||
static const Button buttons[] = {
|
||||
{ MODKEY, BTN_LEFT, moveresize, {.ui = CurMove} },
|
||||
{ MODKEY, BTN_MIDDLE, togglefloating, {0} },
|
||||
{ MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} },
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
442
dwl.c
442
dwl.c
@ -80,12 +80,27 @@
|
||||
#define END(A) ((A) + LENGTH(A))
|
||||
#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) \
|
||||
do { \
|
||||
struct wl_listener *_l = ecalloc(1, sizeof(*_l)); \
|
||||
_l->notify = (H); \
|
||||
wl_signal_add((E), _l); \
|
||||
} while (0)
|
||||
|
||||
/* enums */
|
||||
enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
|
||||
enum { XDGShell, LayerShell, X11 }; /* client types */
|
||||
enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrTop, LyrFS, LyrOverlay, LyrBlock, NUM_LAYERS }; /* scene layers */
|
||||
enum {
|
||||
LyrBg,
|
||||
LyrBottom,
|
||||
LyrTile,
|
||||
LyrFloat,
|
||||
LyrTop,
|
||||
LyrFS,
|
||||
LyrOverlay,
|
||||
LyrBlock,
|
||||
NUM_LAYERS
|
||||
}; /* scene layers */
|
||||
|
||||
typedef union {
|
||||
int i;
|
||||
@ -244,8 +259,8 @@ typedef struct {
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applyrules(Client *c);
|
||||
static void arrange(Monitor *m);
|
||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayer(
|
||||
Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
@ -302,15 +317,15 @@ 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 void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
|
||||
double sy, double sx_unaccel, double sy_unaccel);
|
||||
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);
|
||||
static void moveresize(const Arg *arg);
|
||||
static void outputmgrapply(struct wl_listener *listener, void *data);
|
||||
static void outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test);
|
||||
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 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);
|
||||
@ -349,8 +364,8 @@ 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 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);
|
||||
static void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc,
|
||||
LayerSurface **pl, double *nx, double *ny);
|
||||
static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
@ -364,7 +379,7 @@ static struct wlr_scene *scene;
|
||||
static struct wlr_scene_tree *layers[NUM_LAYERS];
|
||||
static struct wlr_scene_tree *drag_icon;
|
||||
/* Map from ZWLR_LAYER_SHELL_* constants to Lyr* enum */
|
||||
static const int layermap[] = { LyrBg, LyrBottom, LyrTop, LyrOverlay };
|
||||
static const int layermap[] = {LyrBg, LyrBottom, LyrTop, LyrOverlay};
|
||||
static struct wlr_renderer *drw;
|
||||
static struct wlr_allocator *alloc;
|
||||
static struct wlr_compositor *compositor;
|
||||
@ -488,12 +503,12 @@ applyrules(Client *c)
|
||||
title = client_get_title(c);
|
||||
|
||||
for (r = rules; r < END(rules); r++) {
|
||||
if ((!r->title || strstr(title, r->title))
|
||||
&& (!r->id || strstr(appid, r->id))) {
|
||||
if ((!r->title || strstr(title, r->title)) && (!r->id || strstr(appid, r->id))) {
|
||||
c->isfloating = r->isfloating;
|
||||
newtags |= r->tags;
|
||||
i = 0;
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
wl_list_for_each(m, &mons, link)
|
||||
{
|
||||
if (r->monitor == i++)
|
||||
mon = m;
|
||||
}
|
||||
@ -512,29 +527,28 @@ arrange(Monitor *m)
|
||||
if (!m->wlr_output->enabled)
|
||||
return;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (c->mon == m) {
|
||||
wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m));
|
||||
client_set_suspended(c, !VISIBLEON(c, m));
|
||||
}
|
||||
}
|
||||
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node,
|
||||
(c = focustop(m)) && c->isfullscreen);
|
||||
wlr_scene_node_set_enabled(&m->fullscreen_bg->node, (c = focustop(m)) && c->isfullscreen);
|
||||
|
||||
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) {
|
||||
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]
|
||||
(!m->lt[m->sellt]->arrange && c->isfloating) ? layers[LyrTile]
|
||||
: (m->lt[m->sellt]->arrange && c->isfloating) ? layers[LyrFloat]
|
||||
: c->scene->node.parent);
|
||||
}
|
||||
|
||||
@ -550,7 +564,8 @@ arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int
|
||||
LayerSurface *l;
|
||||
struct wlr_box full_area = m->m;
|
||||
|
||||
wl_list_for_each(l, list, link) {
|
||||
wl_list_for_each(l, list, link)
|
||||
{
|
||||
struct wlr_layer_surface_v1 *layer_surface = l->layer_surface;
|
||||
|
||||
if (!layer_surface->initialized)
|
||||
@ -592,7 +607,8 @@ arrangelayers(Monitor *m)
|
||||
|
||||
/* Find topmost keyboard interactive layer, if such a layer exists */
|
||||
for (i = 0; i < (int)LENGTH(layers_above_shell); i++) {
|
||||
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link) {
|
||||
wl_list_for_each_reverse(l, &m->layers[layers_above_shell[i]], link)
|
||||
{
|
||||
if (locked || !l->layer_surface->current.keyboard_interactive || !l->mapped)
|
||||
continue;
|
||||
/* Deactivate the focused client. */
|
||||
@ -614,8 +630,7 @@ axisnotify(struct wl_listener *listener, void *data)
|
||||
/* TODO: allow usage of scroll wheel for mousebindings, it can be implemented
|
||||
* by checking the event's orientation and the delta of the event */
|
||||
/* Notify the client with pointer focus of the axis event. */
|
||||
wlr_seat_pointer_notify_axis(seat,
|
||||
event->time_msec, event->orientation, event->delta,
|
||||
wlr_seat_pointer_notify_axis(seat, event->time_msec, event->orientation, event->delta,
|
||||
event->delta_discrete, event->source, event->relative_direction);
|
||||
}
|
||||
|
||||
@ -645,8 +660,8 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
keyboard = wlr_seat_get_keyboard(seat);
|
||||
mods = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
|
||||
for (b = buttons; b < END(buttons); b++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) &&
|
||||
event->button == b->button && b->func) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(b->mod) && event->button == b->button &&
|
||||
b->func) {
|
||||
b->func(&b->arg);
|
||||
return;
|
||||
}
|
||||
@ -669,8 +684,7 @@ buttonpress(struct wl_listener *listener, void *data)
|
||||
}
|
||||
/* If the event wasn't handled by the compositor, notify the client with
|
||||
* pointer focus that a button press has occurred */
|
||||
wlr_seat_pointer_notify_button(seat,
|
||||
event->time_msec, event->button, event->state);
|
||||
wlr_seat_pointer_notify_button(seat, event->time_msec, event->button, event->state);
|
||||
}
|
||||
|
||||
void
|
||||
@ -684,11 +698,13 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
||||
{
|
||||
int inhibited = 0, unused_lx, unused_ly;
|
||||
struct wlr_idle_inhibitor_v1 *inhibitor;
|
||||
wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) {
|
||||
wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link)
|
||||
{
|
||||
struct wlr_surface *surface = wlr_surface_get_root_surface(inhibitor->surface);
|
||||
struct wlr_scene_tree *tree = surface->data;
|
||||
if (exclude != surface && (bypass_surface_visibility || (!tree
|
||||
|| wlr_scene_node_coords(&tree->node, &unused_lx, &unused_ly)))) {
|
||||
if (exclude != surface &&
|
||||
(bypass_surface_visibility || (!tree || wlr_scene_node_coords(&tree->node,
|
||||
&unused_lx, &unused_ly)))) {
|
||||
inhibited = 1;
|
||||
break;
|
||||
}
|
||||
@ -807,10 +823,15 @@ closemon(Monitor *m)
|
||||
selmon = NULL;
|
||||
}
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (c->isfloating && c->geom.x > m->m.width)
|
||||
resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
|
||||
.width = c->geom.width, .height = c->geom.height}, 0);
|
||||
resize(c,
|
||||
(struct wlr_box){.x = c->geom.x - m->w.width,
|
||||
.y = c->geom.y,
|
||||
.width = c->geom.width,
|
||||
.height = c->geom.height},
|
||||
0);
|
||||
if (c->mon == m)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
@ -846,8 +867,10 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data)
|
||||
wlr_scene_node_reparent(&l->scene->node, scene_layer);
|
||||
wl_list_remove(&l->link);
|
||||
wl_list_insert(&l->mon->layers[layer_surface->current.layer], &l->link);
|
||||
wlr_scene_node_reparent(&l->popups->node, (layer_surface->current.layer
|
||||
< ZWLR_LAYER_SHELL_V1_LAYER_TOP ? layers[LyrTop] : scene_layer));
|
||||
wlr_scene_node_reparent(&l->popups->node,
|
||||
(layer_surface->current.layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP
|
||||
? layers[LyrTop]
|
||||
: scene_layer));
|
||||
}
|
||||
|
||||
arrangelayers(l->mon);
|
||||
@ -871,8 +894,8 @@ commitnotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
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_wm_capabilities(
|
||||
c->surface.xdg->toplevel, WLR_XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN);
|
||||
if (c->decoration)
|
||||
requestdecorationmode(&c->set_decoration_mode, c->decoration);
|
||||
wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, 0, 0);
|
||||
@ -902,8 +925,7 @@ commitpopup(struct wl_listener *listener, void *data)
|
||||
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);
|
||||
popup->base->surface->data = wlr_scene_xdg_surface_create(popup->parent->data, popup->base);
|
||||
if ((l && !l->mon) || (c && !c->mon)) {
|
||||
wlr_xdg_popup_destroy(popup);
|
||||
return;
|
||||
@ -960,8 +982,7 @@ createkeyboardgroup(void)
|
||||
|
||||
/* 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)))
|
||||
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);
|
||||
@ -993,8 +1014,8 @@ createlayersurface(struct wl_listener *listener, void *data)
|
||||
struct wlr_surface *surface = layer_surface->surface;
|
||||
struct wlr_scene_tree *scene_layer = layers[layermap[layer_surface->pending.layer]];
|
||||
|
||||
if (!layer_surface->output
|
||||
&& !(layer_surface->output = selmon ? selmon->wlr_output : NULL)) {
|
||||
if (!layer_surface->output &&
|
||||
!(layer_surface->output = selmon ? selmon->wlr_output : NULL)) {
|
||||
wlr_layer_surface_v1_destroy(layer_surface);
|
||||
return;
|
||||
}
|
||||
@ -1009,11 +1030,12 @@ createlayersurface(struct wl_listener *listener, void *data)
|
||||
l->mon = layer_surface->output->data;
|
||||
l->scene_layer = wlr_scene_layer_surface_v1_create(scene_layer, layer_surface);
|
||||
l->scene = l->scene_layer->tree;
|
||||
l->popups = surface->data = wlr_scene_tree_create(layer_surface->current.layer
|
||||
< ZWLR_LAYER_SHELL_V1_LAYER_TOP ? layers[LyrTop] : scene_layer);
|
||||
l->popups = surface->data = wlr_scene_tree_create(
|
||||
layer_surface->current.layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP ? layers[LyrTop]
|
||||
: scene_layer);
|
||||
l->scene->node.data = l->popups->node.data = l;
|
||||
|
||||
wl_list_insert(&l->mon->layers[layer_surface->pending.layer],&l->link);
|
||||
wl_list_insert(&l->mon->layers[layer_surface->pending.layer], &l->link);
|
||||
wlr_surface_send_enter(surface, layer_surface->output);
|
||||
}
|
||||
|
||||
@ -1023,8 +1045,8 @@ createlocksurface(struct wl_listener *listener, void *data)
|
||||
SessionLock *lock = wl_container_of(listener, lock, new_surface);
|
||||
struct wlr_session_lock_surface_v1 *lock_surface = data;
|
||||
Monitor *m = lock_surface->output->data;
|
||||
struct wlr_scene_tree *scene_tree = lock_surface->surface->data
|
||||
= wlr_scene_subsurface_tree_create(lock->scene, lock_surface->surface);
|
||||
struct wlr_scene_tree *scene_tree = lock_surface->surface->data =
|
||||
wlr_scene_subsurface_tree_create(lock->scene, lock_surface->surface);
|
||||
m->lock_surface = lock_surface;
|
||||
|
||||
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|
||||
@ -1142,8 +1164,8 @@ void
|
||||
createpointer(struct wlr_pointer *pointer)
|
||||
{
|
||||
struct libinput_device *device;
|
||||
if (wlr_input_device_is_libinput(&pointer->base)
|
||||
&& (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||
if (wlr_input_device_is_libinput(&pointer->base) &&
|
||||
(device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||
|
||||
if (libinput_device_config_tap_get_finger_count(device)) {
|
||||
libinput_device_config_tap_set_enabled(device, tap_to_click);
|
||||
@ -1153,7 +1175,8 @@ createpointer(struct wlr_pointer *pointer)
|
||||
}
|
||||
|
||||
if (libinput_device_config_scroll_has_natural_scroll(device))
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(device, natural_scrolling);
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||
device, natural_scrolling);
|
||||
|
||||
if (libinput_device_config_dwt_is_available(device))
|
||||
libinput_device_config_dwt_set_enabled(device, disable_while_typing);
|
||||
@ -1162,12 +1185,15 @@ createpointer(struct wlr_pointer *pointer)
|
||||
libinput_device_config_left_handed_set(device, left_handed);
|
||||
|
||||
if (libinput_device_config_middle_emulation_is_available(device))
|
||||
libinput_device_config_middle_emulation_set_enabled(device, middle_button_emulation);
|
||||
libinput_device_config_middle_emulation_set_enabled(
|
||||
device, middle_button_emulation);
|
||||
|
||||
if (libinput_device_config_scroll_get_methods(device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
|
||||
if (libinput_device_config_scroll_get_methods(device) !=
|
||||
LIBINPUT_CONFIG_SCROLL_NO_SCROLL)
|
||||
libinput_device_config_scroll_set_method(device, scroll_method);
|
||||
|
||||
if (libinput_device_config_click_get_methods(device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE)
|
||||
if (libinput_device_config_click_get_methods(device) !=
|
||||
LIBINPUT_CONFIG_CLICK_METHOD_NONE)
|
||||
libinput_device_config_click_set_method(device, click_method);
|
||||
|
||||
if (libinput_device_config_send_events_get_modes(device))
|
||||
@ -1187,8 +1213,8 @@ createpointerconstraint(struct wl_listener *listener, void *data)
|
||||
{
|
||||
PointerConstraint *pointer_constraint = ecalloc(1, sizeof(*pointer_constraint));
|
||||
pointer_constraint->constraint = data;
|
||||
LISTEN(&pointer_constraint->constraint->events.destroy,
|
||||
&pointer_constraint->destroy, destroypointerconstraint);
|
||||
LISTEN(&pointer_constraint->constraint->events.destroy, &pointer_constraint->destroy,
|
||||
destroypointerconstraint);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1354,7 +1380,8 @@ destroynotify(struct wl_listener *listener, void *data)
|
||||
void
|
||||
destroypointerconstraint(struct wl_listener *listener, void *data)
|
||||
{
|
||||
PointerConstraint *pointer_constraint = wl_container_of(listener, pointer_constraint, destroy);
|
||||
PointerConstraint *pointer_constraint =
|
||||
wl_container_of(listener, pointer_constraint, destroy);
|
||||
|
||||
if (active_constraint == pointer_constraint->constraint) {
|
||||
cursorwarptohint();
|
||||
@ -1390,12 +1417,12 @@ dirtomon(enum wlr_direction dir)
|
||||
struct wlr_output *next;
|
||||
if (!wlr_output_layout_get(output_layout, selmon->wlr_output))
|
||||
return selmon;
|
||||
if ((next = wlr_output_layout_adjacent_output(output_layout,
|
||||
dir, selmon->wlr_output, selmon->m.x, selmon->m.y)))
|
||||
if ((next = wlr_output_layout_adjacent_output(
|
||||
output_layout, dir, selmon->wlr_output, selmon->m.x, selmon->m.y)))
|
||||
return next->data;
|
||||
if ((next = wlr_output_layout_farthest_output(output_layout,
|
||||
dir ^ (WLR_DIRECTION_LEFT|WLR_DIRECTION_RIGHT),
|
||||
selmon->wlr_output, selmon->m.x, selmon->m.y)))
|
||||
dir ^ (WLR_DIRECTION_LEFT | WLR_DIRECTION_RIGHT), selmon->wlr_output,
|
||||
selmon->m.x, selmon->m.y)))
|
||||
return next->data;
|
||||
return selmon;
|
||||
}
|
||||
@ -1442,14 +1469,14 @@ focusclient(Client *c, int lift)
|
||||
/* If an overlay is focused, don't focus or activate the client,
|
||||
* but only update its position in fstack to render its border with focuscolor
|
||||
* and focus it after the overlay is closed. */
|
||||
if (old_client_type == LayerShell && wlr_scene_node_coords(
|
||||
&old_l->scene->node, &unused_lx, &unused_ly)
|
||||
&& old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
|
||||
if (old_client_type == LayerShell &&
|
||||
wlr_scene_node_coords(&old_l->scene->node, &unused_lx, &unused_ly) &&
|
||||
old_l->layer_surface->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
|
||||
return;
|
||||
} else if (old_c && old_c == exclusive_focus && client_wants_focus(old_c)) {
|
||||
return;
|
||||
/* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg
|
||||
* and probably other clients */
|
||||
/* Don't deactivate old client if the new one wants focus, as this causes
|
||||
* issues with winecfg and probably other clients */
|
||||
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
|
||||
client_set_border_color(old_c, bordercolor);
|
||||
|
||||
@ -1494,14 +1521,16 @@ focusstack(const Arg *arg)
|
||||
if (!sel || (sel->isfullscreen && !client_has_children(sel)))
|
||||
return;
|
||||
if (arg->i > 0) {
|
||||
wl_list_for_each(c, &sel->link, link) {
|
||||
wl_list_for_each(c, &sel->link, link)
|
||||
{
|
||||
if (&c->link == &clients)
|
||||
continue; /* wrap past the sentinel node */
|
||||
if (VISIBLEON(c, selmon))
|
||||
break; /* found it */
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each_reverse(c, &sel->link, link) {
|
||||
wl_list_for_each_reverse(c, &sel->link, link)
|
||||
{
|
||||
if (&c->link == &clients)
|
||||
continue; /* wrap past the sentinel node */
|
||||
if (VISIBLEON(c, selmon))
|
||||
@ -1519,7 +1548,8 @@ Client *
|
||||
focustop(Monitor *m)
|
||||
{
|
||||
Client *c;
|
||||
wl_list_for_each(c, &fstack, flink) {
|
||||
wl_list_for_each(c, &fstack, flink)
|
||||
{
|
||||
if (VISIBLEON(c, m))
|
||||
return c;
|
||||
}
|
||||
@ -1550,7 +1580,8 @@ gpureset(struct wl_listener *listener, void *data)
|
||||
|
||||
wlr_compositor_set_renderer(compositor, drw);
|
||||
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
wl_list_for_each(m, &mons, link)
|
||||
{
|
||||
wlr_output_init_render(m->wlr_output, alloc, drw);
|
||||
}
|
||||
|
||||
@ -1562,7 +1593,8 @@ void
|
||||
handlesig(int signo)
|
||||
{
|
||||
if (signo == SIGCHLD)
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||
;
|
||||
else if (signo == SIGINT || signo == SIGTERM)
|
||||
quit(NULL);
|
||||
}
|
||||
@ -1616,9 +1648,8 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
*/
|
||||
const Key *k;
|
||||
for (k = keys; k < END(keys); k++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
|
||||
&& k->func) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod) &&
|
||||
xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym) && k->func) {
|
||||
k->func(&k->arg);
|
||||
return 1;
|
||||
}
|
||||
@ -1638,8 +1669,7 @@ keypress(struct wl_listener *listener, void *data)
|
||||
uint32_t keycode = event->keycode + 8;
|
||||
/* Get a list of keysyms based on the keymap for this keyboard */
|
||||
const xkb_keysym_t *syms;
|
||||
int nsyms = xkb_state_key_get_syms(
|
||||
group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
||||
int nsyms = xkb_state_key_get_syms(group->wlr_group->keyboard.xkb_state, keycode, &syms);
|
||||
|
||||
int handled = 0;
|
||||
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||
@ -1657,8 +1687,8 @@ keypress(struct wl_listener *listener, void *data)
|
||||
group->mods = mods;
|
||||
group->keysyms = syms;
|
||||
group->nsyms = nsyms;
|
||||
wl_event_source_timer_update(group->key_repeat_source,
|
||||
group->wlr_group->keyboard.repeat_info.delay);
|
||||
wl_event_source_timer_update(
|
||||
group->key_repeat_source, group->wlr_group->keyboard.repeat_info.delay);
|
||||
} else {
|
||||
group->nsyms = 0;
|
||||
wl_event_source_timer_update(group->key_repeat_source, 0);
|
||||
@ -1669,8 +1699,7 @@ keypress(struct wl_listener *listener, void *data)
|
||||
|
||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||
/* Pass unhandled keycodes along to the client. */
|
||||
wlr_seat_keyboard_notify_key(seat, event->time_msec,
|
||||
event->keycode, event->state);
|
||||
wlr_seat_keyboard_notify_key(seat, event->time_msec, event->keycode, event->state);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1682,8 +1711,7 @@ keypressmod(struct wl_listener *listener, void *data)
|
||||
|
||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||
/* Send modifiers to the client. */
|
||||
wlr_seat_keyboard_notify_modifiers(seat,
|
||||
&group->wlr_group->keyboard.modifiers);
|
||||
wlr_seat_keyboard_notify_modifiers(seat, &group->wlr_group->keyboard.modifiers);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1694,8 +1722,8 @@ keyrepeat(void *data)
|
||||
if (!group->nsyms || group->wlr_group->keyboard.repeat_info.rate <= 0)
|
||||
return 0;
|
||||
|
||||
wl_event_source_timer_update(group->key_repeat_source,
|
||||
1000 / group->wlr_group->keyboard.repeat_info.rate);
|
||||
wl_event_source_timer_update(
|
||||
group->key_repeat_source, 1000 / group->wlr_group->keyboard.repeat_info.rate);
|
||||
|
||||
for (i = 0; i < group->nsyms; i++)
|
||||
keybinding(group->mods, group->keysyms[i]);
|
||||
@ -1769,8 +1797,8 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
c->border[i] = wlr_scene_rect_create(c->scene, 0, 0,
|
||||
c->isurgent ? urgentcolor : bordercolor);
|
||||
c->border[i] = wlr_scene_rect_create(
|
||||
c->scene, 0, 0, c->isurgent ? urgentcolor : bordercolor);
|
||||
c->border[i]->node.data = c;
|
||||
}
|
||||
|
||||
@ -1797,7 +1825,8 @@ mapnotify(struct wl_listener *listener, void *data)
|
||||
|
||||
unset_fullscreen:
|
||||
m = c->mon ? c->mon : xytomon(c->geom.x, c->geom.y);
|
||||
wl_list_for_each(w, &clients, link) {
|
||||
wl_list_for_each(w, &clients, link)
|
||||
{
|
||||
if (w != c && w != p && w->isfullscreen && m == w->mon && (w->tags & c->tags))
|
||||
setfullscreen(w, 0);
|
||||
}
|
||||
@ -1815,9 +1844,9 @@ 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 (c->surface.xdg->initialized
|
||||
&& wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
||||
< XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1827,7 +1856,8 @@ monocle(Monitor *m)
|
||||
Client *c;
|
||||
int n = 0;
|
||||
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
resize(c, m->w, 0);
|
||||
@ -1853,7 +1883,8 @@ motionabsolute(struct wl_listener *listener, void *data)
|
||||
if (!event->time_msec) /* this is 0 with virtual pointers */
|
||||
wlr_cursor_warp_absolute(cursor, &event->pointer->base, event->x, event->y);
|
||||
|
||||
wlr_cursor_absolute_to_layout_coords(cursor, &event->pointer->base, event->x, event->y, &lx, &ly);
|
||||
wlr_cursor_absolute_to_layout_coords(
|
||||
cursor, &event->pointer->base, event->x, event->y, &lx, &ly);
|
||||
dx = lx - cursor->x;
|
||||
dy = ly - cursor->y;
|
||||
motionnotify(event->time_msec, &event->pointer->base, dx, dy, dx, dy);
|
||||
@ -1872,9 +1903,9 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* 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) {
|
||||
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->scene->node.x : w->geom.x);
|
||||
@ -1883,20 +1914,20 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
|
||||
/* time is 0 in internal calls meant to restore pointer focus. */
|
||||
if (time) {
|
||||
wlr_relative_pointer_manager_v1_send_relative_motion(
|
||||
relative_pointer_mgr, seat, (uint64_t)time * 1000,
|
||||
dx, dy, dx_unaccel, dy_unaccel);
|
||||
wlr_relative_pointer_manager_v1_send_relative_motion(relative_pointer_mgr, seat,
|
||||
(uint64_t)time * 1000, dx, dy, dx_unaccel, dy_unaccel);
|
||||
|
||||
wl_list_for_each(constraint, &pointer_constraints->constraints, link)
|
||||
cursorconstrain(constraint);
|
||||
|
||||
if (active_constraint && cursor_mode != CurResize && cursor_mode != CurMove) {
|
||||
toplevel_from_wlr_surface(active_constraint->surface, &c, NULL);
|
||||
if (c && active_constraint->surface == seat->pointer_state.focused_surface) {
|
||||
if (c &&
|
||||
active_constraint->surface == seat->pointer_state.focused_surface) {
|
||||
sx = cursor->x - c->geom.x - c->bw;
|
||||
sy = cursor->y - c->geom.y - c->bw;
|
||||
if (wlr_region_confine(&active_constraint->region, sx, sy,
|
||||
sx + dx, sy + dy, &sx_confined, &sy_confined)) {
|
||||
if (wlr_region_confine(&active_constraint->region, sx, sy, sx + dx,
|
||||
sy + dy, &sx_confined, &sy_confined)) {
|
||||
dx = sx_confined - sx;
|
||||
dy = sy_confined - sy;
|
||||
}
|
||||
@ -1920,12 +1951,20 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
|
||||
/* If we are currently grabbing the mouse, handle and return */
|
||||
if (cursor_mode == CurMove) {
|
||||
/* Move the grabbed client to the new position. */
|
||||
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);
|
||||
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 = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1);
|
||||
resize(grabc,
|
||||
(struct wlr_box){.x = grabc->geom.x,
|
||||
.y = grabc->geom.y,
|
||||
.width = (int)round(cursor->x) - grabc->geom.x,
|
||||
.height = (int)round(cursor->y) - grabc->geom.y},
|
||||
1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1973,8 +2012,7 @@ moveresize(const Arg *arg)
|
||||
case CurResize:
|
||||
/* Doesn't work for X11 output - the next absolute motion event
|
||||
* returns the cursor to where it started */
|
||||
wlr_cursor_warp_closest(cursor, NULL,
|
||||
grabc->geom.x + grabc->geom.width,
|
||||
wlr_cursor_warp_closest(cursor, NULL, grabc->geom.x + grabc->geom.width,
|
||||
grabc->geom.y + grabc->geom.height);
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
|
||||
break;
|
||||
@ -2000,7 +2038,8 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
|
||||
struct wlr_output_configuration_head_v1 *config_head;
|
||||
int ok = 1;
|
||||
|
||||
wl_list_for_each(config_head, &config->heads, link) {
|
||||
wl_list_for_each(config_head, &config->heads, link)
|
||||
{
|
||||
struct wlr_output *wlr_output = config_head->state.output;
|
||||
Monitor *m = wlr_output->data;
|
||||
struct wlr_output_state state;
|
||||
@ -2024,19 +2063,20 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, int test)
|
||||
|
||||
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,
|
||||
config_head->state.adaptive_sync_enabled);
|
||||
wlr_output_state_set_adaptive_sync_enabled(
|
||||
&state, config_head->state.adaptive_sync_enabled);
|
||||
|
||||
apply_or_test:
|
||||
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 avoids
|
||||
* 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);
|
||||
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);
|
||||
}
|
||||
@ -2059,13 +2099,12 @@ outputmgrtest(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
void
|
||||
pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
|
||||
uint32_t time)
|
||||
pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, uint32_t time)
|
||||
{
|
||||
struct timespec now;
|
||||
|
||||
if (surface != seat->pointer_state.focused_surface &&
|
||||
sloppyfocus && time && c && !client_is_unmanaged(c))
|
||||
if (surface != seat->pointer_state.focused_surface && sloppyfocus && time && c &&
|
||||
!client_is_unmanaged(c))
|
||||
focusclient(c, 0);
|
||||
|
||||
/* If surface is NULL, clear pointer focus */
|
||||
@ -2093,9 +2132,11 @@ printstatus(void)
|
||||
Client *c;
|
||||
uint32_t occ, urg, sel;
|
||||
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
wl_list_for_each(m, &mons, link)
|
||||
{
|
||||
occ = urg = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (c->mon != m)
|
||||
continue;
|
||||
occ |= c->tags;
|
||||
@ -2117,7 +2158,7 @@ printstatus(void)
|
||||
}
|
||||
|
||||
printf("%s selmon %u\n", m->wlr_output->name, m == selmon);
|
||||
printf("%s tags %"PRIu32" %"PRIu32" %"PRIu32" %"PRIu32"\n",
|
||||
printf("%s tags %" PRIu32 " %" PRIu32 " %" PRIu32 " %" PRIu32 "\n",
|
||||
m->wlr_output->name, occ, m->tagset[m->seltags], sel, urg);
|
||||
printf("%s layout %s\n", m->wlr_output->name, m->ltsymbol);
|
||||
}
|
||||
@ -2160,8 +2201,10 @@ rendermon(struct wl_listener *listener, void *data)
|
||||
|
||||
/* Render if no XDG clients have an outstanding resize and are visible on
|
||||
* this monitor. */
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) && !client_is_stopped(c))
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (c->resize && !c->isfloating && client_is_rendered_on_mon(c, m) &&
|
||||
!client_is_stopped(c))
|
||||
goto skip;
|
||||
}
|
||||
|
||||
@ -2179,8 +2222,8 @@ 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);
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(
|
||||
c->decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2188,8 +2231,7 @@ requeststartdrag(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_seat_request_start_drag_event *event = data;
|
||||
|
||||
if (wlr_seat_validate_pointer_grab_serial(seat, event->origin,
|
||||
event->serial))
|
||||
if (wlr_seat_validate_pointer_grab_serial(seat, event->origin, event->serial))
|
||||
wlr_seat_start_pointer_drag(seat, event->drag, event->serial);
|
||||
else
|
||||
wlr_data_source_destroy(event->drag->source);
|
||||
@ -2230,8 +2272,7 @@ resize(Client *c, struct wlr_box geo, int interact)
|
||||
wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw);
|
||||
|
||||
/* this is a no-op if size hasn't changed */
|
||||
c->resize = client_set_size(c, c->geom.width - 2 * c->bw,
|
||||
c->geom.height - 2 * c->bw);
|
||||
c->resize = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw);
|
||||
client_get_clip(c, &clip);
|
||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||
}
|
||||
@ -2313,8 +2354,7 @@ setcursor(struct wl_listener *listener, void *data)
|
||||
* hardware cursor on the output that it's currently on and continue to
|
||||
* do so as the cursor moves between outputs. */
|
||||
if (event->seat_client == seat->pointer_state.focused_client)
|
||||
wlr_cursor_set_surface(cursor, event->surface,
|
||||
event->hotspot_x, event->hotspot_y);
|
||||
wlr_cursor_set_surface(cursor, event->surface, event->hotspot_x, event->hotspot_y);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2327,8 +2367,7 @@ setcursorshape(struct wl_listener *listener, void *data)
|
||||
* actually has pointer focus first. If so, we can tell the cursor to
|
||||
* use the provided cursor shape. */
|
||||
if (event->seat_client == seat->pointer_state.focused_client)
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr,
|
||||
wlr_cursor_shape_v1_name(event->shape));
|
||||
wlr_cursor_set_xcursor(cursor, cursor_mgr, wlr_cursor_shape_v1_name(event->shape));
|
||||
}
|
||||
|
||||
void
|
||||
@ -2339,9 +2378,10 @@ setfloating(Client *c, int floating)
|
||||
/* 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
|
||||
: c->isfloating ? LyrFloat : LyrTile]);
|
||||
wlr_scene_node_reparent(
|
||||
&c->scene->node, layers[c->isfullscreen || (p && p->isfullscreen) ? LyrFS
|
||||
: c->isfloating ? LyrFloat
|
||||
: LyrTile]);
|
||||
arrange(c->mon);
|
||||
printstatus();
|
||||
}
|
||||
@ -2354,8 +2394,9 @@ setfullscreen(Client *c, int fullscreen)
|
||||
return;
|
||||
c->bw = fullscreen ? 0 : borderpx;
|
||||
client_set_fullscreen(c, fullscreen);
|
||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen
|
||||
? LyrFS : c->isfloating ? LyrFloat : LyrTile]);
|
||||
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ? LyrFS
|
||||
: c->isfloating ? LyrFloat
|
||||
: LyrTile]);
|
||||
|
||||
if (fullscreen) {
|
||||
c->prev = c->geom;
|
||||
@ -2414,7 +2455,8 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
|
||||
if (m) {
|
||||
/* Make sure window actually overlaps with the monitor */
|
||||
resize(c, c->geom, 0);
|
||||
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
c->tags = newtags ? newtags
|
||||
: m->tagset[m->seltags]; /* assign tags of target monitor */
|
||||
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
|
||||
setfloating(c, c->isfloating);
|
||||
}
|
||||
@ -2492,12 +2534,12 @@ setup(void)
|
||||
|
||||
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, 5, drw));
|
||||
wlr_scene_set_linux_dmabuf_v1(
|
||||
scene, wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw));
|
||||
}
|
||||
|
||||
if ((drm_fd = wlr_renderer_get_drm_fd(drw)) >= 0 && drw->features.timeline
|
||||
&& backend->features.timeline)
|
||||
if ((drm_fd = wlr_renderer_get_drm_fd(drw)) >= 0 && drw->features.timeline &&
|
||||
backend->features.timeline)
|
||||
wlr_linux_drm_syncobj_manager_v1_create(dpy, 1, drm_fd);
|
||||
|
||||
/* Autocreates an allocator for us.
|
||||
@ -2571,13 +2613,12 @@ setup(void)
|
||||
|
||||
session_lock_mgr = wlr_session_lock_manager_v1_create(dpy);
|
||||
wl_signal_add(&session_lock_mgr->events.new_lock, &new_session_lock);
|
||||
locked_bg = wlr_scene_rect_create(layers[LyrBlock], sgeom.width, sgeom.height,
|
||||
(float [4]){0.1f, 0.1f, 0.1f, 1.0f});
|
||||
locked_bg = wlr_scene_rect_create(
|
||||
layers[LyrBlock], sgeom.width, sgeom.height, (float[4]){0.1f, 0.1f, 0.1f, 1.0f});
|
||||
wlr_scene_node_set_enabled(&locked_bg->node, 0);
|
||||
|
||||
/* 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_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);
|
||||
wl_signal_add(&xdg_decoration_mgr->events.new_toplevel_decoration, &new_xdg_decoration);
|
||||
@ -2628,11 +2669,9 @@ setup(void)
|
||||
*/
|
||||
wl_signal_add(&backend->events.new_input, &new_input_device);
|
||||
virtual_keyboard_mgr = wlr_virtual_keyboard_manager_v1_create(dpy);
|
||||
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard,
|
||||
&new_virtual_keyboard);
|
||||
wl_signal_add(&virtual_keyboard_mgr->events.new_virtual_keyboard, &new_virtual_keyboard);
|
||||
virtual_pointer_mgr = wlr_virtual_pointer_manager_v1_create(dpy);
|
||||
wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer,
|
||||
&new_virtual_pointer);
|
||||
wl_signal_add(&virtual_pointer_mgr->events.new_virtual_pointer, &new_virtual_pointer);
|
||||
|
||||
seat = wlr_seat_create(dpy, "seat0");
|
||||
wl_signal_add(&seat->events.request_set_cursor, &request_cursor);
|
||||
@ -2718,9 +2757,8 @@ tile(Monitor *m)
|
||||
int i, n = 0;
|
||||
Client *c;
|
||||
|
||||
wl_list_for_each(c, &clients, link)
|
||||
if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen)
|
||||
n++;
|
||||
wl_list_for_each(
|
||||
c, &clients, link) if (VISIBLEON(c, m) && !c->isfloating && !c->isfullscreen) n++;
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
@ -2729,16 +2767,25 @@ tile(Monitor *m)
|
||||
else
|
||||
mw = m->w.width;
|
||||
i = my = ty = 0;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
|
||||
continue;
|
||||
if (i < m->nmaster) {
|
||||
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
|
||||
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
|
||||
resize(c,
|
||||
(struct wlr_box){.x = m->w.x,
|
||||
.y = m->w.y + my,
|
||||
.width = mw,
|
||||
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)},
|
||||
0);
|
||||
my += c->geom.height;
|
||||
} else {
|
||||
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
|
||||
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
|
||||
resize(c,
|
||||
(struct wlr_box){.x = m->w.x + mw,
|
||||
.y = m->w.y + ty,
|
||||
.width = m->w.width - mw,
|
||||
.height = (m->w.height - ty) / (n - i)},
|
||||
0);
|
||||
ty += c->geom.height;
|
||||
}
|
||||
i++;
|
||||
@ -2848,14 +2895,14 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
* positions, focus, and the stored configuration in wlroots'
|
||||
* output-manager implementation.
|
||||
*/
|
||||
struct wlr_output_configuration_v1 *config
|
||||
= wlr_output_configuration_v1_create();
|
||||
struct wlr_output_configuration_v1 *config = wlr_output_configuration_v1_create();
|
||||
Client *c;
|
||||
struct wlr_output_configuration_head_v1 *config_head;
|
||||
Monitor *m;
|
||||
|
||||
/* First remove from the layout the disabled monitors */
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
wl_list_for_each(m, &mons, link)
|
||||
{
|
||||
if (m->wlr_output->enabled || m->asleep)
|
||||
continue;
|
||||
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
||||
@ -2866,9 +2913,9 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
m->m = m->w = (struct wlr_box){0};
|
||||
}
|
||||
/* Insert outputs that need to */
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
if (m->wlr_output->enabled
|
||||
&& !wlr_output_layout_get(output_layout, m->wlr_output))
|
||||
wl_list_for_each(m, &mons, link)
|
||||
{
|
||||
if (m->wlr_output->enabled && !wlr_output_layout_get(output_layout, m->wlr_output))
|
||||
wlr_output_layout_add_auto(output_layout, m->wlr_output);
|
||||
}
|
||||
|
||||
@ -2882,7 +2929,8 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
wlr_scene_node_set_position(&locked_bg->node, sgeom.x, sgeom.y);
|
||||
wlr_scene_rect_set_size(locked_bg, sgeom.width, sgeom.height);
|
||||
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
wl_list_for_each(m, &mons, link)
|
||||
{
|
||||
if (!m->wlr_output->enabled)
|
||||
continue;
|
||||
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
|
||||
@ -2898,7 +2946,8 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
if (m->lock_surface) {
|
||||
struct wlr_scene_tree *scene_tree = m->lock_surface->surface->data;
|
||||
wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
|
||||
wlr_session_lock_surface_v1_configure(m->lock_surface, m->m.width, m->m.height);
|
||||
wlr_session_lock_surface_v1_configure(
|
||||
m->lock_surface, m->m.width, m->m.height);
|
||||
}
|
||||
|
||||
/* Calculate the effective monitor geometry to use for clients */
|
||||
@ -2922,14 +2971,15 @@ updatemons(struct wl_listener *listener, void *data)
|
||||
}
|
||||
|
||||
if (selmon && selmon->wlr_output->enabled) {
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (!c->mon && client_surface(c)->mapped)
|
||||
setmon(c, selmon, c->tags);
|
||||
}
|
||||
focusclient(focustop(selmon), 1);
|
||||
if (selmon->lock_surface) {
|
||||
client_notify_enter(selmon->lock_surface->surface,
|
||||
wlr_seat_get_keyboard(seat));
|
||||
client_notify_enter(
|
||||
selmon->lock_surface->surface, wlr_seat_get_keyboard(seat));
|
||||
client_activate_surface(selmon->lock_surface->surface, 1);
|
||||
}
|
||||
}
|
||||
@ -3014,8 +3064,8 @@ xytomon(double x, double y)
|
||||
}
|
||||
|
||||
void
|
||||
xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny)
|
||||
xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl,
|
||||
double *nx, double *ny)
|
||||
{
|
||||
struct wlr_scene_node *node, *pnode;
|
||||
struct wlr_surface *surface = NULL;
|
||||
@ -3028,8 +3078,9 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
continue;
|
||||
|
||||
if (node->type == WLR_SCENE_NODE_BUFFER)
|
||||
surface = wlr_scene_surface_try_from_buffer(
|
||||
wlr_scene_buffer_from_node(node))->surface;
|
||||
surface =
|
||||
wlr_scene_surface_try_from_buffer(wlr_scene_buffer_from_node(node))
|
||||
->surface;
|
||||
/* Walk the tree to find a node that knows the client */
|
||||
for (pnode = node; pnode && !c; pnode = &pnode->parent->node)
|
||||
c = pnode->data;
|
||||
@ -3039,9 +3090,12 @@ xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
}
|
||||
}
|
||||
|
||||
if (psurface) *psurface = surface;
|
||||
if (pc) *pc = c;
|
||||
if (pl) *pl = l;
|
||||
if (psurface)
|
||||
*psurface = surface;
|
||||
if (pc)
|
||||
*pc = c;
|
||||
if (pl)
|
||||
*pl = l;
|
||||
}
|
||||
|
||||
void
|
||||
@ -3054,7 +3108,8 @@ zoom(const Arg *arg)
|
||||
|
||||
/* Search for the first tiled window that is not sel, marking sel as
|
||||
* NULL if we pass it along the way */
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
wl_list_for_each(c, &clients, link)
|
||||
{
|
||||
if (VISIBLEON(c, selmon) && !c->isfloating) {
|
||||
if (c != sel)
|
||||
break;
|
||||
@ -3103,20 +3158,23 @@ configurex11(struct wl_listener *listener, void *data)
|
||||
Client *c = wl_container_of(listener, c, configure);
|
||||
struct wlr_xwayland_surface_configure_event *event = data;
|
||||
if (!client_surface(c) || !client_surface(c)->mapped) {
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland,
|
||||
event->x, event->y, event->width, event->height);
|
||||
wlr_xwayland_surface_configure(
|
||||
c->surface.xwayland, event->x, event->y, event->width, event->height);
|
||||
return;
|
||||
}
|
||||
if (client_is_unmanaged(c)) {
|
||||
wlr_scene_node_set_position(&c->scene->node, event->x, event->y);
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland,
|
||||
event->x, event->y, event->width, event->height);
|
||||
wlr_xwayland_surface_configure(
|
||||
c->surface.xwayland, event->x, event->y, event->width, event->height);
|
||||
return;
|
||||
}
|
||||
if ((c->isfloating && c != grabc) || !c->mon->lt[c->mon->sellt]->arrange) {
|
||||
resize(c, (struct wlr_box){.x = event->x - c->bw,
|
||||
.y = event->y - c->bw, .width = event->width + c->bw * 2,
|
||||
.height = event->height + c->bw * 2}, 0);
|
||||
resize(c,
|
||||
(struct wlr_box){.x = event->x - c->bw,
|
||||
.y = event->y - c->bw,
|
||||
.width = event->width + c->bw * 2,
|
||||
.height = event->height + c->bw * 2},
|
||||
0);
|
||||
} else {
|
||||
arrange(c->mon);
|
||||
}
|
||||
@ -3178,10 +3236,10 @@ xwaylandready(struct wl_listener *listener, void *data)
|
||||
|
||||
/* Set the default XWayland cursor to match the rest of dwl. */
|
||||
if ((xcursor = wlr_xcursor_manager_get_xcursor(cursor_mgr, "default", 1)))
|
||||
wlr_xwayland_set_cursor(xwayland,
|
||||
xcursor->images[0]->buffer, xcursor->images[0]->width * 4,
|
||||
xcursor->images[0]->width, xcursor->images[0]->height,
|
||||
xcursor->images[0]->hotspot_x, xcursor->images[0]->hotspot_y);
|
||||
wlr_xwayland_set_cursor(xwayland, xcursor->images[0]->buffer,
|
||||
xcursor->images[0]->width * 4, xcursor->images[0]->width,
|
||||
xcursor->images[0]->height, xcursor->images[0]->hotspot_x,
|
||||
xcursor->images[0]->hotspot_y);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
14
util.c
14
util.c
@ -1,21 +1,22 @@
|
||||
/* See LICENSE.dwm file for copyright and license details. */
|
||||
#include "util.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void
|
||||
die(const char *fmt, ...) {
|
||||
die(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
if (fmt[0] && fmt[strlen(fmt) - 1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
} else {
|
||||
@ -36,7 +37,8 @@ ecalloc(size_t nmemb, size_t size)
|
||||
}
|
||||
|
||||
int
|
||||
fd_set_nonblock(int fd) {
|
||||
fd_set_nonblock(int fd)
|
||||
{
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
if (flags < 0) {
|
||||
perror("fcntl(F_GETFL):");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user