]> Dogcows Code - chaz/openbox/blobdiff - engines/openbox/openbox.c
set the size of the label properly
[chaz/openbox] / engines / openbox / openbox.c
index fdab22a31a5ecf0d2cc8a8df8a6db787f7f834d6..3fccd2330b1d0357fa344fc40fc886cfa298cd27 100644 (file)
@@ -6,12 +6,14 @@
 #include "../../kernel/frame.h"
 #include "../../render/render.h"
 #include "../../render/color.h"
+#include "../../render/font.h"
+#include "../../render/mask.h"
 
 #include <X11/Xlib.h>
 #include <glib.h>
 
-#define TITLE_HEIGHT    (s_font_height + s_bevel * 2)
-#define LABEL_HEIGHT    (s_font_height)
+#define LABEL_HEIGHT    (s_winfont_height)
+#define TITLE_HEIGHT    (LABEL_HEIGHT + s_bevel * 2)
 #define HANDLE_Y(f)     (f->innersize.top + f->frame.client->area.height + \
                         f->cbwidth)
 #define BUTTON_SIZE     (LABEL_HEIGHT - 2)
@@ -22,7 +24,6 @@
 #define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask)
 
 /* style settings - geometry */
-int s_font_height;
 int s_bevel;
 int s_handle_height;
 int s_bwidth;
@@ -31,6 +32,20 @@ int s_cbwidth;
 color_rgb *s_b_color;
 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;
@@ -127,12 +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;
@@ -149,8 +168,8 @@ gboolean startup()
     a_unfocused_grip = appearance_new(Surface_Planar, 0);
     a_focused_title = appearance_new(Surface_Planar, 0);
     a_unfocused_title = appearance_new(Surface_Planar, 0);
-    a_focused_label = appearance_new(Surface_Planar, 0);//1);
-    a_unfocused_label = appearance_new(Surface_Planar, 0);//1);
+    a_focused_label = appearance_new(Surface_Planar, 1);
+    a_unfocused_label = appearance_new(Surface_Planar, 1);
     a_icon = appearance_new(Surface_Planar, 0);//1);
     a_focused_handle = appearance_new(Surface_Planar, 0);
     a_unfocused_handle = appearance_new(Surface_Planar, 0);
@@ -163,6 +182,19 @@ 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);
 
     appearance_free(a_focused_unpressed_max);
     appearance_free(a_focused_pressed_max);
@@ -564,26 +596,27 @@ static void layout_title(ObFrame *self)
     const char *lc;
     int x;
     gboolean n, d, i, l, m ,c;
+
     n = d = i = l = m = c = FALSE;
 
     /* figure out whats being shown, and the width of the label */
-    self->label_width = self->width - s_bevel * 2;
+    self->label_width = self->width - (s_bevel + 1) * 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 + s_bevel + 1;
            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 + s_bevel + 1;
            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 + s_bevel + 1;
            break;
        case 'L':
            l = TRUE;
@@ -591,18 +624,19 @@ 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 + s_bevel + 1;
            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 + s_bevel + 1;
            break;
        }
     }
     if (self->label_width < 1) self->label_width = 1;
 
-    XResizeWindow(ob_display, self->label, self->label_width, s_font_height);
+    XResizeWindow(ob_display, self->label, self->label_width,
+                  LABEL_HEIGHT);
   
     if (!n) {
        self->frame.client->decorations &= ~Decor_Icon;
@@ -634,7 +668,7 @@ static void layout_title(ObFrame *self)
        self->close_x = -1;
     }
 
-    x = s_bevel;
+    x = s_bevel + 1;
     for (lc = themerc_titlebar_layout; *lc != '\0'; ++lc) {
        switch (*lc) {
        case 'N':
@@ -642,42 +676,42 @@ static void layout_title(ObFrame *self)
            self->icon_x = x;
            XMapWindow(ob_display, self->icon);
            XMoveWindow(ob_display, self->icon, x, s_bevel + 1);
-           x += BUTTON_SIZE + s_bevel;
+           x += BUTTON_SIZE + s_bevel + 1;
            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 + s_bevel + 1;
            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 + s_bevel + 1;
            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 + s_bevel + 1;
            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 + s_bevel + 1;
            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 + s_bevel + 1;
            break;
        }
     }
