X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=engines%2Fopenbox%2Fopenbox.c;h=15cb19d6ce75e093d0b648bc6b036adb186f3b9f;hb=b8de0b48fd32efed1fe242eaee9352cc16b2ee50;hp=8f1019172afc9f4e164e34a54075aa9a4babe26e;hpb=9a3459e983a11d74ec9f5dc415ce0af551c4b74e;p=chaz%2Fopenbox diff --git a/engines/openbox/openbox.c b/engines/openbox/openbox.c index 8f101917..15cb19d6 100644 --- a/engines/openbox/openbox.c +++ b/engines/openbox/openbox.c @@ -2,6 +2,7 @@ #include "../../kernel/openbox.h" #include "../../kernel/screen.h" #include "../../kernel/extensions.h" +#include "../../kernel/dispatch.h" #include "../../kernel/themerc.h" #include "../../kernel/frame.h" #include "../../render/render.h" @@ -12,8 +13,8 @@ #include #include -#define TITLE_HEIGHT (s_winfont_height + s_bevel * 2) #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) @@ -126,6 +127,9 @@ static void render_iconify(ObFrame *self); static void render_desk(ObFrame *self); static void render_close(ObFrame *self); +static void frame_mouse_press(const ObEvent *e, ObFrame *self); +static void frame_mouse_release(const ObEvent *e, ObFrame *self); + gboolean startup() { g_quark_from_string("none"); @@ -314,6 +318,11 @@ Frame *frame_new() self->max_press = self->close_press = self->desk_press = self->iconify_press = FALSE; + dispatch_register(Event_X_ButtonPress, (EventHandler)frame_mouse_press, + self); + dispatch_register(Event_X_ButtonRelease, (EventHandler)frame_mouse_release, + self); + return (Frame*)self; } @@ -329,6 +338,9 @@ static void frame_free(ObFrame *self) XDestroyWindow(ob_display, self->frame.window); + dispatch_register(0, (EventHandler)frame_mouse_press, self); + dispatch_register(0, (EventHandler)frame_mouse_release, self); + g_free(self); } @@ -636,7 +648,7 @@ static void layout_title(ObFrame *self) if (self->label_width < 1) self->label_width = 1; XResizeWindow(ob_display, self->label, self->label_width, - s_winfont_height); + LABEL_HEIGHT); if (!n) { self->frame.client->decorations &= ~Decor_Icon; @@ -720,39 +732,40 @@ 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); } } @@ -763,12 +776,12 @@ static void render_label(ObFrame *self) if (self->label_x < 0) return; a = (self->frame.client->focused ? - self->a_focused_label : self->a_focused_label); + 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, self->label_width, LABEL_HEIGHT); + paint(self->label, a, 0, 0, self->label_width, LABEL_HEIGHT); } static void render_icon(ObFrame *self) @@ -776,7 +789,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) @@ -793,7 +806,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) @@ -807,7 +820,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) @@ -824,7 +837,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) @@ -838,7 +851,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) @@ -865,3 +878,39 @@ GQuark get_context(Client *client, Window win) return g_quark_try_string("none"); } + +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); + } 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); + } +} + +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); + } 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); + } +}