]> Pileus Git - wmpus/commitdiff
Move common types to a separate file
authorAndy Spencer <andy753421@gmail.com>
Mon, 6 Apr 2015 23:57:58 +0000 (23:57 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 15 Apr 2015 19:49:30 +0000 (19:49 +0000)
main.c
sys-win32.c
sys-x11.c
sys.h
types.h [new file with mode: 0644]
wm-mono.c
wm-tags.c
wm-wmii.c

diff --git a/main.c b/main.c
index 8ac32d046400835286ea866adb6a1ffffd3d51b1..f512b248712e4e0f535611daed28426e7693797b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -19,6 +19,7 @@
 
 #include "util.h"
 #include "conf.h"
+#include "types.h"
 #include "sys.h"
 #include "wm.h"
 
index 012a0177eb929221d0cc025620d9a2778789b03f..96d0f20212091ff25eb79a673fe11ace5a56b85a 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "util.h"
 #include "conf.h"
+#include "types.h"
 #include "sys.h"
 #include "wm.h"
 
index 7f17292bf752438714c1b4703dbb2016b82c2583..2f0087fc48a7a29d74da76fb4446688e54780f50 100644 (file)
--- a/sys-x11.c
+++ b/sys-x11.c
@@ -26,6 +26,7 @@
 
 #include "util.h"
 #include "conf.h"
+#include "types.h"
 #include "sys.h"
 #include "wm.h"
 
diff --git a/sys.h b/sys.h
index adc0247590c6470b74e1769607542d492b1dd748..5dc237440d2edcee874c23068cbbe5a699b90011 100644 (file)
--- a/sys.h
+++ b/sys.h
  * The sys also provides the API used by the wm to position
  * and control windows. */
 
-
-/* Window states */
-typedef enum {
-       ST_HIDE,  // completely hidden
-       ST_SHOW,  // show as regular window
-       ST_FULL,  // fullscreen (without decorations)
-       ST_MAX,   // maximized (with decorations)
-       ST_SHADE, // show titlebar only
-       ST_ICON,  // iconified/minimized
-       ST_CLOSE, // close the window
-} state_t;
-
-/* Window types */
-typedef enum {
-       TYPE_NORMAL,
-       TYPE_DIALOG,
-       TYPE_TOOLBAR,
-} type_t;
-
-/* Basic window type */
-typedef struct win_sys win_sys_t;
-typedef struct win_wm  win_wm_t;
-typedef struct win {
-       int x, y, z;
-       int w, h;
-       state_t state;
-       type_t  type;
-       struct win *parent;
-       win_sys_t  *sys;
-       win_wm_t   *wm;
-} win_t;
-
-/* Generic key codes, also used for some other events
- * Keys map to their Unicode value */
-typedef int event_t;
-enum {
-       EV_ALERT       = '\a',
-       EV_BACKSPACE   = '\b',
-       EV_FORMFEED    = '\f',
-       EV_NEWLINE     = '\n',
-       EV_RETURN      = '\r',
-       EV_TAB         = '\t',
-       EV_VTAB        = '\v',
-       EV_SINGLEQUOTE = '\'',
-       EV_DOUBLEQUOTE = '\"',
-       EV_BACKSLASH   = '\\',
-       EV_QUESTION    = '\?',
-       EV_NONE        = 0xF0000, // unused Unicode space
-       EV_MOUSE0, EV_MOUSE1, EV_MOUSE2, EV_MOUSE3,
-       EV_MOUSE4, EV_MOUSE5, EV_MOUSE6, EV_MOUSE7,
-       EV_LEFT, EV_RIGHT, EV_UP,     EV_DOWN,
-       EV_HOME, EV_END,   EV_PAGEUP, EV_PAGEDOWN,
-       EV_F1, EV_F2,  EV_F3,  EV_F4,
-       EV_F5, EV_F6,  EV_F7,  EV_F8,
-       EV_F9, EV_F10, EV_F11, EV_F12,
-       EV_ALT, EV_CTRL, EV_SHIFT, EV_WIN,
-       EV_ENTER, EV_LEAVE, EV_FOCUS, EV_UNFOCUS,
-};
-
-/* Key modifiers, up is for button release */
-typedef struct {
-       unsigned char alt   : 1;
-       unsigned char ctrl  : 1;
-       unsigned char shift : 1;
-       unsigned char win   : 1;
-       unsigned char up    : 1;
-} mod_t;
-#define MOD(...)     ((mod_t){__VA_ARGS__})
-#define mod2int(mod) (*((unsigned char*)&(mod)))
-
-/* Mouse movement */
-typedef struct {
-       int  x,  y;
-       int rx, ry;
-} ptr_t;
-#define PTR(...) ((ptr_t){__VA_ARGS__})
-
-
 /* Move the window to the specified location and set it's
  * geometry. The position and size include borders and
  * window decorations. */
diff --git a/types.h b/types.h
new file mode 100644 (file)
index 0000000..033d010
--- /dev/null
+++ b/types.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015 Andy Spencer <andy753421@gmail.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ */
+
+/* Forward definitions for sys and wm */
+typedef struct win_sys win_sys_t;
+typedef struct win_wm  win_wm_t;
+
+/* Window states */
+typedef enum {
+       ST_HIDE,  // completely hidden
+       ST_SHOW,  // show as regular window
+       ST_FULL,  // fullscreen (without decorations)
+       ST_MAX,   // maximized (with decorations)
+       ST_SHADE, // show titlebar only
+       ST_ICON,  // iconified/minimized
+       ST_CLOSE, // close the window
+} state_t;
+
+/* Window types */
+typedef enum {
+       TYPE_NORMAL,
+       TYPE_DIALOG,
+       TYPE_TOOLBAR,
+} type_t;
+
+/* Basic window type */
+typedef struct win {
+       int x, y, z;
+       int w, h;
+       state_t state;
+       type_t  type;
+       struct win *parent;
+       win_sys_t  *sys;
+       win_wm_t   *wm;
+} win_t;
+
+/* Generic key codes, also used for some other events
+ * Keys map to their Unicode value */
+typedef int event_t;
+enum {
+       EV_ALERT       = '\a',
+       EV_BACKSPACE   = '\b',
+       EV_FORMFEED    = '\f',
+       EV_NEWLINE     = '\n',
+       EV_RETURN      = '\r',
+       EV_TAB         = '\t',
+       EV_VTAB        = '\v',
+       EV_SINGLEQUOTE = '\'',
+       EV_DOUBLEQUOTE = '\"',
+       EV_BACKSLASH   = '\\',
+       EV_QUESTION    = '\?',
+       EV_NONE        = 0xF0000, // unused Unicode space
+       EV_MOUSE0, EV_MOUSE1, EV_MOUSE2, EV_MOUSE3,
+       EV_MOUSE4, EV_MOUSE5, EV_MOUSE6, EV_MOUSE7,
+       EV_LEFT, EV_RIGHT, EV_UP,     EV_DOWN,
+       EV_HOME, EV_END,   EV_PAGEUP, EV_PAGEDOWN,
+       EV_F1, EV_F2,  EV_F3,  EV_F4,
+       EV_F5, EV_F6,  EV_F7,  EV_F8,
+       EV_F9, EV_F10, EV_F11, EV_F12,
+       EV_ALT, EV_CTRL, EV_SHIFT, EV_WIN,
+       EV_ENTER, EV_LEAVE, EV_FOCUS, EV_UNFOCUS,
+};
+
+/* Key modifiers, up is for button release */
+typedef struct {
+       unsigned char alt   : 1;
+       unsigned char ctrl  : 1;
+       unsigned char shift : 1;
+       unsigned char win   : 1;
+       unsigned char up    : 1;
+} mod_t;
+
+/* Mouse movement */
+typedef struct {
+       int  x,  y;
+       int rx, ry;
+} ptr_t;
+
+/* Creation functions */
+#define MOD(...) ((mod_t){__VA_ARGS__})
+#define PTR(...) ((ptr_t){__VA_ARGS__})
+
+/* Conversion functions */
+#define mod2int(mod) (*((unsigned char*)&(mod)))
index fb52c8836e1bce2e55961c5a0dd79895b6a09c24..4cce15564c9872771bb2b890dd30a58bd845dd8d 100644 (file)
--- a/wm-mono.c
+++ b/wm-mono.c
@@ -18,6 +18,7 @@
 #include <stdio.h>
 
 #include "util.h"
+#include "types.h"
 #include "sys.h"
 #include "wm.h"
 
index a8756f43858e6c9e5b569116ea091ff975157e04..ed3ea79d2c5d09693372dbdefdd9c6669e7e3457 100644 (file)
--- a/wm-tags.c
+++ b/wm-tags.c
@@ -18,6 +18,7 @@
 #include <stdio.h>
 
 #include "util.h"
+#include "types.h"
 #include "sys.h"
 #include "wm.h"
 
index b5b09806a893752353cb4a0880fdaf79645dca33..b8c6d3d213c419c3206d1e40f5ae7fe3cb98ad4b 100644 (file)
--- a/wm-wmii.c
+++ b/wm-wmii.c
@@ -19,6 +19,7 @@
 
 #include "util.h"
 #include "conf.h"
+#include "types.h"
 #include "sys.h"
 #include "wm.h"