]> Dogcows Code - chaz/openbox/blobdiff - engines/openbox/openbox.c
properly layout the titlebar, with proper separatation
[chaz/openbox] / engines / openbox / openbox.c
index 80e9e81216d11382eda7f70b67c2d5148bd3fa87..36e1641169e1836fd0a2311b7840d336a30a8003 100644 (file)
@@ -7,6 +7,7 @@
 #include "../../render/render.h"
 #include "../../render/color.h"
 #include "../../render/font.h"
+#include "../../render/mask.h"
 
 #include <X11/Xlib.h>
 #include <glib.h>
@@ -33,11 +34,18 @@ color_rgb *s_cb_focused_color;
 color_rgb *s_cb_unfocused_color;
 color_rgb *s_title_focused_color;
 color_rgb *s_title_unfocused_color;
+color_rgb *s_titlebut_focused_color;
+color_rgb *s_titlebut_unfocused_color;
 /* style settings - fonts */
 int s_winfont_height;
 int s_winfont_shadow;
 int s_winfont_shadow_offset;
 ObFont *s_winfont;
+/* style settings - masks */
+pixmap_mask *s_max_mask;
+pixmap_mask *s_icon_mask;
+pixmap_mask *s_desk_mask;
+pixmap_mask *s_close_mask;
 
 /* global appearances */
 Appearance *a_focused_unpressed_max;
@@ -134,13 +142,16 @@ gboolean startup()
     g_quark_from_string("icon");
     g_quark_from_string("close");
 
-    s_b_color = s_cb_unfocused_color = s_cb_focused_color = NULL;
+    s_b_color = s_cb_unfocused_color = s_cb_focused_color = 
+        s_title_unfocused_color = s_title_focused_color = 
+        s_titlebut_unfocused_color = s_titlebut_focused_color = NULL;
     s_winfont = NULL;
+    s_max_mask = s_icon_mask = s_desk_mask = s_close_mask = NULL;
 
-    a_focused_unpressed_max = appearance_new(Surface_Planar, 0);//1);
-    a_focused_pressed_max = appearance_new(Surface_Planar, 0);//1);
-    a_unfocused_unpressed_max = appearance_new(Surface_Planar, 0);//1);
-    a_unfocused_pressed_max = appearance_new(Surface_Planar, 0);//1);
+    a_focused_unpressed_max = appearance_new(Surface_Planar, 1);
+    a_focused_pressed_max = appearance_new(Surface_Planar, 1);
+    a_unfocused_unpressed_max = appearance_new(Surface_Planar, 1);
+    a_unfocused_pressed_max = appearance_new(Surface_Planar, 1);
     a_focused_unpressed_close = NULL;
     a_focused_pressed_close = NULL;
     a_unfocused_unpressed_close = NULL;
@@ -163,18 +174,6 @@ gboolean startup()
     a_focused_handle = appearance_new(Surface_Planar, 0);
     a_unfocused_handle = appearance_new(Surface_Planar, 0);
 
-    a_focused_label->texture[0].type = Text;
-    a_focused_label->texture[0].data.text.font = s_winfont;
-    a_focused_label->texture[0].data.text.shadow = s_winfont_shadow;
-    a_focused_label->texture[0].data.text.offset = s_winfont_shadow_offset;
-    a_focused_label->texture[0].data.text.color = s_title_focused_color;
-
-    a_unfocused_label->texture[0].type = Text;
-    a_unfocused_label->texture[0].data.text.font = s_winfont;
-    a_unfocused_label->texture[0].data.text.shadow = s_winfont_shadow;
-    a_unfocused_label->texture[0].data.text.offset = s_winfont_shadow_offset;
-    a_unfocused_label->texture[0].data.text.color = s_title_unfocused_color;
-
     return load();
 }
 
@@ -183,6 +182,17 @@ void shutdown()
     if (s_b_color != NULL) color_free(s_b_color);
     if (s_cb_unfocused_color != NULL) color_free(s_cb_unfocused_color);
     if (s_cb_focused_color != NULL) color_free(s_cb_focused_color);
+    if (s_title_unfocused_color != NULL) color_free(s_title_unfocused_color);
+    if (s_title_focused_color != NULL) color_free(s_title_focused_color);
+    if (s_titlebut_unfocused_color != NULL)
+        color_free(s_titlebut_unfocused_color);
+    if (s_titlebut_focused_color != NULL)
+        color_free(s_titlebut_focused_color);
+
+    if (s_max_mask != NULL) pixmap_mask_free(s_max_mask);
+    if (s_desk_mask != NULL) pixmap_mask_free(s_desk_mask);
+    if (s_icon_mask != NULL) pixmap_mask_free(s_icon_mask);
+    if (s_close_mask != NULL) pixmap_mask_free(s_close_mask);
 
     if (s_winfont != NULL) font_close(s_winfont);
 
