diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index bf76887..edd223a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -17,7 +17,7 @@ If you already have your own pull request habits, feel free to use them. If you
don't, however, allow me to make a suggestion: feature branches pulled from
upstream. Try this:
-1. Fork waybox
+1. Fork Waybox
2. `git clone https://github.com/username/waybox && cd waybox`
3. `git remote add upstream https://github.com/wizbright/waybox`
@@ -87,7 +87,7 @@ process is:
## Style Reference
-waybox is written in C with a style similar to the [kernel
+Waybox is written in C with a style similar to the [kernel
style](https://www.kernel.org/doc/Documentation/process/coding-style.rst), but
with a few notable differences.
diff --git a/data/environment b/data/environment
index eb26fe2..a9953b8 100644
--- a/data/environment
+++ b/data/environment
@@ -21,7 +21,7 @@
#export ECORE_IMF_MODULE=uim
# Current compositor. Needed for Wayland security negotiation.
-export XDG_CURRENT_DESKTOP=waybox
+export XDG_CURRENT_DESKTOP=Waybox
export XDG_SESSION_TYPE=wayland
# Make sure to run the X initialization if started through a display manager
diff --git a/data/rc.xml b/data/rc.xml
index af37c1a..d3bb8fb 100644
--- a/data/rc.xml
+++ b/data/rc.xml
@@ -43,14 +43,23 @@
+
+
+
+
+
+
+
+
+
@@ -64,6 +73,11 @@
grim "$(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S_grim_fs.png')"
+
+
+ grim -g "$(slurp -d)" "$(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S_grim_sel.png')"
+
+
obrun l
diff --git a/include/waybox/output.h b/include/waybox/output.h
index a126f0e..55807ec 100644
--- a/include/waybox/output.h
+++ b/include/waybox/output.h
@@ -4,11 +4,6 @@
#include
#include
-#include
-#include
-#include
-#include
-
#include "waybox/server.h"
struct wb_output {
diff --git a/include/waybox/seat.h b/include/waybox/seat.h
index c3a60c2..33f2031 100644
--- a/include/waybox/seat.h
+++ b/include/waybox/seat.h
@@ -1,13 +1,8 @@
#ifndef _WB_SEAT_H
#define _WB_SEAT_H
-#include
-#include
-#include
#include
-struct wb_server;
-
struct wb_seat {
struct wlr_seat *seat;
@@ -24,6 +19,7 @@ struct wb_keyboard {
struct wb_server *server;
struct wlr_input_device *device;
+ struct wl_listener destroy;
struct wl_listener modifiers;
struct wl_listener key;
};
diff --git a/include/waybox/server.h b/include/waybox/server.h
index a8e1860..99dc8f6 100644
--- a/include/waybox/server.h
+++ b/include/waybox/server.h
@@ -1,26 +1,27 @@
#ifndef _WB_SERVER_H
#define _WB_SERVER_H
-#include
-
#define MAX(a, b) ((a > b) ? (a) : (b))
#define MIN(a, b) ((a < b) ? (a) : (b))
+#define TITLEBAR_HEIGHT 8 /* TODO: Get this from the theme */
#include
#define WLR_CHECK_VERSION(major, minor, micro) (WLR_VERSION_NUM >= ((major << 16) | (minor << 8) | (micro)))
#include
#include
+
#include
-#include
#include
#include
-#include
-#include
#include
+#include
#include
+#include
+#include
#if WLR_CHECK_VERSION(0, 16, 0)
#include
#endif
+#include
#include
#include
@@ -77,8 +78,8 @@ struct wb_server {
struct wl_list outputs; /* wb_output::link */
};
-bool wb_create_backend(struct wb_server* server);
-bool wb_start_server(struct wb_server* server);
-bool wb_terminate(struct wb_server* server);
+bool wb_create_backend(struct wb_server *server);
+bool wb_start_server(struct wb_server *server);
+bool wb_terminate(struct wb_server *server);
#endif /* server.h */
diff --git a/waybox/config.h b/waybox/config.h
index 6a527b3..82cca4d 100644
--- a/waybox/config.h
+++ b/waybox/config.h
@@ -4,16 +4,16 @@
#include "waybox/server.h"
enum action_type {
- ACTION_EXECUTE = 1<<0,
- ACTION_EXIT = 1<<1,
- ACTION_NEXT_WINDOW = 1<<2,
- ACTION_PREVIOUS_WINDOW = 1<<3,
- ACTION_CLOSE = 1<<4,
- ACTION_RECONFIGURE = 1<<5,
- ACTION_ICONIFY = 1<<6,
- ACTION_TOGGLE_MAXIMIZE = 1<<7,
- ACTION_SHADE = 1<<8,
- ACTION_UNSHADE = 1<<9,
+ ACTION_EXIT = 1 << 0,
+ ACTION_NEXT_WINDOW = 1 << 1,
+ ACTION_EXECUTE = 1 << 2,
+ ACTION_PREVIOUS_WINDOW = 1 << 3,
+ ACTION_CLOSE = 1 << 4,
+ ACTION_RECONFIGURE = 1 << 5,
+ ACTION_TOGGLE_MAXIMIZE = 1 << 6,
+ ACTION_ICONIFY = 1 << 7,
+ ACTION_SHADE = 1 << 8,
+ ACTION_UNSHADE = 1 << 9,
};
struct wb_config {
diff --git a/waybox/cursor.c b/waybox/cursor.c
index d93d893..7ad8da7 100644
--- a/waybox/cursor.c
+++ b/waybox/cursor.c
@@ -1,13 +1,12 @@
-#include
#include "waybox/cursor.h"
#include "waybox/xdg_shell.h"
static void process_cursor_move(struct wb_server *server) {
/* Move the grabbed view to the new position. */
struct wb_view *view = server->grabbed_view;
- view->current_position.x = server->cursor->cursor->x - server->grab_x;
- view->current_position.y = server->cursor->cursor->y - server->grab_y;
if (view->scene_node->parent->type == WLR_SCENE_NODE_ROOT) {
+ view->current_position.x = server->cursor->cursor->x - server->grab_x;
+ view->current_position.y = server->cursor->cursor->y - server->grab_y;
wlr_scene_node_set_position(view->scene_node,
view->current_position.x, view->current_position.y);
}
diff --git a/waybox/layer_shell.c b/waybox/layer_shell.c
index 637e37e..b67c8c4 100644
--- a/waybox/layer_shell.c
+++ b/waybox/layer_shell.c
@@ -45,7 +45,7 @@ void assign_scene_descriptor(struct wlr_scene_node *node,
node->data = desc;
}
-static void arrange_surface (struct wb_output *output, struct wlr_box *full_area,
+static void arrange_surface(struct wb_output *output, struct wlr_box *full_area,
struct wlr_box *usable_area, struct wlr_scene_node *scene_node) {
struct wlr_scene_node *node;
wl_list_for_each(node, &scene_node->state.children, state.link) {
@@ -75,24 +75,22 @@ void arrange_layers(struct wb_output *output) {
arrange_surface(output, &full_area, &usable_area, output->layers.shell_overlay);
}
-#if WLR_CHECK_VERSION(0, 16, 0)
static struct wlr_scene_node *wb_layer_get_scene(struct wb_output *output,
enum zwlr_layer_shell_v1_layer type) {
switch (type) {
- case ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND:
- return output->layers.shell_background;
- case ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM:
- return output->layers.shell_bottom;
- case ZWLR_LAYER_SHELL_V1_LAYER_TOP:
- return output->layers.shell_top;
- case ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY:
- return output->layers.shell_overlay;
+ case ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND:
+ return output->layers.shell_background;
+ case ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM:
+ return output->layers.shell_bottom;
+ case ZWLR_LAYER_SHELL_V1_LAYER_TOP:
+ return output->layers.shell_top;
+ case ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY:
+ return output->layers.shell_overlay;
}
/* Unreachable */
return NULL;
}
-#endif
static struct wb_layer_surface *wb_layer_surface_create(
#if WLR_CHECK_VERSION(0, 16, 0)
@@ -120,7 +118,6 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
return;
}
-#if WLR_CHECK_VERSION(0, 16, 0)
struct wlr_layer_surface_v1 *layer_surface = surface->scene->layer_surface;
uint32_t committed = layer_surface->current.committed;
@@ -141,22 +138,19 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
wlr_surface_send_frame_done(layer_surface->surface, &now);
}
- if (surface->scene->layer_surface->current.layer !=
- ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
+ if (layer_surface->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) {
wlr_scene_node_raise_to_top(output_layer);
}
if (layer_surface == surface->server->seat->focused_layer) {
seat_focus_surface(surface->server->seat, layer_surface->surface);
}
-#endif
}
static void handle_map(struct wl_listener *listener, void *data) {
struct wb_layer_surface *surface = wl_container_of(listener,
surface, map);
-#if WLR_CHECK_VERSION(0, 16, 0)
struct wlr_layer_surface_v1 *layer_surface =
surface->scene->layer_surface;
@@ -173,19 +167,16 @@ static void handle_map(struct wl_listener *listener, void *data) {
}
arrange_layers(surface->output);
}
-#endif
}
static void handle_unmap(struct wl_listener *listener, void *data) {
struct wb_layer_surface *surface = wl_container_of(
listener, surface, unmap);
-#if WLR_CHECK_VERSION(0, 16, 0)
struct wb_seat *seat = surface->server->seat;
if (seat->focused_layer == surface->scene->layer_surface) {
seat_set_focus_layer(seat, NULL);
}
-#endif
struct wb_view *view = wl_container_of(surface->server->views.next, view, link);
if (view) {
@@ -310,11 +301,9 @@ static void popup_handle_new_popup(struct wl_listener *listener, void *data) {
static void handle_new_popup(struct wl_listener *listener, void *data) {
struct wb_layer_surface *wb_layer_surface =
wl_container_of(listener, wb_layer_surface, new_popup);
-#if WLR_CHECK_VERSION(0, 16, 0)
struct wlr_xdg_popup *wlr_popup = data;
create_popup(wlr_popup, wb_layer_surface->scene->node);
-#endif
}
void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
@@ -333,10 +322,10 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
}
-#if WLR_CHECK_VERSION(0, 16, 0)
enum zwlr_layer_shell_v1_layer layer_type = layer_surface->pending.layer;
struct wlr_scene_node *output_layer = wb_layer_get_scene(
output, layer_type);
+#if WLR_CHECK_VERSION(0, 16, 0)
struct wlr_scene_layer_surface_v1 *scene_surface =
wlr_scene_layer_surface_v1_create(output_layer, layer_surface);
if (!scene_surface) {
@@ -348,6 +337,9 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
#else
struct wb_layer_surface *surface =
wb_layer_surface_create(layer_surface);
+ surface->scene = calloc(1, sizeof(*surface->scene));
+ surface->scene->layer_surface = layer_surface;
+ surface->scene->node = output_layer;
#endif
if (!surface) {
wlr_layer_surface_v1_destroy(layer_surface);
diff --git a/waybox/layer_shell.h b/waybox/layer_shell.h
index 128cc76..02fad7a 100644
--- a/waybox/layer_shell.h
+++ b/waybox/layer_shell.h
@@ -10,6 +10,11 @@ struct wb_layer_surface {
#if WLR_CHECK_VERSION(0, 16, 0)
struct wlr_scene_layer_surface_v1 *scene;
+#else
+ struct {
+ struct wlr_layer_surface_v1 *layer_surface;
+ struct wlr_scene_node *node;
+ } *scene;
#endif
bool mapped;
diff --git a/waybox/main.c b/waybox/main.c
index bace5c7..3db1d9f 100644
--- a/waybox/main.c
+++ b/waybox/main.c
@@ -113,6 +113,7 @@ int main(int argc, char **argv) {
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
+
wl_display_run(server.wl_display);
wb_terminate(&server);
diff --git a/waybox/output.c b/waybox/output.c
index a1bb7ac..242bb04 100644
--- a/waybox/output.c
+++ b/waybox/output.c
@@ -33,9 +33,9 @@ void output_frame_notify(struct wl_listener *listener, void *data) {
void output_destroy_notify(struct wl_listener *listener, void *data) {
struct wb_output *output = wl_container_of(listener, output, destroy);
- wl_list_remove(&output->link);
wl_list_remove(&output->destroy.link);
wl_list_remove(&output->frame.link);
+ wl_list_remove(&output->link);
/* Frees the layers */
size_t num_layers = sizeof(output->layers) / sizeof(struct wlr_scene_node *);
diff --git a/waybox/seat.c b/waybox/seat.c
index e5cf54f..8fc7f3b 100644
--- a/waybox/seat.c
+++ b/waybox/seat.c
@@ -1,5 +1,8 @@
#include
+#include
+#include
+
#include "waybox/seat.h"
#include "waybox/xdg_shell.h"
@@ -107,8 +110,7 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
if (view->scene_node->state.enabled) {
struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
- /* TODO: Get the minimum height from the theme rather than hard-coded. */
- int decoration_height = MAX(geo_box.y - view->current_position.y, 8);
+ int decoration_height = MAX(geo_box.y - view->current_position.y, TITLEBAR_HEIGHT);
view->previous_position = view->current_position;
#if WLR_CHECK_VERSION(0, 16, 0)
@@ -144,6 +146,19 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
return false;
}
+static void keyboard_handle_destroy(struct wl_listener *listener, void *data) {
+ /* This event is raised by the keyboard base wlr_input_device to signal
+ * the destruction of the wlr_keyboard. It will no longer receive events
+ * and should be destroyed.
+ */
+ struct wb_keyboard *keyboard = wl_container_of(listener, keyboard, destroy);
+ wl_list_remove(&keyboard->destroy.link);
+ wl_list_remove(&keyboard->key.link);
+ wl_list_remove(&keyboard->modifiers.link);
+ wl_list_remove(&keyboard->link);
+ free(keyboard);
+}
+
static void keyboard_handle_modifiers(
struct wl_listener *listener, void *data) {
/* This event is raised when a modifier key, such as shift or alt, is
@@ -234,6 +249,8 @@ static void handle_new_keyboard(struct wb_server *server,
xkb_context_unref(context);
/* Here we set up listeners for keyboard events. */
+ keyboard->destroy.notify = keyboard_handle_destroy;
+ wl_signal_add(&device->events.destroy, &keyboard->destroy);
keyboard->modifiers.notify = keyboard_handle_modifiers;
wl_signal_add(&device->keyboard->events.modifiers, &keyboard->modifiers);
keyboard->key.notify = keyboard_handle_key;
diff --git a/waybox/xdg_shell.c b/waybox/xdg_shell.c
index 186a9d6..f0df11f 100644
--- a/waybox/xdg_shell.c
+++ b/waybox/xdg_shell.c
@@ -53,7 +53,9 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) {
#endif
}
/* Move the view to the front */
- wlr_scene_node_raise_to_top(view->scene_node);
+ if (!server->seat->focused_layer) {
+ wlr_scene_node_raise_to_top(view->scene_node);
+ }
wl_list_remove(&view->link);
wl_list_insert(&server->views, &view->link);
/* Activate the new surface */
@@ -113,9 +115,8 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data) {
}
/* A view no larger than a title bar shouldn't be sized or focused */
- /* TODO: Get the title bar height from the theme */
- if (view->current_position.height > 9 &&
- view->current_position.height > 9 *
+ if (view->current_position.height > TITLEBAR_HEIGHT &&
+ view->current_position.height > TITLEBAR_HEIGHT *
(usable_area.width / usable_area.height)) {
#if WLR_CHECK_VERSION(0, 16, 0)
wlr_xdg_toplevel_set_size(view->xdg_toplevel,
@@ -280,6 +281,7 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
view->server->output_layout,
view->current_position.x + popup->geometry.x,
view->current_position.y + popup->geometry.y);
+ if (!wlr_output) return;
struct wb_output *output = wlr_output->data;
struct wlr_box output_toplevel_box = {