@@ -686,51 +720,56 @@ static void layout_title(ObFrame *self)
 static void render(ObFrame *self)
 {
     if (self->frame.client->focused) {
-       XSetWindowBorder(ob_display, self->frame.plate,
-                        s_cb_focused_color->pixel);
+        XSetWindowBorder(ob_display, self->frame.plate,
+                         s_cb_focused_color->pixel);
     } else {
-       XSetWindowBorder(ob_display, self->frame.plate,
-                        s_cb_unfocused_color->pixel);
+        XSetWindowBorder(ob_display, self->frame.plate,
+                         s_cb_unfocused_color->pixel);
     }
 
     if (self->frame.client->decorations & Decor_Titlebar) {
-       paint(self->title, (self->frame.client->focused ?
-                           self->a_focused_title :
-                           self->a_unfocused_title),
-             self->width, TITLE_HEIGHT);
-       render_label(self);
-       render_max(self);
-       render_icon(self);
-       render_iconify(self);
-       render_desk(self);
-       render_close(self);
+        paint(self->title, (self->frame.client->focused ?
+                            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);
     }
 
     if (self->frame.client->decorations & Decor_Handle) {
-       paint(self->handle, (self->frame.client->focused ?
-                            self->a_focused_handle :
-                            self->a_unfocused_handle),
-             HANDLE_WIDTH(self), s_handle_height);
-       paint(self->lgrip, (self->frame.client->focused ?
-                           a_focused_grip :
-                           a_unfocused_grip),
-             GRIP_WIDTH, s_handle_height);
-       paint(self->rgrip, (self->frame.client->focused ?
-                           a_focused_grip :
-                           a_unfocused_grip),
-             GRIP_WIDTH, s_handle_height);
+        paint(self->handle, (self->frame.client->focused ?
+                             self->a_focused_handle :
+                             self->a_unfocused_handle),
+              GRIP_WIDTH + self->bwidth, 0,
+              HANDLE_WIDTH(self), s_handle_height);
+        paint(self->lgrip, (self->frame.client->focused ?
+                            a_focused_grip :
+                            a_unfocused_grip),
+              0, 0, GRIP_WIDTH, s_handle_height);
+        paint(self->rgrip, (self->frame.client->focused ?
+                            a_focused_grip :
+                            a_unfocused_grip),
+              0, 0, GRIP_WIDTH, s_handle_height);
     }
 }
 
 static void render_label(ObFrame *self)
 {
+    Appearance *a;
+
     if (self->label_x < 0) return;
 
-    /* XXX set the texture's text! */
-    paint(self->label, (self->frame.client->focused ?
-                       self->a_focused_label :
-                       self->a_unfocused_label),
-         self->label_width, LABEL_HEIGHT);
+    a = (self->frame.client->focused ?
+         self->a_focused_label : self->a_unfocused_label);
+
+    /* set the texture's text! */
+    a->texture[0].data.text.string = self->frame.client->title;
+
+    paint(self->label, a, 0, 0, self->label_width, LABEL_HEIGHT);
 }
 
 static void render_icon(ObFrame *self)
@@ -738,7 +777,7 @@ static void render_icon(ObFrame *self)
     if (self->icon_x < 0) return;
 
     /* XXX set the texture's icon picture! */
-    paint(self->icon, self->a_icon, BUTTON_SIZE, BUTTON_SIZE);
+    paint(self->icon, self->a_icon, 0, 0, BUTTON_SIZE, BUTTON_SIZE);
 }
 
 static void render_max(ObFrame *self)
@@ -755,7 +794,7 @@ static void render_max(ObFrame *self)
                      (press ?
                       a_unfocused_pressed_max :
                       a_unfocused_unpressed_max)),
-         BUTTON_SIZE, BUTTON_SIZE);
+         0, 0, BUTTON_SIZE, BUTTON_SIZE);
 }
 
 static void render_iconify(ObFrame *self)
@@ -769,7 +808,7 @@ static void render_iconify(ObFrame *self)
                          (self->iconify_press ?
                           a_unfocused_pressed_iconify :
                           a_unfocused_unpressed_iconify)),
-         BUTTON_SIZE, BUTTON_SIZE);
+         0, 0, BUTTON_SIZE, BUTTON_SIZE);
 }
 
 static void render_desk(ObFrame *self)
@@ -786,7 +825,7 @@ static void render_desk(ObFrame *self)
                       (press ?
                        a_unfocused_pressed_desk :
                        a_unfocused_unpressed_desk)),
-         BUTTON_SIZE, BUTTON_SIZE);
+         0, 0, BUTTON_SIZE, BUTTON_SIZE);
 }
 
 static void render_close(ObFrame *self)
@@ -800,7 +839,7 @@ static void render_close(ObFrame *self)
                          (self->close_press ?
                           a_unfocused_pressed_close :
                           a_unfocused_unpressed_close)),
-         BUTTON_SIZE, BUTTON_SIZE);
+         0, 0, BUTTON_SIZE, BUTTON_SIZE);
 }
 
 GQuark get_context(Client *client, Window win)
@@ -827,3 +866,51 @@ GQuark get_context(Client *client, Window win)
 
     return g_quark_try_string("none");
 }
+
+void frame_mouse_enter(ObFrame *self, Window win)
+{
+}
+
+void frame_mouse_leave(ObFrame *self, Window win)
+{
+}
+
+void frame_mouse_press(ObFrame *self, Window win, int x, int y)
+{
+    if (win == self->max) {
+        self->max_press = TRUE;
+        render_max(self);
+    }
+    else if (win == self->close) {
+        self->close_press = TRUE;
+        render_close(self);
+    }
+    else if (win == self->iconify) {
+        self->iconify_press = TRUE;
+        render_iconify(self);
+    }
+    else if (win == self->desk) { 
+        self->desk_press = TRUE;
+        render_desk(self);
+    }
+}
+
+void frame_mouse_release(ObFrame *self, Window win, int x, int y)
+{
+    if (win == self->max) {
+        self->max_press = FALSE;
+        render_max(self);
+    }
+    else if (win == self->close) {
+        self->close_press = FALSE; 
+        render_close(self);
+    }
+    else if (win == self->iconify) {
+        self->iconify_press = FALSE;
+        render_iconify(self);
+    }
+    else if (win == self->desk) {
+        self->desk_press = FALSE;
+        render_desk(self);
+    }
+}
This page took 0.035739 seconds and 4 git commands to generate.