WIP version 1 of edges thinger
authorMikael Magnusson <mikachu@comhem.se>
Wed, 5 Sep 2007 01:54:24 +0000 (03:54 +0200)
committerMikael Magnusson <mikachu@comhem.se>
Sat, 8 Mar 2008 16:21:12 +0000 (17:21 +0100)
This is meant to eventually let you do things like trigger actions on
press or hover or whatever on screen edges/corners. Right now it just
maps the windows and does nothing with them.

Makefile.am
openbox/edges.c [new file with mode: 0644]
openbox/edges.h [new file with mode: 0644]
openbox/openbox.c

index 00d7998ae91a169d967d20d4d0bd2573784ebde8..f0fa240ddef506d3fb06d95fefd93e5c35a5291c 100644 (file)
@@ -225,6 +225,8 @@ openbox_openbox_SOURCES = \
        openbox/debug.h \
        openbox/dock.c \
        openbox/dock.h \
+       openbox/edges.c \
+       openbox/edges.h \
        openbox/event.c \
        openbox/event.h \
        openbox/focus.c \
diff --git a/openbox/edges.c b/openbox/edges.c
new file mode 100644 (file)
index 0000000..259d1bf
--- /dev/null
@@ -0,0 +1,105 @@
+#include "openbox.h"
+#include "config.h"
+#include "screen.h"
+#include "edges.h"
+
+#include <X11/Xlib.h>
+#include <glib.h>
+
+#warning Do something clever with xinerama
+Window edge[OB_NUM_EDGES];
+#warning put in config.c and parse configs of course
+gboolean config_edge_enabled[OB_NUM_EDGES] = {1, 1, 1, 1, 1, 1, 1, 1};
+
+#define EDGE_WIDTH 10
+#define CORNER_SIZE 20
+static void get_position(ObEdge edge, Rect screen, Rect *rect)
+{
+    switch (edge) {
+        case OB_EDGE_TOP:
+            rect->x = CORNER_SIZE;
+            rect->y = 0;
+            rect->width = screen.width - 2 * CORNER_SIZE;
+            rect->height = EDGE_WIDTH;
+            break;
+        case OB_EDGE_TOPRIGHT:
+            rect->x = screen.width - CORNER_SIZE;
+            rect->y = 0;
+            rect->width = CORNER_SIZE;
+            rect->height = CORNER_SIZE;
+            break;
+        case OB_EDGE_RIGHT:
+            rect->x = screen.width - EDGE_WIDTH;
+            rect->y = CORNER_SIZE;
+            rect->width = EDGE_WIDTH;
+            rect->height = screen.height - 2 * CORNER_SIZE;
+            break;
+        case OB_EDGE_BOTTOMRIGHT:
+            rect->x = screen.width - CORNER_SIZE;
+            rect->y = screen.height - CORNER_SIZE;
+            rect->width = CORNER_SIZE;
+            rect->height = CORNER_SIZE;
+            break;
+        case OB_EDGE_BOTTOM:
+            rect->x = CORNER_SIZE;
+            rect->y = screen.height - EDGE_WIDTH;
+            rect->width = screen.width - 2 * CORNER_SIZE;
+            rect->height = EDGE_WIDTH;
+            break;
+        case OB_EDGE_BOTTOMLEFT:
+            rect->x = 0;
+            rect->y = screen.height - CORNER_SIZE;
+            rect->width = CORNER_SIZE;
+            rect->height = CORNER_SIZE;
+            break;
+        case OB_EDGE_LEFT:
+            rect->x = 0;
+            rect->y = CORNER_SIZE;
+            rect->width = EDGE_WIDTH;
+            rect->height = screen.height - CORNER_SIZE;
+            break;
+        case OB_EDGE_TOPLEFT:
+            rect->x = 0;
+            rect->y = 0;
+            rect->width = CORNER_SIZE;
+            rect->height = CORNER_SIZE;
+            break;
+    }
+}
+
+void edges_startup(gboolean reconfigure)
+{
+    gint i;
+    Rect r;
+    XSetWindowAttributes xswa;
+    Rect *screen = screen_physical_area_all_monitors();
+
+    xswa.override_redirect = True;
+
+#warning insert into window_map and make an obwindow type
+/*    g_hash_table_insert(window_map, &dock->frame, dock); */
+
+    for (i=0; i < OB_NUM_EDGES; i++) {
+        if (!config_edge_enabled[i])
+            continue;
+        get_position(i, *screen, &r);
+        edge[i] = XCreateWindow(obt_display, RootWindow(obt_display, ob_screen),
+                                r.x, r.y, r.width, r.height, 0, 0, InputOnly,
+                                CopyFromParent, CWOverrideRedirect, &xswa);
+        XMapWindow(obt_display, edge[i]);
+        printf("mapped edge window %i at %03i %03i %02i %02i\n", i, r.x, r.y, r.width, r.height);
+        fflush(stdout);
+    }
+
+    XFlush(obt_display);
+
+    g_free(screen);
+}
+
+void edges_shutdown(gboolean reconfigure)
+{
+    gint i;
+
+    for (i=0; i < OB_NUM_EDGES; i++)
+        XDestroyWindow(obt_display, edge[i]);
+}
diff --git a/openbox/edges.h b/openbox/edges.h
new file mode 100644 (file)
index 0000000..a3fe136
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __edges_h
+#define __edges_h
+
+typedef enum
+{
+    OB_EDGE_TOP,
+    OB_EDGE_TOPRIGHT,
+    OB_EDGE_RIGHT,
+    OB_EDGE_BOTTOMRIGHT,
+    OB_EDGE_BOTTOM,
+    OB_EDGE_BOTTOMLEFT,
+    OB_EDGE_LEFT,
+    OB_EDGE_TOPLEFT,
+    OB_NUM_EDGES
+} ObEdge;
+
+void edges_startup(gboolean reconfigure);
+void edges_shutdown(gboolean reconfigure);
+
+#endif
index d6e87d94802ad750ef67cd4bd37fb7be6649c97e..e917cf6c739be83850efcd3b87cbf7a46da7716f 100644 (file)
@@ -21,6 +21,7 @@
 #include "openbox.h"
 #include "session.h"
 #include "dock.h"
+#include "edges.h"
 #include "event.h"
 #include "menu.h"
 #include "client.h"
@@ -317,6 +318,7 @@ gint main(gint argc, gchar **argv)
             mouse_startup(reconfigure);
             menu_frame_startup(reconfigure);
             menu_startup(reconfigure);
+            edges_startup(reconfigure);
             prompt_startup(reconfigure);
 
             if (!reconfigure) {
@@ -382,6 +384,7 @@ gint main(gint argc, gchar **argv)
                 window_unmanage_all();
 
             prompt_shutdown(reconfigure);
+            edges_shutdown(reconfigure);
             menu_shutdown(reconfigure);
             menu_frame_shutdown(reconfigure);
             mouse_shutdown(reconfigure);