[PATCH kmscon] wlterm: Add maximize toggle functionality.
Scott Moreau
oreaus at gmail.com
Sat Sep 29 00:10:01 PDT 2012
---
src/wlt_theme.c | 1 +
src/wlt_toolkit.c | 20 ++++++++++++++++++++
src/wlt_toolkit.h | 1 +
3 files changed, 22 insertions(+)
diff --git a/src/wlt_theme.c b/src/wlt_theme.c
index c69d889..de54cc7 100644
--- a/src/wlt_theme.c
+++ b/src/wlt_theme.c
@@ -443,6 +443,7 @@ static void button_action(struct wlt_theme *theme)
wlt_window_close(theme->wnd);
break;
case LOC_MAXIMIZE:
+ wlt_window_toggle_maximize(theme->wnd);
break;
case LOC_MINIMIZE:
break;
diff --git a/src/wlt_toolkit.c b/src/wlt_toolkit.c
index d34eb64..4f73c3e 100644
--- a/src/wlt_toolkit.c
+++ b/src/wlt_toolkit.c
@@ -114,7 +114,10 @@ struct wlt_window {
bool idle_pending;
unsigned int new_width;
unsigned int new_height;
+ unsigned int saved_width;
+ unsigned int saved_height;
unsigned int resize_edges;
+ bool maximized;
struct wlt_shm_buffer buffer;
struct wl_callback *w_frame;
@@ -1482,6 +1485,23 @@ void wlt_window_close(struct wlt_window *wnd)
ev_eloop_register_idle_cb(wnd->disp->eloop, close_window, wnd);
}
+void wlt_window_toggle_maximize(struct wlt_window *wnd)
+{
+ if (!wnd)
+ return;
+
+ if (wnd->maximized) {
+ wl_shell_surface_set_toplevel(wnd->w_shell_surface);
+ wlt_window_set_size(wnd, wnd->saved_width, wnd->saved_height);
+ } else {
+ wnd->saved_width = wnd->buffer.width;
+ wnd->saved_height = wnd->buffer.height;
+ wl_shell_surface_set_maximized(wnd->w_shell_surface, NULL);
+ }
+
+ wnd->maximized = !wnd->maximized;
+}
+
struct ev_eloop *wlt_window_get_eloop(struct wlt_window *wnd)
{
if (!wnd)
diff --git a/src/wlt_toolkit.h b/src/wlt_toolkit.h
index e24486f..2780969 100644
--- a/src/wlt_toolkit.h
+++ b/src/wlt_toolkit.h
@@ -143,6 +143,7 @@ void wlt_window_set_cursor(struct wlt_window *wnd, unsigned int cursor);
void wlt_window_set_close_cb(struct wlt_window *wnd,
wlt_window_close_cb cb);
void wlt_window_close(struct wlt_window *wnd);
+void wlt_window_toggle_maximize(struct wlt_window *wnd);
struct ev_eloop *wlt_window_get_eloop(struct wlt_window *wnd);
void wlt_widget_destroy(struct wlt_widget *widget);
--
1.7.11.4
More information about the wayland-devel
mailing list