]> git.sur5r.net Git - i3/i3/blobdiff - src/click.c
first step of the big refactoring ("tree" branch).
[i3/i3] / src / click.c
index dccd5b4f0e4bdc093ad4a07a77a39d1d51ba6141..61328e0604c30f755fa5901bc543e803681a3ca3 100644 (file)
@@ -3,7 +3,7 @@
  *
  * i3 - an improved dynamic tiling window manager
  *
- * © 2009 Michael Stapelberg and contributors
+ * © 2009-2010 Michael Stapelberg and contributors
  *
  * See file LICENSE for license information.
  *
  *              because they are quite large.
  *
  */
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
 #include <time.h>
-#include <stdbool.h>
 #include <math.h>
 
-#include <xcb/xcb.h>
 #include <xcb/xcb_atom.h>
 #include <xcb/xcb_icccm.h>
 
 #include <X11/XKBlib.h>
 
-#include "i3.h"
-#include "queue.h"
-#include "table.h"
-#include "config.h"
-#include "util.h"
-#include "xcb.h"
-#include "client.h"
-#include "workspace.h"
-#include "commands.h"
-#include "floating.h"
-#include "resize.h"
-#include "log.h"
+#include "all.h"
 
+#if 0
 static struct Stack_Window *get_stack_window(xcb_window_t window_id) {
         struct Stack_Window *current;
 
@@ -125,9 +109,9 @@ static bool button_press_stackwin(xcb_connection_t *conn, xcb_button_press_event
  *
  */
 static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *event) {
-        i3Screen *screen;
-        TAILQ_FOREACH(screen, virtual_screens, screens) {
-                if (screen->bar != event->event)
+        Output *output;
+        TAILQ_FOREACH(output, &outputs, outputs) {
+                if (output->bar != event->event)
                         continue;
 
                 DLOG("Click on a bar\n");
@@ -137,14 +121,14 @@ static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *e
                         Workspace *ws = c_ws;
                         if (event->detail == XCB_BUTTON_INDEX_5) {
                                 while ((ws = TAILQ_NEXT(ws, workspaces)) != TAILQ_END(workspaces_head)) {
-                                        if (ws->screen == screen) {
+                                        if (ws->output == output) {
                                                 workspace_show(conn, ws->num + 1);
                                                 return true;
                                         }
                                 }
                         } else {
                                 while ((ws = TAILQ_PREV(ws, workspaces_head, workspaces)) != TAILQ_END(workspaces)) {
-                                        if (ws->screen == screen) {
+                                        if (ws->output == output) {
                                                 workspace_show(conn, ws->num + 1);
                                                 return true;
                                         }
@@ -153,11 +137,11 @@ static bool button_press_bar(xcb_connection_t *conn, xcb_button_press_event_t *e
                         return true;
                 }
                 int drawn = 0;
-                /* Because workspaces can be on different screens, we need to loop
-                   through all of them and decide to count it based on its ->screen */
+                /* Because workspaces can be on different outputs, we need to loop
+                   through all of them and decide to count it based on its ->output */
                 Workspace *ws;
                 TAILQ_FOREACH(ws, workspaces, workspaces) {
-                        if (ws->screen != screen)
+                        if (ws->output != output)
                                 continue;
                         DLOG("Checking if click was on workspace %d with drawn = %d, tw = %d\n",
                                         ws->num, drawn, ws->text_width);
@@ -212,7 +196,7 @@ static bool floating_mod_on_tiled_client(xcb_connection_t *conn, Client *client,
                 first = con->col + (con->colspan - 1);
                 DLOG("column %d\n", first);
 
-                if (!cell_exists(first, con->row) ||
+                if (!cell_exists(ws, first, con->row) ||
                     (first == (ws->cols-1)))
                         return false;
 
@@ -240,7 +224,7 @@ static bool floating_mod_on_tiled_client(xcb_connection_t *conn, Client *client,
                    to_bottom < to_top) {
                 /* …bottom border */
                 first = con->row + (con->rowspan - 1);
-                if (!cell_exists(con->col, first) ||
+                if (!cell_exists(ws, con->col, first) ||
                     (first == (ws->rows-1)))
                         return false;
 
@@ -250,49 +234,63 @@ static bool floating_mod_on_tiled_client(xcb_connection_t *conn, Client *client,
 
        return resize_graphical_handler(conn, ws, first, second, orientation, event);
 }
+#endif
 
 int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_event_t *event) {
-        DLOG("Button %d pressed\n", event->state);
-        /* This was either a focus for a client’s parent (= titlebar)… */
-        Client *client = table_get(&by_child, event->event);
+        Con *con;
+        LOG("Button %d pressed\n", event->state);
+
+        con = con_by_window_id(event->event);
         bool border_click = false;
-        if (client == NULL) {
-                client = table_get(&by_parent, event->event);
+        if (con == NULL) {
+                con = con_by_frame_id(event->event);
                 border_click = true;
         }
+        //if (con && con->type == CT_FLOATING_CON)
+                //con = TAILQ_FIRST(&(con->nodes_head));
+
         /* See if this was a click with the configured modifier. If so, we need
          * to move around the client if it was floating. if not, we just process
          * as usual. */
-        if (config.floating_modifier != 0 &&
-            (event->state & config.floating_modifier) != 0) {
-                if (client == NULL) {
-                        DLOG("Not handling, floating_modifier was pressed and no client found\n");
+        //if (config.floating_modifier != 0 &&
+            //(event->state & config.floating_modifier) == config.floating_modifier) {
+                if (con == NULL) {
+                        LOG("Not handling, floating_modifier was pressed and no client found\n");
                         return 1;
                 }
-                if (client->fullscreen) {
-                        DLOG("Not handling, client is in fullscreen mode\n");
+#if 0
+                if (con->fullscreen) {
+                        LOG("Not handling, client is in fullscreen mode\n");
                         return 1;
                 }
-                if (client_is_floating(client)) {
-                        DLOG("button %d pressed\n", event->detail);
+#endif
+                if (con->type == CT_FLOATING_CON) {
+                        LOG("button %d pressed\n", event->detail);
                         if (event->detail == 1) {
-                                DLOG("left mouse button, dragging\n");
-                                floating_drag_window(conn, client, event);
-                        } else if (event->detail == 3) {
+                                LOG("left mouse button, dragging\n");
+                                floating_drag_window(con, event);
+                        } 
+#if 0
+                        else if (event->detail == 3) {
+                                bool proportional = (event->state & BIND_SHIFT);
                                 DLOG("right mouse button\n");
-                                floating_resize_window(conn, client, event);
+                                floating_resize_window(conn, client, proportional, event);
                         }
+#endif
                         return 1;
                 }
 
+#if 0
                 if (!floating_mod_on_tiled_client(conn, client, event)) {
                         xcb_allow_events(conn, XCB_ALLOW_REPLAY_POINTER, event->time);
                         xcb_flush(conn);
                 }
+#endif
 
                 return 1;
-        }
+        //}
 
+#if 0
         if (client == NULL) {
                 /* The client was neither on a client’s titlebar nor on a client itself, maybe on a stack_window? */
                 if (button_press_stackwin(conn, event))
@@ -377,7 +375,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
         } else if (event->event_y >= (client->rect.height - 2)) {
                 /* …bottom border */
                 first = con->row + (con->rowspan - 1);
-                if (!cell_exists(con->col, first) ||
+                if (!cell_exists(ws, con->col, first) ||
                     (first == (ws->rows-1)))
                         return 1;
 
@@ -395,7 +393,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
                 first = con->col + (con->colspan - 1);
                 DLOG("column %d\n", first);
 
-                if (!cell_exists(first, con->row) ||
+                if (!cell_exists(ws, first, con->row) ||
                     (first == (ws->cols-1)))
                         return 1;
 
@@ -403,4 +401,5 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
         }
 
         return resize_graphical_handler(conn, ws, first, second, orientation, event);
+#endif
 }