From 7d943a950e39d4d93113c0efc7b41916f6b8c66d Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 10 Jul 2003 07:16:19 +0000 Subject: [PATCH] prefixing and capitalization for the Frame->ObFrame struct and the Context->ObFrameContext enum and its constants. --- openbox/client.h | 4 +- openbox/event.c | 10 ++-- openbox/frame.c | 118 +++++++++++++++++++++--------------------- openbox/frame.h | 81 ++++++++++++++--------------- openbox/framerender.c | 32 ++++++------ openbox/framerender.h | 2 +- openbox/popup.c | 1 + plugins/mouse/mouse.c | 33 ++++++------ 8 files changed, 141 insertions(+), 140 deletions(-) diff --git a/openbox/client.h b/openbox/client.h index 52005fcb..9c96351e 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -10,7 +10,7 @@ #include #include -struct Frame; +struct _ObFrame; struct _ObGroup; typedef struct _ObClient ObClient; @@ -75,7 +75,7 @@ struct _ObClient Window window; /*! The window's decorations. NULL while the window is being managed! */ - struct Frame *frame; + struct _ObFrame *frame; /*! The number of unmap events to ignore on the window */ int ignore_unmaps; diff --git a/openbox/event.c b/openbox/event.c index df9cddb2..7c5ab11f 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -620,23 +620,23 @@ static void event_handle_client(ObClient *client, XEvent *e) is a waste of resources to go drawing it. */ if (!(e->xbutton.button == 4 || e->xbutton.button == 5)) { switch (frame_context(client, e->xbutton.window)) { - case Context_Maximize: + case OB_FRAME_CONTEXT_MAXIMIZE: client->frame->max_press = (e->type == ButtonPress); framerender_frame(client->frame); break; - case Context_Close: + case OB_FRAME_CONTEXT_CLOSE: client->frame->close_press = (e->type == ButtonPress); framerender_frame(client->frame); break; - case Context_Iconify: + case OB_FRAME_CONTEXT_ICONIFY: client->frame->iconify_press = (e->type == ButtonPress); framerender_frame(client->frame); break; - case Context_AllDesktops: + case OB_FRAME_CONTEXT_ALLDESKTOPS: client->frame->desk_press = (e->type == ButtonPress); framerender_frame(client->frame); break; - case Context_Shade: + case OB_FRAME_CONTEXT_SHADE: client->frame->shade_press = (e->type == ButtonPress); framerender_frame(client->frame); break; diff --git a/openbox/frame.c b/openbox/frame.c index a2335e9f..decebbce 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -1,4 +1,5 @@ #include "frame.h" +#include "client.h" #include "openbox.h" #include "extensions.h" #include "framerender.h" @@ -10,7 +11,10 @@ #define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \ ButtonMotionMask | ExposureMask) -static void layout_title(Frame *self); +#define FRAME_HANDLE_Y(f) (f->innersize.top + f->client->area.height + \ + f->cbwidth) + +static void layout_title(ObFrame *self); void frame_startup() { @@ -29,13 +33,13 @@ static Window createWindow(Window parent, unsigned long mask, } -Frame *frame_new() +ObFrame *frame_new() { XSetWindowAttributes attrib; unsigned long mask; - Frame *self; + ObFrame *self; - self = g_new(Frame, 1); + self = g_new(ObFrame, 1); self->visible = FALSE; self->decorations = 0; @@ -110,10 +114,10 @@ Frame *frame_new() self->max_press = self->close_press = self->desk_press = self->iconify_press = self->shade_press = FALSE; - return (Frame*)self; + return (ObFrame*)self; } -static void frame_free(Frame *self) +static void frame_free(ObFrame *self) { RrAppearanceFree(self->a_unfocused_title); RrAppearanceFree(self->a_focused_title); @@ -128,7 +132,7 @@ static void frame_free(Frame *self) g_free(self); } -void frame_show(Frame *self) +void frame_show(ObFrame *self) { if (!self->visible) { self->visible = TRUE; @@ -136,7 +140,7 @@ void frame_show(Frame *self) } } -void frame_hide(Frame *self) +void frame_hide(ObFrame *self) { if (self->visible) { self->visible = FALSE; @@ -145,7 +149,7 @@ void frame_hide(Frame *self) } } -void frame_adjust_shape(Frame *self) +void frame_adjust_shape(ObFrame *self) { #ifdef SHAPE int num; @@ -191,7 +195,7 @@ void frame_adjust_shape(Frame *self) #endif } -void frame_adjust_area(Frame *self, gboolean moved, gboolean resized) +void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized) { if (resized) { self->decorations = self->client->decorations; @@ -291,7 +295,7 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized) frame_client_gravity. */ self->area.x = self->client->area.x; self->area.y = self->client->area.y; - frame_client_gravity((Frame*)self, + frame_client_gravity((ObFrame*)self, &self->area.x, &self->area.y); } @@ -309,28 +313,28 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized) } } -void frame_adjust_state(Frame *self) +void frame_adjust_state(ObFrame *self) { framerender_frame(self); } -void frame_adjust_focus(Frame *self, gboolean hilite) +void frame_adjust_focus(ObFrame *self, gboolean hilite) { self->focused = hilite; framerender_frame(self); } -void frame_adjust_title(Frame *self) +void frame_adjust_title(ObFrame *self) { framerender_frame(self); } -void frame_adjust_icon(Frame *self) +void frame_adjust_icon(ObFrame *self) { framerender_frame(self); } -void frame_grab_client(Frame *self, ObClient *client) +void frame_grab_client(ObFrame *self, ObClient *client) { self->client = client; @@ -372,7 +376,7 @@ void frame_grab_client(Frame *self, ObClient *client) g_hash_table_insert(window_map, &self->rgrip, client); } -void frame_release_client(Frame *self, ObClient *client) +void frame_release_client(ObFrame *self, ObClient *client) { XEvent ev; @@ -414,7 +418,7 @@ void frame_release_client(Frame *self, ObClient *client) frame_free(self); } -static void layout_title(Frame *self) +static void layout_title(ObFrame *self) { char *lc; int x; @@ -543,68 +547,64 @@ static void layout_title(Frame *self) } } -Context frame_context_from_string(char *name) +ObFrameContext frame_context_from_string(char *name) { if (!g_ascii_strcasecmp("root", name)) - return Context_Root; + return OB_FRAME_CONTEXT_ROOT; else if (!g_ascii_strcasecmp("client", name)) - return Context_Client; + return OB_FRAME_CONTEXT_CLIENT; else if (!g_ascii_strcasecmp("titlebar", name)) - return Context_Titlebar; + return OB_FRAME_CONTEXT_TITLEBAR; else if (!g_ascii_strcasecmp("handle", name)) - return Context_Handle; + return OB_FRAME_CONTEXT_HANDLE; else if (!g_ascii_strcasecmp("frame", name)) - return Context_Frame; + return OB_FRAME_CONTEXT_FRAME; else if (!g_ascii_strcasecmp("blcorner", name)) - return Context_BLCorner; - else if (!g_ascii_strcasecmp("tlcorner", name)) - return Context_TLCorner; + return OB_FRAME_CONTEXT_BLCORNER; else if (!g_ascii_strcasecmp("brcorner", name)) - return Context_BRCorner; - else if (!g_ascii_strcasecmp("trcorner", name)) - return Context_TRCorner; + return OB_FRAME_CONTEXT_BRCORNER; else if (!g_ascii_strcasecmp("maximize", name)) - return Context_Maximize; + return OB_FRAME_CONTEXT_MAXIMIZE; else if (!g_ascii_strcasecmp("alldesktops", name)) - return Context_AllDesktops; + return OB_FRAME_CONTEXT_ALLDESKTOPS; else if (!g_ascii_strcasecmp("shade", name)) - return Context_Shade; + return OB_FRAME_CONTEXT_SHADE; else if (!g_ascii_strcasecmp("iconify", name)) - return Context_Iconify; + return OB_FRAME_CONTEXT_ICONIFY; else if (!g_ascii_strcasecmp("icon", name)) - return Context_Icon; + return OB_FRAME_CONTEXT_ICON; else if (!g_ascii_strcasecmp("close", name)) - return Context_Close; - return Context_None; + return OB_FRAME_CONTEXT_CLOSE; + return OB_FRAME_CONTEXT_NONE; } -Context frame_context(ObClient *client, Window win) +ObFrameContext frame_context(ObClient *client, Window win) { - Frame *self; + ObFrame *self; - if (win == ob_root) return Context_Root; - if (client == NULL) return Context_None; - if (win == client->window) return Context_Client; + if (win == ob_root) return OB_FRAME_CONTEXT_ROOT; + if (client == NULL) return OB_FRAME_CONTEXT_NONE; + if (win == client->window) return OB_FRAME_CONTEXT_CLIENT; self = client->frame; - if (win == self->window) return Context_Frame; - if (win == self->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; + if (win == self->window) return OB_FRAME_CONTEXT_FRAME; + if (win == self->plate) return OB_FRAME_CONTEXT_CLIENT; + if (win == self->title) return OB_FRAME_CONTEXT_TITLEBAR; + if (win == self->label) return OB_FRAME_CONTEXT_TITLEBAR; + if (win == self->handle) return OB_FRAME_CONTEXT_HANDLE; + if (win == self->lgrip) return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->rgrip) return OB_FRAME_CONTEXT_BRCORNER; + if (win == self->max) return OB_FRAME_CONTEXT_MAXIMIZE; + if (win == self->iconify)return OB_FRAME_CONTEXT_ICONIFY; + if (win == self->close) return OB_FRAME_CONTEXT_CLOSE; + if (win == self->icon) return OB_FRAME_CONTEXT_ICON; + if (win == self->desk) return OB_FRAME_CONTEXT_ALLDESKTOPS; + if (win == self->shade) return OB_FRAME_CONTEXT_SHADE; + + return OB_FRAME_CONTEXT_NONE; } -void frame_client_gravity(Frame *self, int *x, int *y) +void frame_client_gravity(ObFrame *self, int *x, int *y) { /* horizontal */ switch (self->client->gravity) { @@ -659,7 +659,7 @@ void frame_client_gravity(Frame *self, int *x, int *y) } } -void frame_frame_gravity(Frame *self, int *x, int *y) +void frame_frame_gravity(ObFrame *self, int *x, int *y) { /* horizontal */ switch (self->client->gravity) { diff --git a/openbox/frame.h b/openbox/frame.h index f36522fe..4f117fae 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -2,34 +2,33 @@ #define __frame_h #include "geom.h" -#include "client.h" #include "render/render.h" +typedef struct _ObFrame ObFrame; + +struct _ObClient; + 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; - -#define FRAME_HANDLE_Y(f) (f->innersize.top + f->client->area.height + \ - f->cbwidth) - -typedef struct Frame { - ObClient *client; + OB_FRAME_CONTEXT_NONE, + OB_FRAME_CONTEXT_ROOT, + OB_FRAME_CONTEXT_CLIENT, + OB_FRAME_CONTEXT_TITLEBAR, + OB_FRAME_CONTEXT_HANDLE, + OB_FRAME_CONTEXT_FRAME, + OB_FRAME_CONTEXT_BLCORNER, + OB_FRAME_CONTEXT_BRCORNER, + OB_FRAME_CONTEXT_MAXIMIZE, + OB_FRAME_CONTEXT_ALLDESKTOPS, + OB_FRAME_CONTEXT_SHADE, + OB_FRAME_CONTEXT_ICONIFY, + OB_FRAME_CONTEXT_ICON, + OB_FRAME_CONTEXT_CLOSE, + OB_FRAME_NUM_CONTEXTS +} ObFrameContext; + +struct _ObFrame +{ + struct _ObClient *client; Window window; Window plate; @@ -82,38 +81,38 @@ typedef struct Frame { gboolean iconify_press; gboolean focused; -} Frame; +}; void frame_startup(); void frame_shutdown(); -Frame *frame_new(); -void frame_show(Frame *self); -void frame_hide(Frame *self); -void frame_adjust_shape(Frame *self); -void frame_adjust_area(Frame *self, gboolean moved, gboolean resized); -void frame_adjust_state(Frame *self); -void frame_adjust_focus(Frame *self, gboolean hilite); -void frame_adjust_title(Frame *self); -void frame_adjust_icon(Frame *self); -void frame_grab_client(Frame *self, ObClient *client); -void frame_release_client(Frame *self, ObClient *client); +ObFrame *frame_new(); +void frame_show(ObFrame *self); +void frame_hide(ObFrame *self); +void frame_adjust_shape(ObFrame *self); +void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized); +void frame_adjust_state(ObFrame *self); +void frame_adjust_focus(ObFrame *self, gboolean hilite); +void frame_adjust_title(ObFrame *self); +void frame_adjust_icon(ObFrame *self); +void frame_grab_client(ObFrame *self, struct _ObClient *client); +void frame_release_client(ObFrame *self, struct _ObClient *client); -Context frame_context_from_string(char *name); +ObFrameContext frame_context_from_string(char *name); -Context frame_context(ObClient *self, Window win); +ObFrameContext frame_context(struct _ObClient *self, Window win); /*! Applies gravity to the client's position to find where the frame should be positioned. @return The proper coordinates for the frame, based on the client. */ -void frame_client_gravity(Frame *self, int *x, int *y); +void frame_client_gravity(ObFrame *self, int *x, int *y); /*! Reversly applies gravity to the frame's position to find where the client should be positioned. @return The proper coordinates for the client, based on the frame. */ -void frame_frame_gravity(Frame *self, int *x, int *y); +void frame_frame_gravity(ObFrame *self, int *x, int *y); #endif diff --git a/openbox/framerender.c b/openbox/framerender.c index 2769bbeb..ec69c983 100644 --- a/openbox/framerender.c +++ b/openbox/framerender.c @@ -4,15 +4,15 @@ #include "framerender.h" #include "render/theme.h" -static void framerender_label(Frame *self, RrAppearance *a); -static void framerender_icon(Frame *self, RrAppearance *a); -static void framerender_max(Frame *self, RrAppearance *a); -static void framerender_iconify(Frame *self, RrAppearance *a); -static void framerender_desk(Frame *self, RrAppearance *a); -static void framerender_shade(Frame *self, RrAppearance *a); -static void framerender_close(Frame *self, RrAppearance *a); - -void framerender_frame(Frame *self) +static void framerender_label(ObFrame *self, RrAppearance *a); +static void framerender_icon(ObFrame *self, RrAppearance *a); +static void framerender_max(ObFrame *self, RrAppearance *a); +static void framerender_iconify(ObFrame *self, RrAppearance *a); +static void framerender_desk(ObFrame *self, RrAppearance *a); +static void framerender_shade(ObFrame *self, RrAppearance *a); +static void framerender_close(ObFrame *self, RrAppearance *a); + +void framerender_frame(ObFrame *self) { if (self->focused) XSetWindowBorder(ob_display, self->plate, @@ -145,7 +145,7 @@ void framerender_frame(Frame *self) } } -static void framerender_label(Frame *self, RrAppearance *a) +static void framerender_label(ObFrame *self, RrAppearance *a) { if (self->label_x < 0) return; /* set the texture's text! */ @@ -153,7 +153,7 @@ static void framerender_label(Frame *self, RrAppearance *a) RrPaint(a, self->label, self->label_width, ob_rr_theme->label_height); } -static void framerender_icon(Frame *self, RrAppearance *a) +static void framerender_icon(ObFrame *self, RrAppearance *a) { if (self->icon_x < 0) return; @@ -172,33 +172,33 @@ static void framerender_icon(Frame *self, RrAppearance *a) ob_rr_theme->button_size + 2, ob_rr_theme->button_size + 2); } -static void framerender_max(Frame *self, RrAppearance *a) +static void framerender_max(ObFrame *self, RrAppearance *a) { if (self->max_x < 0) return; RrPaint(a, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size); } -static void framerender_iconify(Frame *self, RrAppearance *a) +static void framerender_iconify(ObFrame *self, RrAppearance *a) { if (self->iconify_x < 0) return; RrPaint(a, self->iconify, ob_rr_theme->button_size, ob_rr_theme->button_size); } -static void framerender_desk(Frame *self, RrAppearance *a) +static void framerender_desk(ObFrame *self, RrAppearance *a) { if (self->desk_x < 0) return; RrPaint(a, self->desk, ob_rr_theme->button_size, ob_rr_theme->button_size); } -static void framerender_shade(Frame *self, RrAppearance *a) +static void framerender_shade(ObFrame *self, RrAppearance *a) { if (self->shade_x < 0) return; RrPaint(a, self->shade, ob_rr_theme->button_size, ob_rr_theme->button_size); } -static void framerender_close(Frame *self, RrAppearance *a) +static void framerender_close(ObFrame *self, RrAppearance *a) { if (self->close_x < 0) return; RrPaint(a, self->close, diff --git a/openbox/framerender.h b/openbox/framerender.h index 9655a932..1aee9027 100644 --- a/openbox/framerender.h +++ b/openbox/framerender.h @@ -3,6 +3,6 @@ #include "frame.h" -void framerender_frame(Frame *self); +void framerender_frame(ObFrame *self); #endif diff --git a/openbox/popup.c b/openbox/popup.c index be0057b2..769b942c 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -1,5 +1,6 @@ #include "openbox.h" #include "frame.h" +#include "client.h" #include "window.h" #include "stacking.h" #include "render/render.h" diff --git a/plugins/mouse/mouse.c b/plugins/mouse/mouse.c index 4ed7b9dd..91ff7c4b 100644 --- a/plugins/mouse/mouse.c +++ b/plugins/mouse/mouse.c @@ -102,14 +102,14 @@ void plugin_setup_config() } /* Array of GSList*s of PointerBinding*s. */ -static GSList *bound_contexts[NUM_CONTEXTS]; +static GSList *bound_contexts[OB_FRAME_NUM_CONTEXTS]; static void grab_for_client(ObClient *client, gboolean grab) { int i; GSList *it; - for (i = 0; i < NUM_CONTEXTS; ++i) + for (i = 0; i < OB_FRAME_NUM_CONTEXTS; ++i) for (it = bound_contexts[i]; it != NULL; it = it->next) { /* grab/ungrab the button */ MouseBinding *b = it->data; @@ -117,11 +117,11 @@ static void grab_for_client(ObClient *client, gboolean grab) int mode; unsigned int mask; - if (i == Context_Frame) { + if (i == OB_FRAME_CONTEXT_FRAME) { win = client->frame->window; mode = GrabModeAsync; mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask; - } else if (i == Context_Client) { + } else if (i == OB_FRAME_CONTEXT_CLIENT) { win = client->frame->plate; mode = GrabModeSync; /* this is handled in event */ mask = ButtonPressMask; /* can't catch more than this with Sync @@ -149,7 +149,7 @@ static void clearall() int i; GSList *it; - for(i = 0; i < NUM_CONTEXTS; ++i) { + for(i = 0; i < OB_FRAME_NUM_CONTEXTS; ++i) { for (it = bound_contexts[i]; it != NULL; it = it->next) { int j; @@ -167,7 +167,8 @@ static void clearall() } } -static void fire_button(MouseAction a, Context context, ObClient *c, guint state, +static void fire_button(MouseAction a, ObFrameContext context, + ObClient *c, guint state, guint button, int x, int y) { GSList *it; @@ -198,7 +199,7 @@ static void fire_button(MouseAction a, Context context, ObClient *c, guint state } } -static void fire_motion(MouseAction a, Context context, ObClient *c, +static void fire_motion(MouseAction a, ObFrameContext context, ObClient *c, guint state, guint button, int x_root, int y_root, guint32 corner) { @@ -259,7 +260,7 @@ static void event(ObEvent *e, void *foo) static int px, py; gboolean click = FALSE; gboolean dclick = FALSE; - Context context; + ObFrameContext context; switch (e->type) { case Event_Client_Mapped: @@ -284,7 +285,7 @@ static void event(ObEvent *e, void *foo) e->data.x.e->xbutton.button, e->data.x.e->xbutton.x_root, e->data.x.e->xbutton.y_root); - if (context == Context_Client) { + if (context == OB_FRAME_CONTEXT_CLIENT) { /* Replay the event, so it goes to the client*/ XAllowEvents(ob_display, ReplayPointer, event_lasttime); /* Fall through to the release case! */ @@ -348,12 +349,12 @@ static void event(ObEvent *e, void *foo) e->data.x.e->xmotion.window); /* You can't drag on buttons */ - if (context == Context_Maximize || - context == Context_AllDesktops || - context == Context_Shade || - context == Context_Iconify || - context == Context_Icon || - context == Context_Close) + if (context == OB_FRAME_CONTEXT_MAXIMIZE || + context == OB_FRAME_CONTEXT_ALLDESKTOPS || + context == OB_FRAME_CONTEXT_SHADE || + context == OB_FRAME_CONTEXT_ICONIFY || + context == OB_FRAME_CONTEXT_ICON || + context == OB_FRAME_CONTEXT_CLOSE) break; if (!e->data.x.client) @@ -393,7 +394,7 @@ gboolean mbind(char *buttonstr, char *contextstr, MouseAction mact, Action *action) { guint state, button; - Context context; + ObFrameContext context; MouseBinding *b; GSList *it; -- 2.45.2