#include <glib.h>
#include <X11/Xlib.h>
-struct Frame;
+struct _ObFrame;
struct _ObGroup;
typedef struct _ObClient 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;
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;
#include "frame.h"
+#include "client.h"
#include "openbox.h"
#include "extensions.h"
#include "framerender.h"
#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()
{
}
-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;
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);
g_free(self);
}
-void frame_show(Frame *self)
+void frame_show(ObFrame *self)
{
if (!self->visible) {
self->visible = TRUE;
}
}
-void frame_hide(Frame *self)
+void frame_hide(ObFrame *self)
{
if (self->visible) {
self->visible = FALSE;
}
}
-void frame_adjust_shape(Frame *self)
+void frame_adjust_shape(ObFrame *self)
{
#ifdef SHAPE
int num;
#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;
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);
}
}
}
-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;
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;
frame_free(self);
}
-static void layout_title(Frame *self)
+static void layout_title(ObFrame *self)
{
char *lc;
int x;
}
}
-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) {
}
}
-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) {
#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;
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
#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,
}
}
-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! */
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;
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,
#include "frame.h"
-void framerender_frame(Frame *self);
+void framerender_frame(ObFrame *self);
#endif
#include "openbox.h"
#include "frame.h"
+#include "client.h"
#include "window.h"
#include "stacking.h"
#include "render/render.h"
}
/* 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;
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
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;
}
}
-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;
}
}
-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)
{
static int px, py;
gboolean click = FALSE;
gboolean dclick = FALSE;
- Context context;
+ ObFrameContext context;
switch (e->type) {
case Event_Client_Mapped:
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! */
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)
Action *action)
{
guint state, button;
- Context context;
+ ObFrameContext context;
MouseBinding *b;
GSList *it;