X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=engines%2Fopenbox%2Fopenbox.c;h=0123f474246e30466a6f491cddb9bc61ed71e3d1;hb=4135ceb672b124f3ed372414a230b6318d7d9d21;hp=792ed2480b048936ba49ce80d05a101f621251df;hpb=a0a55d5761b7c104ac66ba6dc64d33cd66a211b5;p=chaz%2Fopenbox diff --git a/engines/openbox/openbox.c b/engines/openbox/openbox.c index 792ed248..0123f474 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) @@ -22,6 +23,9 @@ #define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask) #define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask) +#define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \ + ButtonMotionMask | ExposureMask | \ + EnterWindowMask | LeaveWindowMask) /* style settings - geometry */ int s_bevel; @@ -126,6 +130,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"); @@ -170,7 +177,7 @@ gboolean startup() a_unfocused_title = appearance_new(Surface_Planar, 0); 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_icon = appearance_new(Surface_Planar, 0);/*1);*/ a_focused_handle = appearance_new(Surface_Planar, 0); a_unfocused_handle = appearance_new(Surface_Planar, 0); @@ -238,10 +245,8 @@ void shutdown() static Window createWindow(Window parent, unsigned long mask, XSetWindowAttributes *attrib) { - /* XXX DONT USE THE DEFAULT SHIT */ return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0, - DefaultDepth(ob_display, ob_screen), InputOutput, - DefaultVisual(ob_display, ob_screen), + render_depth, InputOutput, render_visual, mask, attrib); } @@ -266,8 +271,7 @@ Frame *frame_new() self->frame.plate = createWindow(self->frame.window, mask, &attrib); mask = CWEventMask; - attrib.event_mask = (ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask); + attrib.event_mask = ELEMENT_EVENTMASK; self->title = createWindow(self->frame.window, mask, &attrib); self->label = createWindow(self->title, mask, &attrib); self->max = createWindow(self->title, mask, &attrib); @@ -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); } @@ -395,7 +407,7 @@ void frame_adjust_shape(ObFrame *self) #endif } -void frame_adjust_size(ObFrame *self) +void frame_adjust_area(ObFrame *self) { if (self->frame.client->decorations & Decor_Border) { self->bwidth = s_bwidth; @@ -449,20 +461,28 @@ void frame_adjust_size(ObFrame *self) XMapWindow(ob_display, self->handle); } else XUnmapWindow(ob_display, self->handle); - - XResizeWindow(ob_display, self->frame.window, self->width, - (self->frame.client->shaded ? TITLE_HEIGHT : - self->innersize.top + self->innersize.bottom + - self->frame.client->area.height)); - - /* do this in two steps because clients whose gravity is set to - 'Static' don't end up getting moved at all with an XMoveResizeWindow */ - XMoveWindow(ob_display, self->frame.plate, - self->innersize.left - self->cbwidth, - self->innersize.top - self->cbwidth); - XResizeWindow(ob_display, self->frame.plate, - self->frame.client->area.width, - self->frame.client->area.height); + + /* find the new coordinates */ + self->frame.area.x = self->frame.client->area.x; + self->frame.area.y = self->frame.client->area.y; + frame_client_gravity((Frame*)self, + &self->frame.area.x, &self->frame.area.y); + /* move and resize the top level frame */ + XMoveResizeWindow(ob_display, self->frame.window, + self->frame.area.x, self->frame.area.y, + self->width, + (self->frame.client->shaded ? TITLE_HEIGHT : + self->innersize.top + self->innersize.bottom + + self->frame.client->area.height)); + + /* move and resize the plate */ + XMoveResizeWindow(ob_display, self->frame.plate, + self->innersize.left - self->cbwidth, + self->innersize.top - self->cbwidth, + self->frame.client->area.width, + self->frame.client->area.height); + /* when the client has StaticGravity, it likes to move around. */ + XMoveWindow(ob_display, self->frame.client->window, 0, 0); STRUT_SET(self->frame.size, self->innersize.left + self->bwidth, @@ -477,18 +497,8 @@ void frame_adjust_size(ObFrame *self) self->frame.size.top + self->frame.size.bottom); render(self); - - frame_adjust_shape(self); -} -void frame_adjust_position(ObFrame *self) -{ - self->frame.area.x = self->frame.client->area.x; - self->frame.area.y = self->frame.client->area.y; - frame_client_gravity((Frame*)self, - &self->frame.area.x, &self->frame.area.y); - XMoveWindow(ob_display, self->frame.window, - self->frame.area.x, self->frame.area.y); + frame_adjust_shape(self); } void frame_adjust_state(ObFrame *self) @@ -536,8 +546,7 @@ void frame_grab_client(ObFrame *self, Client *client) /* map the client so it maps when the frame does */ XMapWindow(ob_display, client->window); - frame_adjust_size(self); - frame_adjust_position(self); + frame_adjust_area(self); /* set all the windows for the frame in the client_map */ g_hash_table_insert(client_map, (gpointer)self->frame.window, client); @@ -636,7 +645,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; @@ -719,7 +728,7 @@ static void layout_title(ObFrame *self) static void render(ObFrame *self) { - if (self->frame.client->focused) { + if (client_focused(self->frame.client)) { XSetWindowBorder(ob_display, self->frame.plate, s_cb_focused_color->pixel); } else { @@ -728,7 +737,7 @@ static void render(ObFrame *self) } if (self->frame.client->decorations & Decor_Titlebar) { - paint(self->title, (self->frame.client->focused ? + paint(self->title, (client_focused(self->frame.client) ? self->a_focused_title : self->a_unfocused_title), 0, 0, self->width, TITLE_HEIGHT); @@ -741,16 +750,16 @@ static void render(ObFrame *self) } if (self->frame.client->decorations & Decor_Handle) { - paint(self->handle, (self->frame.client->focused ? + paint(self->handle, (client_focused(self->frame.client) ? 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 ? + paint(self->lgrip, (client_focused(self->frame.client) ? a_focused_grip : a_unfocused_grip), 0, 0, GRIP_WIDTH, s_handle_height); - paint(self->rgrip, (self->frame.client->focused ? + paint(self->rgrip, (client_focused(self->frame.client) ? a_focused_grip : a_unfocused_grip), 0, 0, GRIP_WIDTH, s_handle_height); @@ -763,8 +772,8 @@ 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); + 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; @@ -787,7 +796,7 @@ static void render_max(ObFrame *self) if (self->max_x < 0) return; - paint(self->max, (self->frame.client->focused ? + paint(self->max, (client_focused(self->frame.client) ? (press ? a_focused_pressed_max : a_focused_unpressed_max) : @@ -801,7 +810,7 @@ static void render_iconify(ObFrame *self) { if (self->iconify_x < 0) return; - paint(self->iconify, (self->frame.client->focused ? + paint(self->iconify, (client_focused(self->frame.client) ? (self->iconify_press ? a_focused_pressed_iconify : a_focused_unpressed_iconify) : @@ -818,7 +827,7 @@ static void render_desk(ObFrame *self) if (self->desk_x < 0) return; - paint(self->desk, (self->frame.client->focused ? + paint(self->desk, (client_focused(self->frame.client) ? (press ? a_focused_pressed_desk : a_focused_unpressed_desk) : @@ -832,7 +841,7 @@ static void render_close(ObFrame *self) { if (self->close_x < 0) return; - paint(self->close, (self->frame.client->focused ? + paint(self->close, (client_focused(self->frame.client) ? (self->close_press ? a_focused_pressed_close : a_focused_unpressed_close) : @@ -867,49 +876,37 @@ 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) +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) { + } else if (win == self->close) { self->close_press = TRUE; render_close(self); - } - else if (win == self->iconify) { + } else if (win == self->iconify) { self->iconify_press = TRUE; render_iconify(self); - } - else if (win == self->desk) { + } else if (win == self->desk) { self->desk_press = TRUE; render_desk(self); } } -void frame_mouse_release(ObFrame *self, Window win, int x, int y) +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) { + } else if (win == self->close) { self->close_press = FALSE; render_close(self); - } - else if (win == self->iconify) { + } else if (win == self->iconify) { self->iconify_press = FALSE; render_iconify(self); - } - else if (win == self->desk) { + } else if (win == self->desk) { self->desk_press = FALSE; render_desk(self); }