diff options
author | Scott Moreau <oreaus@gmail.com> | 2012-03-22 11:01:03 -0600 |
---|---|---|
committer | Scott Moreau <oreaus@gmail.com> | 2012-03-22 11:03:41 -0600 |
commit | a3aa9c9dd6d4e7b8d7df347ad1d5d981f43f5057 (patch) | |
tree | 15909ade627f4bb5aa154d012fec37669fa9c6c1 /src | |
parent | 1b45a79a0a395c77a3d2f4b5ffa945a17b7b9292 (diff) |
Add surface opacity controls.
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/shell.c b/src/shell.c index 6e9b159..b26cbf4 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1162,6 +1162,41 @@ resize_binding(struct wl_input_device *device, uint32_t time, } static void +surface_opacity_binding(struct wl_input_device *device, uint32_t time, + uint32_t key, uint32_t button, uint32_t axis, int32_t value, void *data) +{ + int step = 15; + struct shell_surface *shsurf; + struct weston_surface *surface = + (struct weston_surface *) device->pointer_focus; + + if (surface == NULL) + return; + + shsurf = get_shell_surface(surface); + if (!shsurf) + return; + + switch (shsurf->type) { + case SHELL_SURFACE_BACKGROUND: + case SHELL_SURFACE_SCREENSAVER: + return; + default: + break; + } + + surface->alpha += value * step; + + if (surface->alpha > 255) + surface->alpha = 255; + if (surface->alpha < step) + surface->alpha = step; + + surface->geometry.dirty = 1; + weston_surface_damage(surface); +} + +static void zoom_binding(struct wl_input_device *device, uint32_t time, uint32_t key, uint32_t button, uint32_t axis, int32_t value, void *data) { @@ -2071,6 +2106,9 @@ shell_init(struct weston_compositor *ec) weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0, click_to_activate_binding, ec); weston_compositor_add_binding(ec, 0, 0, WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, + MODIFIER_SUPER | MODIFIER_ALT, + surface_opacity_binding, NULL); + weston_compositor_add_binding(ec, 0, 0, WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, MODIFIER_SUPER, zoom_binding, NULL); weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, MODIFIER_SUPER | MODIFIER_ALT, |