diff --git a/.gitignore b/.gitignore index 6ee2b17..876ef93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ absinthe -.cache/ -result/ -result -compile_commands.json xdg-shell-protocol.h +TAGS diff --git a/Makefile b/Makefile index f600050..10a5229 100644 --- a/Makefile +++ b/Makefile @@ -5,5 +5,5 @@ proto: compile: proto gcc -o absinthe src/* \ - -I./ -I./include -DWLR_USE_UNSTABLE $(shell pkg-config wlroots-0.19 --libs --cflags) -lwayland-server -lxkbcommon \ + -I./ -I./include -DWLR_USE_UNSTABLE $(shell pkg-config wlroots-0.20 --libs --cflags) -lwayland-server -lxkbcommon \ -ggdb diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 931e8c2..0000000 --- a/flake.lock +++ /dev/null @@ -1,27 +0,0 @@ -{ - "nodes": { - "nixpkgs": { - "locked": { - "lastModified": 1768773494, - "narHash": "sha256-XsM7GP3jHlephymxhDE+/TKKO1Q16phz/vQiLBGhpF4=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "77ef7a29d276c6d8303aece3444d61118ef71ac2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-25.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index 944a80f..0000000 --- a/flake.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ - description = "Absinthe wayland compositor"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; - }; - - outputs = { self, nixpkgs, ... }: - let - system = "x86_64-linux"; - pkgs = import nixpkgs { inherit system; }; - in - { - packages.${system}.default = pkgs.stdenv.mkDerivation { - pname = "absinthe"; - version = "0.1"; - - src = ./.; - - nativeBuildInputs = with pkgs; [ - gcc - gnumake - pkg-config - wayland-scanner - ]; - - buildInputs = with pkgs; [ - wayland - wayland-protocols - wlroots_0_19 - pixman - libxkbcommon - ]; - - buildPhase = '' - make - ''; - - installPhase = '' - mkdir -p $out/bin - cp absinthe $out/bin/ - ''; - }; - - devShells."${system}".default = pkgs.mkShell { - packages = with pkgs; [ - pkg-config - gnumake - gcc - gdb - wayland - wayland-protocols - wayland-scanner - wlroots_0_19 - pixman - libxkbcommon - fish - ]; - - shellHook = '' - echo "Absinthe dev shell" - exec fish - ''; - }; - }; -} diff --git a/src/cursor.c b/src/cursor.c index 162d433..eba306f 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -127,6 +127,16 @@ static void process_cursor_resize(struct absinthe_server *server) { void process_cursor_motion(struct absinthe_server *server, uint32_t time) { + double sx, sy; + struct wlr_seat *seat = server->seat; + struct wlr_surface *surface = NULL; + struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); + + if (!toplevel) { + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default"); + return; + } + if (server->cursor_mode == ABSINTHE_CURSOR_MOVE) { process_cursor_move(server); return; @@ -135,14 +145,6 @@ void process_cursor_motion(struct absinthe_server *server, uint32_t time) return; } - double sx, sy; - struct wlr_seat *seat = server->seat; - struct wlr_surface *surface = NULL; - struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); - - if (!toplevel) - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "default"); - if (surface) { wlr_seat_pointer_notify_enter(seat, surface, sx, sy); wlr_seat_pointer_notify_motion(seat, time, sx, sy); diff --git a/src/server.c b/src/server.c index 97079be..faca282 100644 --- a/src/server.c +++ b/src/server.c @@ -31,7 +31,7 @@ void server_new_output(struct wl_listener *listener, void *data) wlr_output_commit_state(wlr_output, &state); wlr_output_state_finish(&state); - struct absinthe_output *output = calloc(1, sizeof(*output)); + struct absinthe_output *output = malloc(sizeof(*output)); output->wlr_output = wlr_output; output->server = server; @@ -57,7 +57,7 @@ void server_new_xdg_toplevel(struct wl_listener *listener, void *data) struct absinthe_server *server = wl_container_of(listener, server, new_xdg_toplevel); struct wlr_xdg_toplevel *xdg_toplevel = data; - struct absinthe_toplevel *toplevel = calloc(1, sizeof(*toplevel)); + struct absinthe_toplevel *toplevel = malloc(sizeof(*toplevel)); toplevel->server = server; toplevel->xdg_toplevel = xdg_toplevel; toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree); @@ -90,12 +90,12 @@ void server_new_xdg_popup(struct wl_listener *listener, void *data) struct absinthe_server *server = wl_container_of(listener, server, new_xdg_popup); struct wlr_xdg_popup *xdg_popup = data; - struct absinthe_popup *popup = calloc(1, sizeof(*popup)); + struct absinthe_popup *popup = malloc(sizeof(*popup)); popup->xdg_popup = xdg_popup; struct wlr_xdg_surface *parent = wlr_xdg_surface_try_from_wlr_surface(xdg_popup->parent); struct absinthe_toplevel *parent_toplevel = parent->data; - struct wlr_scene_tree *parent_tree = parent_toplevel->scene_tree; + struct wlr_scene_tree *parent_tree = parent_toplevel->scene_tree; xdg_popup->base->data = wlr_scene_xdg_surface_create(parent_tree, xdg_popup->base); popup->commit.notify = xdg_popup_commit; @@ -221,7 +221,7 @@ void server_cursor_frame(struct wl_listener *listener, void *data) static void server_new_keyboard(struct absinthe_server *server, struct wlr_input_device *device) { struct wlr_keyboard *wlr_keyboard = wlr_keyboard_from_input_device(device); - struct absinthe_keyboard *keyboard = calloc(1, sizeof(*keyboard)); + struct absinthe_keyboard *keyboard = malloc(sizeof(*keyboard)); keyboard->server = server; keyboard->wlr_keyboard = wlr_keyboard; diff --git a/src/xdg-toplevel.c b/src/xdg-toplevel.c index 386cdd7..da411b9 100644 --- a/src/xdg-toplevel.c +++ b/src/xdg-toplevel.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -12,24 +13,17 @@ void xdg_toplevel_commit(struct wl_listener *listener, void *data) struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, commit); if (toplevel->xdg_toplevel->base->initial_commit) { - // Let client set the preferred size - wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, 0, 0); - // Forse server side decoration mode if (toplevel->decoration) xdg_decoration_request_mode(&toplevel->decoration_request_mode, toplevel->decoration); + + // Let toplevel set preferred size + wlr_xdg_toplevel_set_size(toplevel->xdg_toplevel, 0, 0); } else { // Check for size because we did't set it on initial commit - if (toplevel->geometry.width == 0 || toplevel->geometry.height == 0) { - int32_t bw = toplevel->border_width; - toplevel->geometry.width = toplevel->xdg_toplevel->base->geometry.width + 2 * bw; - toplevel->geometry.height = toplevel->xdg_toplevel->base->geometry.height + 2 * bw; - - int32_t rel_x = toplevel->output->geometry.x + toplevel->output->geometry.width / 2 - toplevel->geometry.width / 2; - int32_t rel_y = toplevel->output->geometry.y + toplevel->output->geometry.height / 2 - toplevel->geometry.height / 2; - toplevel->geometry.x += abs(rel_x); - toplevel->geometry.y += abs(rel_y); - } + int32_t bw = toplevel->border_width; + toplevel->geometry.width = toplevel->xdg_toplevel->base->geometry.width + 2 * bw; + toplevel->geometry.height = toplevel->xdg_toplevel->base->geometry.height + 2 * bw; absinthe_toplevel_set_position(toplevel, toplevel->geometry.x, toplevel->geometry.y); absinthe_toplevel_update_borders_geometry(toplevel); @@ -48,9 +42,6 @@ void xdg_toplevel_map(struct wl_listener *listener, void *data) toplevel->border_width = ABSINTHE_WINDOW_BORDER_WIDTH; - absinthe_toplevel_set_border_color(toplevel, unfocused_border_color); - absinthe_toplevel_update_borders_geometry(toplevel); - toplevel->output = toplevel->server->focused_output; toplevel->fullscreen = false;