From: Johan Malm Date: Fri, 22 May 2020 20:13:43 +0000 (+0100) Subject: Move begin_interactive() to server.c X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=9a0c2b841794827ff4c22f010c4f295bd5c42eee;p=proto%2Flabwc.git Move begin_interactive() to server.c --- diff --git a/README.md b/README.md index c760f514..820bb7b0 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ This software is in early development. ## Aim -[x] Support xwayland -[ ] Support some of openbox's rc.xml -[ ] Support openbox themes -[ ] Support layer-shell's background layer +- [x] Support xwayland +- [ ] Support some of openbox's rc.xml +- [ ] Support openbox themes +- [ ] Support layer-shell's background layer ## Influenced by @@ -67,51 +67,54 @@ example `gb`. Read `xkeyboard-config(7)` for details. ### Debian - sudo apt install \ - build-essential \ - cmake \ - libwayland-dev \ - wayland-protocols \ - libegl1-mesa-dev \ - libgles2-mesa-dev \ - libdrm-dev libgbm-dev \ - libinput-dev \ - libxkbcommon-dev \ - libudev-dev \ - libpixman-1-dev \ - libsystemd-dev \ - libcap-dev \ - libxcb1-dev \ - libxcb-composite0-dev \ - libxcb-xfixes0-dev \ - libxcb-xinput-dev \ - libxcb-image0-dev \ - libxcb-render-util0-dev \ - libx11-xcb-dev \ - libxcb-icccm4-dev \ - freerdp2-dev \ - libwinpr2-dev \ - libpng-dev \ - libavutil-dev \ - libavcodec-dev \ - libavformat-dev \ - universal-ctags \ - xwayland - - # Debian Buster has an old version of meson, so we use pip3 - pip3 install --target=$HOME/bin meson - - git clone https://github.com/johanmalm/labwc - cd labwc - git clone https://github.com/swaywm/wlroots subprojects/wlroots - - # wlroots 0.10.0 is the last version which runs with Wayland 0.16 - # (which is what Buster runs) - cd subprojects/wlroots && git checkout 0.10.0 && cd ../.. - - meson build - ninja -C build +``` +sudo apt install \ + build-essential \ + cmake \ + libwayland-dev \ + wayland-protocols \ + libegl1-mesa-dev \ + libgles2-mesa-dev \ + libdrm-dev libgbm-dev \ + libinput-dev \ + libxkbcommon-dev \ + libudev-dev \ + libpixman-1-dev \ + libsystemd-dev \ + libcap-dev \ + libxcb1-dev \ + libxcb-composite0-dev \ + libxcb-xfixes0-dev \ + libxcb-xinput-dev \ + libxcb-image0-dev \ + libxcb-render-util0-dev \ + libx11-xcb-dev \ + libxcb-icccm4-dev \ + freerdp2-dev \ + libwinpr2-dev \ + libpng-dev \ + libavutil-dev \ + libavcodec-dev \ + libavformat-dev \ + universal-ctags \ + xwayland + +# Debian Buster has an old version of meson, so we use pip3 +pip3 install --target=$HOME/bin meson + +git clone https://github.com/johanmalm/labwc +cd labwc +git clone https://github.com/swaywm/wlroots subprojects/wlroots + +# wlroots 0.10.0 is the last version which runs with Wayland 0.16 +# (which is what Buster runs) +cd subprojects/wlroots && git checkout 0.10.0 && cd ../.. + +meson build +ninja -C build +``` ## Debug To enable ASAN and UBSAN, run meson with `-Db_sanitize=address,undefined` + diff --git a/labwc.h b/labwc.h index 05d5755c..46be920a 100644 --- a/labwc.h +++ b/labwc.h @@ -142,14 +142,14 @@ void xwl_surface_new(struct wl_listener *listener, void *data); bool view_want_deco(struct view *view); void view_focus(struct view *view); -void begin_interactive(struct view *view, enum cursor_mode mode, - uint32_t edges); struct view *view_front_toplevel(struct server *server); struct view *next_toplevel(struct view *current); struct view *view_at(struct server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy, int *view_area); +void begin_interactive(struct view *view, enum cursor_mode mode, + uint32_t edges); void server_new_input(struct wl_listener *listener, void *data); void seat_request_cursor(struct wl_listener *listener, void *data); void seat_request_set_selection(struct wl_listener *listener, void *data); diff --git a/server.c b/server.c index c5eef472..6368e94b 100644 --- a/server.c +++ b/server.c @@ -3,6 +3,49 @@ static bool in_alt_tab_mode; static struct view *alt_tab_view; +void begin_interactive(struct view *view, enum cursor_mode mode, + uint32_t edges) +{ + /* This function sets up an interactive move or resize operation, where + * the compositor stops propegating pointer events to clients and + * instead consumes them itself, to move or resize windows. */ + struct server *server = view->server; + server->grabbed_view = view; + server->cursor_mode = mode; + + if (mode == TINYWL_CURSOR_MOVE) { + server->grab_x = server->cursor->x - view->x; + server->grab_y = server->cursor->y - view->y; + } else { + struct wlr_box geo_box; + switch (view->type) { + case LAB_XDG_SHELL_VIEW: + wlr_xdg_surface_get_geometry(view->xdg_surface, + &geo_box); + break; + case LAB_XWAYLAND_VIEW: + geo_box.x = view->xwayland_surface->x; + geo_box.y = view->xwayland_surface->y; + geo_box.width = view->xwayland_surface->width; + geo_box.height = view->xwayland_surface->height; + break; + } + + double border_x = + (view->x + geo_box.x) + + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0); + double border_y = + (view->y + geo_box.y) + + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0); + server->grab_x = server->cursor->x - border_x; + server->grab_y = server->cursor->y - border_y; + server->grab_box = geo_box; + server->grab_box.x += view->x; + server->grab_box.y += view->y; + server->resize_edges = edges; + } +} + 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 diff --git a/view.c b/view.c index 966b8690..8d8912a5 100644 --- a/view.c +++ b/view.c @@ -85,48 +85,6 @@ void view_focus(struct view *view) &keyboard->modifiers); } -void begin_interactive(struct view *view, enum cursor_mode mode, uint32_t edges) -{ - /* This function sets up an interactive move or resize operation, where - * the compositor stops propegating pointer events to clients and - * instead consumes them itself, to move or resize windows. */ - struct server *server = view->server; - server->grabbed_view = view; - server->cursor_mode = mode; - - if (mode == TINYWL_CURSOR_MOVE) { - server->grab_x = server->cursor->x - view->x; - server->grab_y = server->cursor->y - view->y; - } else { - struct wlr_box geo_box; - switch (view->type) { - case LAB_XDG_SHELL_VIEW: - wlr_xdg_surface_get_geometry(view->xdg_surface, - &geo_box); - break; - case LAB_XWAYLAND_VIEW: - geo_box.x = view->xwayland_surface->x; - geo_box.y = view->xwayland_surface->y; - geo_box.width = view->xwayland_surface->width; - geo_box.height = view->xwayland_surface->height; - break; - } - - double border_x = - (view->x + geo_box.x) + - ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0); - double border_y = - (view->y + geo_box.y) + - ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0); - server->grab_x = server->cursor->x - border_x; - server->grab_y = server->cursor->y - border_y; - server->grab_box = geo_box; - server->grab_box.x += view->x; - server->grab_box.y += view->y; - server->resize_edges = edges; - } -} - struct view *view_front_toplevel(struct server *server) { struct view *view;