mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-14 23:28:11 +00:00
xwm: Implement resizing by frame borders
This commit is contained in:
parent
f96e6c00d9
commit
c1693f209a
|
@ -73,6 +73,9 @@ struct weston_shell_interface {
|
||||||
struct shell_surface *pshsurf,
|
struct shell_surface *pshsurf,
|
||||||
int x, int y, uint32_t flags);
|
int x, int y, uint32_t flags);
|
||||||
int (*move)(struct shell_surface *shsurf, struct weston_seat *ws);
|
int (*move)(struct shell_surface *shsurf, struct weston_seat *ws);
|
||||||
|
int (*resize)(struct shell_surface *shsurf,
|
||||||
|
struct weston_seat *ws, uint32_t edges);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct weston_border {
|
struct weston_border {
|
||||||
|
|
|
@ -626,8 +626,8 @@ static const struct wl_pointer_grab_interface resize_grab_interface = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
weston_surface_resize(struct shell_surface *shsurf,
|
surface_resize(struct shell_surface *shsurf,
|
||||||
struct weston_seat *ws, uint32_t edges)
|
struct weston_seat *ws, uint32_t edges)
|
||||||
{
|
{
|
||||||
struct weston_resize_grab *resize;
|
struct weston_resize_grab *resize;
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ shell_surface_resize(struct wl_client *client, struct wl_resource *resource,
|
||||||
ws->seat.pointer->focus != &shsurf->surface->surface)
|
ws->seat.pointer->focus != &shsurf->surface->surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (weston_surface_resize(shsurf, ws, edges) < 0)
|
if (surface_resize(shsurf, ws, edges) < 0)
|
||||||
wl_resource_post_no_memory(resource);
|
wl_resource_post_no_memory(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1610,7 +1610,7 @@ resize_binding(struct wl_seat *seat, uint32_t time,
|
||||||
else
|
else
|
||||||
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
edges |= WL_SHELL_SURFACE_RESIZE_BOTTOM;
|
||||||
|
|
||||||
weston_surface_resize(shsurf, (struct weston_seat *) seat, edges);
|
surface_resize(shsurf, (struct weston_seat *) seat, edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2658,6 +2658,7 @@ shell_init(struct weston_compositor *ec)
|
||||||
ec->shell_interface.set_toplevel = set_toplevel;
|
ec->shell_interface.set_toplevel = set_toplevel;
|
||||||
ec->shell_interface.set_transient = set_transient;
|
ec->shell_interface.set_transient = set_transient;
|
||||||
ec->shell_interface.move = surface_move;
|
ec->shell_interface.move = surface_move;
|
||||||
|
ec->shell_interface.resize = surface_resize;
|
||||||
|
|
||||||
wl_list_init(&shell->backgrounds);
|
wl_list_init(&shell->backgrounds);
|
||||||
wl_list_init(&shell->panels);
|
wl_list_init(&shell->panels);
|
||||||
|
|
|
@ -781,25 +781,39 @@ weston_wm_handle_button(struct weston_wm *wm, xcb_generic_event_t *event)
|
||||||
struct weston_wm_window *window;
|
struct weston_wm_window *window;
|
||||||
enum theme_location location;
|
enum theme_location location;
|
||||||
struct theme *t = wm->theme;
|
struct theme *t = wm->theme;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
fprintf(stderr, "XCB_BUTTON_%s (detail %d)\n",
|
fprintf(stderr, "XCB_BUTTON_%s (detail %d)\n",
|
||||||
button->response_type == XCB_BUTTON_PRESS ?
|
button->response_type == XCB_BUTTON_PRESS ?
|
||||||
"PRESS" : "RELEASE", button->detail);
|
"PRESS" : "RELEASE", button->detail);
|
||||||
|
|
||||||
window = hash_table_lookup(wm->window_hash, button->event);
|
window = hash_table_lookup(wm->window_hash, button->event);
|
||||||
|
weston_wm_window_get_frame_size(window, &width, &height);
|
||||||
|
|
||||||
if (button->response_type == XCB_BUTTON_PRESS &&
|
if (button->response_type == XCB_BUTTON_PRESS &&
|
||||||
button->detail == 1) {
|
button->detail == 1) {
|
||||||
location = theme_get_location(t,
|
location = theme_get_location(t,
|
||||||
button->event_x,
|
button->event_x,
|
||||||
button->event_y,
|
button->event_y,
|
||||||
window->width,
|
width, height);
|
||||||
window->height);
|
|
||||||
|
|
||||||
switch (location) {
|
switch (location) {
|
||||||
case THEME_LOCATION_TITLEBAR:
|
case THEME_LOCATION_TITLEBAR:
|
||||||
shell_interface->move(window->shsurf,
|
shell_interface->move(window->shsurf,
|
||||||
wm->server->compositor->seat);
|
wm->server->compositor->seat);
|
||||||
break;
|
break;
|
||||||
|
case THEME_LOCATION_RESIZING_TOP:
|
||||||
|
case THEME_LOCATION_RESIZING_BOTTOM:
|
||||||
|
case THEME_LOCATION_RESIZING_LEFT:
|
||||||
|
case THEME_LOCATION_RESIZING_RIGHT:
|
||||||
|
case THEME_LOCATION_RESIZING_TOP_LEFT:
|
||||||
|
case THEME_LOCATION_RESIZING_TOP_RIGHT:
|
||||||
|
case THEME_LOCATION_RESIZING_BOTTOM_LEFT:
|
||||||
|
case THEME_LOCATION_RESIZING_BOTTOM_RIGHT:
|
||||||
|
shell_interface->resize(window->shsurf,
|
||||||
|
wm->server->compositor->seat,
|
||||||
|
location);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue