mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
Cleanups and omissions
This commit is contained in:
parent
553096a611
commit
df38ee39e0
14 changed files with 85 additions and 63 deletions
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
14
data/rc.xml
14
data/rc.xml
|
|
@ -43,14 +43,23 @@
|
|||
<!-- Keybindings for window switching -->
|
||||
<keybind key="A-Tab">
|
||||
<action name="NextWindow">
|
||||
<finalactions>
|
||||
<action name="Unshade"/>
|
||||
</finalactions>
|
||||
</action>
|
||||
</keybind>
|
||||
<keybind key="A-S-ISO_Left_Tab">
|
||||
<action name="PreviousWindow">
|
||||
<finalactions>
|
||||
<action name="Unshade"/>
|
||||
</finalactions>
|
||||
</action>
|
||||
</keybind>
|
||||
<keybind key="C-A-Tab">
|
||||
<action name="NextWindow">
|
||||
<finalactions>
|
||||
<action name="Unshade"/>
|
||||
</finalactions>
|
||||
</action>
|
||||
</keybind>
|
||||
<!-- Keybindings for running applications -->
|
||||
|
|
@ -64,6 +73,11 @@
|
|||
<execute>grim "$(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S_grim_fs.png')"</execute>
|
||||
</action>
|
||||
</keybind>
|
||||
<keybind key="A-Sys_Req">
|
||||
<action name="Execute">
|
||||
<execute>grim -g "$(slurp -d)" "$(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S_grim_sel.png')"</execute>
|
||||
</action>
|
||||
</keybind>
|
||||
<keybind key="A-F2">
|
||||
<action name="Execute">
|
||||
<execute>obrun l</execute>
|
||||
|
|
|
|||
|
|
@ -4,11 +4,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/render/wlr_texture.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
|
||||
#include "waybox/server.h"
|
||||
|
||||
struct wb_output {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
#ifndef _WB_SEAT_H
|
||||
#define _WB_SEAT_H
|
||||
|
||||
#include <wlr/types/wlr_keyboard.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,26 +1,27 @@
|
|||
#ifndef _WB_SERVER_H
|
||||
#define _WB_SERVER_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#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 <wlr/version.h>
|
||||
#define WLR_CHECK_VERSION(major, minor, micro) (WLR_VERSION_NUM >= ((major << 16) | (minor << 8) | (micro)))
|
||||
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/render/wlr_texture.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_idle.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#if WLR_CHECK_VERSION(0, 16, 0)
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
#endif
|
||||
#include <wlr/types/wlr_xdg_output_v1.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
#include <stdlib.h>
|
||||
#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;
|
||||
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;
|
||||
if (view->scene_node->parent->type == WLR_SCENE_NODE_ROOT) {
|
||||
wlr_scene_node_set_position(view->scene_node,
|
||||
view->current_position.x, view->current_position.y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,7 +75,6 @@ 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) {
|
||||
|
|
@ -92,7 +91,6 @@ static struct wlr_scene_node *wb_layer_get_scene(struct wb_output *output,
|
|||
/* 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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 *);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) {
|
|||
#endif
|
||||
}
|
||||
/* Move the view to the front */
|
||||
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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue