]> git.sur5r.net Git - i3/i3/commitdiff
Move toggle_fullscreen to client.c
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 26 May 2009 14:49:57 +0000 (16:49 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 26 May 2009 14:49:57 +0000 (16:49 +0200)
include/client.h
include/util.h
src/client.c
src/commands.c
src/handlers.c
src/manage.c
src/util.c

index a88f8d0baf797adba74441ec6557fd974eb61d7f..2547c52fb0817b185bc5453f38b696da6bd49f54 100644 (file)
@@ -44,4 +44,12 @@ void client_kill(xcb_connection_t *conn, Client *window);
 bool client_matches_class_name(Client *client, char *to_class, char *to_title,
                                char *to_title_ucs, int to_title_ucs_len);
 
+/**
+ * Toggles fullscreen mode for the given client. It updates the data structures and
+ * reconfigures (= resizes/moves) the client and its frame to the full size of the
+ * screen. When leaving fullscreen, re-rendering the layout is forced.
+ *
+ */
+void client_toggle_fullscreen(xcb_connection_t *conn, Client *client);
+
 #endif
index 709e48a471b204039bf31aa7892665a950629498..5658492e08f0cd38dda99f108df614b6215ad40b 100644 (file)
@@ -162,14 +162,6 @@ void leave_stack_mode(xcb_connection_t *conn, Container *container);
  */
 void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode);
 
-/**
- * Toggles fullscreen mode for the given client. It updates the data structures and
- * reconfigures (= resizes/moves) the client and its frame to the full size of the
- * screen. When leaving fullscreen, re-rendering the layout is forced.
- *
- */
-void toggle_fullscreen(xcb_connection_t *conn, Client *client);
-
 /**
  * Gets the first matching client for the given window class/window title.
  * If the paramater specific is set to a specific client, only this one
index f5409d095f4314056229e2995a1a123ed4a28b15..f4df06ae623b6b3cb8b6b57063a03d8b5d944f12 100644 (file)
@@ -12,6 +12,7 @@
  */
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include <xcb/xcb.h>
 #include <xcb/xcb_icccm.h>
@@ -21,6 +22,7 @@
 #include "xcb.h"
 #include "util.h"
 #include "queue.h"
+#include "layout.h"
 
 /*
  * Removes the given client from the container, either because it will be inserted into another
@@ -131,3 +133,73 @@ bool client_matches_class_name(Client *client, char *to_class, char *to_title,
 
         return true;
 }
+
+/*
+ * Toggles fullscreen mode for the given client. It updates the data structures and
+ * reconfigures (= resizes/moves) the client and its frame to the full size of the
+ * screen. When leaving fullscreen, re-rendering the layout is forced.
+ *
+ */
+void client_toggle_fullscreen(xcb_connection_t *conn, Client *client) {
+        /* dock clients cannot enter fullscreen mode */
+        assert(!client->dock);
+
+        Workspace *workspace = client->workspace;
+
+        if (!client->fullscreen) {
+                if (workspace->fullscreen_client != NULL) {
+                        LOG("Not entering fullscreen mode, there already is a fullscreen client.\n");
+                        return;
+                }
+                client->fullscreen = true;
+                workspace->fullscreen_client = client;
+                LOG("Entering fullscreen mode...\n");
+                /* We just entered fullscreen mode, let’s configure the window */
+                uint32_t mask = XCB_CONFIG_WINDOW_X |
+                                XCB_CONFIG_WINDOW_Y |
+                                XCB_CONFIG_WINDOW_WIDTH |
+                                XCB_CONFIG_WINDOW_HEIGHT;
+                uint32_t values[4] = {workspace->rect.x,
+                                      workspace->rect.y,
+                                      workspace->rect.width,
+                                      workspace->rect.height};
+
+                LOG("child itself will be at %dx%d with size %dx%d\n",
+                                values[0], values[1], values[2], values[3]);
+
+                xcb_configure_window(conn, client->frame, mask, values);
+
+                /* Child’s coordinates are relative to the parent (=frame) */
+                values[0] = 0;
+                values[1] = 0;
+                xcb_configure_window(conn, client->child, mask, values);
+
+                /* Raise the window */
+                values[0] = XCB_STACK_MODE_ABOVE;
+                xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_STACK_MODE, values);
+
+                Rect child_rect = workspace->rect;
+                child_rect.x = child_rect.y = 0;
+                fake_configure_notify(conn, child_rect, client->child);
+        } else {
+                LOG("leaving fullscreen mode\n");
+                client->fullscreen = false;
+                workspace->fullscreen_client = NULL;
+                if (client->floating) {
+                        /* For floating clients it’s enough if we just reconfigure that window (in fact,
+                         * re-rendering the layout will not update the client.) */
+                        reposition_client(conn, client);
+                        resize_client(conn, client);
+                        /* redecorate_window flushes */
+                        redecorate_window(conn, client);
+                } else {
+                        /* Because the coordinates of the window haven’t changed, it would not be
+                           re-configured if we don’t set the following flag */
+                        client->force_reconfigure = true;
+                        /* We left fullscreen mode, redraw the whole layout to ensure enternotify events are disabled */
+                        render_layout(conn);
+                }
+        }
+
+        xcb_flush(conn);
+}
index 96f390f2293819db00f9f600e13cf2bc469e5504..76953abff2da6a6ddb85c3c525e79b5981feae9b 100644 (file)
@@ -798,7 +798,7 @@ void parse_command(xcb_connection_t *conn, const char *command) {
         if (command[0] == 'f') {
                 if (last_focused == NULL)
                         return;
-                toggle_fullscreen(conn, last_focused);
+                client_toggle_fullscreen(conn, last_focused);
                 return;
         }
 
index bd8d0f9a0ebc1a164adb1b8911b2c810f5b39b4b..81fb865519b27b59836ebd2eceea324b85494e98 100644 (file)
@@ -830,7 +830,7 @@ int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message
                     (!client->fullscreen &&
                      (event->data.data32[0] == _NET_WM_STATE_ADD ||
                       event->data.data32[0] == _NET_WM_STATE_TOGGLE)))
-                        toggle_fullscreen(conn, client);
+                        client_toggle_fullscreen(conn, client);
         } else {
                 LOG("unhandled clientmessage\n");
                 return 0;
index e139b6c1fc7c42aced272b8b53741c9ee6301167..5e6e6eed58506bfe60bdfe8d927f9bced9070dbe 100644 (file)
@@ -28,6 +28,7 @@
 #include "layout.h"
 #include "manage.h"
 #include "floating.h"
+#include "client.h"
 
 /*
  * Go through all existing windows (if the window manager is restarted) and manage them
@@ -359,7 +360,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
                         /* If the window got the fullscreen state, we just toggle fullscreen
                            and don’t event bother to redraw the layout – that would not change
                            anything anyways */
-                        toggle_fullscreen(conn, new);
+                        client_toggle_fullscreen(conn, new);
                         return;
                 }
 
index 5174c91c46c53be769ca0062e4c8f72c293b27e2..6b93199591cfb30a0268b5e362e301830b875125 100644 (file)
@@ -440,76 +440,6 @@ void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode)
                 set_focus(conn, container->currently_focused, true);
 }
 
-/*
- * Toggles fullscreen mode for the given client. It updates the data structures and
- * reconfigures (= resizes/moves) the client and its frame to the full size of the
- * screen. When leaving fullscreen, re-rendering the layout is forced.
- *
- */
-void toggle_fullscreen(xcb_connection_t *conn, Client *client) {
-        /* dock clients cannot enter fullscreen mode */
-        assert(!client->dock);
-
-        Workspace *workspace = client->workspace;
-
-        if (!client->fullscreen) {
-                if (workspace->fullscreen_client != NULL) {
-                        LOG("Not entering fullscreen mode, there already is a fullscreen client.\n");
-                        return;
-                }
-                client->fullscreen = true;
-                workspace->fullscreen_client = client;
-                LOG("Entering fullscreen mode...\n");
-                /* We just entered fullscreen mode, let’s configure the window */
-                uint32_t mask = XCB_CONFIG_WINDOW_X |
-                                XCB_CONFIG_WINDOW_Y |
-                                XCB_CONFIG_WINDOW_WIDTH |
-                                XCB_CONFIG_WINDOW_HEIGHT;
-                uint32_t values[4] = {workspace->rect.x,
-                                      workspace->rect.y,
-                                      workspace->rect.width,
-                                      workspace->rect.height};
-
-                LOG("child itself will be at %dx%d with size %dx%d\n",
-                                values[0], values[1], values[2], values[3]);
-
-                xcb_configure_window(conn, client->frame, mask, values);
-
-                /* Child’s coordinates are relative to the parent (=frame) */
-                values[0] = 0;
-                values[1] = 0;
-                xcb_configure_window(conn, client->child, mask, values);
-
-                /* Raise the window */
-                values[0] = XCB_STACK_MODE_ABOVE;
-                xcb_configure_window(conn, client->frame, XCB_CONFIG_WINDOW_STACK_MODE, values);
-
-                Rect child_rect = workspace->rect;
-                child_rect.x = child_rect.y = 0;
-                fake_configure_notify(conn, child_rect, client->child);
-        } else {
-                LOG("leaving fullscreen mode\n");
-                client->fullscreen = false;
-                workspace->fullscreen_client = NULL;
-                if (client->floating) {
-                        /* For floating clients it’s enough if we just reconfigure that window (in fact,
-                         * re-rendering the layout will not update the client.) */
-                        reposition_client(conn, client);
-                        resize_client(conn, client);
-                        /* redecorate_window flushes */
-                        redecorate_window(conn, client);
-                } else {
-                        /* Because the coordinates of the window haven’t changed, it would not be
-                           re-configured if we don’t set the following flag */
-                        client->force_reconfigure = true;
-                        /* We left fullscreen mode, redraw the whole layout to ensure enternotify events are disabled */
-                        render_layout(conn);
-                }
-        }
-
-        xcb_flush(conn);
-}
-
 /*
  * Gets the first matching client for the given window class/window title.
  * If the paramater specific is set to a specific client, only this one