commit 443386e

Michael Forney  ·  2014-08-16 21:39:22 +0000 UTC
parent c6daffd
Add API to change window modes
4 files changed,  +72, -0
+1, -0
1@@ -206,6 +206,7 @@ static void new_window(struct swc_window * swc)
2     window->swc = swc;
3     window->screen = NULL;
4     swc_window_set_handler(swc, &window_handler, window);
5+    swc_window_set_tiled(swc);
6     screen_add_window(active_screen, window);
7     focus(window);
8 }
+28, -0
 1@@ -158,6 +158,34 @@ void swc_window_hide(struct swc_window * window);
 2  */
 3 void swc_window_focus(struct swc_window * window);
 4 
 5+/**
 6+ * Sets the window to stacked mode.
 7+ *
 8+ * A window in this mode has its size specified by the client. The window's
 9+ * viewport will be adjusted to the size of the buffer attached by the
10+ * client.
11+ *
12+ * Use of this mode is required to allow interactive moving and resizing.
13+ */
14+void swc_window_set_stacked(struct swc_window * window);
15+
16+/**
17+ * Sets the window to tiled mode.
18+ *
19+ * A window in this mode has its size specified by the window manager.
20+ * Additionally, swc will configure the window to operate in a tiled or
21+ * maximized state in order to prevent the window from drawing shadows.
22+ *
23+ * It is invalid to interactively move or resize a window in tiled mode.
24+ */
25+void swc_window_set_tiled(struct swc_window * window);
26+
27+/**
28+ * Sets the window to fullscreen mode.
29+ */
30+void swc_window_set_fullscreen(struct swc_window * window,
31+                               struct swc_screen * screen);
32+
33 /**
34  * Set the window's position.
35  *
+34, -0
 1@@ -111,6 +111,39 @@ void swc_window_focus(struct swc_window * base)
 2     keyboard_set_focus(swc.seat->keyboard, new_focus);
 3 }
 4 
 5+EXPORT
 6+void swc_window_set_stacked(struct swc_window * base)
 7+{
 8+    struct window * window = INTERNAL(base);
 9+
10+    if (window->impl->set_mode)
11+        window->impl->set_mode(window, WINDOW_MODE_STACKED);
12+    window->mode = WINDOW_MODE_STACKED;
13+}
14+
15+EXPORT
16+void swc_window_set_tiled(struct swc_window * base)
17+{
18+    struct window * window = INTERNAL(base);
19+
20+    if (window->impl->set_mode)
21+        window->impl->set_mode(window, WINDOW_MODE_TILED);
22+    window->mode = WINDOW_MODE_TILED;
23+}
24+
25+EXPORT
26+void swc_window_set_fullscreen(struct swc_window * base,
27+                               struct swc_screen * screen)
28+{
29+    struct window * window = INTERNAL(base);
30+
31+    /* TODO: Implement fullscreen windows. */
32+
33+    if (window->impl->set_mode)
34+        window->impl->set_mode(window, WINDOW_MODE_FULLSCREEN);
35+    window->mode = WINDOW_MODE_FULLSCREEN;
36+}
37+
38 EXPORT
39 void swc_window_set_position(struct swc_window * base, int32_t x, int32_t y)
40 {
41@@ -278,6 +311,7 @@ bool window_initialize(struct window * window, const struct window_impl * impl,
42     window->handler = &null_handler;
43     window->view->window = window;
44     window->managed = false;
45+    window->mode = WINDOW_MODE_STACKED;
46     window->move.interaction.handler = (struct pointer_handler) {
47         .motion = &move_motion,
48         .button = &handle_button
+9, -0
 1@@ -35,6 +35,13 @@ struct window_pointer_interaction
 2     struct pointer_handler handler, * original_handler;
 3 };
 4 
 5+enum window_mode
 6+{
 7+    WINDOW_MODE_STACKED,
 8+    WINDOW_MODE_TILED,
 9+    WINDOW_MODE_FULLSCREEN,
10+};
11+
12 struct window
13 {
14     struct swc_window base;
15@@ -44,6 +51,7 @@ struct window
16 
17     struct compositor_view * view;
18     bool managed;
19+    enum window_mode mode;
20 
21     struct
22     {
23@@ -65,6 +73,7 @@ struct window_impl
24     void (* focus)(struct window * window);
25     void (* unfocus)(struct window * window);
26     void (* close)(struct window * window);
27+    void (* set_mode)(struct window * window, enum window_mode mode);
28 };
29 
30 extern struct wl_listener window_enter_listener;