summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-04-05 17:22:01 +0000
committerDana Jansens <danakj@orodu.net>2003-04-05 17:22:01 +0000
commitbca8082d6d09a16a116c70001469a576b93157ce (patch)
tree2e8c8bd22e8a1d5cdbdf3c4c20c7b5b78a4cf935
parent831db744f4c023bd0478631a6050c394497bb2ea (diff)
use a context enum instead of quarks
-rw-r--r--engines/engineinterface.h2
-rw-r--r--engines/openbox/obengine.c53
-rw-r--r--openbox/frame.c35
-rw-r--r--openbox/frame.h22
4 files changed, 77 insertions, 35 deletions
diff --git a/engines/engineinterface.h b/engines/engineinterface.h
index 5b9ec847..fd77ca29 100644
--- a/engines/engineinterface.h
+++ b/engines/engineinterface.h
@@ -46,6 +46,6 @@ typedef void EngineFrameShow(Frame *self);
typedef void EngineFrameHide(Frame *self);
/* get_context */
-typedef GQuark EngineGetContext(Client *client, Window win);
+typedef Context EngineGetContext(Client *client, Window win);
#endif
diff --git a/engines/openbox/obengine.c b/engines/openbox/obengine.c
index f98bb36c..4dda711e 100644
--- a/engines/openbox/obengine.c
+++ b/engines/openbox/obengine.c
@@ -92,21 +92,6 @@ gboolean startup()
{
char *path;
- g_quark_from_string("none");
- g_quark_from_string("root");
- g_quark_from_string("client");
- g_quark_from_string("titlebar");
- g_quark_from_string("handle");
- g_quark_from_string("frame");
- g_quark_from_string("blcorner");
- g_quark_from_string("brcorner");
- g_quark_from_string("maximize");
- g_quark_from_string("alldesktops");
- g_quark_from_string("shade");
- g_quark_from_string("iconify");
- g_quark_from_string("icon");
- g_quark_from_string("close");
-
/* create the ~/.openbox/themes/openbox dir */
path = g_build_filename(g_get_home_dir(), ".openbox", "themes", "openbox",
NULL);
@@ -861,28 +846,28 @@ static void mouse_event(const ObEvent *e, ObFrame *self)
}
}
-GQuark get_context(Client *client, Window win)
+Context get_context(Client *client, Window win)
{
ObFrame *self;
- if (win == ob_root) return g_quark_try_string("root");
- if (client == NULL) return g_quark_try_string("none");
- if (win == client->window) return g_quark_try_string("client");
+ if (win == ob_root) return Context_Root;
+ if (client == NULL) return Context_None;
+ if (win == client->window) return Context_Client;
self = (ObFrame*) client->frame;
- if (win == self->frame.window) return g_quark_try_string("frame");
- if (win == self->frame.plate) return g_quark_try_string("client");
- if (win == self->title) return g_quark_try_string("titlebar");
- if (win == self->label) return g_quark_try_string("titlebar");
- if (win == self->handle) return g_quark_try_string("handle");
- if (win == self->lgrip) return g_quark_try_string("blcorner");
- if (win == self->rgrip) return g_quark_try_string("brcorner");
- if (win == self->max) return g_quark_try_string("maximize");
- if (win == self->iconify) return g_quark_try_string("iconify");
- if (win == self->close) return g_quark_try_string("close");
- if (win == self->icon) return g_quark_try_string("icon");
- if (win == self->desk) return g_quark_try_string("alldesktops");
- if (win == self->shade) return g_quark_try_string("shade");
-
- return g_quark_try_string("none");
+ if (win == self->frame.window) return Context_Frame;
+ if (win == self->frame.plate) return Context_Client;
+ if (win == self->title) return Context_Titlebar;
+ if (win == self->label) return Context_Titlebar;
+ if (win == self->handle) return Context_Handle;
+ if (win == self->lgrip) return Context_BLCorner;
+ if (win == self->rgrip) return Context_BRCorner;
+ if (win == self->max) return Context_Maximize;
+ if (win == self->iconify) return Context_Iconify;
+ if (win == self->close) return Context_Close;
+ if (win == self->icon) return Context_Icon;
+ if (win == self->desk) return Context_AllDesktops;
+ if (win == self->shade) return Context_Shade;
+
+ return Context_None;
}
diff --git a/openbox/frame.c b/openbox/frame.c
index 2976ca2f..2064f304 100644
--- a/openbox/frame.c
+++ b/openbox/frame.c
@@ -1,5 +1,40 @@
#include "frame.h"
+Context frame_context_from_string(char *name)
+{
+ if (!g_ascii_strcasecmp("root", name))
+ return Context_Root;
+ else if (!g_ascii_strcasecmp("client", name))
+ return Context_Client;
+ else if (!g_ascii_strcasecmp("titlebar", name))
+ return Context_Titlebar;
+ else if (!g_ascii_strcasecmp("handle", name))
+ return Context_Handle;
+ else if (!g_ascii_strcasecmp("frame", name))
+ return Context_Frame;
+ else if (!g_ascii_strcasecmp("blcorner", name))
+ return Context_BLCorner;
+ else if (!g_ascii_strcasecmp("tlcorner", name))
+ return Context_TLCorner;
+ else if (!g_ascii_strcasecmp("brcorner", name))
+ return Context_BRCorner;
+ else if (!g_ascii_strcasecmp("trcorner", name))
+ return Context_TRCorner;
+ else if (!g_ascii_strcasecmp("maximize", name))
+ return Context_Maximize;
+ else if (!g_ascii_strcasecmp("alldesktops", name))
+ return Context_AllDesktops;
+ else if (!g_ascii_strcasecmp("shade", name))
+ return Context_Shade;
+ else if (!g_ascii_strcasecmp("iconify", name))
+ return Context_Iconify;
+ else if (!g_ascii_strcasecmp("icon", name))
+ return Context_Icon;
+ else if (!g_ascii_strcasecmp("close", name))
+ return Context_Close;
+ return Context_None;
+}
+
void frame_client_gravity(Frame *self, int *x, int *y)
{
/* horizontal */
diff --git a/openbox/frame.h b/openbox/frame.h
index ec530934..fb492d8c 100644
--- a/openbox/frame.h
+++ b/openbox/frame.h
@@ -4,6 +4,28 @@
#include "geom.h"
#include "client.h"
+typedef enum {
+ Context_None,
+ Context_Root,
+ Context_Client,
+ Context_Titlebar,
+ Context_Handle,
+ Context_Frame,
+ Context_BLCorner,
+ Context_BRCorner,
+ Context_TLCorner,
+ Context_TRCorner,
+ Context_Maximize,
+ Context_AllDesktops,
+ Context_Shade,
+ Context_Iconify,
+ Context_Icon,
+ Context_Close,
+ NUM_CONTEXTS
+} Context;
+
+Context frame_context_from_string(char *name);
+
typedef struct Frame {
Client *client;