]> Dogcows Code - chaz/openbox/commitdiff
support parent relative titlebar elements
authorDana Jansens <danakj@orodu.net>
Thu, 27 Mar 2003 23:33:07 +0000 (23:33 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 27 Mar 2003 23:33:07 +0000 (23:33 +0000)
engines/openbox/openbox.c

index 69888b42c6e12cd3b68885758943792344d6f16d..d8c10c2f0281500ee6592d9cc3c82796caabc77f 100644 (file)
@@ -122,12 +122,12 @@ typedef struct ObFrame {
 
 static void layout_title(ObFrame *self);
 static void render(ObFrame *self);
-static void render_label(ObFrame *self);
-static void render_max(ObFrame *self);
-static void render_icon(ObFrame *self);
-static void render_iconify(ObFrame *self);
-static void render_desk(ObFrame *self);
-static void render_close(ObFrame *self);
+static void render_label(ObFrame *self, Appearance *a);
+static void render_max(ObFrame *self, Appearance *a);
+static void render_icon(ObFrame *self, Appearance *a);
+static void render_iconify(ObFrame *self, Appearance *a);
+static void render_desk(ObFrame *self, Appearance *a);
+static void render_close(ObFrame *self, Appearance *a);
 
 static void frame_mouse_press(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)
 {
-    render_max(self);
-    render_desk(self);
+    render(self);
 }
 
 void frame_adjust_focus(ObFrame *self)
@@ -533,12 +532,12 @@ void frame_adjust_focus(ObFrame *self)
 
 void frame_adjust_title(ObFrame *self)
 {
-    render_label(self);
+    render(self);
 }
 
 void frame_adjust_icon(ObFrame *self)
 {
-    render_icon(self);
+    render(self);
 }
 
 void frame_grab_client(ObFrame *self, Client *client)
@@ -739,16 +738,69 @@ static void render(ObFrame *self)
     }
 
     if (self->frame.client->decorations & Decor_Titlebar) {
-        paint(self->title, (client_focused(self->frame.client) ?
-                            self->a_focused_title :
-                            self->a_unfocused_title),
-              0, 0, self->width, TITLE_HEIGHT);
-        render_label(self);
-        render_max(self);
-        render_icon(self);
-        render_iconify(self);
-        render_desk(self);
-        render_close(self);
+        Appearance *t, *l, *m, *n, *i, *d, *c;
+
+        t = (client_focused(self->frame.client) ?
+             self->a_focused_title : self->a_unfocused_title);
+        l = (client_focused(self->frame.client) ?
+             self->a_focused_label : self->a_unfocused_label);
+        m = (client_focused(self->frame.client) ?
+             ((self->max_press ||
+              self->frame.client->max_vert || self->frame.client->max_horz) ?
+              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) {
@@ -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;
 
-    a = (client_focused(self->frame.client) ?
-         self->a_focused_label : self->a_unfocused_label);
 
     /* set the texture's text! */
     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);
 }
 
-static void render_icon(ObFrame *self)
+static void render_icon(ObFrame *self, Appearance *a)
 {
     if (self->icon_x < 0) return;
 
     if (self->frame.client->nicons) {
         Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE);
-        self->a_icon->texture[0].type = RGBA;
-        self->a_icon->texture[0].data.rgba.width = icon->width;
-        self->a_icon->texture[0].data.rgba.height = icon->height;
-        self->a_icon->texture[0].data.rgba.data = icon->data;
+        a->texture[0].type = RGBA;
+        a->texture[0].data.rgba.width = icon->width;
+        a->texture[0].data.rgba.height = icon->height;
+        a->texture[0].data.rgba.data = icon->data;
         RECT_SET(self->a_icon->texture[0].position, 0, 0,
                  BUTTON_SIZE,BUTTON_SIZE);
     } 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;
 
-    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);
     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;
 
-    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);
     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;
 
-    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);
     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;
 
-    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);
     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;
     if (win == self->max) {
         self->max_press = TRUE;
-        render_max(self);
+        render(self);
     } else if (win == self->close) {
         self->close_press = TRUE;
-        render_close(self);
+        render(self);
     } else if (win == self->iconify) {
         self->iconify_press = TRUE;
-        render_iconify(self);
+        render(self);
     } else if (win == self->desk) { 
         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;
     if (win == self->max) {
         self->max_press = FALSE;
-        render_max(self);
+        render(self);
     } else if (win == self->close) {
         self->close_press = FALSE; 
-        render_close(self);
+        render(self);
     } else if (win == self->iconify) {
         self->iconify_press = FALSE;
-        render_iconify(self);
+        render(self);
     } else if (win == self->desk) {
         self->desk_press = FALSE;
-        render_desk(self);
+        render(self);
     }
 }
This page took 0.032115 seconds and 4 git commands to generate.