mirror of
https://github.com/labwc/labwc.git
synced 2026-03-14 05:33:52 -04:00
Move begin_interactive() to server.c
This commit is contained in:
parent
efd98eaebb
commit
9a0c2b8417
4 changed files with 96 additions and 92 deletions
99
README.md
99
README.md
|
|
@ -12,10 +12,10 @@ This software is in early development.
|
||||||
|
|
||||||
## Aim
|
## Aim
|
||||||
|
|
||||||
[x] Support xwayland
|
- [x] Support xwayland
|
||||||
[ ] Support some of openbox's rc.xml
|
- [ ] Support some of openbox's rc.xml
|
||||||
[ ] Support openbox themes
|
- [ ] Support openbox themes
|
||||||
[ ] Support layer-shell's background layer
|
- [ ] Support layer-shell's background layer
|
||||||
|
|
||||||
## Influenced by
|
## Influenced by
|
||||||
|
|
||||||
|
|
@ -67,51 +67,54 @@ example `gb`. Read `xkeyboard-config(7)` for details.
|
||||||
|
|
||||||
### Debian
|
### Debian
|
||||||
|
|
||||||
sudo apt install \
|
```
|
||||||
build-essential \
|
sudo apt install \
|
||||||
cmake \
|
build-essential \
|
||||||
libwayland-dev \
|
cmake \
|
||||||
wayland-protocols \
|
libwayland-dev \
|
||||||
libegl1-mesa-dev \
|
wayland-protocols \
|
||||||
libgles2-mesa-dev \
|
libegl1-mesa-dev \
|
||||||
libdrm-dev libgbm-dev \
|
libgles2-mesa-dev \
|
||||||
libinput-dev \
|
libdrm-dev libgbm-dev \
|
||||||
libxkbcommon-dev \
|
libinput-dev \
|
||||||
libudev-dev \
|
libxkbcommon-dev \
|
||||||
libpixman-1-dev \
|
libudev-dev \
|
||||||
libsystemd-dev \
|
libpixman-1-dev \
|
||||||
libcap-dev \
|
libsystemd-dev \
|
||||||
libxcb1-dev \
|
libcap-dev \
|
||||||
libxcb-composite0-dev \
|
libxcb1-dev \
|
||||||
libxcb-xfixes0-dev \
|
libxcb-composite0-dev \
|
||||||
libxcb-xinput-dev \
|
libxcb-xfixes0-dev \
|
||||||
libxcb-image0-dev \
|
libxcb-xinput-dev \
|
||||||
libxcb-render-util0-dev \
|
libxcb-image0-dev \
|
||||||
libx11-xcb-dev \
|
libxcb-render-util0-dev \
|
||||||
libxcb-icccm4-dev \
|
libx11-xcb-dev \
|
||||||
freerdp2-dev \
|
libxcb-icccm4-dev \
|
||||||
libwinpr2-dev \
|
freerdp2-dev \
|
||||||
libpng-dev \
|
libwinpr2-dev \
|
||||||
libavutil-dev \
|
libpng-dev \
|
||||||
libavcodec-dev \
|
libavutil-dev \
|
||||||
libavformat-dev \
|
libavcodec-dev \
|
||||||
universal-ctags \
|
libavformat-dev \
|
||||||
xwayland
|
universal-ctags \
|
||||||
|
xwayland
|
||||||
# Debian Buster has an old version of meson, so we use pip3
|
|
||||||
pip3 install --target=$HOME/bin meson
|
# 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/johanmalm/labwc
|
||||||
git clone https://github.com/swaywm/wlroots subprojects/wlroots
|
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)
|
# wlroots 0.10.0 is the last version which runs with Wayland 0.16
|
||||||
cd subprojects/wlroots && git checkout 0.10.0 && cd ../..
|
# (which is what Buster runs)
|
||||||
|
cd subprojects/wlroots && git checkout 0.10.0 && cd ../..
|
||||||
meson build
|
|
||||||
ninja -C build
|
meson build
|
||||||
|
ninja -C build
|
||||||
|
```
|
||||||
|
|
||||||
## Debug
|
## Debug
|
||||||
|
|
||||||
To enable ASAN and UBSAN, run meson with `-Db_sanitize=address,undefined`
|
To enable ASAN and UBSAN, run meson with `-Db_sanitize=address,undefined`
|
||||||
|
|
||||||
|
|
|
||||||
4
labwc.h
4
labwc.h
|
|
@ -142,14 +142,14 @@ void xwl_surface_new(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
bool view_want_deco(struct view *view);
|
bool view_want_deco(struct view *view);
|
||||||
void view_focus(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 *view_front_toplevel(struct server *server);
|
||||||
struct view *next_toplevel(struct view *current);
|
struct view *next_toplevel(struct view *current);
|
||||||
struct view *view_at(struct server *server, double lx, double ly,
|
struct view *view_at(struct server *server, double lx, double ly,
|
||||||
struct wlr_surface **surface, double *sx, double *sy,
|
struct wlr_surface **surface, double *sx, double *sy,
|
||||||
int *view_area);
|
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 server_new_input(struct wl_listener *listener, void *data);
|
||||||
void seat_request_cursor(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);
|
void seat_request_set_selection(struct wl_listener *listener, void *data);
|
||||||
|
|
|
||||||
43
server.c
43
server.c
|
|
@ -3,6 +3,49 @@
|
||||||
static bool in_alt_tab_mode;
|
static bool in_alt_tab_mode;
|
||||||
static struct view *alt_tab_view;
|
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)
|
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
|
/* This event is raised when a modifier key, such as shift or alt, is
|
||||||
|
|
|
||||||
42
view.c
42
view.c
|
|
@ -85,48 +85,6 @@ void view_focus(struct view *view)
|
||||||
&keyboard->modifiers);
|
&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_front_toplevel(struct server *server)
|
||||||
{
|
{
|
||||||
struct view *view;
|
struct view *view;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue