aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-04-05 23:04:04 -0500
committerLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-04-05 23:04:04 -0500
commitc00697e6438164e08baacc309b3dcdb727053aeb (patch)
tree84d7fe82debb875118b7cb8cd90e0b0fc7e06b22
parentaf741e586b80440b59b61e8fdc22c69fb7e8a457 (diff)
abc
-rw-r--r--dwl.c238
1 files changed, 119 insertions, 119 deletions
diff --git a/dwl.c b/dwl.c
index 424485f..b09fc6f 100644
--- a/dwl.c
+++ b/dwl.c
@@ -221,9 +221,9 @@ static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
static void commitnotify(struct wl_listener *listener, void *data);
static void createidleinhibitor(struct wl_listener *listener, void *data);
static void createkeyboard(struct wlr_input_device *device);
+static void createlayersurface(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 createlayersurface(struct wl_listener *listener, void *data);
static void createpointer(struct wlr_input_device *device);
static void cursorframe(struct wl_listener *listener, void *data);
static void destroyidleinhibitor(struct wl_listener *listener, void *data);
@@ -234,8 +234,8 @@ static void dragicondestroy(struct wl_listener *listener, void *data);
static void focusclient(Client *c, int lift);
static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
-static void fullscreennotify(struct wl_listener *listener, void *data);
static Client *focustop(Monitor *m);
+static void fullscreennotify(struct wl_listener *listener, void *data);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
static int keybinding(uint32_t mods, xkb_keysym_t sym);
@@ -263,13 +263,13 @@ static void resize(Client *c, int x, int y, int w, int h, int interact);
static void run(char *startup_cmd);
static Client *selclient(void);
static void setcursor(struct wl_listener *listener, void *data);
-static void setpsel(struct wl_listener *listener, void *data);
-static void setsel(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, unsigned int newtags);
+static void setpsel(struct wl_listener *listener, void *data);
+static void setsel(struct wl_listener *listener, void *data);
static void setup(void);
static void sigchld(int unused);
static void spawn(const Arg *arg);
@@ -289,9 +289,9 @@ static void updatetitle(struct wl_listener *listener, void *data);
static void urgent(struct wl_listener *listener, void *data);
static void view(const Arg *arg);
static void virtualkeyboard(struct wl_listener *listener, void *data);
+static Monitor *xytomon(double x, double y);
static struct wlr_scene_node *xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
-static Monitor *xytomon(double x, double y);
static void zoom(const Arg *arg);
/* variables */
@@ -819,6 +819,50 @@ createkeyboard(struct wlr_input_device *device)
}
void
+createlayersurface(struct wl_listener *listener, void *data)
+{
+ struct wlr_layer_surface_v1 *wlr_layer_surface = data;
+ LayerSurface *layersurface;
+ Monitor *m;
+ struct wlr_layer_surface_v1_state old_state;
+
+ if (!wlr_layer_surface->output) {
+ wlr_layer_surface->output = selmon->wlr_output;
+ }
+
+ layersurface = ecalloc(1, sizeof(LayerSurface));
+ layersurface->type = LayerShell;
+ LISTEN(&wlr_layer_surface->surface->events.commit,
+ &layersurface->surface_commit, commitlayersurfacenotify);
+ LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy,
+ destroylayersurfacenotify);
+ LISTEN(&wlr_layer_surface->events.map, &layersurface->map,
+ maplayersurfacenotify);
+ LISTEN(&wlr_layer_surface->events.unmap, &layersurface->unmap,
+ unmaplayersurfacenotify);
+
+ layersurface->layer_surface = wlr_layer_surface;
+ wlr_layer_surface->data = layersurface;
+ m = wlr_layer_surface->output->data;
+
+ layersurface->scene = wlr_layer_surface->surface->data =
+ wlr_scene_subsurface_tree_create(layers[wlr_layer_surface->pending.layer],
+ wlr_layer_surface->surface);
+ layersurface->scene->data = layersurface;
+
+ wl_list_insert(&m->layers[wlr_layer_surface->pending.layer],
+ &layersurface->link);
+
+ /* Temporarily set the layer's current state to pending
+ * so that we can easily arrange it
+ */
+ old_state = wlr_layer_surface->current;
+ wlr_layer_surface->current = wlr_layer_surface->pending;
+ arrangelayers(m);
+ wlr_layer_surface->current = old_state;
+}
+
+void
createmon(struct wl_listener *listener, void *data)
{
/* This event is raised by the backend when a new output (aka a display or
@@ -925,50 +969,6 @@ createnotify(struct wl_listener *listener, void *data)
}
void
-createlayersurface(struct wl_listener *listener, void *data)
-{
- struct wlr_layer_surface_v1 *wlr_layer_surface = data;
- LayerSurface *layersurface;
- Monitor *m;
- struct wlr_layer_surface_v1_state old_state;
-
- if (!wlr_layer_surface->output) {
- wlr_layer_surface->output = selmon->wlr_output;
- }
-
- layersurface = ecalloc(1, sizeof(LayerSurface));
- layersurface->type = LayerShell;
- LISTEN(&wlr_layer_surface->surface->events.commit,
- &layersurface->surface_commit, commitlayersurfacenotify);
- LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy,
- destroylayersurfacenotify);
- LISTEN(&wlr_layer_surface->events.map, &layersurface->map,
- maplayersurfacenotify);
- LISTEN(&wlr_layer_surface->events.unmap, &layersurface->unmap,
- unmaplayersurfacenotify);
-
- layersurface->layer_surface = wlr_layer_surface;
- wlr_layer_surface->data = layersurface;
- m = wlr_layer_surface->output->data;
-
- layersurface->scene = wlr_layer_surface->surface->data =
- wlr_scene_subsurface_tree_create(layers[wlr_layer_surface->pending.layer],
- wlr_layer_surface->surface);
- layersurface->scene->data = layersurface;
-
- wl_list_insert(&m->layers[wlr_layer_surface->pending.layer],
- &layersurface->link);
-
- /* Temporarily set the layer's current state to pending
- * so that we can easily arrange it
- */
- old_state = wlr_layer_surface->current;
- wlr_layer_surface->current = wlr_layer_surface->pending;
- arrangelayers(m);
- wlr_layer_surface->current = old_state;
-}
-
-void
createpointer(struct wlr_input_device *device)
{
if (wlr_input_device_is_libinput(device)) {
@@ -1049,57 +1049,6 @@ destroynotify(struct wl_listener *listener, void *data)
free(c);
}
-void
-dragicondestroy(struct wl_listener *listener, void *data)
-{
- struct wlr_drag_icon *icon = data;
- wlr_scene_node_destroy(icon->data);
- // Focus enter isn't sent during drag, so refocus the focused node.
- focusclient(selclient(), 1);
- motionnotify(0);
-}
-
-void
-togglefullscreen(const Arg *arg)
-{
- Client *sel = selclient();
- if (sel)
- setfullscreen(sel, !sel->isfullscreen);
-}
-
-void
-setfullscreen(Client *c, int fullscreen)
-{
- c->isfullscreen = fullscreen;
- c->bw = fullscreen ? 0 : borderpx;
- client_set_fullscreen(c, fullscreen);
-
- if (fullscreen) {
- c->prev = c->geom;
- resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
- } else {
- /* restore previous size instead of arrange for floating windows since
- * client positions are set by the user and cannot be recalculated */
- resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0);
- }
- arrange(c->mon);
- printstatus();
-}
-
-void
-fullscreennotify(struct wl_listener *listener, void *data)
-{
- Client *c = wl_container_of(listener, c, fullscreen);
- int fullscreen = client_wants_fullscreen(c);
-
- if (!c->mon) {
- /* if the client is not mapped yet, let mapnotify() call setfullscreen() */
- c->isfullscreen = fullscreen;
- return;
- }
- setfullscreen(c, fullscreen);
-}
-
Monitor *
dirtomon(enum wlr_direction dir)
{
@@ -1115,6 +1064,16 @@ dirtomon(enum wlr_direction dir)
}
void
+dragicondestroy(struct wl_listener *listener, void *data)
+{
+ struct wlr_drag_icon *icon = data;
+ wlr_scene_node_destroy(icon->data);
+ // Focus enter isn't sent during drag, so refocus the focused node.
+ focusclient(selclient(), 1);
+ motionnotify(0);
+}
+
+void
focusclient(Client *c, int lift)
{
struct wlr_surface *old = seat->keyboard_state.focused_surface;
@@ -1230,6 +1189,20 @@ focustop(Monitor *m)
}
void
+fullscreennotify(struct wl_listener *listener, void *data)
+{
+ Client *c = wl_container_of(listener, c, fullscreen);
+ int fullscreen = client_wants_fullscreen(c);
+
+ if (!c->mon) {
+ /* if the client is not mapped yet, let mapnotify() call setfullscreen() */
+ c->isfullscreen = fullscreen;
+ return;
+ }
+ setfullscreen(c, fullscreen);
+}
+
+void
incnmaster(const Arg *arg)
{
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
@@ -1693,6 +1666,18 @@ rendermon(struct wl_listener *listener, void *data)
}
void
+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))
+ wlr_seat_start_pointer_drag(seat, event->drag, event->serial);
+ else
+ wlr_data_source_destroy(event->drag->source);
+}
+
+void
resize(Client *c, int x, int y, int w, int h, int interact)
{
int min_width = 0, min_height = 0;
@@ -1721,18 +1706,6 @@ resize(Client *c, int x, int y, int w, int h, int interact)
}
void
-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))
- wlr_seat_start_pointer_drag(seat, event->drag, event->serial);
- else
- wlr_data_source_destroy(event->drag->source);
-}
-
-void
run(char *startup_cmd)
{
pid_t startup_pid = -1;
@@ -1831,6 +1804,25 @@ setfloating(Client *c, int floating)
}
void
+setfullscreen(Client *c, int fullscreen)
+{
+ c->isfullscreen = fullscreen;
+ c->bw = fullscreen ? 0 : borderpx;
+ client_set_fullscreen(c, fullscreen);
+
+ if (fullscreen) {
+ c->prev = c->geom;
+ resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0);
+ } else {
+ /* restore previous size instead of arrange for floating windows since
+ * client positions are set by the user and cannot be recalculated */
+ resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0);
+ }
+ arrange(c->mon);
+ printstatus();
+}
+
+void
setlayout(const Arg *arg)
{
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
@@ -2177,6 +2169,14 @@ togglefloating(const Arg *arg)
}
void
+togglefullscreen(const Arg *arg)
+{
+ Client *sel = selclient();
+ if (sel)
+ setfullscreen(sel, !sel->isfullscreen);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
@@ -2329,6 +2329,13 @@ virtualkeyboard(struct wl_listener *listener, void *data)
createkeyboard(device);
}
+Monitor *
+xytomon(double x, double y)
+{
+ struct wlr_output *o = wlr_output_layout_output_at(output_layout, x, y);
+ return o ? o->data : NULL;
+}
+
struct wlr_scene_node *
xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny)
@@ -2362,13 +2369,6 @@ xytonode(double x, double y, struct wlr_surface **psurface,
return node;
}
-Monitor *
-xytomon(double x, double y)
-{
- struct wlr_output *o = wlr_output_layout_output_at(output_layout, x, y);
- return o ? o->data : NULL;
-}
-
void
zoom(const Arg *arg)
{