[PATCH weston 6/8 v2] shell: Install listeners to reflect shell surface protocol changes.
Scott Moreau
oreaus at gmail.com
Wed Nov 14 23:37:05 PST 2012
This patch adds listeners for the maximize and minimize events found in the
wayland patch "protocol: Add minimize/maximize protocol.". It also hooks up the
minimize titlebar button along the way.
---
clients/simple-egl.c | 26 +++++++++++++++++++++-
clients/simple-shm.c | 26 +++++++++++++++++++++-
clients/simple-touch.c | 26 +++++++++++++++++++++-
clients/window.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++---
clients/window.h | 3 +++
src/shell.c | 14 ++++++++++++
6 files changed, 147 insertions(+), 6 deletions(-)
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index fcbea75..273159b 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -250,10 +250,34 @@ handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
{
}
+static void
+handle_maximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unmaximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_minimize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unminimize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
- handle_popup_done
+ handle_popup_done,
+ handle_maximize,
+ handle_unmaximize,
+ handle_minimize,
+ handle_unminimize
};
static void
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index a09ec91..7f8809a 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -107,10 +107,34 @@ handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
{
}
+static void
+handle_maximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unmaximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_minimize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unminimize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
- handle_popup_done
+ handle_popup_done,
+ handle_maximize,
+ handle_unmaximize,
+ handle_minimize,
+ handle_unminimize
};
static struct window *
diff --git a/clients/simple-touch.c b/clients/simple-touch.c
index cbe3877..c9b594b 100644
--- a/clients/simple-touch.c
+++ b/clients/simple-touch.c
@@ -233,10 +233,34 @@ handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
{
}
+static void
+handle_maximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unmaximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_minimize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unminimize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
- handle_popup_done
+ handle_popup_done,
+ handle_maximize,
+ handle_unmaximize,
+ handle_minimize,
+ handle_unminimize
};
static void
diff --git a/clients/window.c b/clients/window.c
index 288a526..b2dbd9c 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -132,6 +132,7 @@ enum {
TYPE_TOPLEVEL,
TYPE_FULLSCREEN,
TYPE_MAXIMIZED,
+ TYPE_MINIMIZED,
TYPE_TRANSIENT,
TYPE_MENU,
TYPE_CUSTOM
@@ -160,7 +161,7 @@ struct window {
int redraw_needed;
struct task redraw_task;
int resize_needed;
- int type;
+ int type, saved_type;
int transparent;
int focus_count;
@@ -1564,7 +1565,7 @@ frame_button_button_handler(struct widget *widget,
display_exit(window->display);
break;
case FRAME_BUTTON_MINIMIZE:
- fprintf(stderr,"Minimize stub\n");
+ window_set_minimized(window, window->type != TYPE_MINIMIZED);
break;
case FRAME_BUTTON_MAXIMIZE:
window_set_maximized(window, window->type != TYPE_MAXIMIZED);
@@ -2938,10 +2939,44 @@ handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
menu_destroy(menu);
}
+static void
+handle_maximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_unmaximize(void *data, struct wl_shell_surface *shell_surface)
+{
+}
+
+static void
+handle_minimize(void *data, struct wl_shell_surface *shell_surface)
+{
+ struct window *window = data;
+
+ if (window->type != TYPE_MINIMIZED) {
+ window->saved_type = window->type;
+ window->type = TYPE_MINIMIZED;
+ }
+}
+
+static void
+handle_unminimize(void *data, struct wl_shell_surface *shell_surface)
+{
+ struct window *window = data;
+
+ if (window->type == TYPE_MINIMIZED)
+ window->type = window->saved_type;
+}
+
static const struct wl_shell_surface_listener shell_surface_listener = {
handle_ping,
handle_configure,
- handle_popup_done
+ handle_popup_done,
+ handle_maximize,
+ handle_unmaximize,
+ handle_minimize,
+ handle_unminimize
};
void
@@ -3067,6 +3102,23 @@ window_set_maximized(struct window *window, int maximized)
}
void
+window_set_minimized(struct window *window, int minimized)
+{
+ if (!window->display->shell)
+ return;
+
+ if ((window->type == TYPE_MINIMIZED) == minimized)
+ return;
+
+ if (window->type != TYPE_MINIMIZED) {
+ window->saved_type = window->type;
+ wl_shell_surface_set_minimized(window->shell_surface);
+ window->type = TYPE_MINIMIZED;
+ } else
+ window->type = window->saved_type;
+}
+
+void
window_set_user_data(struct window *window, void *data)
{
window->user_data = data;
diff --git a/clients/window.h b/clients/window.h
index 84846ff..81fd1ea 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -304,6 +304,9 @@ void
window_set_maximized(struct window *window, int maximized);
void
+window_set_minimized(struct window *window, int minimized);
+
+void
window_set_user_data(struct window *window, void *data);
void *
diff --git a/src/shell.c b/src/shell.c
index 40b77e1..d2fcfad 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1472,6 +1472,8 @@ shell_surface_minimize(struct shell_surface *shsurf)
}
send_surface_data_focused_state(surface);
+ wl_shell_surface_send_minimize(&shsurf->resource);
+
weston_compositor_damage_all(compositor);
}
@@ -1494,6 +1496,7 @@ shell_surface_unminimize(struct shell_surface *shsurf)
shsurf->type = shsurf->saved_type;
shell_surface_focus(shsurf);
send_surface_data_focused_state(surface);
+ wl_shell_surface_send_unminimize(&shsurf->resource);
weston_compositor_damage_all(compositor);
}
}
@@ -1922,6 +1925,16 @@ shell_surface_set_maximized(struct wl_client *client,
}
static void
+shell_surface_set_minimized(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct shell_surface *shsurf = resource->data;
+
+ shell_surface_minimize(shsurf);
+ send_surface_data_minimized_state(shsurf->surface);
+}
+
+static void
black_surface_configure(struct weston_surface *es, int32_t sx, int32_t sy);
static struct weston_surface *
@@ -2228,6 +2241,7 @@ static const struct wl_shell_surface_interface shell_surface_implementation = {
shell_surface_set_fullscreen,
shell_surface_set_popup,
shell_surface_set_maximized,
+ shell_surface_set_minimized,
shell_surface_set_title,
shell_surface_set_class
};
--
1.7.11.7
More information about the wayland-devel
mailing list