[PATCH 16/16] xdg-shell: Add key bindings for setting maximized and fullscreen.
Rafael Antognolli
rafael.antognolli at intel.com
Wed Nov 27 09:50:32 PST 2013
---
clients/window.c | 34 ++++++++++++++++++++++++++++++++++
src/shell.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/clients/window.c b/clients/window.c
index 5cac1e1..52f6678 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3778,6 +3778,36 @@ handle_surface_configure(void *data, struct xdg_surface *xdg_surface,
}
static void
+handle_surface_request_set_fullscreen(void *data, struct xdg_surface *xdg_surface)
+{
+ struct window *window = data;
+
+ window_set_fullscreen(window, 1);
+}
+
+static void
+handle_surface_request_unset_fullscreen(void *data, struct xdg_surface *xdg_surface)
+{
+ struct window *window = data;
+
+ window_set_fullscreen(window, 0);
+}
+
+static void
+handle_surface_request_set_maximized(void *data, struct xdg_surface *xdg_surface)
+{
+ struct window *window = data;
+ window_set_maximized(window, 1);
+}
+
+static void
+handle_surface_request_unset_maximized(void *data, struct xdg_surface *xdg_surface)
+{
+ struct window *window = data;
+ window_set_maximized(window, 0);
+}
+
+static void
handle_surface_focused_set(void *data, struct xdg_surface *xdg_surface)
{
struct window *window = data;
@@ -3794,6 +3824,10 @@ handle_surface_focused_unset(void *data, struct xdg_surface *xdg_surface)
static const struct xdg_surface_listener xdg_surface_listener = {
handle_surface_ping,
handle_surface_configure,
+ handle_surface_request_set_fullscreen,
+ handle_surface_request_unset_fullscreen,
+ handle_surface_request_set_maximized,
+ handle_surface_request_unset_maximized,
handle_surface_focused_set,
handle_surface_focused_unset,
};
diff --git a/src/shell.c b/src/shell.c
index 5d1dcd1..03cfb09 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -3698,6 +3698,48 @@ move_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *dat
}
static void
+maximize_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data)
+{
+ struct weston_surface *focus = seat->pointer->focus->surface;
+ struct weston_surface *surface;
+ struct shell_surface *shsurf;
+
+ surface = weston_surface_get_main_surface(focus);
+ if (surface == NULL)
+ return;
+
+ shsurf = get_shell_surface(surface);
+ if (shsurf == NULL || shsurf->shell_class != SHELL_CLASS_XDG_SURFACE)
+ return;
+
+ if (shsurf->cur.maximized)
+ xdg_surface_send_request_unset_maximized(shsurf->resource);
+ else
+ xdg_surface_send_request_set_maximized(shsurf->resource);
+}
+
+static void
+fullscreen_binding(struct weston_seat *seat, uint32_t time, uint32_t button, void *data)
+{
+ struct weston_surface *focus = seat->pointer->focus->surface;
+ struct weston_surface *surface;
+ struct shell_surface *shsurf;
+
+ surface = weston_surface_get_main_surface(focus);
+ if (surface == NULL)
+ return;
+
+ shsurf = get_shell_surface(surface);
+ if (shsurf == NULL || shsurf->shell_class != SHELL_CLASS_XDG_SURFACE)
+ return;
+
+ if (shsurf->cur.fullscreen)
+ xdg_surface_send_request_unset_fullscreen(shsurf->resource);
+ else
+ xdg_surface_send_request_set_fullscreen(shsurf->resource);
+}
+
+static void
touch_move_binding(struct weston_seat *seat, uint32_t time, void *data)
{
struct weston_surface *focus = seat->touch->focus->surface;
@@ -6397,6 +6439,10 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)
zoom_key_binding, NULL);
weston_compositor_add_key_binding(ec, KEY_PAGEDOWN, mod,
zoom_key_binding, NULL);
+ weston_compositor_add_key_binding(ec, KEY_M, mod, maximize_binding,
+ NULL);
+ weston_compositor_add_key_binding(ec, KEY_F, mod, fullscreen_binding,
+ NULL);
weston_compositor_add_button_binding(ec, BTN_LEFT, mod, move_binding,
shell);
weston_compositor_add_touch_binding(ec, mod, touch_move_binding, shell);
--
1.8.3.1
More information about the wayland-devel
mailing list