swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 443386e9b5f2ee84abadec9841f80d8ee732dcb9
parent c6daffdc4667e0396be62993409d5490f3e05252
Author: Michael Forney <mforney@mforney.org>
Date:   Sat, 16 Aug 2014 14:39:22 -0700

Add API to change window modes

Diffstat:
Mexample/wm.c | 1+
Mlibswc/swc.h | 28++++++++++++++++++++++++++++
Mlibswc/window.c | 34++++++++++++++++++++++++++++++++++
Mlibswc/window.h | 9+++++++++
4 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/example/wm.c b/example/wm.c @@ -206,6 +206,7 @@ static void new_window(struct swc_window * swc) window->swc = swc; window->screen = NULL; swc_window_set_handler(swc, &window_handler, window); + swc_window_set_tiled(swc); screen_add_window(active_screen, window); focus(window); } diff --git a/libswc/swc.h b/libswc/swc.h @@ -159,6 +159,34 @@ void swc_window_hide(struct swc_window * window); void swc_window_focus(struct swc_window * window); /** + * Sets the window to stacked mode. + * + * A window in this mode has its size specified by the client. The window's + * viewport will be adjusted to the size of the buffer attached by the + * client. + * + * Use of this mode is required to allow interactive moving and resizing. + */ +void swc_window_set_stacked(struct swc_window * window); + +/** + * Sets the window to tiled mode. + * + * A window in this mode has its size specified by the window manager. + * Additionally, swc will configure the window to operate in a tiled or + * maximized state in order to prevent the window from drawing shadows. + * + * It is invalid to interactively move or resize a window in tiled mode. + */ +void swc_window_set_tiled(struct swc_window * window); + +/** + * Sets the window to fullscreen mode. + */ +void swc_window_set_fullscreen(struct swc_window * window, + struct swc_screen * screen); + +/** * Set the window's position. * * The x and y coordinates refer to the top-left corner of the actual contents diff --git a/libswc/window.c b/libswc/window.c @@ -112,6 +112,39 @@ void swc_window_focus(struct swc_window * base) } EXPORT +void swc_window_set_stacked(struct swc_window * base) +{ + struct window * window = INTERNAL(base); + + if (window->impl->set_mode) + window->impl->set_mode(window, WINDOW_MODE_STACKED); + window->mode = WINDOW_MODE_STACKED; +} + +EXPORT +void swc_window_set_tiled(struct swc_window * base) +{ + struct window * window = INTERNAL(base); + + if (window->impl->set_mode) + window->impl->set_mode(window, WINDOW_MODE_TILED); + window->mode = WINDOW_MODE_TILED; +} + +EXPORT +void swc_window_set_fullscreen(struct swc_window * base, + struct swc_screen * screen) +{ + struct window * window = INTERNAL(base); + + /* TODO: Implement fullscreen windows. */ + + if (window->impl->set_mode) + window->impl->set_mode(window, WINDOW_MODE_FULLSCREEN); + window->mode = WINDOW_MODE_FULLSCREEN; +} + +EXPORT void swc_window_set_position(struct swc_window * base, int32_t x, int32_t y) { struct window * window = INTERNAL(base); @@ -278,6 +311,7 @@ bool window_initialize(struct window * window, const struct window_impl * impl, window->handler = &null_handler; window->view->window = window; window->managed = false; + window->mode = WINDOW_MODE_STACKED; window->move.interaction.handler = (struct pointer_handler) { .motion = &move_motion, .button = &handle_button diff --git a/libswc/window.h b/libswc/window.h @@ -35,6 +35,13 @@ struct window_pointer_interaction struct pointer_handler handler, * original_handler; }; +enum window_mode +{ + WINDOW_MODE_STACKED, + WINDOW_MODE_TILED, + WINDOW_MODE_FULLSCREEN, +}; + struct window { struct swc_window base; @@ -44,6 +51,7 @@ struct window struct compositor_view * view; bool managed; + enum window_mode mode; struct { @@ -65,6 +73,7 @@ struct window_impl void (* focus)(struct window * window); void (* unfocus)(struct window * window); void (* close)(struct window * window); + void (* set_mode)(struct window * window, enum window_mode mode); }; extern struct wl_listener window_enter_listener;