[PATCH weston 9/9] shell: Implement maximize menu button functionality
Scott Moreau
oreaus at gmail.com
Thu Mar 7 20:47:18 PST 2013
Add maximize button for list item drop down menu.
---
clients/desktop-shell.c | 44 +++++++++++++++++++++++++++++++++++++++-----
clients/window.c | 6 ++++++
src/shell.c | 23 +++++++++++++++++++++++
3 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index 1fa7387..4b2f805 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -70,7 +70,7 @@ struct surface {
struct desktop *desktop;
uint32_t output_mask;
char *title;
- int minimized, focused;
+ int maximized, minimized, focused;
/* One window list item per panel of the surface's output_mask */
struct wl_list item_list;
@@ -1159,7 +1159,7 @@ static int
panel_list_item_enter_handler(struct widget *widget, struct input *input,
float x, float y, void *data)
{
- struct list_item *item = data;
+ struct list_item *item = data, *t_item;
item->x = x;
item->y = y;
@@ -1167,6 +1167,13 @@ panel_list_item_enter_handler(struct widget *widget, struct input *input,
item->focused = 1;
widget_schedule_redraw(widget);
+ wl_list_for_each(t_item, &item->panel->window_list, link) {
+ if(item == t_item)
+ continue;
+ t_item->highlight = 0;
+ t_item->focused = 0;
+ }
+
return CURSOR_LEFT_PTR;
}
@@ -1201,7 +1208,17 @@ list_item_menu_handle_button(struct list_item *item, int index)
surface->minimized = 1;
}
break;
- case 1: /* Close */
+ case 1: /* (Un)Maximize */
+ if (surface->maximized) {
+ surface_data_unmaximize(surface->surface_data);
+ surface->maximized = 0;
+ }
+ else {
+ surface_data_maximize(surface->surface_data);
+ surface->maximized = 1;
+ }
+ break;
+ case 2: /* Close */
surface_data_close(surface->surface_data);
break;
default:
@@ -1231,7 +1248,7 @@ list_item_menu_func(struct window *window, int index, void *data)
}
}
-#define MENU_ENTRIES 2
+#define MENU_ENTRIES 3
static void
list_item_show_menu(struct list_item *item, struct input *input, uint32_t time)
@@ -1241,7 +1258,8 @@ list_item_show_menu(struct list_item *item, struct input *input, uint32_t time)
static const char *entries[MENU_ENTRIES];
entries[0] = item->surface->minimized ? "Unminimize" : "Minimize";
- entries[1] = "Close";
+ entries[1] = item->surface->maximized ? "Unmaximize" : "Maximize";
+ entries[2] = "Close";
panel = item->panel;
input_get_position(input, &x, &y);
@@ -1503,6 +1521,21 @@ surface_data_set_title(void *data,
}
static void
+surface_data_set_maximized_state(void *data,
+ struct surface_data *surface_data,
+ int maximized)
+{
+ struct desktop *desktop;
+ struct surface *surface = data;
+
+ desktop = surface->desktop;
+
+ surface->maximized = maximized;
+
+ desktop_update_list_items(desktop, surface);
+}
+
+static void
surface_data_set_minimized_state(void *data,
struct surface_data *surface_data,
int minimized)
@@ -1568,6 +1601,7 @@ surface_data_destroy_handler(void *data, struct surface_data *surface_data)
static const struct surface_data_listener surface_data_listener = {
surface_data_set_output_mask,
surface_data_set_title,
+ surface_data_set_maximized_state,
surface_data_set_minimized_state,
surface_data_set_focused_state,
surface_data_destroy_handler
diff --git a/clients/window.c b/clients/window.c
index 7093a38..d5a1898 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3317,11 +3317,17 @@ handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
static void
handle_maximize(void *data, struct wl_shell_surface *shell_surface)
{
+ struct window *window = data;
+
+ window_set_maximized(window, 1);
}
static void
handle_unmaximize(void *data, struct wl_shell_surface *shell_surface)
{
+ struct window *window = data;
+
+ window_set_maximized(window, 0);
}
static void
diff --git a/src/shell.c b/src/shell.c
index fd1411b..1e2eb52 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -1508,6 +1508,7 @@ surface_unminimize(struct shell_surface *shsurf, struct workspace *ws)
shell_surface_focus(shsurf);
send_surface_data_focused_state(surface);
shsurf->minimized = false;
+ shsurf->type = shsurf->saved_type;
wl_shell_surface_send_unminimize(&shsurf->resource);
weston_compositor_damage_all(compositor);
}
@@ -1526,6 +1527,24 @@ shell_surface_unminimize(struct shell_surface *shsurf)
}
static void
+surface_data_maximize_handler(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct shell_surface *shsurf = resource->data;
+
+ wl_shell_surface_send_maximize(&shsurf->resource);
+}
+
+static void
+surface_data_unmaximize_handler(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct shell_surface *shsurf = resource->data;
+
+ wl_shell_surface_send_unmaximize(&shsurf->resource);
+}
+
+static void
surface_data_minimize_handler(struct wl_client *client,
struct wl_resource *resource)
{
@@ -1593,6 +1612,8 @@ surface_data_destroy_handler(struct wl_client *client,
static const struct surface_data_interface
surface_data_implementation = {
+ surface_data_maximize_handler,
+ surface_data_unmaximize_handler,
surface_data_minimize_handler,
surface_data_unminimize_handler,
surface_data_focus_handler,
@@ -1791,6 +1812,7 @@ reset_shell_surface_type(struct shell_surface *surface)
weston_surface_set_position(surface->surface,
surface->saved_x,
surface->saved_y);
+ surface_data_send_maximized(surface->surface_data, 0);
break;
case SHELL_SURFACE_NONE:
case SHELL_SURFACE_TOPLEVEL:
@@ -1827,6 +1849,7 @@ set_surface_type(struct shell_surface *shsurf)
shsurf->saved_x = surface->geometry.x;
shsurf->saved_y = surface->geometry.y;
shsurf->saved_position_valid = true;
+ surface_data_send_maximized(shsurf->surface_data, 1);
break;
case SHELL_SURFACE_FULLSCREEN:
--
1.7.10.4
More information about the wayland-devel
mailing list