@@ -584,28 +594,30 @@ void frame_release_client(ObFrame *self, Client *client)
 static void layout_title(ObFrame *self)
 {
     const char *lc;
-    int x;
+    int x, sep;
     gboolean n, d, i, l, m ,c;
+
     n = d = i = l = m = c = FALSE;
+    sep = s_bevel + 1;
 
     /* figure out whats being shown, and the width of the label */
-    self->label_width = self->width - s_bevel * 2;
+    self->label_width = self->width - sep * 2;
     for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
            if (!(self->frame.client->decorations & Decor_Icon)) break;
            n = TRUE;
-           self->label_width -= BUTTON_SIZE + s_bevel;
+           self->label_width -= BUTTON_SIZE + sep;
            break;
        case 'D':
            if (!(self->frame.client->decorations & Decor_AllDesktops)) break;
            d = TRUE;
-           self->label_width -= BUTTON_SIZE + s_bevel;
+           self->label_width -= BUTTON_SIZE + sep;
            break;
        case 'I':
            if (!(self->frame.client->decorations & Decor_Iconify)) break;
            i = TRUE;
-           self->label_width -= BUTTON_SIZE + s_bevel;
+           self->label_width -= BUTTON_SIZE + sep;
            break;
        case 'L':
            l = TRUE;
@@ -613,12 +625,12 @@ static void layout_title(ObFrame *self)
        case 'M':
            if (!(self->frame.client->decorations & Decor_Maximize)) break;
            m = TRUE;
-           self->label_width -= BUTTON_SIZE + s_bevel;
+           self->label_width -= BUTTON_SIZE + sep;
            break;
        case 'C':
            if (!(self->frame.client->decorations & Decor_Close)) break;
            c = TRUE;
-           self->label_width -= BUTTON_SIZE + s_bevel;
+           self->label_width -= BUTTON_SIZE + sep;
            break;
        }
     }
@@ -657,50 +669,50 @@ static void layout_title(ObFrame *self)
        self->close_x = -1;
     }
 
-    x = s_bevel;
+    x = sep;
     for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
            if (!n) break;
            self->icon_x = x;
            XMapWindow(ob_display, self->icon);
-           XMoveWindow(ob_display, self->icon, x, s_bevel + 1);
-           x += BUTTON_SIZE + s_bevel;
+           XMoveWindow(ob_display, self->icon, x, sep + 1);
+           x += BUTTON_SIZE + sep;
            break;
        case 'D':
            if (!d) break;
            self->desk_x = x;
            XMapWindow(ob_display, self->desk);
            XMoveWindow(ob_display, self->desk, x, s_bevel + 1);
-           x += BUTTON_SIZE + s_bevel;
+           x += BUTTON_SIZE + sep;
            break;
        case 'I':
            if (!i) break;
            self->iconify_x = x;
            XMapWindow(ob_display, self->iconify);
            XMoveWindow(ob_display, self->iconify, x, s_bevel + 1);
-           x += BUTTON_SIZE + s_bevel;
+           x += BUTTON_SIZE + sep;
            break;
        case 'L':
            if (!l) break;
            self->label_x = x;
            XMapWindow(ob_display, self->label);
            XMoveWindow(ob_display, self->label, x, s_bevel);
-           x += self->label_width + s_bevel;
+           x += self->label_width + sep;
            break;
        case 'M':
            if (!m) break;
            self->max_x = x;
            XMapWindow(ob_display, self->max);
            XMoveWindow(ob_display, self->max, x, s_bevel + 1);
-           x += BUTTON_SIZE + s_bevel;
+           x += BUTTON_SIZE + sep;
            break;
        case 'C':
            if (!c) break;
            self->close_x = x;
            XMapWindow(ob_display, self->close);
            XMoveWindow(ob_display, self->close, x, s_bevel + 1);
-           x += BUTTON_SIZE + s_bevel;
+           x += BUTTON_SIZE + sep;
            break;
        }
     }
@@ -747,16 +759,17 @@ static void render(ObFrame *self)
 
 static void render_label(ObFrame *self)
 {
+    Appearance *a;
+
     if (self->label_x < 0) return;
 
+    a = (self->frame.client->focused ?
+         self->a_focused_label : self->a_focused_label);
+
     /* set the texture's text! */
-    self->a_focused_label->texture[0].data.text.string =
-        self->frame.client->title;
+    a->texture[0].data.text.string = self->frame.client->title;
 
-    paint(self->label, (self->frame.client->focused ?
-                       self->a_focused_label :
-                       self->a_unfocused_label),
-         self->label_width, LABEL_HEIGHT);
+    paint(self->label, a, self->label_width, LABEL_HEIGHT);
 }
 
 static void render_icon(ObFrame *self)
This page took 0.025805 seconds and 4 git commands to generate.