support parent relative titlebar elements

This commit is contained in:
Dana Jansens 2003-03-27 23:33:07 +00:00
parent 6b52a86dc6
commit d54b8724e7

View file

@ -122,12 +122,12 @@ typedef struct ObFrame {
static void layout_title(ObFrame *self); static void layout_title(ObFrame *self);
static void render(ObFrame *self); static void render(ObFrame *self);
static void render_label(ObFrame *self); static void render_label(ObFrame *self, Appearance *a);
static void render_max(ObFrame *self); static void render_max(ObFrame *self, Appearance *a);
static void render_icon(ObFrame *self); static void render_icon(ObFrame *self, Appearance *a);
static void render_iconify(ObFrame *self); static void render_iconify(ObFrame *self, Appearance *a);
static void render_desk(ObFrame *self); static void render_desk(ObFrame *self, Appearance *a);
static void render_close(ObFrame *self); static void render_close(ObFrame *self, Appearance *a);
static void frame_mouse_press(const ObEvent *e, ObFrame *self); static void frame_mouse_press(const ObEvent *e, ObFrame *self);
static void frame_mouse_release(const ObEvent *e, ObFrame *self); static void frame_mouse_release(const ObEvent *e, ObFrame *self);
@ -522,8 +522,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized)
void frame_adjust_state(ObFrame *self) void frame_adjust_state(ObFrame *self)
{ {
render_max(self); render(self);
render_desk(self);
} }
void frame_adjust_focus(ObFrame *self) void frame_adjust_focus(ObFrame *self)
@ -533,12 +532,12 @@ void frame_adjust_focus(ObFrame *self)
void frame_adjust_title(ObFrame *self) void frame_adjust_title(ObFrame *self)
{ {
render_label(self); render(self);
} }
void frame_adjust_icon(ObFrame *self) void frame_adjust_icon(ObFrame *self)
{ {
render_icon(self); render(self);
} }
void frame_grab_client(ObFrame *self, Client *client) void frame_grab_client(ObFrame *self, Client *client)
@ -739,16 +738,69 @@ static void render(ObFrame *self)
} }
if (self->frame.client->decorations & Decor_Titlebar) { if (self->frame.client->decorations & Decor_Titlebar) {
paint(self->title, (client_focused(self->frame.client) ? Appearance *t, *l, *m, *n, *i, *d, *c;
self->a_focused_title :
self->a_unfocused_title), t = (client_focused(self->frame.client) ?
0, 0, self->width, TITLE_HEIGHT); self->a_focused_title : self->a_unfocused_title);
render_label(self); l = (client_focused(self->frame.client) ?
render_max(self); self->a_focused_label : self->a_unfocused_label);
render_icon(self); m = (client_focused(self->frame.client) ?
render_iconify(self); ((self->max_press ||
render_desk(self); self->frame.client->max_vert || self->frame.client->max_horz) ?
render_close(self); a_focused_pressed_max : a_focused_unpressed_max) :
((self->max_press ||
self->frame.client->max_vert || self->frame.client->max_horz) ?
a_unfocused_pressed_max : a_unfocused_unpressed_max));
n = self->a_icon;
i = (client_focused(self->frame.client) ?
(self->iconify_press ?
a_focused_pressed_iconify : a_focused_unpressed_iconify) :
(self->iconify_press ?
a_unfocused_pressed_iconify : a_unfocused_unpressed_iconify));
d = (client_focused(self->frame.client) ?
(self->desk_press || self->frame.client->desktop == DESKTOP_ALL ?
a_focused_pressed_desk : a_focused_unpressed_desk) :
(self->desk_press || self->frame.client->desktop == DESKTOP_ALL ?
a_unfocused_pressed_desk : a_unfocused_unpressed_desk));
c = (client_focused(self->frame.client) ?
(self->close_press ?
a_focused_pressed_close : a_focused_unpressed_close) :
(self->close_press ?
a_unfocused_pressed_close : a_unfocused_unpressed_close));
paint(self->title, t, 0, 0, self->width, TITLE_HEIGHT);
/* set parents for any parent relative guys */
l->surface.data.planar.parent = t;
l->surface.data.planar.parentx = self->label_x;
l->surface.data.planar.parenty = s_bevel;
m->surface.data.planar.parent = t;
m->surface.data.planar.parentx = self->max_x;
m->surface.data.planar.parenty = s_bevel + 1;
n->surface.data.planar.parent = t;
n->surface.data.planar.parentx = self->icon_x;
n->surface.data.planar.parenty = s_bevel + 1;
i->surface.data.planar.parent = t;
i->surface.data.planar.parentx = self->iconify_x;
i->surface.data.planar.parenty = s_bevel + 1;
d->surface.data.planar.parent = t;
d->surface.data.planar.parentx = self->desk_x;
d->surface.data.planar.parenty = s_bevel + 1;
c->surface.data.planar.parent = t;
c->surface.data.planar.parentx = self->close_x;
c->surface.data.planar.parenty = s_bevel + 1;
render_label(self, l);
render_max(self, m);
render_icon(self, n);
render_iconify(self, i);
render_desk(self, d);
render_close(self, c);
} }
if (self->frame.client->decorations & Decor_Handle) { if (self->frame.client->decorations & Decor_Handle) {
@ -768,14 +820,10 @@ static void render(ObFrame *self)
} }
} }
static void render_label(ObFrame *self) static void render_label(ObFrame *self, Appearance *a)
{ {
Appearance *a;
if (self->label_x < 0) return; if (self->label_x < 0) return;
a = (client_focused(self->frame.client) ?
self->a_focused_label : self->a_unfocused_label);
/* set the texture's text! */ /* set the texture's text! */
a->texture[0].data.text.string = self->frame.client->title; a->texture[0].data.text.string = self->frame.client->title;
@ -784,82 +832,52 @@ static void render_label(ObFrame *self)
paint(self->label, a, 0, 0, self->label_width, LABEL_HEIGHT); paint(self->label, a, 0, 0, self->label_width, LABEL_HEIGHT);
} }
static void render_icon(ObFrame *self) static void render_icon(ObFrame *self, Appearance *a)
{ {
if (self->icon_x < 0) return; if (self->icon_x < 0) return;
if (self->frame.client->nicons) { if (self->frame.client->nicons) {
Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE); Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
self->a_icon->texture[0].type = RGBA; a->texture[0].type = RGBA;
self->a_icon->texture[0].data.rgba.width = icon->width; a->texture[0].data.rgba.width = icon->width;
self->a_icon->texture[0].data.rgba.height = icon->height; a->texture[0].data.rgba.height = icon->height;
self->a_icon->texture[0].data.rgba.data = icon->data; a->texture[0].data.rgba.data = icon->data;
RECT_SET(self->a_icon->texture[0].position, 0, 0, RECT_SET(self->a_icon->texture[0].position, 0, 0,
BUTTON_SIZE,BUTTON_SIZE); BUTTON_SIZE,BUTTON_SIZE);
} else } else
self->a_icon->texture[0].type = NoTexture; a->texture[0].type = NoTexture;
paint(self->icon, self->a_icon, 0, 0, BUTTON_SIZE, BUTTON_SIZE); paint(self->icon, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE);
} }
static void render_max(ObFrame *self) static void render_max(ObFrame *self, Appearance *a)
{ {
Appearance *a;
gboolean press = self->max_press ||
self->frame.client->max_vert || self->frame.client->max_horz;
if (self->max_x < 0) return; if (self->max_x < 0) return;
a = (client_focused(self->frame.client) ?
(press ? a_focused_pressed_max : a_focused_unpressed_max) :
(press ? a_unfocused_pressed_max : a_unfocused_unpressed_max));
RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
paint(self->max, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); paint(self->max, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE);
} }
static void render_iconify(ObFrame *self) static void render_iconify(ObFrame *self, Appearance *a)
{ {
Appearance *a;
if (self->iconify_x < 0) return; if (self->iconify_x < 0) return;
a = (client_focused(self->frame.client) ?
(self->iconify_press ?
a_focused_pressed_iconify : a_focused_unpressed_iconify) :
(self->iconify_press ?
a_unfocused_pressed_iconify : a_unfocused_unpressed_iconify));
RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
paint(self->iconify, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); paint(self->iconify, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE);
} }
static void render_desk(ObFrame *self) static void render_desk(ObFrame *self, Appearance *a)
{ {
Appearance *a;
gboolean press = self->desk_press ||
self->frame.client->desktop == DESKTOP_ALL;
if (self->desk_x < 0) return; if (self->desk_x < 0) return;
a = (client_focused(self->frame.client) ?
(press ? a_focused_pressed_desk : a_focused_unpressed_desk) :
(press ? a_unfocused_pressed_desk : a_unfocused_unpressed_desk));
RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
paint(self->desk, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); paint(self->desk, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE);
} }
static void render_close(ObFrame *self) static void render_close(ObFrame *self, Appearance *a)
{ {
Appearance *a;
if (self->close_x < 0) return; if (self->close_x < 0) return;
a = (client_focused(self->frame.client) ?
(self->close_press ?
a_focused_pressed_close : a_focused_unpressed_close) :
(self->close_press ?
a_unfocused_pressed_close : a_unfocused_unpressed_close));
RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE);
paint(self->close, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); paint(self->close, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE);
} }
@ -894,16 +912,16 @@ static void frame_mouse_press(const ObEvent *e, ObFrame *self)
Window win = e->data.x.e->xbutton.window; Window win = e->data.x.e->xbutton.window;
if (win == self->max) { if (win == self->max) {
self->max_press = TRUE; self->max_press = TRUE;
render_max(self); render(self);
} else if (win == self->close) { } else if (win == self->close) {
self->close_press = TRUE; self->close_press = TRUE;
render_close(self); render(self);
} else if (win == self->iconify) { } else if (win == self->iconify) {
self->iconify_press = TRUE; self->iconify_press = TRUE;
render_iconify(self); render(self);
} else if (win == self->desk) { } else if (win == self->desk) {
self->desk_press = TRUE; self->desk_press = TRUE;
render_desk(self); render(self);
} }
} }
@ -912,15 +930,15 @@ static void frame_mouse_release(const ObEvent *e, ObFrame *self)
Window win = e->data.x.e->xbutton.window; Window win = e->data.x.e->xbutton.window;
if (win == self->max) { if (win == self->max) {
self->max_press = FALSE; self->max_press = FALSE;
render_max(self); render(self);
} else if (win == self->close) { } else if (win == self->close) {
self->close_press = FALSE; self->close_press = FALSE;
render_close(self); render(self);
} else if (win == self->iconify) { } else if (win == self->iconify) {
self->iconify_press = FALSE; self->iconify_press = FALSE;
render_iconify(self); render(self);
} else if (win == self->desk) { } else if (win == self->desk) {
self->desk_press = FALSE; self->desk_press = FALSE;
render_desk(self); render(self);
} }
} }