commit 4615f58310f0567e77010ef393e16ac76781a8ca Author: BenoƮt Gschwind Date: Fri Dec 21 14:52:43 2007 +0100 Crazy patch? diff --git a/Makefile.am b/Makefile.am index 1af9f5a..c5c346f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,8 @@ check_PROGRAMS = \ lib_LTLIBRARIES = \ parser/libobparser.la \ - render/libobrender.la + render/libobrender.la \ + frameplugins/libframedefault.la bin_PROGRAMS = \ openbox/openbox \ @@ -109,6 +110,50 @@ parser_libobparser_la_SOURCES = \ parser/parse.h \ parser/parse.c +## framedefault ## + +frameplugins_libframedefault_la_CPPFLAGS = \ + $(X_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(XML_CFLAGS) \ + $(PANGO_CFLAGS) \ + $(XFT_CFLAGS) \ + -DG_LOG_DOMAIN=\"ObRender\" \ + -DDEFAULT_THEME=\"$(theme)\" +frameplugins_libframedefault_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +frameplugins_libframedefault_la_LIBADD = \ + parser/libobparser.la \ + $(X_LIBS) \ + $(PANGO_LIBS) \ + $(XFT_LIBS) \ + $(GLIB_LIBS) \ + $(XML_LIBS) +frameplugins_libframedefault_la_SOURCES = \ + gettext.h \ + render/color.h \ + render/color.c \ + render/font.h \ + render/font.c \ + render/geom.h \ + render/gradient.h \ + render/gradient.c \ + render/icon.h \ + render/image.h \ + render/image.c \ + render/instance.h \ + render/instance.c \ + render/mask.h \ + render/mask.c \ + render/render.h \ + render/render.c \ + render/theme.h \ + render/theme.c \ + frameplugins/default/framerender.h \ + frameplugins/default/framerender.c \ + frameplugins/default/frame_default_plugin.h \ + frameplugins/default/frame_default_plugin.c + ## openbox ## openbox_openbox_CPPFLAGS = \ @@ -214,10 +259,7 @@ openbox_openbox_SOURCES = \ openbox/focus_cycle_indicator.h \ openbox/focus_cycle_popup.c \ openbox/focus_cycle_popup.h \ - openbox/frame.c \ openbox/frame.h \ - openbox/framerender.c \ - openbox/framerender.h \ openbox/geom.h \ openbox/grab.c \ openbox/grab.h \ @@ -234,6 +276,8 @@ openbox_openbox_SOURCES = \ openbox/menu.c \ openbox/menu.h \ openbox/misc.h \ + openbox/plugin.h \ + openbox/plugin.c \ openbox/modkeys.c \ openbox/modkeys.h \ openbox/mouse.c \ diff --git a/frameplugins/default/frame_default_plugin.c b/frameplugins/default/frame_default_plugin.c new file mode 100644 index 0000000..c99405e --- /dev/null +++ b/frameplugins/default/frame_default_plugin.c @@ -0,0 +1,2117 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + frame_default_plugin.c for the Openbox window manager + Copyright (c) 2006 Mikael Magnusson + Copyright (c) 2003-2007 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. + */ + +#include "frame_default_plugin.h" +#include "framerender.h" +#include "openbox/frame.h" +#include "openbox/client.h" +#include "openbox/openbox.h" +#include "openbox/extensions.h" +#include "openbox/prop.h" +#include "openbox/grab.h" +#include "openbox/config.h" +#include "openbox/mainloop.h" +#include "openbox/focus_cycle.h" +#include "openbox/focus_cycle_indicator.h" +#include "openbox/moveresize.h" +#include "openbox/screen.h" +#include "render/theme.h" + + +typedef enum + { + OB_FLAG_MAX = 1 << 0, + OB_FLAG_CLOSE = 1 << 1, + OB_FLAG_DESK = 1 << 2, + OB_FLAG_SHADE = 1 << 3, + OB_FLAG_ICONIFY = 1 << 4 + } ObFrameFlags; + +#define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ + ButtonPressMask | ButtonReleaseMask | \ + SubstructureRedirectMask | FocusChangeMask) +#define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \ + ButtonMotionMask | PointerMotionMask | \ + EnterWindowMask | LeaveWindowMask) + +#define FRAME_ANIMATE_ICONIFY_TIME 150000 /* .15 seconds */ +#define FRAME_ANIMATE_ICONIFY_STEP_TIME (G_USEC_PER_SEC / 60) /* 60 Hz */ + +#define FRAME_HANDLE_Y(f) (f->size.top + f->client->area.height + f->cbwidth_b) + +Window createWindow(Window parent, Visual *visual, gulong mask, + XSetWindowAttributes *attrib) + { + return XCreateWindow(default_plugin.ob_display, parent, 0, 0, 1, 1, 0, + (visual ? 32 : RrDepth(default_plugin.ob_rr_inst)), InputOutput, + (visual ? visual : RrVisual(default_plugin.ob_rr_inst)), mask, attrib); + + } + +Visual *check_32bit_client(ObClient *c) + { + XWindowAttributes wattrib; + Status ret; + + /* we're already running at 32 bit depth, yay. we don't need to use their + visual */ + if (RrDepth(default_plugin.ob_rr_inst) == 32) + return NULL; + + ret = XGetWindowAttributes(default_plugin.ob_display, c->window, &wattrib); + g_assert(ret != BadDrawable); + g_assert(ret != BadWindow); + + if (wattrib.depth == 32) + return wattrib.visual; + return NULL; + } + +/* Not used */ +gint init(Display * display, gint screen) + { + default_plugin.ob_display = display; + default_plugin.ob_screen = screen; + } + +gpointer frame_new(struct _ObClient * client) + { + XSetWindowAttributes attrib; + gulong mask; + ObDefaultFrame *self; + Visual *visual; + + self = g_new0(ObDefaultFrame, 1); + self->client = client; + + visual = check_32bit_client(client); + + /* create the non-visible decor windows */ + + mask = 0; + if (visual) + { + /* client has a 32-bit visual */ + mask |= CWColormap | CWBackPixel | CWBorderPixel; + /* create a colormap with the visual */ + OBDEFAULTFRAME(self)->colormap = attrib.colormap = XCreateColormap( + default_plugin.ob_display, RootWindow(default_plugin.ob_display, + default_plugin.ob_screen), visual, AllocNone); + attrib.background_pixel = BlackPixel(default_plugin.ob_display, + default_plugin.ob_screen); + attrib.border_pixel = BlackPixel(default_plugin.ob_display, + default_plugin.ob_screen); + } + self->window = createWindow(RootWindow(default_plugin.ob_display, + default_plugin.ob_screen), visual, mask, &attrib); + + /* create the visible decor windows */ + + mask = 0; + if (visual) + { + /* client has a 32-bit visual */ + mask |= CWColormap | CWBackPixel | CWBorderPixel; + attrib.colormap = RrColormap(default_plugin.ob_rr_inst); + } + + self->backback = createWindow(self->window, NULL, mask, &attrib); + self->backfront = createWindow(self->backback, NULL, mask, &attrib); + + mask |= CWEventMask; + attrib.event_mask = ELEMENT_EVENTMASK; + self->innerleft = createWindow(self->window, NULL, mask, &attrib); + self->innertop = createWindow(self->window, NULL, mask, &attrib); + self->innerright = createWindow(self->window, NULL, mask, &attrib); + self->innerbottom = createWindow(self->window, NULL, mask, &attrib); + + self->innerblb = createWindow(self->innerbottom, NULL, mask, &attrib); + self->innerbrb = createWindow(self->innerbottom, NULL, mask, &attrib); + self->innerbll = createWindow(self->innerleft, NULL, mask, &attrib); + self->innerbrr = createWindow(self->innerright, NULL, mask, &attrib); + + self->title = createWindow(self->window, NULL, mask, &attrib); + self->titleleft = createWindow(self->window, NULL, mask, &attrib); + self->titletop = createWindow(self->window, NULL, mask, &attrib); + self->titletopleft = createWindow(self->window, NULL, mask, &attrib); + self->titletopright = createWindow(self->window, NULL, mask, &attrib); + self->titleright = createWindow(self->window, NULL, mask, &attrib); + self->titlebottom = createWindow(self->window, NULL, mask, &attrib); + + self->topresize = createWindow(self->title, NULL, mask, &attrib); + self->tltresize = createWindow(self->title, NULL, mask, &attrib); + self->tllresize = createWindow(self->title, NULL, mask, &attrib); + self->trtresize = createWindow(self->title, NULL, mask, &attrib); + self->trrresize = createWindow(self->title, NULL, mask, &attrib); + + self->left = createWindow(self->window, NULL, mask, &attrib); + self->right = createWindow(self->window, NULL, mask, &attrib); + + self->label = createWindow(self->title, NULL, mask, &attrib); + self->max = createWindow(self->title, NULL, mask, &attrib); + self->close = createWindow(self->title, NULL, mask, &attrib); + self->desk = createWindow(self->title, NULL, mask, &attrib); + self->shade = createWindow(self->title, NULL, mask, &attrib); + self->icon = createWindow(self->title, NULL, mask, &attrib); + self->iconify = createWindow(self->title, NULL, mask, &attrib); + + self->handle = createWindow(self->window, NULL, mask, &attrib); + self->lgrip = createWindow(self->handle, NULL, mask, &attrib); + self->rgrip = createWindow(self->handle, NULL, mask, &attrib); + + self->handleleft = createWindow(self->handle, NULL, mask, &attrib); + self->handleright = createWindow(self->handle, NULL, mask, &attrib); + + self->handletop = createWindow(self->window, NULL, mask, &attrib); + self->handlebottom = createWindow(self->window, NULL, mask, &attrib); + self->lgripleft = createWindow(self->window, NULL, mask, &attrib); + self->lgriptop = createWindow(self->window, NULL, mask, &attrib); + self->lgripbottom = createWindow(self->window, NULL, mask, &attrib); + self->rgripright = createWindow(self->window, NULL, mask, &attrib); + self->rgriptop = createWindow(self->window, NULL, mask, &attrib); + self->rgripbottom = createWindow(self->window, NULL, mask, &attrib); + + self->focused = FALSE; + + /* the other stuff is shown based on decor settings */ + XMapWindow(default_plugin.ob_display, self->label); + XMapWindow(default_plugin.ob_display, self->backback); + XMapWindow(default_plugin.ob_display, self->backfront); + + self->max_press = self->close_press = self->desk_press + = self->iconify_press = self->shade_press = FALSE; + self->max_hover = self->close_hover = self->desk_hover + = self->iconify_hover = self->shade_hover = FALSE; + + set_theme_statics(self); + + return (ObFrame*)self; + } + +void set_theme_statics(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + /* set colors/appearance/sizes for stuff that doesn't change */ + XResizeWindow(default_plugin.ob_display, self->max, + default_plugin.ob_rr_theme->button_size, + default_plugin.ob_rr_theme->button_size); + XResizeWindow(default_plugin.ob_display, self->iconify, + default_plugin.ob_rr_theme->button_size, + default_plugin.ob_rr_theme->button_size); + XResizeWindow(default_plugin.ob_display, self->icon, + default_plugin.ob_rr_theme->button_size + 2, + default_plugin.ob_rr_theme->button_size + 2); + XResizeWindow(default_plugin.ob_display, self->close, + default_plugin.ob_rr_theme->button_size, + default_plugin.ob_rr_theme->button_size); + XResizeWindow(default_plugin.ob_display, self->desk, + default_plugin.ob_rr_theme->button_size, + default_plugin.ob_rr_theme->button_size); + XResizeWindow(default_plugin.ob_display, self->shade, + default_plugin.ob_rr_theme->button_size, + default_plugin.ob_rr_theme->button_size); + XResizeWindow(default_plugin.ob_display, self->tltresize, + default_plugin.ob_rr_theme->grip_width, + default_plugin.ob_rr_theme->paddingy + 1); + XResizeWindow(default_plugin.ob_display, self->trtresize, + default_plugin.ob_rr_theme->grip_width, + default_plugin.ob_rr_theme->paddingy + 1); + XResizeWindow(default_plugin.ob_display, self->tllresize, + default_plugin.ob_rr_theme->paddingx + 1, + default_plugin.ob_rr_theme->title_height); + XResizeWindow(default_plugin.ob_display, self->trrresize, + default_plugin.ob_rr_theme->paddingx + 1, + default_plugin.ob_rr_theme->title_height); + + /* set up the dynamic appearances */ + self->a_unfocused_title + = RrAppearanceCopy(default_plugin.ob_rr_theme->a_unfocused_title); + self->a_focused_title + = RrAppearanceCopy(default_plugin.ob_rr_theme->a_focused_title); + self->a_unfocused_label + = RrAppearanceCopy(default_plugin.ob_rr_theme->a_unfocused_label); + self->a_focused_label + = RrAppearanceCopy(default_plugin.ob_rr_theme->a_focused_label); + self->a_unfocused_handle + = RrAppearanceCopy(default_plugin.ob_rr_theme->a_unfocused_handle); + self->a_focused_handle + = RrAppearanceCopy(default_plugin.ob_rr_theme->a_focused_handle); + self->a_icon = RrAppearanceCopy(default_plugin.ob_rr_theme->a_icon); + } + +void free_theme_statics(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + RrAppearanceFree(self->a_unfocused_title); + RrAppearanceFree(self->a_focused_title); + RrAppearanceFree(self->a_unfocused_label); + RrAppearanceFree(self->a_focused_label); + RrAppearanceFree(self->a_unfocused_handle); + RrAppearanceFree(self->a_focused_handle); + RrAppearanceFree(self->a_icon); + } + +void frame_free(gpointer self) + { + free_theme_statics(OBDEFAULTFRAME(self)); + XDestroyWindow(default_plugin.ob_display, OBDEFAULTFRAME(self)->window); + if (OBDEFAULTFRAME(self)->colormap) + XFreeColormap(default_plugin.ob_display, OBDEFAULTFRAME(self)->colormap); + g_free(self); + } + +void frame_show(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + if (!self->visible) + { + self->visible = TRUE; + framerender_frame(self); + /* Grab the server to make sure that the frame window is mapped before + the client gets its MapNotify, i.e. to make sure the client is + _visible_ when it gets MapNotify. */ + grab_server(TRUE); + XMapWindow(default_plugin.ob_display, self->client->window); + XMapWindow(default_plugin.ob_display, self->window); + grab_server(FALSE); + } + } + +void frame_hide(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + if (self->visible) + { + self->visible = FALSE; + if (!frame_iconify_animating(self)) + XUnmapWindow(default_plugin.ob_display, self->window); + /* we unmap the client itself so that we can get MapRequest + events, and because the ICCCM tells us to! */ + XUnmapWindow(default_plugin.ob_display, self->client->window); + self->client->ignore_unmaps += 1; + } + } + +void frame_adjust_theme(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + free_theme_statics(self); + set_theme_statics(self); + } + +void frame_adjust_shape(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; +#ifdef SHAPE + gint num; + XRectangle xrect[2]; + + if (!self->client->shaped) + { + /* clear the shape on the frame window */ + XShapeCombineMask(default_plugin.ob_display, self->window, ShapeBounding, + self->size.left, + self->size.top, + None, ShapeSet); + } + else + { + /* make the frame's shape match the clients */ + XShapeCombineShape(default_plugin.ob_display, self->window, ShapeBounding, + self->size.left, + self->size.top, + self->client->window, + ShapeBounding, ShapeSet); + + num = 0; + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) + { + xrect[0].x = 0; + xrect[0].y = 0; + xrect[0].width = self->area.width; + xrect[0].height = self->size.top; + ++num; + } + + if (self->decorations & OB_FRAME_DECOR_HANDLE && + default_plugin.ob_rr_theme->handle_height > 0) + { + xrect[1].x = 0; + xrect[1].y = FRAME_HANDLE_Y(self); + xrect[1].width = self->area.width; + xrect[1].height = default_plugin.ob_rr_theme->handle_height + + self->bwidth * 2; + ++num; + } + + XShapeCombineRectangles(default_plugin.ob_display, self->window, + ShapeBounding, 0, 0, xrect, num, + ShapeUnion, Unsorted); + } +#endif + } + +void frame_adjust_area(gpointer _self, gboolean moved, gboolean resized, + gboolean fake) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + Strut oldsize; + + oldsize = self->size; + + if (resized) + { + /* do this before changing the frame's status like max_horz max_vert */ + frame_adjust_cursors(self); + + self->functions = self->client->functions; + self->decorations = self->client->decorations; + self->max_horz = self->client->max_horz; + self->max_vert = self->client->max_vert; + self->shaded = self->client->shaded; + + if (self->decorations & OB_FRAME_DECOR_BORDER + || (self->client->undecorated + && default_plugin.config_theme_keepborder)) + self->bwidth = default_plugin.ob_rr_theme->fbwidth; + else + self->bwidth = 0; + + if (self->decorations & OB_FRAME_DECOR_BORDER) + { + self->cbwidth_l = self->cbwidth_r + = default_plugin.ob_rr_theme->cbwidthx; + self->cbwidth_t = self->cbwidth_b + = default_plugin.ob_rr_theme->cbwidthy; + } + else + self->cbwidth_l = self->cbwidth_t = self->cbwidth_r = self->cbwidth_b + = 0; + + if (self->max_horz) + { + self->cbwidth_l = self->cbwidth_r = 0; + self->width = self->client->area.width; + if (self->max_vert) + self->cbwidth_b = 0; + } + else + self->width = self->client->area.width + self->cbwidth_l + + self->cbwidth_r; + + /* some elements are sized based of the width, so don't let them have + negative values */ + self->width = MAX(self->width, (default_plugin.ob_rr_theme->grip_width + + self->bwidth) * 2 + 1); + + STRUT_SET(self->size, self->cbwidth_l + (!self->max_horz ? self->bwidth + : 0), self->cbwidth_t + self->bwidth, self->cbwidth_r + + (!self->max_horz ? self->bwidth : 0), self->cbwidth_b + + (!self->max_horz || !self->max_vert ? self->bwidth : 0)); + + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) + self->size.top += default_plugin.ob_rr_theme->title_height + + self->bwidth; + if (self->decorations & OB_FRAME_DECOR_HANDLE + && default_plugin.ob_rr_theme->handle_height > 0) + { + self->size.bottom += default_plugin.ob_rr_theme->handle_height + + self->bwidth; + } + + /* position/size and map/unmap all the windows */ + + if (!fake) + { + gint innercornerheight = default_plugin.ob_rr_theme->grip_width + - self->size.bottom; + + if (self->cbwidth_l) + { + XMoveResizeWindow(default_plugin.ob_display, self->innerleft, + self->size.left - self->cbwidth_l, self->size.top, + self->cbwidth_l, self->client->area.height); + + XMapWindow(default_plugin.ob_display, self->innerleft); + } + else + XUnmapWindow(default_plugin.ob_display, self->innerleft); + + if (self->cbwidth_l && innercornerheight > 0) + { + XMoveResizeWindow(default_plugin.ob_display, self->innerbll, 0, + self->client->area.height + - (default_plugin.ob_rr_theme->grip_width + - self->size.bottom), self->cbwidth_l, + default_plugin.ob_rr_theme->grip_width - self->size.bottom); + + XMapWindow(default_plugin.ob_display, self->innerbll); + } + else + XUnmapWindow(default_plugin.ob_display, self->innerbll); + + if (self->cbwidth_r) + { + XMoveResizeWindow(default_plugin.ob_display, self->innerright, + self->size.left + self->client->area.width, self->size.top, + self->cbwidth_r, self->client->area.height); + + XMapWindow(default_plugin.ob_display, self->innerright); + } + else + XUnmapWindow(default_plugin.ob_display, self->innerright); + + if (self->cbwidth_r && innercornerheight > 0) + { + XMoveResizeWindow(default_plugin.ob_display, self->innerbrr, 0, + self->client->area.height + - (default_plugin.ob_rr_theme->grip_width + - self->size.bottom), self->cbwidth_r, + default_plugin.ob_rr_theme->grip_width - self->size.bottom); + + XMapWindow(default_plugin.ob_display, self->innerbrr); + } + else + XUnmapWindow(default_plugin.ob_display, self->innerbrr); + + if (self->cbwidth_t) + { + XMoveResizeWindow(default_plugin.ob_display, self->innertop, + self->size.left - self->cbwidth_l, self->size.top + - self->cbwidth_t, self->client->area.width + + self->cbwidth_l + self->cbwidth_r, self->cbwidth_t); + + XMapWindow(default_plugin.ob_display, self->innertop); + } + else + XUnmapWindow(default_plugin.ob_display, self->innertop); + + if (self->cbwidth_b) + { + XMoveResizeWindow(default_plugin.ob_display, self->innerbottom, + self->size.left - self->cbwidth_l, self->size.top + + self->client->area.height, self->client->area.width + + self->cbwidth_l + self->cbwidth_r, self->cbwidth_b); + + XMoveResizeWindow(default_plugin.ob_display, self->innerblb, 0, + 0, default_plugin.ob_rr_theme->grip_width + self->bwidth, + self->cbwidth_b); + XMoveResizeWindow(default_plugin.ob_display, self->innerbrb, + self->client->area.width + self->cbwidth_l + + self->cbwidth_r + - (default_plugin.ob_rr_theme->grip_width + + self->bwidth), 0, + default_plugin.ob_rr_theme->grip_width + self->bwidth, + self->cbwidth_b); + + XMapWindow(default_plugin.ob_display, self->innerbottom); + XMapWindow(default_plugin.ob_display, self->innerblb); + XMapWindow(default_plugin.ob_display, self->innerbrb); + } + else + { + XUnmapWindow(default_plugin.ob_display, self->innerbottom); + XUnmapWindow(default_plugin.ob_display, self->innerblb); + XUnmapWindow(default_plugin.ob_display, self->innerbrb); + } + + if (self->bwidth) + { + gint titlesides; + + /* height of titleleft and titleright */ + titlesides + = (!self->max_horz ? default_plugin.ob_rr_theme->grip_width + : 0); + + XMoveResizeWindow(default_plugin.ob_display, self->titletop, + default_plugin.ob_rr_theme->grip_width + self->bwidth, 0, + /* width + bwidth*2 - bwidth*2 - grips*2 */ + self->width - default_plugin.ob_rr_theme->grip_width * 2, + self->bwidth); + XMoveResizeWindow(default_plugin.ob_display, + self->titletopleft, 0, 0, + default_plugin.ob_rr_theme->grip_width + self->bwidth, + self->bwidth); + XMoveResizeWindow( + default_plugin.ob_display, + self->titletopright, + self->client->area.width + self->size.left + + self->size.right + - default_plugin.ob_rr_theme->grip_width - self->bwidth, + 0, default_plugin.ob_rr_theme->grip_width + self->bwidth, + self->bwidth); + + if (titlesides > 0) + { + XMoveResizeWindow(default_plugin.ob_display, + self->titleleft, 0, self->bwidth, self->bwidth, + titlesides); + XMoveResizeWindow(default_plugin.ob_display, + self->titleright, + self->client->area.width + self->size.left + + self->size.right - self->bwidth, self->bwidth, + self->bwidth, titlesides); + + XMapWindow(default_plugin.ob_display, self->titleleft); + XMapWindow(default_plugin.ob_display, self->titleright); + } + else + { + XUnmapWindow(default_plugin.ob_display, self->titleleft); + XUnmapWindow(default_plugin.ob_display, self->titleright); + } + + XMapWindow(default_plugin.ob_display, self->titletop); + XMapWindow(default_plugin.ob_display, self->titletopleft); + XMapWindow(default_plugin.ob_display, self->titletopright); + + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) + { + XMoveResizeWindow( + default_plugin.ob_display, + self->titlebottom, + (self->max_horz ? 0 : self->bwidth), + default_plugin.ob_rr_theme->title_height + self->bwidth, + self->width, self->bwidth); + + XMapWindow(default_plugin.ob_display, self->titlebottom); + } + else + XUnmapWindow(default_plugin.ob_display, self->titlebottom); + } + else + { + XUnmapWindow(default_plugin.ob_display, self->titlebottom); + + XUnmapWindow(default_plugin.ob_display, self->titletop); + XUnmapWindow(default_plugin.ob_display, self->titletopleft); + XUnmapWindow(default_plugin.ob_display, self->titletopright); + XUnmapWindow(default_plugin.ob_display, self->titleleft); + XUnmapWindow(default_plugin.ob_display, self->titleright); + } + + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) + { + XMoveResizeWindow(default_plugin.ob_display, self->title, + (self->max_horz ? 0 : self->bwidth), self->bwidth, + self->width, default_plugin.ob_rr_theme->title_height); + + XMapWindow(default_plugin.ob_display, self->title); + + if (self->decorations & OB_FRAME_DECOR_GRIPS) + { + XMoveResizeWindow(default_plugin.ob_display, + self->topresize, + default_plugin.ob_rr_theme->grip_width, 0, self->width + - default_plugin.ob_rr_theme->grip_width *2, + default_plugin.ob_rr_theme->paddingy + 1); + + XMoveWindow(default_plugin.ob_display, self->tltresize, 0, + 0); + XMoveWindow(default_plugin.ob_display, self->tllresize, 0, + 0); + XMoveWindow(default_plugin.ob_display, self->trtresize, + self->width - default_plugin.ob_rr_theme->grip_width, 0); + XMoveWindow(default_plugin.ob_display, self->trrresize, + self->width - default_plugin.ob_rr_theme->paddingx - 1, + 0); + + XMapWindow(default_plugin.ob_display, self->topresize); + XMapWindow(default_plugin.ob_display, self->tltresize); + XMapWindow(default_plugin.ob_display, self->tllresize); + XMapWindow(default_plugin.ob_display, self->trtresize); + XMapWindow(default_plugin.ob_display, self->trrresize); + } + else + { + XUnmapWindow(default_plugin.ob_display, self->topresize); + XUnmapWindow(default_plugin.ob_display, self->tltresize); + XUnmapWindow(default_plugin.ob_display, self->tllresize); + XUnmapWindow(default_plugin.ob_display, self->trtresize); + XUnmapWindow(default_plugin.ob_display, self->trrresize); + } + } + else + XUnmapWindow(default_plugin.ob_display, self->title); + } + + if ((self->decorations & OB_FRAME_DECOR_TITLEBAR)) + /* layout the title bar elements */ + layout_title(self); + + if (!fake) + { + gint sidebwidth = self->max_horz ? 0 : self->bwidth; + + if (self->bwidth && self->size.bottom) + { + XMoveResizeWindow(default_plugin.ob_display, + self->handlebottom, default_plugin.ob_rr_theme->grip_width + + self->bwidth + sidebwidth, self->size.top + + self->client->area.height + self->size.bottom + - self->bwidth, self->width + - (default_plugin.ob_rr_theme->grip_width + sidebwidth) + * 2, self->bwidth); + + if (sidebwidth) + { + XMoveResizeWindow( + default_plugin.ob_display, + self->lgripleft, + 0, + self->size.top + self->client->area.height + + self->size.bottom + - (!self->max_horz ? default_plugin.ob_rr_theme->grip_width + : self->size.bottom - self->cbwidth_b), + self->bwidth, + (!self->max_horz ? default_plugin.ob_rr_theme->grip_width + : self->size.bottom - self->cbwidth_b)); + XMoveResizeWindow( + default_plugin.ob_display, + self->rgripright, + self->size.left + self->client->area.width + + self->size.right - self->bwidth, + self->size.top + self->client->area.height + + self->size.bottom + - (!self->max_horz ? default_plugin.ob_rr_theme->grip_width + : self->size.bottom - self->cbwidth_b), + self->bwidth, + (!self->max_horz ? default_plugin.ob_rr_theme->grip_width + : self->size.bottom - self->cbwidth_b)); + + XMapWindow(default_plugin.ob_display, self->lgripleft); + XMapWindow(default_plugin.ob_display, self->rgripright); + } + else + { + XUnmapWindow(default_plugin.ob_display, self->lgripleft); + XUnmapWindow(default_plugin.ob_display, self->rgripright); + } + + XMoveResizeWindow(default_plugin.ob_display, self->lgripbottom, + sidebwidth, self->size.top + self->client->area.height + + self->size.bottom - self->bwidth, + default_plugin.ob_rr_theme->grip_width + self->bwidth, + self->bwidth); + XMoveResizeWindow(default_plugin.ob_display, self->rgripbottom, + self->size.left + self->client->area.width + + self->size.right - self->bwidth - sidebwidth + - default_plugin.ob_rr_theme->grip_width, + self->size.top + self->client->area.height + + self->size.bottom - self->bwidth, + default_plugin.ob_rr_theme->grip_width + self->bwidth, + self->bwidth); + + XMapWindow(default_plugin.ob_display, self->handlebottom); + XMapWindow(default_plugin.ob_display, self->lgripbottom); + XMapWindow(default_plugin.ob_display, self->rgripbottom); + + if (self->decorations & OB_FRAME_DECOR_HANDLE + && default_plugin.ob_rr_theme->handle_height > 0) + { + XMoveResizeWindow(default_plugin.ob_display, + self->handletop, default_plugin.ob_rr_theme->grip_width + + self->bwidth + sidebwidth, + FRAME_HANDLE_Y(self), self->width + - (default_plugin.ob_rr_theme->grip_width + + sidebwidth) * 2, self->bwidth); + XMapWindow(default_plugin.ob_display, self->handletop); + + if (self->decorations & OB_FRAME_DECOR_GRIPS) + { + XMoveResizeWindow(default_plugin.ob_display, + self->handleleft, + default_plugin.ob_rr_theme->grip_width, 0, + self->bwidth, + default_plugin.ob_rr_theme->handle_height); + XMoveResizeWindow(default_plugin.ob_display, + self->handleright, self->width + - default_plugin.ob_rr_theme->grip_width + - self->bwidth, 0, self->bwidth, + default_plugin.ob_rr_theme->handle_height); + + XMoveResizeWindow(default_plugin.ob_display, + self->lgriptop, sidebwidth, + FRAME_HANDLE_Y(self), default_plugin.ob_rr_theme->grip_width + + self->bwidth, self->bwidth); + XMoveResizeWindow(default_plugin.ob_display, + self->rgriptop, self->size.left + + self->client->area.width + self->size.right + - self->bwidth - sidebwidth + - default_plugin.ob_rr_theme->grip_width, + FRAME_HANDLE_Y(self), default_plugin.ob_rr_theme->grip_width + + self->bwidth, self->bwidth); + + XMapWindow(default_plugin.ob_display, self->handleleft); + XMapWindow(default_plugin.ob_display, self->handleright); + XMapWindow(default_plugin.ob_display, self->lgriptop); + XMapWindow(default_plugin.ob_display, self->rgriptop); + } + else + { + XUnmapWindow(default_plugin.ob_display, + self->handleleft); + XUnmapWindow(default_plugin.ob_display, + self->handleright); + XUnmapWindow(default_plugin.ob_display, self->lgriptop); + XUnmapWindow(default_plugin.ob_display, self->rgriptop); + } + } + else + { + XUnmapWindow(default_plugin.ob_display, self->handleleft); + XUnmapWindow(default_plugin.ob_display, self->handleright); + XUnmapWindow(default_plugin.ob_display, self->lgriptop); + XUnmapWindow(default_plugin.ob_display, self->rgriptop); + + XUnmapWindow(default_plugin.ob_display, self->handletop); + } + } + else + { + XUnmapWindow(default_plugin.ob_display, self->handleleft); + XUnmapWindow(default_plugin.ob_display, self->handleright); + XUnmapWindow(default_plugin.ob_display, self->lgriptop); + XUnmapWindow(default_plugin.ob_display, self->rgriptop); + + XUnmapWindow(default_plugin.ob_display, self->handletop); + + XUnmapWindow(default_plugin.ob_display, self->handlebottom); + XUnmapWindow(default_plugin.ob_display, self->lgripleft); + XUnmapWindow(default_plugin.ob_display, self->rgripright); + XUnmapWindow(default_plugin.ob_display, self->lgripbottom); + XUnmapWindow(default_plugin.ob_display, self->rgripbottom); + } + + if (self->decorations & OB_FRAME_DECOR_HANDLE + && default_plugin.ob_rr_theme->handle_height > 0) + { + XMoveResizeWindow(default_plugin.ob_display, self->handle, + sidebwidth, + FRAME_HANDLE_Y(self) + self->bwidth, self->width, + default_plugin.ob_rr_theme->handle_height); + XMapWindow(default_plugin.ob_display, self->handle); + + if (self->decorations & OB_FRAME_DECOR_GRIPS) + { + XMoveResizeWindow(default_plugin.ob_display, self->lgrip, + 0, 0, default_plugin.ob_rr_theme->grip_width, + default_plugin.ob_rr_theme->handle_height); + XMoveResizeWindow(default_plugin.ob_display, self->rgrip, + self->width - default_plugin.ob_rr_theme->grip_width, + 0, default_plugin.ob_rr_theme->grip_width, + default_plugin.ob_rr_theme->handle_height); + + XMapWindow(default_plugin.ob_display, self->lgrip); + XMapWindow(default_plugin.ob_display, self->rgrip); + } + else + { + XUnmapWindow(default_plugin.ob_display, self->lgrip); + XUnmapWindow(default_plugin.ob_display, self->rgrip); + } + } + else + { + XUnmapWindow(default_plugin.ob_display, self->lgrip); + XUnmapWindow(default_plugin.ob_display, self->rgrip); + + XUnmapWindow(default_plugin.ob_display, self->handle); + } + + if (self->bwidth && !self->max_horz && (self->client->area.height + + self->size.top + self->size.bottom) + > default_plugin.ob_rr_theme->grip_width * 2) + { + XMoveResizeWindow(default_plugin.ob_display, self->left, 0, + self->bwidth + default_plugin.ob_rr_theme->grip_width, + self->bwidth, self->client->area.height + self->size.top + + self->size.bottom + - default_plugin.ob_rr_theme->grip_width * 2); + + XMapWindow(default_plugin.ob_display, self->left); + } + else + XUnmapWindow(default_plugin.ob_display, self->left); + + if (self->bwidth && !self->max_horz && (self->client->area.height + + self->size.top + self->size.bottom) + > default_plugin.ob_rr_theme->grip_width * 2) + { + XMoveResizeWindow(default_plugin.ob_display, self->right, + self->client->area.width + self->cbwidth_l + + self->cbwidth_r + self->bwidth, self->bwidth + + default_plugin.ob_rr_theme->grip_width, self->bwidth, + self->client->area.height + self->size.top + + self->size.bottom + - default_plugin.ob_rr_theme->grip_width * 2); + + XMapWindow(default_plugin.ob_display, self->right); + } + else + XUnmapWindow(default_plugin.ob_display, self->right); + + XMoveResizeWindow(default_plugin.ob_display, self->backback, + self->size.left, self->size.top, self->client->area.width, + self->client->area.height); + } + } + + /* shading can change without being moved or resized */ + RECT_SET_SIZE(self->area, self->client->area.width + self->size.left + + self->size.right, + (self->client->shaded ? default_plugin.ob_rr_theme->title_height + + self->bwidth * 2 : self->client->area.height + self->size.top + + self->size.bottom)); + + if ((moved || resized) && !fake) + { + /* find the new coordinates, done after setting the frame.size, for + frame_client_gravity. */ + self->area.x = self->client->area.x; + self->area.y = self->client->area.y; + frame_client_gravity(self, &self->area.x, &self->area.y); + } + + if (!fake) + { + if (!frame_iconify_animating(self)) + /* move and resize the top level frame. + shading can change without being moved or resized. + + but don't do this during an iconify animation. it will be + reflected afterwards. + */ + XMoveResizeWindow(default_plugin.ob_display, self->window, + self->area.x, self->area.y, self->area.width, self->area.height); + + /* when the client has StaticGravity, it likes to move around. + also this correctly positions the client when it maps. + this also needs to be run when the frame's decorations sizes change! + */ + XMoveWindow(default_plugin.ob_display, self->client->window, + self->size.left, self->size.top); + + if (resized) + { + self->need_render = TRUE; + framerender_frame(self); + frame_adjust_shape(self); + } + + if (!STRUT_EQUAL(self->size, oldsize)) + { + gulong vals[4]; + vals[0] = self->size.left; + vals[1] = self->size.right; + vals[2] = self->size.top; + vals[3] = self->size.bottom; + PROP_SETA32(self->client->window, net_frame_extents, cardinal, + vals, 4); + PROP_SETA32(self->client->window, kde_net_wm_frame_strut, cardinal, + vals, 4); + } + + /* if this occurs while we are focus cycling, the indicator needs to + match the changes */ + if (default_plugin.focus_cycle_target == self->client) + focus_cycle_draw_indicator(self->client); + } + if (resized && (self->decorations & OB_FRAME_DECOR_TITLEBAR)) + XResizeWindow(default_plugin.ob_display, self->label, self->label_width, + default_plugin.ob_rr_theme->label_height); + + } + +void frame_adjust_cursors(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + if ((self->functions & OB_CLIENT_FUNC_RESIZE) != (self->client->functions + & OB_CLIENT_FUNC_RESIZE) || self->max_horz != self->client->max_horz + || self->max_vert != self->client->max_vert || self->shaded + != self->client->shaded) + { + gboolean r = (self->client->functions & OB_CLIENT_FUNC_RESIZE) + && !(self->client->max_horz && self->client->max_vert); + gboolean topbot = !self->client->max_vert; + gboolean sh = self->client->shaded; + XSetWindowAttributes a; + + /* these ones turn off when max vert, and some when shaded */ + a.cursor = ob_cursor(r && topbot && !sh ? OB_CURSOR_NORTH + : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->topresize, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->titletop, + CWCursor, &a); + a.cursor = ob_cursor(r && topbot ? OB_CURSOR_SOUTH : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->handle, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->handletop, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->handlebottom, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerbottom, + CWCursor, &a); + + /* these ones change when shaded */ + a.cursor = ob_cursor(r ? (sh ? OB_CURSOR_WEST : OB_CURSOR_NORTHWEST) + : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->titleleft, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->tltresize, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->tllresize, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->titletopleft, + CWCursor, &a); + a.cursor = ob_cursor(r ? (sh ? OB_CURSOR_EAST : OB_CURSOR_NORTHEAST) + : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->titleright, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->trtresize, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->trrresize, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->titletopright, + CWCursor, &a); + + /* these ones are pretty static */ + a.cursor = ob_cursor(r ? OB_CURSOR_WEST : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->left, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerleft, + CWCursor, &a); + a.cursor = ob_cursor(r ? OB_CURSOR_EAST : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->right, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerright, + CWCursor, &a); + a.cursor = ob_cursor(r ? OB_CURSOR_SOUTHWEST : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->lgrip, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->handleleft, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->lgripleft, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->lgriptop, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->lgripbottom, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerbll, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerblb, + CWCursor, &a); + a.cursor = ob_cursor(r ? OB_CURSOR_SOUTHEAST : OB_CURSOR_NONE); + XChangeWindowAttributes(default_plugin.ob_display, self->rgrip, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->handleright, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->rgripright, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->rgriptop, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->rgripbottom, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerbrr, + CWCursor, &a); + XChangeWindowAttributes(default_plugin.ob_display, self->innerbrb, + CWCursor, &a); + } + } + +void frame_adjust_client_area(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + /* adjust the window which is there to prevent flashing on unmap */ + XMoveResizeWindow(default_plugin.ob_display, self->backfront, 0, 0, + self->client->area.width, self->client->area.height); + } + +void frame_adjust_state(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + self->need_render = TRUE; + framerender_frame(self); + } + +void frame_adjust_focus(gpointer _self, gboolean hilite) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + self->focused = hilite; + self->need_render = TRUE; + framerender_frame(self); + XFlush(default_plugin.ob_display); + } + +void frame_adjust_title(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + self->need_render = TRUE; + framerender_frame(self); + } + +void frame_adjust_icon(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + self->need_render = TRUE; + framerender_frame(self); + } + +void frame_grab_client(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + /* DO NOT map the client window here. we used to do that, but it is bogus. + we need to set up the client's dimensions and everything before we + send a mapnotify or we create race conditions. + */ + + /* reparent the client to the frame */ + XReparentWindow(default_plugin.ob_display, self->client->window, + self->window, 0, 0); + + /* + When reparenting the client window, it is usually not mapped yet, since + this occurs from a MapRequest. However, in the case where Openbox is + starting up, the window is already mapped, so we'll see an unmap event + for it. + */ + if (ob_state() == OB_STATE_STARTING) + ++self->client->ignore_unmaps; + + /* select the event mask on the client's parent (to receive config/map + req's) the ButtonPress is to catch clicks on the client border */ + XSelectInput(default_plugin.ob_display, self->window, FRAME_EVENTMASK); + + /* set all the windows for the frame in the window_map */ + g_hash_table_insert(window_map, &self->window, self->client); + g_hash_table_insert(window_map, &self->backback, self->client); + g_hash_table_insert(window_map, &self->backfront, self->client); + g_hash_table_insert(window_map, &self->innerleft, self->client); + g_hash_table_insert(window_map, &self->innertop, self->client); + g_hash_table_insert(window_map, &self->innerright, self->client); + g_hash_table_insert(window_map, &self->innerbottom, self->client); + g_hash_table_insert(window_map, &self->title, self->client); + g_hash_table_insert(window_map, &self->label, self->client); + g_hash_table_insert(window_map, &self->max, self->client); + g_hash_table_insert(window_map, &self->close, self->client); + g_hash_table_insert(window_map, &self->desk, self->client); + g_hash_table_insert(window_map, &self->shade, self->client); + g_hash_table_insert(window_map, &self->icon, self->client); + g_hash_table_insert(window_map, &self->iconify, self->client); + g_hash_table_insert(window_map, &self->handle, self->client); + g_hash_table_insert(window_map, &self->lgrip, self->client); + g_hash_table_insert(window_map, &self->rgrip, self->client); + g_hash_table_insert(window_map, &self->topresize, self->client); + g_hash_table_insert(window_map, &self->tltresize, self->client); + g_hash_table_insert(window_map, &self->tllresize, self->client); + g_hash_table_insert(window_map, &self->trtresize, self->client); + g_hash_table_insert(window_map, &self->trrresize, self->client); + g_hash_table_insert(window_map, &self->left, self->client); + g_hash_table_insert(window_map, &self->right, self->client); + g_hash_table_insert(window_map, &self->titleleft, self->client); + g_hash_table_insert(window_map, &self->titletop, self->client); + g_hash_table_insert(window_map, &self->titletopleft, self->client); + g_hash_table_insert(window_map, &self->titletopright, self->client); + g_hash_table_insert(window_map, &self->titleright, self->client); + g_hash_table_insert(window_map, &self->titlebottom, self->client); + g_hash_table_insert(window_map, &self->handleleft, self->client); + g_hash_table_insert(window_map, &self->handletop, self->client); + g_hash_table_insert(window_map, &self->handleright, self->client); + g_hash_table_insert(window_map, &self->handlebottom, self->client); + g_hash_table_insert(window_map, &self->lgripleft, self->client); + g_hash_table_insert(window_map, &self->lgriptop, self->client); + g_hash_table_insert(window_map, &self->lgripbottom, self->client); + g_hash_table_insert(window_map, &self->rgripright, self->client); + g_hash_table_insert(window_map, &self->rgriptop, self->client); + g_hash_table_insert(window_map, &self->rgripbottom, self->client); + } + +void frame_release_client(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + XEvent ev; + gboolean reparent = TRUE; + + /* if there was any animation going on, kill it */ + ob_main_loop_timeout_remove_data(default_plugin.ob_main_loop, + frame_animate_iconify, self, FALSE); + + /* check if the app has already reparented its window away */ + while (XCheckTypedWindowEvent(default_plugin.ob_display, + self->client->window, ReparentNotify, &ev)) + { + /* This check makes sure we don't catch our own reparent action to + our frame window. This doesn't count as the app reparenting itself + away of course. + + Reparent events that are generated by us are just discarded here. + They are of no consequence to us anyhow. + */ + if (ev.xreparent.parent != self->window) + { + reparent = FALSE; + XPutBackEvent(default_plugin.ob_display, &ev); + break; + } + } + + if (reparent) + { + /* according to the ICCCM - if the client doesn't reparent itself, + then we will reparent the window to root for them */ + XReparentWindow(default_plugin.ob_display, self->client->window, + RootWindow(default_plugin.ob_display, default_plugin.ob_screen), + self->client->area.x, self->client->area.y); + } + + /* remove all the windows for the frame from the window_map */ + g_hash_table_remove(window_map, &self->window); + g_hash_table_remove(window_map, &self->backback); + g_hash_table_remove(window_map, &self->backfront); + g_hash_table_remove(window_map, &self->innerleft); + g_hash_table_remove(window_map, &self->innertop); + g_hash_table_remove(window_map, &self->innerright); + g_hash_table_remove(window_map, &self->innerbottom); + g_hash_table_remove(window_map, &self->title); + g_hash_table_remove(window_map, &self->label); + g_hash_table_remove(window_map, &self->max); + g_hash_table_remove(window_map, &self->close); + g_hash_table_remove(window_map, &self->desk); + g_hash_table_remove(window_map, &self->shade); + g_hash_table_remove(window_map, &self->icon); + g_hash_table_remove(window_map, &self->iconify); + g_hash_table_remove(window_map, &self->handle); + g_hash_table_remove(window_map, &self->lgrip); + g_hash_table_remove(window_map, &self->rgrip); + g_hash_table_remove(window_map, &self->topresize); + g_hash_table_remove(window_map, &self->tltresize); + g_hash_table_remove(window_map, &self->tllresize); + g_hash_table_remove(window_map, &self->trtresize); + g_hash_table_remove(window_map, &self->trrresize); + g_hash_table_remove(window_map, &self->left); + g_hash_table_remove(window_map, &self->right); + g_hash_table_remove(window_map, &self->titleleft); + g_hash_table_remove(window_map, &self->titletop); + g_hash_table_remove(window_map, &self->titletopleft); + g_hash_table_remove(window_map, &self->titletopright); + g_hash_table_remove(window_map, &self->titleright); + g_hash_table_remove(window_map, &self->titlebottom); + g_hash_table_remove(window_map, &self->handleleft); + g_hash_table_remove(window_map, &self->handletop); + g_hash_table_remove(window_map, &self->handleright); + g_hash_table_remove(window_map, &self->handlebottom); + g_hash_table_remove(window_map, &self->lgripleft); + g_hash_table_remove(window_map, &self->lgriptop); + g_hash_table_remove(window_map, &self->lgripbottom); + g_hash_table_remove(window_map, &self->rgripright); + g_hash_table_remove(window_map, &self->rgriptop); + g_hash_table_remove(window_map, &self->rgripbottom); + + ob_main_loop_timeout_remove_data(default_plugin.ob_main_loop, + flash_timeout, self, TRUE); + } + +/* is there anything present between us and the label? */ +static gboolean is_button_present(ObDefaultFrame *_self, const gchar *lc, gint dir) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + for (; *lc != '\0' && lc >= default_plugin.config_title_layout; lc += dir) + { + if (*lc == ' ') + continue; /* it was invalid */ + if (*lc == 'N' && self->decorations & OB_FRAME_DECOR_ICON) + return TRUE; + if (*lc == 'D' && self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) + return TRUE; + if (*lc == 'S' && self->decorations & OB_FRAME_DECOR_SHADE) + return TRUE; + if (*lc == 'I' && self->decorations & OB_FRAME_DECOR_ICONIFY) + return TRUE; + if (*lc == 'M' && self->decorations & OB_FRAME_DECOR_MAXIMIZE) + return TRUE; + if (*lc == 'C' && self->decorations & OB_FRAME_DECOR_CLOSE) + return TRUE; + if (*lc == 'L') + return FALSE; + } + return FALSE; + } + +void layout_title(ObDefaultFrame * self) + { + gchar *lc; + gint i; + + const gint bwidth = default_plugin.ob_rr_theme->button_size + + default_plugin.ob_rr_theme->paddingx + 1; + /* position of the left most button */ + const gint left = default_plugin.ob_rr_theme->paddingx + 1; + /* position of the right most button */ + const gint right = self->width; + + /* turn them all off */ + self->icon_on = self->desk_on = self->shade_on = self->iconify_on + = self->max_on = self->close_on = self->label_on = FALSE; + self->label_width = self->width + - (default_plugin.ob_rr_theme->paddingx + 1) * 2; + self->leftmost = self->rightmost = OB_FRAME_CONTEXT_NONE; + + /* figure out what's being show, find each element's position, and the + width of the label + + do the ones before the label, then after the label, + i will be +1 the first time through when working to the left, + and -1 the second time through when working to the right */ + for (i = 1; i >= -1; i-=2) + { + gint x; + ObFrameContext *firstcon; + + if (i > 0) + { + x = left; + lc = default_plugin.config_title_layout; + firstcon = &self->leftmost; + } + else + { + x = right; + lc = default_plugin.config_title_layout + + strlen(default_plugin.config_title_layout)-1; + firstcon = &self->rightmost; + } + + /* stop at the end of the string (or the label, which calls break) */ + for (; *lc != '\0' && lc >= default_plugin.config_title_layout; lc+=i) + { + if (*lc == 'L') + { + if (i > 0) + { + self->label_on = TRUE; + self->label_x = x; + } + break; /* break the for loop, do other side of label */ + } + else if (*lc == 'N') + { + if (firstcon) + *firstcon = OB_FRAME_CONTEXT_ICON; + if ((self->icon_on = is_button_present(self, lc, i))) + { + /* icon is bigger than buttons */ + self->label_width -= bwidth + 2; + if (i > 0) + self->icon_x = x; + x += i * (bwidth + 2); + if (i < 0) + self->icon_x = x; + } + } + else if (*lc == 'D') + { + if (firstcon) + *firstcon = OB_FRAME_CONTEXT_ALLDESKTOPS; + if ((self->desk_on = is_button_present(self, lc, i))) + { + self->label_width -= bwidth; + if (i > 0) + self->desk_x = x; + x += i * bwidth; + if (i < 0) + self->desk_x = x; + } + } + else if (*lc == 'S') + { + if (firstcon) + *firstcon = OB_FRAME_CONTEXT_SHADE; + if ((self->shade_on = is_button_present(self, lc, i))) + { + self->label_width -= bwidth; + if (i > 0) + self->shade_x = x; + x += i * bwidth; + if (i < 0) + self->shade_x = x; + } + } + else if (*lc == 'I') + { + if (firstcon) + *firstcon = OB_FRAME_CONTEXT_ICONIFY; + if ((self->iconify_on = is_button_present(self, lc, i))) + { + self->label_width -= bwidth; + if (i > 0) + self->iconify_x = x; + x += i * bwidth; + if (i < 0) + self->iconify_x = x; + } + } + else if (*lc == 'M') + { + if (firstcon) + *firstcon = OB_FRAME_CONTEXT_MAXIMIZE; + if ((self->max_on = is_button_present(self, lc, i))) + { + self->label_width -= bwidth; + if (i > 0) + self->max_x = x; + x += i * bwidth; + if (i < 0) + self->max_x = x; + } + } + else if (*lc == 'C') + { + if (firstcon) + *firstcon = OB_FRAME_CONTEXT_CLOSE; + if ((self->close_on = is_button_present(self, lc, i))) + { + self->label_width -= bwidth; + if (i > 0) + self->close_x = x; + x += i * bwidth; + if (i < 0) + self->close_x = x; + } + } + else + continue; /* don't set firstcon */ + firstcon = NULL; + } + } + + /* position and map the elements */ + if (self->icon_on) + { + XMapWindow(default_plugin.ob_display, self->icon); + XMoveWindow(default_plugin.ob_display, self->icon, self->icon_x, + default_plugin.ob_rr_theme->paddingy); + } + else + XUnmapWindow(default_plugin.ob_display, self->icon); + + if (self->desk_on) + { + XMapWindow(default_plugin.ob_display, self->desk); + XMoveWindow(default_plugin.ob_display, self->desk, self->desk_x, + default_plugin.ob_rr_theme->paddingy + 1); + } + else + XUnmapWindow(default_plugin.ob_display, self->desk); + + if (self->shade_on) + { + XMapWindow(default_plugin.ob_display, self->shade); + XMoveWindow(default_plugin.ob_display, self->shade, self->shade_x, + default_plugin.ob_rr_theme->paddingy + 1); + } + else + XUnmapWindow(default_plugin.ob_display, self->shade); + + if (self->iconify_on) + { + XMapWindow(default_plugin.ob_display, self->iconify); + XMoveWindow(default_plugin.ob_display, self->iconify, self->iconify_x, + default_plugin.ob_rr_theme->paddingy + 1); + } + else + XUnmapWindow(default_plugin.ob_display, self->iconify); + + if (self->max_on) + { + XMapWindow(default_plugin.ob_display, self->max); + XMoveWindow(default_plugin.ob_display, self->max, self->max_x, + default_plugin.ob_rr_theme->paddingy + 1); + } + else + XUnmapWindow(default_plugin.ob_display, self->max); + + if (self->close_on) + { + XMapWindow(default_plugin.ob_display, self->close); + XMoveWindow(default_plugin.ob_display, self->close, self->close_x, + default_plugin.ob_rr_theme->paddingy + 1); + } + else + XUnmapWindow(default_plugin.ob_display, self->close); + + if (self->label_on) + { + self->label_width = MAX(1, self->label_width); /* no lower than 1 */ + XMapWindow(default_plugin.ob_display, self->label); + XMoveWindow(default_plugin.ob_display, self->label, self->label_x, + default_plugin.ob_rr_theme->paddingy); + } + else + XUnmapWindow(default_plugin.ob_display, self->label); + } + +ObFrameContext frame_context_from_string(const gchar *name) + { + if (!g_ascii_strcasecmp("Desktop", name)) + return OB_FRAME_CONTEXT_DESKTOP; + else if (!g_ascii_strcasecmp("Root", name)) + return OB_FRAME_CONTEXT_ROOT; + else if (!g_ascii_strcasecmp("Client", name)) + return OB_FRAME_CONTEXT_CLIENT; + else if (!g_ascii_strcasecmp("Titlebar", name)) + return OB_FRAME_CONTEXT_TITLEBAR; + else if (!g_ascii_strcasecmp("Frame", name)) + return OB_FRAME_CONTEXT_FRAME; + else if (!g_ascii_strcasecmp("TLCorner", name)) + return OB_FRAME_CONTEXT_TLCORNER; + else if (!g_ascii_strcasecmp("TRCorner", name)) + return OB_FRAME_CONTEXT_TRCORNER; + else if (!g_ascii_strcasecmp("BLCorner", name)) + return OB_FRAME_CONTEXT_BLCORNER; + else if (!g_ascii_strcasecmp("BRCorner", name)) + return OB_FRAME_CONTEXT_BRCORNER; + else if (!g_ascii_strcasecmp("Top", name)) + return OB_FRAME_CONTEXT_TOP; + else if (!g_ascii_strcasecmp("Bottom", name)) + return OB_FRAME_CONTEXT_BOTTOM; + else if (!g_ascii_strcasecmp("Handle", name)) + return OB_FRAME_CONTEXT_BOTTOM; + else if (!g_ascii_strcasecmp("Left", name)) + return OB_FRAME_CONTEXT_LEFT; + else if (!g_ascii_strcasecmp("Right", name)) + return OB_FRAME_CONTEXT_RIGHT; + else if (!g_ascii_strcasecmp("Maximize", name)) + return OB_FRAME_CONTEXT_MAXIMIZE; + else if (!g_ascii_strcasecmp("AllDesktops", name)) + return OB_FRAME_CONTEXT_ALLDESKTOPS; + else if (!g_ascii_strcasecmp("Shade", name)) + return OB_FRAME_CONTEXT_SHADE; + else if (!g_ascii_strcasecmp("Iconify", name)) + return OB_FRAME_CONTEXT_ICONIFY; + else if (!g_ascii_strcasecmp("Icon", name)) + return OB_FRAME_CONTEXT_ICON; + else if (!g_ascii_strcasecmp("Close", name)) + return OB_FRAME_CONTEXT_CLOSE; + else if (!g_ascii_strcasecmp("MoveResize", name)) + return OB_FRAME_CONTEXT_MOVE_RESIZE; + return OB_FRAME_CONTEXT_NONE; + } + +ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y) + { + ObDefaultFrame *self; + + if (default_plugin.moveresize_in_progress) + return OB_FRAME_CONTEXT_MOVE_RESIZE; + + if (win == RootWindow(default_plugin.ob_display, default_plugin.ob_screen)) + return OB_FRAME_CONTEXT_ROOT; + if (client == NULL) + return OB_FRAME_CONTEXT_NONE; + if (win == client->window) + { + /* conceptually, this is the desktop, as far as users are + concerned */ + if (client->type == OB_CLIENT_TYPE_DESKTOP) + return OB_FRAME_CONTEXT_DESKTOP; + return OB_FRAME_CONTEXT_CLIENT; + } + + self = (ObDefaultFrame *) client->frame; + + /* when the user clicks in the corners of the titlebar and the client + is fully maximized, then treat it like they clicked in the + button that is there */ + if (self->max_horz && self->max_vert && (win == self->title || win + == self->titletop || win == self->titleleft || win + == self->titletopleft || win == self->titleright || win + == self->titletopright)) + { + /* get the mouse coords in reference to the whole frame */ + gint fx = x; + gint fy = y; + + /* these windows are down a border width from the top of the frame */ + if (win == self->title || win == self->titleleft || win + == self->titleright) + fy += self->bwidth; + + /* title is a border width in from the edge */ + if (win == self->title) + fx += self->bwidth; + /* titletop is a bit to the right */ + else if (win == self->titletop) + fx += default_plugin.ob_rr_theme->grip_width + self->bwidth; + /* titletopright is way to the right edge */ + else if (win == self->titletopright) + fx += self->area.width - (default_plugin.ob_rr_theme->grip_width + + self->bwidth); + /* titleright is even more way to the right edge */ + else if (win == self->titleright) + fx += self->area.width - self->bwidth; + + /* figure out if we're over the area that should be considered a + button */ + if (fy < self->bwidth + default_plugin.ob_rr_theme->paddingy + 1 + + default_plugin.ob_rr_theme->button_size) + { + if (fx < (self->bwidth + default_plugin.ob_rr_theme->paddingx + 1 + + default_plugin.ob_rr_theme->button_size)) + { + if (self->leftmost != OB_FRAME_CONTEXT_NONE) + return self->leftmost; + } + else if (fx >= (self->area.width - (self->bwidth + + default_plugin.ob_rr_theme->paddingx + 1 + + default_plugin.ob_rr_theme->button_size))) + { + if (self->rightmost != OB_FRAME_CONTEXT_NONE) + return self->rightmost; + } + } + + /* there is no resizing maximized windows so make them the titlebar + context */ + return OB_FRAME_CONTEXT_TITLEBAR; + } + else if (self->max_vert + && (win == self->titletop || win == self->topresize)) + /* can't resize vertically when max vert */ + return OB_FRAME_CONTEXT_TITLEBAR; + else if (self->shaded && (win == self->titletop || win == self->topresize)) + /* can't resize vertically when shaded */ + return OB_FRAME_CONTEXT_TITLEBAR; + + if (win == self->window) + return OB_FRAME_CONTEXT_FRAME; + if (win == self->label) + return OB_FRAME_CONTEXT_TITLEBAR; + if (win == self->handle) + return OB_FRAME_CONTEXT_BOTTOM; + if (win == self->handletop) + return OB_FRAME_CONTEXT_BOTTOM; + if (win == self->handlebottom) + return OB_FRAME_CONTEXT_BOTTOM; + if (win == self->handleleft) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->lgrip) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->lgripleft) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->lgriptop) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->lgripbottom) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->handleright) + return OB_FRAME_CONTEXT_BRCORNER; + if (win == self->rgrip) + return OB_FRAME_CONTEXT_BRCORNER; + if (win == self->rgripright) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->rgriptop) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->rgripbottom) + return OB_FRAME_CONTEXT_BLCORNER; + if (win == self->title) + return OB_FRAME_CONTEXT_TITLEBAR; + if (win == self->titlebottom) + return OB_FRAME_CONTEXT_TITLEBAR; + if (win == self->titleleft) + return OB_FRAME_CONTEXT_TLCORNER; + if (win == self->titletopleft) + return OB_FRAME_CONTEXT_TLCORNER; + if (win == self->titleright) + return OB_FRAME_CONTEXT_TRCORNER; + if (win == self->titletopright) + return OB_FRAME_CONTEXT_TRCORNER; + if (win == self->titletop) + return OB_FRAME_CONTEXT_TOP; + if (win == self->topresize) + return OB_FRAME_CONTEXT_TOP; + if (win == self->tltresize) + return OB_FRAME_CONTEXT_TLCORNER; + if (win == self->tllresize) + return OB_FRAME_CONTEXT_TLCORNER; + if (win == self->trtresize) + return OB_FRAME_CONTEXT_TRCORNER; + if (win == self->trrresize) + return OB_FRAME_CONTEXT_TRCORNER; + if (win == self->left) + return OB_FRAME_CONTEXT_LEFT; + if (win == self->right) + return OB_FRAME_CONTEXT_RIGHT; + if (win == self->innertop) + return OB_FRAME_CONTEXT_TITLEBAR; + if (win == self->innerleft) + return OB_FRAME_CONTEXT_LEFT; + if (win == self->innerbottom) + return OB_FRAME_CONTEXT_BOTTOM; + if (win == self->innerright) + return OB_FRAME_CONTEXT_RIGHT; + if (win == self->max) + return OB_FRAME_CONTEXT_MAXIMIZE; + if (win == self->iconify) + return OB_FRAME_CONTEXT_ICONIFY; + if (win == self->close) + return OB_FRAME_CONTEXT_CLOSE; + if (win == self->icon) + return OB_FRAME_CONTEXT_ICON; + if (win == self->desk) + return OB_FRAME_CONTEXT_ALLDESKTOPS; + if (win == self->shade) + return OB_FRAME_CONTEXT_SHADE; + + return OB_FRAME_CONTEXT_NONE; + } + +void frame_client_gravity(gpointer _self, gint *x, gint *y) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + /* horizontal */ + switch (self->client->gravity) + { + default: + case NorthWestGravity: + case SouthWestGravity: + case WestGravity: + break; + + case NorthGravity: + case SouthGravity: + case CenterGravity: + /* the middle of the client will be the middle of the frame */ + *x -= (self->size.right - self->size.left) / 2; + break; + + case NorthEastGravity: + case SouthEastGravity: + case EastGravity: + /* the right side of the client will be the right side of the frame */ + *x -= self->size.right + self->size.left - self->client->border_width + * 2; + break; + + case ForgetGravity: + case StaticGravity: + /* the client's position won't move */ + *x -= self->size.left - self->client->border_width; + break; + } + + /* vertical */ + switch (self->client->gravity) + { + default: + case NorthWestGravity: + case NorthEastGravity: + case NorthGravity: + break; + + case CenterGravity: + case EastGravity: + case WestGravity: + /* the middle of the client will be the middle of the frame */ + *y -= (self->size.bottom - self->size.top) / 2; + break; + + case SouthWestGravity: + case SouthEastGravity: + case SouthGravity: + /* the bottom of the client will be the bottom of the frame */ + *y -= self->size.bottom + self->size.top - self->client->border_width + * 2; + break; + + case ForgetGravity: + case StaticGravity: + /* the client's position won't move */ + *y -= self->size.top - self->client->border_width; + break; + } + } + +void frame_frame_gravity(gpointer _self, gint *x, gint *y) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + /* horizontal */ + switch (self->client->gravity) + { + default: + case NorthWestGravity: + case WestGravity: + case SouthWestGravity: + break; + case NorthGravity: + case CenterGravity: + case SouthGravity: + /* the middle of the client will be the middle of the frame */ + *x += (self->size.right - self->size.left) / 2; + break; + case NorthEastGravity: + case EastGravity: + case SouthEastGravity: + /* the right side of the client will be the right side of the frame */ + *x += self->size.right + self->size.left - self->client->border_width + * 2; + break; + case StaticGravity: + case ForgetGravity: + /* the client's position won't move */ + *x += self->size.left - self->client->border_width; + break; + } + + /* vertical */ + switch (self->client->gravity) + { + default: + case NorthWestGravity: + case NorthGravity: + case NorthEastGravity: + break; + case WestGravity: + case CenterGravity: + case EastGravity: + /* the middle of the client will be the middle of the frame */ + *y += (self->size.bottom - self->size.top) / 2; + break; + case SouthWestGravity: + case SouthGravity: + case SouthEastGravity: + /* the bottom of the client will be the bottom of the frame */ + *y += self->size.bottom + self->size.top - self->client->border_width + * 2; + break; + case StaticGravity: + case ForgetGravity: + /* the client's position won't move */ + *y += self->size.top - self->client->border_width; + break; + } + } + +void frame_rect_to_frame(gpointer _self, Rect *r) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + r->width += self->size.left + self->size.right; + r->height += self->size.top + self->size.bottom; + frame_client_gravity(self, &r->x, &r->y); + } + +void frame_rect_to_client(gpointer _self, Rect *r) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + r->width -= self->size.left + self->size.right; + r->height -= self->size.top + self->size.bottom; + frame_frame_gravity(self, &r->x, &r->y); + } + +void flash_done(gpointer data) + { + ObDefaultFrame *self = data; + + if (self->focused != self->flash_on) + frame_adjust_focus(self, self->focused); + } + +gboolean flash_timeout(gpointer data) + { + ObDefaultFrame *self = data; + GTimeVal now; + + g_get_current_time(&now); + if (now.tv_sec > self->flash_end.tv_sec || (now.tv_sec + == self->flash_end.tv_sec && now.tv_usec >= self->flash_end.tv_usec)) + self->flashing = FALSE; + + if (!self->flashing) + return FALSE; /* we are done */ + + self->flash_on = !self->flash_on; + if (!self->focused) + { + frame_adjust_focus(self, self->flash_on); + self->focused = FALSE; + } + + return TRUE; /* go again */ + } + +void frame_flash_start(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + self->flash_on = self->focused; + + if (!self->flashing) + ob_main_loop_timeout_add(default_plugin.ob_main_loop, G_USEC_PER_SEC + * 0.6, flash_timeout, self, g_direct_equal, flash_done); + g_get_current_time(&self->flash_end); + g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5); + + self->flashing = TRUE; + } + +void frame_flash_stop(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + self->flashing = FALSE; + } + +static gulong frame_animate_iconify_time_left(gpointer _self, + const GTimeVal *now) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + glong sec, usec; + sec = self->iconify_animation_end.tv_sec - now->tv_sec; + usec = self->iconify_animation_end.tv_usec - now->tv_usec; + if (usec < 0) + { + usec += G_USEC_PER_SEC; + sec--; + } + /* no negative values */ + return MAX(sec * G_USEC_PER_SEC + usec, 0); + } + +gboolean frame_animate_iconify(gpointer p) + { + ObDefaultFrame *self = p; + gint x, y, w, h; + gint iconx, icony, iconw; + GTimeVal now; + gulong time; + gboolean iconifying; + + if (self->client->icon_geometry.width == 0) + { + /* there is no icon geometry set so just go straight down */ + Rect *a = + screen_physical_area_monitor(screen_find_monitor(&self->area)); + iconx = self->area.x + self->area.width / 2 + 32; + icony = a->y + a->width; + iconw = 64; + g_free(a); + } + else + { + iconx = self->client->icon_geometry.x; + icony = self->client->icon_geometry.y; + iconw = self->client->icon_geometry.width; + } + + iconifying = self->iconify_animation_going > 0; + + /* how far do we have left to go ? */ + g_get_current_time(&now); + time = frame_animate_iconify_time_left(self, &now); + + if (time == 0 || iconifying) + { + /* start where the frame is supposed to be */ + x = self->area.x; + y = self->area.y; + w = self->area.width; + h = self->area.height; + } + else + { + /* start at the icon */ + x = iconx; + y = icony; + w = iconw; + h = self->size.top; /* just the titlebar */ + } + + if (time > 0) + { + glong dx, dy, dw; + glong elapsed; + + dx = self->area.x - iconx; + dy = self->area.y - icony; + dw = self->area.width - self->bwidth * 2 - iconw; + /* if restoring, we move in the opposite direction */ + if (!iconifying) + { + dx = -dx; + dy = -dy; + dw = -dw; + } + + elapsed = FRAME_ANIMATE_ICONIFY_TIME - time; + x = x - (dx * elapsed) / FRAME_ANIMATE_ICONIFY_TIME; + y = y - (dy * elapsed) / FRAME_ANIMATE_ICONIFY_TIME; + w = w - (dw * elapsed) / FRAME_ANIMATE_ICONIFY_TIME; + h = self->size.top; /* just the titlebar */ + } + + if (time == 0) + frame_end_iconify_animation(self); + else + { + XMoveResizeWindow(default_plugin.ob_display, self->window, x, y, w, h); + XFlush(default_plugin.ob_display); + } + + return time > 0; /* repeat until we're out of time */ + } + +void frame_end_iconify_animation(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + /* see if there is an animation going */ + if (self->iconify_animation_going == 0) + return; + + if (!self->visible) + XUnmapWindow(default_plugin.ob_display, self->window); + else + { + /* Send a ConfigureNotify when the animation is done, this fixes + KDE's pager showing the window in the wrong place. since the + window is mapped at a different location and is then moved, we + need to send the synthetic configurenotify, since apps may have + read the position when the client mapped, apparently. */ + client_reconfigure(self->client, TRUE); + } + + /* we're not animating any more ! */ + self->iconify_animation_going = 0; + + XMoveResizeWindow(default_plugin.ob_display, self->window, self->area.x, + self->area.y, self->area.width, self->area.height); + /* we delay re-rendering until after we're done animating */ + framerender_frame(self); + XFlush(default_plugin.ob_display); + } + +void frame_begin_iconify_animation(gpointer _self, gboolean iconifying) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + gulong time; + gboolean new_anim = FALSE; + gboolean set_end = TRUE; + GTimeVal now; + + /* if there is no titlebar, just don't animate for now + XXX it would be nice tho.. */ + if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR)) + return; + + /* get the current time */ + g_get_current_time(&now); + + /* get how long until the end */ + time = FRAME_ANIMATE_ICONIFY_TIME; + if (self->iconify_animation_going) + { + if (!!iconifying != (self->iconify_animation_going > 0)) + { + /* animation was already going on in the opposite direction */ + time = time - frame_animate_iconify_time_left(self, &now); + } + else + /* animation was already going in the same direction */ + set_end = FALSE; + } + else + new_anim = TRUE; + self->iconify_animation_going = iconifying ? 1 : -1; + + /* set the ending time */ + if (set_end) + { + self->iconify_animation_end.tv_sec = now.tv_sec; + self->iconify_animation_end.tv_usec = now.tv_usec; + g_time_val_add(&self->iconify_animation_end, time); + } + + if (new_anim) + { + ob_main_loop_timeout_remove_data(default_plugin.ob_main_loop, + frame_animate_iconify, self, FALSE); + ob_main_loop_timeout_add(default_plugin.ob_main_loop, + FRAME_ANIMATE_ICONIFY_STEP_TIME, frame_animate_iconify, self, + g_direct_equal, NULL); + + /* do the first step */ + frame_animate_iconify(self); + + /* show it during the animation even if it is not "visible" */ + if (!self->visible) + XMapWindow(default_plugin.ob_display, self->window); + } + } + +gboolean frame_iconify_animating(gpointer _self) + { + ObDefaultFrame * self = (ObDefaultFrame *) _self; + return self->iconify_animation_going != 0; + } + +ObFramePlugin default_plugin = + { 0, //gpointer handler; + "libdefault.la", //gchar * filename; + "Default", //gchar * name; + init, //gint (*init) (Display * display, gint screen); + frame_new, //gpointer (*frame_new) (struct _ObClient *c); + frame_free, //void (*frame_free) (gpointer self); + frame_show, //void (*frame_show) (gpointer self); + frame_hide, //void (*frame_hide) (gpointer self); + frame_adjust_theme, //void (*frame_adjust_theme) (gpointer self); + frame_adjust_shape, //void (*frame_adjust_shape) (gpointer self); + frame_adjust_area, //void (*frame_adjust_area) (gpointer self, gboolean moved, gboolean resized, gboolean fake); + frame_adjust_client_area, //void (*frame_adjust_client_area) (gpointer self); + frame_adjust_state, //void (*frame_adjust_state) (gpointer self); + frame_adjust_focus, //void (*frame_adjust_focus) (gpointer self, gboolean hilite); + frame_adjust_title, //void (*frame_adjust_title) (gpointer self); + frame_adjust_icon, //void (*frame_adjust_icon) (gpointer self); + frame_grab_client, //void (*frame_grab_client) (gpointer self); + frame_release_client, //void (*frame_release_client) (gpointer self); + frame_context_from_string, //ObFrameContext (*frame_context_from_string) (const gchar *name); + frame_context, //ObFrameContext (*frame_context) (struct _ObClient *self, Window win, gint x, gint y); + frame_client_gravity, //void (*frame_client_gravity) (gpointer self, gint *x, gint *y); + frame_frame_gravity, //void (*frame_frame_gravity) (gpointer self, gint *x, gint *y); + frame_rect_to_frame, //void (*frame_rect_to_frame) (gpointer self, Rect *r); + frame_rect_to_client, //void (*frame_rect_to_client) (gpointer self, Rect *r); + frame_flash_start, //void (*frame_flash_start) (gpointer self); + frame_flash_stop, //void (*frame_flash_stop) (gpointer self); + frame_begin_iconify_animation, //void (*frame_begin_iconify_animation) (gpointer self, gboolean iconifying); + frame_end_iconify_animation, //void (*frame_end_iconify_animation) (gpointer self); + frame_iconify_animating, // gboolean (*frame_iconify_animating)(gpointer p); + + /* This fields are fill by openbox. */ + 0, //Display * ob_display; + 0, //gint ob_screen; + 0, //RrInstance *ob_rr_inst; + 0, //RrTheme *ob_rr_theme; + 0, //gboolean config_theme_keepborder; + 0, //struct _ObClient *focus_cycle_target; + 0, //gchar *config_title_layout; + 0, //gboolean moveresize_in_progress; + 0, //struct _ObMainLoop *ob_main_loop; +}; + +ObFramePlugin * get_info() + { + return &default_plugin; + } + diff --git a/frameplugins/default/frame_default_plugin.h b/frameplugins/default/frame_default_plugin.h new file mode 100644 index 0000000..954a9a0 --- /dev/null +++ b/frameplugins/default/frame_default_plugin.h @@ -0,0 +1,206 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + frame_default_plugin.h for the Openbox window manager + Copyright (c) 2003-2007 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ +#ifndef FRAME_DEFAULT_PLUGIN_H_ +#define FRAME_DEFAULT_PLUGIN_H_ + +#include "render/render.h" +#include "render/theme.h" +#include "openbox/plugin.h" + +struct _ObDefaultFrame + { + // PUBLIC : + struct _ObClient *client; + + Window window; + + Strut size; + Rect area; + gint bwidth; /* border width */ + guint decorations; + + gboolean visible; + + gboolean max_horz; /* when maxed some decorations are hidden */ + gboolean max_vert; /* when maxed some decorations are hidden */ + + gboolean max_press; + gboolean close_press; + gboolean desk_press; + gboolean shade_press; + gboolean iconify_press; + + gboolean max_hover; + gboolean close_hover; + gboolean desk_hover; + gboolean shade_hover; + gboolean iconify_hover; + + gint iconify_animation_going; + + /* PRIVATE: */ + /* You are free to add what you want here */ + + ObStyle style; + + guint functions; + + Window title; + Window label; + Window max; + Window close; + Window desk; + Window shade; + Window icon; + Window iconify; + Window handle; + Window lgrip; + Window rgrip; + + /* These are borders of the frame and its elements */ + Window titleleft; + Window titletop; + Window titletopleft; + Window titletopright; + Window titleright; + Window titlebottom; + Window left; + Window right; + Window handleleft; + Window handletop; + Window handleright; + Window handlebottom; + Window lgriptop; + Window lgripleft; + Window lgripbottom; + Window rgriptop; + Window rgripright; + Window rgripbottom; + Window innerleft; /*!< For drawing the inner client border */ + Window innertop; /*!< For drawing the inner client border */ + Window innerright; /*!< For drawing the inner client border */ + Window innerbottom; /*!< For drawing the inner client border */ + Window innerblb; + Window innerbll; + Window innerbrb; + Window innerbrr; + Window backback; /*!< A colored window shown while resizing */ + Window backfront; /*!< An undrawn-in window, to prevent flashing on unmap */ + + /* These are resize handles inside the titlebar */ + Window topresize; + Window tltresize; + Window tllresize; + Window trtresize; + Window trrresize; + + Colormap colormap; + + RrAppearance *a_unfocused_title; + RrAppearance *a_focused_title; + RrAppearance *a_unfocused_label; + RrAppearance *a_focused_label; + RrAppearance *a_icon; + RrAppearance *a_unfocused_handle; + RrAppearance *a_focused_handle; + + gint icon_on; /* if the window icon button is on */ + gint label_on; /* if the window title is on */ + gint iconify_on; /* if the window iconify button is on */ + gint desk_on; /* if the window all-desktops button is on */ + gint shade_on; /* if the window shade button is on */ + gint max_on; /* if the window maximize button is on */ + gint close_on; /* if the window close button is on */ + + gint width; /* width of the titlebar and handle */ + gint label_width; /* width of the label in the titlebar */ + gint icon_x; /* x-position of the window icon button */ + gint label_x; /* x-position of the window title */ + gint iconify_x; /* x-position of the window iconify button */ + gint desk_x; /* x-position of the window all-desktops button */ + gint shade_x; /* x-position of the window shade button */ + gint max_x; /* x-position of the window maximize button */ + gint close_x; /* x-position of the window close button */ + + gint cbwidth_l; /* client border width */ + gint cbwidth_t; /* client border width */ + gint cbwidth_r; /* client border width */ + gint cbwidth_b; /* client border width */ + gboolean shaded; /* decorations adjust when shaded */ + + /* the leftmost and rightmost elements in the titlebar */ + ObFrameContext leftmost; + ObFrameContext rightmost; + + gboolean focused; + gboolean need_render; + + gboolean flashing; + gboolean flash_on; + GTimeVal flash_end; + + GTimeVal iconify_animation_end; + + }; + +typedef struct _ObDefaultFrame ObDefaultFrame; + +/* Function use for interface */ +gint init(Display *, gint); +gpointer frame_new(struct _ObClient *c); +void frame_free(gpointer self); +void frame_show(gpointer self); +void frame_hide(gpointer self); +void frame_adjust_theme(gpointer self); +void frame_adjust_shape(gpointer self); +void frame_adjust_area(gpointer self, gboolean moved, gboolean resized, + gboolean fake); +void frame_adjust_client_area(gpointer self); +void frame_adjust_state(gpointer self); +void frame_adjust_focus(gpointer self, gboolean hilite); +void frame_adjust_title(gpointer self); +void frame_adjust_icon(gpointer self); +void frame_grab_client(gpointer self); +void frame_release_client(gpointer self); +ObFrameContext frame_context_from_string(const gchar *name); +ObFrameContext + frame_context(struct _ObClient *self, Window win, gint x, gint y); +void frame_client_gravity(gpointer self, gint *x, gint *y); +void frame_frame_gravity(gpointer self, gint *x, gint *y); +void frame_rect_to_frame(gpointer self, Rect *r); +void frame_rect_to_client(gpointer self, Rect *r); +void frame_flash_start(gpointer self); +void frame_flash_stop(gpointer self); +void frame_begin_iconify_animation(gpointer self, gboolean iconifying); +void frame_end_iconify_animation(gpointer self); +gboolean frame_iconify_animating(gpointer _self); + +void flash_done(gpointer data); +gboolean flash_timeout(gpointer data); + +void layout_title(ObDefaultFrame *); +void set_theme_statics(gpointer self); +void free_theme_statics(gpointer self); +gboolean frame_animate_iconify(gpointer self); +void frame_adjust_cursors(gpointer self); + +/* Global for renderframe.c only */ +extern ObFramePlugin default_plugin; +#define OBDEFAULTFRAME(x) ((ObDefaultFrame *)(x)) + +#endif /*FRAME_DEFAULT_PLUGIN_H_*/ diff --git a/frameplugins/default/framerender.c b/frameplugins/default/framerender.c new file mode 100644 index 0000000..734cbae --- /dev/null +++ b/frameplugins/default/framerender.c @@ -0,0 +1,412 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + framerender.c for the Openbox window manager + Copyright (c) 2006 Mikael Magnusson + Copyright (c) 2003-2007 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#include "openbox/plugin.h" +#include "openbox/openbox.h" +#include "openbox/screen.h" +#include "openbox/client.h" +#include "framerender.h" +#include "render/theme.h" +#include "frame_default_plugin.h" + +static void framerender_label(ObDefaultFrame *self, RrAppearance *a); +static void framerender_icon(ObDefaultFrame *self, RrAppearance *a); +static void framerender_max(ObDefaultFrame *self, RrAppearance *a); +static void framerender_iconify(ObDefaultFrame *self, RrAppearance *a); +static void framerender_desk(ObDefaultFrame *self, RrAppearance *a); +static void framerender_shade(ObDefaultFrame *self, RrAppearance *a); +static void framerender_close(ObDefaultFrame *self, RrAppearance *a); + +void framerender_frame(gpointer _self) +{ + ObDefaultFrame * self = (ObDefaultFrame *) _self; + if (render_plugin->frame_iconify_animating(self)) + return; /* delay redrawing until the animation is done */ + if (!self->need_render) + return; + if (!self->visible) + return; + self->need_render = FALSE; + + { + gulong px; + + px = (self->focused ? + RrColorPixel(render_plugin->ob_rr_theme->cb_focused_color) : + RrColorPixel(render_plugin->ob_rr_theme->cb_unfocused_color)); + + XSetWindowBackground(render_plugin->ob_display, self->backback, px); + XClearWindow(render_plugin->ob_display, self->backback); + XSetWindowBackground(render_plugin->ob_display, self->innerleft, px); + XClearWindow(render_plugin->ob_display, self->innerleft); + XSetWindowBackground(render_plugin->ob_display, self->innertop, px); + XClearWindow(render_plugin->ob_display, self->innertop); + XSetWindowBackground(render_plugin->ob_display, self->innerright, px); + XClearWindow(render_plugin->ob_display, self->innerright); + XSetWindowBackground(render_plugin->ob_display, self->innerbottom, px); + XClearWindow(render_plugin->ob_display, self->innerbottom); + XSetWindowBackground(render_plugin->ob_display, self->innerbll, px); + XClearWindow(render_plugin->ob_display, self->innerbll); + XSetWindowBackground(render_plugin->ob_display, self->innerbrr, px); + XClearWindow(render_plugin->ob_display, self->innerbrr); + XSetWindowBackground(render_plugin->ob_display, self->innerblb, px); + XClearWindow(render_plugin->ob_display, self->innerblb); + XSetWindowBackground(render_plugin->ob_display, self->innerbrb, px); + XClearWindow(render_plugin->ob_display, self->innerbrb); + + px = (self->focused ? + RrColorPixel(render_plugin->ob_rr_theme->frame_focused_border_color) : + RrColorPixel(render_plugin->ob_rr_theme->frame_unfocused_border_color)); + + XSetWindowBackground(render_plugin->ob_display, self->left, px); + XClearWindow(render_plugin->ob_display, self->left); + XSetWindowBackground(render_plugin->ob_display, self->right, px); + XClearWindow(render_plugin->ob_display, self->right); + + XSetWindowBackground(render_plugin->ob_display, self->titleleft, px); + XClearWindow(render_plugin->ob_display, self->titleleft); + XSetWindowBackground(render_plugin->ob_display, self->titletop, px); + XClearWindow(render_plugin->ob_display, self->titletop); + XSetWindowBackground(render_plugin->ob_display, self->titletopleft, px); + XClearWindow(render_plugin->ob_display, self->titletopleft); + XSetWindowBackground(render_plugin->ob_display, self->titletopright, px); + XClearWindow(render_plugin->ob_display, self->titletopright); + XSetWindowBackground(render_plugin->ob_display, self->titleright, px); + XClearWindow(render_plugin->ob_display, self->titleright); + + XSetWindowBackground(render_plugin->ob_display, self->handleleft, px); + XClearWindow(render_plugin->ob_display, self->handleleft); + XSetWindowBackground(render_plugin->ob_display, self->handletop, px); + XClearWindow(render_plugin->ob_display, self->handletop); + XSetWindowBackground(render_plugin->ob_display, self->handleright, px); + XClearWindow(render_plugin->ob_display, self->handleright); + XSetWindowBackground(render_plugin->ob_display, self->handlebottom, px); + XClearWindow(render_plugin->ob_display, self->handlebottom); + + XSetWindowBackground(render_plugin->ob_display, self->lgripleft, px); + XClearWindow(render_plugin->ob_display, self->lgripleft); + XSetWindowBackground(render_plugin->ob_display, self->lgriptop, px); + XClearWindow(render_plugin->ob_display, self->lgriptop); + XSetWindowBackground(render_plugin->ob_display, self->lgripbottom, px); + XClearWindow(render_plugin->ob_display, self->lgripbottom); + + XSetWindowBackground(render_plugin->ob_display, self->rgripright, px); + XClearWindow(render_plugin->ob_display, self->rgripright); + XSetWindowBackground(render_plugin->ob_display, self->rgriptop, px); + XClearWindow(render_plugin->ob_display, self->rgriptop); + XSetWindowBackground(render_plugin->ob_display, self->rgripbottom, px); + XClearWindow(render_plugin->ob_display, self->rgripbottom); + + /* don't use the separator color for shaded windows */ + if (!self->client->shaded) + px = (self->focused ? + RrColorPixel(render_plugin->ob_rr_theme->title_separator_focused_color) : + RrColorPixel(render_plugin->ob_rr_theme->title_separator_unfocused_color)); + + XSetWindowBackground(render_plugin->ob_display, self->titlebottom, px); + XClearWindow(render_plugin->ob_display, self->titlebottom); + } + + if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { + RrAppearance *t, *l, *m, *n, *i, *d, *s, *c, *clear; + if (self->focused) { + + t = self->a_focused_title; + l = self->a_focused_label; + + m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ? + render_plugin->ob_rr_theme->a_disabled_focused_max : + (self->client->max_vert || self->client->max_horz ? + (self->max_press ? + render_plugin->ob_rr_theme->a_toggled_focused_pressed_max : + (self->max_hover ? + render_plugin->ob_rr_theme->a_toggled_hover_focused_max : + render_plugin->ob_rr_theme->a_toggled_focused_unpressed_max)) : + (self->max_press ? + render_plugin->ob_rr_theme->a_focused_pressed_max : + (self->max_hover ? + render_plugin->ob_rr_theme->a_hover_focused_max : + render_plugin->ob_rr_theme->a_focused_unpressed_max)))); + n = self->a_icon; + i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? + render_plugin->ob_rr_theme->a_disabled_focused_iconify : + (self->iconify_press ? + render_plugin->ob_rr_theme->a_focused_pressed_iconify : + (self->iconify_hover ? + render_plugin->ob_rr_theme->a_hover_focused_iconify : + render_plugin->ob_rr_theme->a_focused_unpressed_iconify))); + d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ? + render_plugin->ob_rr_theme->a_disabled_focused_desk : + (self->client->desktop == DESKTOP_ALL ? + (self->desk_press ? + render_plugin->ob_rr_theme->a_toggled_focused_pressed_desk : + (self->desk_hover ? + render_plugin->ob_rr_theme->a_toggled_hover_focused_desk : + render_plugin->ob_rr_theme->a_toggled_focused_unpressed_desk)) : + (self->desk_press ? + render_plugin->ob_rr_theme->a_focused_pressed_desk : + (self->desk_hover ? + render_plugin->ob_rr_theme->a_hover_focused_desk : + render_plugin->ob_rr_theme->a_focused_unpressed_desk)))); + s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ? + render_plugin->ob_rr_theme->a_disabled_focused_shade : + (self->client->shaded ? + (self->shade_press ? + render_plugin->ob_rr_theme->a_toggled_focused_pressed_shade : + (self->shade_hover ? + render_plugin->ob_rr_theme->a_toggled_hover_focused_shade : + render_plugin->ob_rr_theme->a_toggled_focused_unpressed_shade)) : + (self->shade_press ? + render_plugin->ob_rr_theme->a_focused_pressed_shade : + (self->shade_hover ? + render_plugin->ob_rr_theme->a_hover_focused_shade : + render_plugin->ob_rr_theme->a_focused_unpressed_shade)))); + c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ? + render_plugin->ob_rr_theme->a_disabled_focused_close : + (self->close_press ? + render_plugin->ob_rr_theme->a_focused_pressed_close : + (self->close_hover ? + render_plugin->ob_rr_theme->a_hover_focused_close : + render_plugin->ob_rr_theme->a_focused_unpressed_close))); + } else { + t = self->a_unfocused_title; + l = self->a_unfocused_label; + m = (!(self->decorations & OB_FRAME_DECOR_MAXIMIZE) ? + render_plugin->ob_rr_theme->a_disabled_unfocused_max : + (self->client->max_vert || self->client->max_horz ? + (self->max_press ? + render_plugin->ob_rr_theme->a_toggled_unfocused_pressed_max : + (self->max_hover ? + render_plugin->ob_rr_theme->a_toggled_hover_unfocused_max : + render_plugin->ob_rr_theme->a_toggled_unfocused_unpressed_max)) : + (self->max_press ? + render_plugin->ob_rr_theme->a_unfocused_pressed_max : + (self->max_hover ? + render_plugin->ob_rr_theme->a_hover_unfocused_max : + render_plugin->ob_rr_theme->a_unfocused_unpressed_max)))); + n = self->a_icon; + i = (!(self->decorations & OB_FRAME_DECOR_ICONIFY) ? + render_plugin->ob_rr_theme->a_disabled_unfocused_iconify : + (self->iconify_press ? + render_plugin->ob_rr_theme->a_unfocused_pressed_iconify : + (self->iconify_hover ? + render_plugin->ob_rr_theme->a_hover_unfocused_iconify : + render_plugin->ob_rr_theme->a_unfocused_unpressed_iconify))); + d = (!(self->decorations & OB_FRAME_DECOR_ALLDESKTOPS) ? + render_plugin->ob_rr_theme->a_disabled_unfocused_desk : + (self->client->desktop == DESKTOP_ALL ? + (self->desk_press ? + render_plugin->ob_rr_theme->a_toggled_unfocused_pressed_desk : + (self->desk_hover ? + render_plugin->ob_rr_theme->a_toggled_hover_unfocused_desk : + render_plugin->ob_rr_theme->a_toggled_unfocused_unpressed_desk)) : + (self->desk_press ? + render_plugin->ob_rr_theme->a_unfocused_pressed_desk : + (self->desk_hover ? + render_plugin->ob_rr_theme->a_hover_unfocused_desk : + render_plugin->ob_rr_theme->a_unfocused_unpressed_desk)))); + s = (!(self->decorations & OB_FRAME_DECOR_SHADE) ? + render_plugin->ob_rr_theme->a_disabled_unfocused_shade : + (self->client->shaded ? + (self->shade_press ? + render_plugin->ob_rr_theme->a_toggled_unfocused_pressed_shade : + (self->shade_hover ? + render_plugin->ob_rr_theme->a_toggled_hover_unfocused_shade : + render_plugin->ob_rr_theme->a_toggled_unfocused_unpressed_shade)) : + (self->shade_press ? + render_plugin->ob_rr_theme->a_unfocused_pressed_shade : + (self->shade_hover ? + render_plugin->ob_rr_theme->a_hover_unfocused_shade : + render_plugin->ob_rr_theme->a_unfocused_unpressed_shade)))); + c = (!(self->decorations & OB_FRAME_DECOR_CLOSE) ? + render_plugin->ob_rr_theme->a_disabled_unfocused_close : + (self->close_press ? + render_plugin->ob_rr_theme->a_unfocused_pressed_close : + (self->close_hover ? + render_plugin->ob_rr_theme->a_hover_unfocused_close : + render_plugin->ob_rr_theme->a_unfocused_unpressed_close))); + } + clear = render_plugin->ob_rr_theme->a_clear; + + RrPaint(t, self->title, self->width, render_plugin->ob_rr_theme->title_height); + + clear->surface.parent = t; + clear->surface.parenty = 0; + + clear->surface.parentx = render_plugin->ob_rr_theme->grip_width; + + RrPaint(clear, self->topresize, + self->width - render_plugin->ob_rr_theme->grip_width * 2, + render_plugin->ob_rr_theme->paddingy + 1); + + clear->surface.parentx = 0; + + if (render_plugin->ob_rr_theme->grip_width > 0) + RrPaint(clear, self->tltresize, + render_plugin->ob_rr_theme->grip_width, render_plugin->ob_rr_theme->paddingy + 1); + if (render_plugin->ob_rr_theme->title_height > 0) + RrPaint(clear, self->tllresize, + render_plugin->ob_rr_theme->paddingx + 1, render_plugin->ob_rr_theme->title_height); + + clear->surface.parentx = self->width - render_plugin->ob_rr_theme->grip_width; + + if (render_plugin->ob_rr_theme->grip_width > 0) + RrPaint(clear, self->trtresize, + render_plugin->ob_rr_theme->grip_width, render_plugin->ob_rr_theme->paddingy + 1); + + clear->surface.parentx = self->width - (render_plugin->ob_rr_theme->paddingx + 1); + + if (render_plugin->ob_rr_theme->title_height > 0) + RrPaint(clear, self->trrresize, + render_plugin->ob_rr_theme->paddingx + 1, render_plugin->ob_rr_theme->title_height); + + /* set parents for any parent relative guys */ + l->surface.parent = t; + l->surface.parentx = self->label_x; + l->surface.parenty = render_plugin->ob_rr_theme->paddingy; + + m->surface.parent = t; + m->surface.parentx = self->max_x; + m->surface.parenty = render_plugin->ob_rr_theme->paddingy + 1; + + n->surface.parent = t; + n->surface.parentx = self->icon_x; + n->surface.parenty = render_plugin->ob_rr_theme->paddingy; + + i->surface.parent = t; + i->surface.parentx = self->iconify_x; + i->surface.parenty = render_plugin->ob_rr_theme->paddingy + 1; + + d->surface.parent = t; + d->surface.parentx = self->desk_x; + d->surface.parenty = render_plugin->ob_rr_theme->paddingy + 1; + + s->surface.parent = t; + s->surface.parentx = self->shade_x; + s->surface.parenty = render_plugin->ob_rr_theme->paddingy + 1; + + c->surface.parent = t; + c->surface.parentx = self->close_x; + c->surface.parenty = render_plugin->ob_rr_theme->paddingy + 1; + + framerender_label(self, l); + framerender_max(self, m); + framerender_icon(self, n); + framerender_iconify(self, i); + framerender_desk(self, d); + framerender_shade(self, s); + framerender_close(self, c); + } + + if (self->decorations & OB_FRAME_DECOR_HANDLE && + render_plugin->ob_rr_theme->handle_height > 0) + { + RrAppearance *h, *g; + + h = (self->focused ? + self->a_focused_handle : self->a_unfocused_handle); + + RrPaint(h, self->handle, self->width, render_plugin->ob_rr_theme->handle_height); + + if (self->decorations & OB_FRAME_DECOR_GRIPS) { + g = (self->focused ? + render_plugin->ob_rr_theme->a_focused_grip : render_plugin->ob_rr_theme->a_unfocused_grip); + + if (g->surface.grad == RR_SURFACE_PARENTREL) + g->surface.parent = h; + + g->surface.parentx = 0; + g->surface.parenty = 0; + + RrPaint(g, self->lgrip, + render_plugin->ob_rr_theme->grip_width, render_plugin->ob_rr_theme->handle_height); + + g->surface.parentx = self->width - render_plugin->ob_rr_theme->grip_width; + g->surface.parenty = 0; + + RrPaint(g, self->rgrip, + render_plugin->ob_rr_theme->grip_width, render_plugin->ob_rr_theme->handle_height); + } + } + + XFlush(render_plugin->ob_display); +} + +static void framerender_label(ObDefaultFrame *self, RrAppearance *a) +{ + if (!self->label_on) return; + /* set the texture's text! */ + a->texture[0].data.text.string = self->client->title; + RrPaint(a, self->label, self->label_width, render_plugin->ob_rr_theme->label_height); +} + +static void framerender_icon(ObDefaultFrame *self, RrAppearance *a) +{ + const ObClientIcon *icon; + + if (!self->icon_on) return; + + icon = client_icon(self->client, + render_plugin->ob_rr_theme->button_size + 2, + render_plugin->ob_rr_theme->button_size + 2); + if (icon) { + a->texture[0].type = RR_TEXTURE_RGBA; + a->texture[0].data.rgba.width = icon->width; + a->texture[0].data.rgba.height = icon->height; + a->texture[0].data.rgba.alpha = 0xff; + a->texture[0].data.rgba.data = icon->data; + } else + a->texture[0].type = RR_TEXTURE_NONE; + + RrPaint(a, self->icon, + render_plugin->ob_rr_theme->button_size + 2, render_plugin->ob_rr_theme->button_size + 2); +} + +static void framerender_max(ObDefaultFrame *self, RrAppearance *a) +{ + if (!self->max_on) return; + RrPaint(a, self->max, render_plugin->ob_rr_theme->button_size, render_plugin->ob_rr_theme->button_size); +} + +static void framerender_iconify(ObDefaultFrame *self, RrAppearance *a) +{ + if (!self->iconify_on) return; + RrPaint(a, self->iconify, + render_plugin->ob_rr_theme->button_size, render_plugin->ob_rr_theme->button_size); +} + +static void framerender_desk(ObDefaultFrame *self, RrAppearance *a) +{ + if (!self->desk_on) return; + RrPaint(a, self->desk, render_plugin->ob_rr_theme->button_size, render_plugin->ob_rr_theme->button_size); +} + +static void framerender_shade(ObDefaultFrame *self, RrAppearance *a) +{ + if (!self->shade_on) return; + RrPaint(a, self->shade, + render_plugin->ob_rr_theme->button_size, render_plugin->ob_rr_theme->button_size); +} + +static void framerender_close(ObDefaultFrame *self, RrAppearance *a) +{ + if (!self->close_on) return; + RrPaint(a, self->close, + render_plugin->ob_rr_theme->button_size, render_plugin->ob_rr_theme->button_size); +} diff --git a/frameplugins/default/framerender.h b/frameplugins/default/framerender.h new file mode 100644 index 0000000..d30df94 --- /dev/null +++ b/frameplugins/default/framerender.h @@ -0,0 +1,26 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + framerender.h for the Openbox window manager + Copyright (c) 2003-2007 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + +#ifndef __framerender_h +#define __framerender_h + +#include "frame_default_plugin.h" + +void framerender_frame(gpointer self); + +#endif diff --git a/openbox/actions.h b/openbox/actions.h index 477e4ba..0310b0d 100644 --- a/openbox/actions.h +++ b/openbox/actions.h @@ -17,7 +17,7 @@ */ #include "misc.h" -#include "frame.h" +#include "plugin.h" #include "parser/parse.h" #include #include diff --git a/openbox/actions/growtoedge.c b/openbox/actions/growtoedge.c index 11ea2fa..70c586c 100644 --- a/openbox/actions/growtoedge.c +++ b/openbox/actions/growtoedge.c @@ -1,7 +1,7 @@ #include "openbox/actions.h" #include "openbox/misc.h" #include "openbox/client.h" -#include "openbox/frame.h" +#include "openbox/plugin.h" #include "openbox/screen.h" #include diff --git a/openbox/actions/moverelative.c b/openbox/actions/moverelative.c index deb1eae..2679e36 100644 --- a/openbox/actions/moverelative.c +++ b/openbox/actions/moverelative.c @@ -1,7 +1,7 @@ #include "openbox/actions.h" #include "openbox/client.h" #include "openbox/screen.h" -#include "openbox/frame.h" +#include "openbox/plugin.h" #include /* for atoi */ typedef struct { diff --git a/openbox/actions/moveresizeto.c b/openbox/actions/moveresizeto.c index 982f762..924fe57 100644 --- a/openbox/actions/moveresizeto.c +++ b/openbox/actions/moveresizeto.c @@ -1,7 +1,8 @@ #include "openbox/actions.h" #include "openbox/client.h" #include "openbox/screen.h" -#include "openbox/frame.h" +#include "openbox/plugin.h" +#include "openbox/openbox.h" #include /* for atoi */ enum { @@ -180,7 +181,7 @@ static gboolean run_func(ObActionsData *data, gpointer options) w -= c->frame->size.left + c->frame->size.right; h -= c->frame->size.top + c->frame->size.bottom; - frame_frame_gravity(c->frame, &x, &y); /* get the client coords */ + render_plugin->frame_frame_gravity(c->frame, &x, &y); /* get the client coords */ client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE); /* force it on screen if its moving to another monitor */ client_find_onscreen(c, &x, &y, w, h, mon != cmon); diff --git a/openbox/actions/movetoedge.c b/openbox/actions/movetoedge.c index f09bfd8..0076519 100644 --- a/openbox/actions/movetoedge.c +++ b/openbox/actions/movetoedge.c @@ -1,7 +1,7 @@ #include "openbox/actions.h" #include "openbox/misc.h" #include "openbox/client.h" -#include "openbox/frame.h" +#include "openbox/plugin.h" #include "openbox/geom.h" #include diff --git a/openbox/actions/resize.c b/openbox/actions/resize.c index 2695137..2cbd0b4 100644 --- a/openbox/actions/resize.c +++ b/openbox/actions/resize.c @@ -2,7 +2,7 @@ #include "openbox/prop.h" #include "openbox/moveresize.h" #include "openbox/client.h" -#include "openbox/frame.h" +#include "openbox/plugin.h" typedef struct { guint32 corner; diff --git a/openbox/actions/resizerelative.c b/openbox/actions/resizerelative.c index 668a063..b5c9e1f 100644 --- a/openbox/actions/resizerelative.c +++ b/openbox/actions/resizerelative.c @@ -1,7 +1,7 @@ #include "openbox/actions.h" #include "openbox/client.h" #include "openbox/screen.h" -#include "openbox/frame.h" +#include "openbox/plugin.h" #include /* for atoi */ typedef struct { diff --git a/openbox/client.c b/openbox/client.c index f97bd43..4797623 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -27,7 +27,7 @@ #include "place.h" #include "prop.h" #include "extensions.h" -#include "frame.h" +#include "plugin.h" #include "session.h" #include "event.h" #include "grab.h" @@ -155,7 +155,7 @@ void client_set_list() } else windows = NULL; - PROP_SETA32(RootWindow(ob_display, ob_screen), + PROP_SETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_client_list, window, (gulong*)windows, size); if (windows) @@ -171,13 +171,13 @@ void client_manage_all() XWMHints *wmhints; XWindowAttributes attrib; - XQueryTree(ob_display, RootWindow(ob_display, ob_screen), + XQueryTree(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), &w, &w, &children, &nchild); /* remove all icon windows from the list */ for (i = 0; i < nchild; i++) { if (children[i] == None) continue; - wmhints = XGetWMHints(ob_display, children[i]); + wmhints = XGetWMHints(render_plugin->ob_display, children[i]); if (wmhints) { if ((wmhints->flags & IconWindowHint) && (wmhints->icon_window != children[i])) @@ -193,7 +193,7 @@ void client_manage_all() for (i = 0; i < nchild; ++i) { if (children[i] == None) continue; - if (XGetWindowAttributes(ob_display, children[i], &attrib)) { + if (XGetWindowAttributes(render_plugin->ob_display, children[i], &attrib)) { if (attrib.override_redirect) continue; if (attrib.map_state != IsUnmapped) @@ -220,10 +220,10 @@ void client_manage(Window window) /* check if it has already been unmapped by the time we started mapping. the grab does a sync so we don't have to here */ - if (XCheckTypedWindowEvent(ob_display, window, DestroyNotify, &e) || - XCheckTypedWindowEvent(ob_display, window, UnmapNotify, &e)) + if (XCheckTypedWindowEvent(render_plugin->ob_display, window, DestroyNotify, &e) || + XCheckTypedWindowEvent(render_plugin->ob_display, window, UnmapNotify, &e)) { - XPutBackEvent(ob_display, &e); + XPutBackEvent(render_plugin->ob_display, &e); ob_debug("Trying to manage unmapped window. Aborting that.\n"); grab_server(FALSE); @@ -231,7 +231,7 @@ void client_manage(Window window) } /* make sure it isn't an override-redirect window */ - if (!XGetWindowAttributes(ob_display, window, &attrib) || + if (!XGetWindowAttributes(render_plugin->ob_display, window, &attrib) || attrib.override_redirect) { grab_server(FALSE); @@ -239,7 +239,7 @@ void client_manage(Window window) } /* is the window a docking app */ - if ((wmhint = XGetWMHints(ob_display, window))) { + if ((wmhint = XGetWMHints(render_plugin->ob_display, window))) { if ((wmhint->flags & StateHint) && wmhint->initial_state == WithdrawnState) { @@ -258,7 +258,7 @@ void client_manage(Window window) /* choose the events we want to receive on the CLIENT window */ attrib_set.event_mask = CLIENT_EVENTMASK; attrib_set.do_not_propagate_mask = CLIENT_NOPROPAGATEMASK; - XChangeWindowAttributes(ob_display, window, + XChangeWindowAttributes(render_plugin->ob_display, window, CWEventMask|CWDontPropagate, &attrib_set); /* create the ObClient struct, and populate it from the hints on the @@ -280,12 +280,12 @@ void client_manage(Window window) /* specify that if we exit, the window should not be destroyed and should be reparented back to root automatically */ - XChangeSaveSet(ob_display, window, SetModeInsert); + XChangeSaveSet(render_plugin->ob_display, window, SetModeInsert); /* create the decoration frame for the client window */ - self->frame = frame_new(self); + self->frame = OBFRAME(render_plugin->frame_new(self)); - frame_grab_client(self->frame); + render_plugin->frame_grab_client(self->frame); /* we've grabbed everything and set everything that we need to at mapping time now */ @@ -328,12 +328,12 @@ void client_manage(Window window) } /* remove the client's border */ - XSetWindowBorderWidth(ob_display, self->window, 0); + XSetWindowBorderWidth(render_plugin->ob_display, self->window, 0); /* adjust the frame to the client's size before showing or placing the window */ - frame_adjust_area(self->frame, FALSE, TRUE, FALSE); - frame_adjust_client_area(self->frame); + render_plugin->frame_adjust_area(self->frame, FALSE, TRUE, FALSE); + render_plugin->frame_adjust_client_area(self->frame); /* where the frame was placed is where the window was originally */ place = self->area; @@ -460,7 +460,7 @@ void client_manage(Window window) self->window, map_time, launch_time, event_last_user_time); - if (menu_frame_visible || moveresize_in_progress) { + if (menu_frame_visible || render_plugin->moveresize_in_progress) { activate = FALSE; raise = TRUE; ob_debug_type(OB_DEBUG_FOCUS, @@ -624,8 +624,8 @@ ObClient *client_fake_manage(Window window) client_setup_decor_and_functions(self, FALSE); /* create the decoration frame for the client window and adjust its size */ - self->frame = frame_new(self); - frame_adjust_area(self->frame, FALSE, TRUE, TRUE); + self->frame = OBFRAME(render_plugin->frame_new(self)); + render_plugin->frame_adjust_area(self->frame, FALSE, TRUE, TRUE); ob_debug("gave extents left %d right %d top %d bottom %d\n", self->frame->size.left, self->frame->size.right, @@ -657,15 +657,15 @@ void client_unmanage(ObClient *self) /* we dont want events no more. do this before hiding the frame so we don't generate more events */ - XSelectInput(ob_display, self->window, NoEventMask); + XSelectInput(render_plugin->ob_display, self->window, NoEventMask); /* ignore enter events from the unmap so it doesnt mess with the focus */ if (!config_focus_under_mouse) ignore_start = event_start_ignore_all_enters(); - frame_hide(self->frame); + render_plugin->frame_hide(self->frame); /* flush to send the hide to the server quickly */ - XFlush(ob_display); + XFlush(render_plugin->ob_display); if (!config_focus_under_mouse) event_end_ignore_all_enters(ignore_start); @@ -673,7 +673,7 @@ void client_unmanage(ObClient *self) mouse_grab_for_client(self, FALSE); /* remove the window from our save set */ - XChangeSaveSet(ob_display, self->window, SetModeDelete); + XChangeSaveSet(render_plugin->ob_display, self->window, SetModeDelete); /* update the focus lists */ focus_order_remove(self); @@ -737,14 +737,14 @@ void client_unmanage(ObClient *self) self->decorations = 0; /* unmanaged windows have no decor */ /* give the client its border back */ - XSetWindowBorderWidth(ob_display, self->window, self->border_width); + XSetWindowBorderWidth(render_plugin->ob_display, self->window, self->border_width); client_move_resize(self, a.x, a.y, a.width, a.height); } /* reparent the window out of the frame, and free the frame */ - frame_release_client(self->frame); - frame_free(self->frame); + render_plugin->frame_release_client(self->frame); + render_plugin->frame_free(self->frame); self->frame = NULL; if (ob_state() != OB_STATE_EXITING) { @@ -757,7 +757,7 @@ void client_unmanage(ObClient *self) /* if we're left in an unmapped state, the client wont be mapped. this is bad, since we will no longer be managing the window on restart */ - XMapWindow(ob_display, self->window); + XMapWindow(render_plugin->ob_display, self->window); } /* update the list hints */ @@ -786,7 +786,7 @@ void client_fake_unmanage(ObClient *self) { /* this is all that got allocated to get the decorations */ - frame_free(self->frame); + render_plugin->frame_free(self->frame); g_free(self); } @@ -895,7 +895,7 @@ static void client_restore_session_state(ObClient *self) self->area.width = self->session->w; if (self->session->h > 0) self->area.height = self->session->h; - XResizeWindow(ob_display, self->window, + XResizeWindow(render_plugin->ob_display, self->window, self->area.width, self->area.height); self->desktop = (self->session->desktop == DESKTOP_ALL ? @@ -962,10 +962,10 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h, guint i; RECT_SET(desired, *x, *y, w, h); - frame_rect_to_frame(self->frame, &desired); + render_plugin->frame_rect_to_frame(self->frame, &desired); /* get where the frame would be */ - frame_client_gravity(self->frame, x, y); + render_plugin->frame_client_gravity(self->frame, x, y); /* get the requested size of the window with decorations */ fw = self->frame->size.left + w + self->frame->size.right; @@ -1058,7 +1058,7 @@ gboolean client_find_onscreen(ObClient *self, gint *x, gint *y, gint w, gint h, } /* get where the client should be */ - frame_frame_gravity(self->frame, x, y); + render_plugin->frame_frame_gravity(self->frame, x, y); return ox != *x || oy != *y; } @@ -1130,7 +1130,7 @@ static void client_get_area(ObClient *self) XWindowAttributes wattrib; Status ret; - ret = XGetWindowAttributes(ob_display, self->window, &wattrib); + ret = XGetWindowAttributes(render_plugin->ob_display, self->window, &wattrib); g_assert(ret != BadWindow); RECT_SET(self->area, wattrib.x, wattrib.y, wattrib.width, wattrib.height); @@ -1240,9 +1240,9 @@ static void client_get_shaped(ObClient *self) guint ufoo; gint s; - XShapeSelectInput(ob_display, self->window, ShapeNotifyMask); + XShapeSelectInput(render_plugin->ob_display, self->window, ShapeNotifyMask); - XShapeQueryExtents(ob_display, self->window, &s, &foo, + XShapeQueryExtents(render_plugin->ob_display, self->window, &s, &foo, &foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo, &ufoo); self->shaped = (s != 0); @@ -1256,7 +1256,7 @@ void client_update_transient_for(ObClient *self) ObClient *target = NULL; gboolean trangroup = FALSE; - if (XGetTransientForHint(ob_display, self->window, &t)) { + if (XGetTransientForHint(render_plugin->ob_display, self->window, &t)) { if (t != self->window) { /* cant be transient to itself! */ target = g_hash_table_lookup(window_map, &t); /* if this happens then we need to check for it*/ @@ -1271,7 +1271,7 @@ void client_update_transient_for(ObClient *self) /* Setting the transient_for to Root is actually illegal, however applications from time have done this to specify transient for their group */ - if (!target && self->group && t == RootWindow(ob_display, ob_screen)) + if (!target && self->group && t == RootWindow(render_plugin->ob_display, render_plugin->ob_screen)) trangroup = TRUE; } else if (self->group && self->transient) trangroup = TRUE; @@ -1460,7 +1460,7 @@ void client_get_type_and_transientness(ObClient *self) g_free(val); } - if (XGetTransientForHint(ob_display, self->window, &t)) + if (XGetTransientForHint(render_plugin->ob_display, self->window, &t)) self->transient = TRUE; if (self->type == (ObClientType) -1) { @@ -1528,7 +1528,7 @@ void client_get_colormap(ObClient *self) { XWindowAttributes wa; - if (XGetWindowAttributes(ob_display, self->window, &wa)) + if (XGetWindowAttributes(render_plugin->ob_display, self->window, &wa)) client_update_colormap(self, wa.colormap); } @@ -1560,7 +1560,7 @@ void client_update_normal_hints(ObClient *self) SIZE_SET(self->max_size, G_MAXINT, G_MAXINT); /* get the hints from the window */ - if (XGetWMNormalHints(ob_display, self->window, &size, &ret)) { + if (XGetWMNormalHints(render_plugin->ob_display, self->window, &size, &ret)) { /* normal windows can't request placement! har har if (!client_normal(self)) */ @@ -1822,7 +1822,7 @@ void client_update_wmhints(ObClient *self) /* assume a window takes input if it doesnt specify */ self->can_focus = TRUE; - if ((hints = XGetWMHints(ob_display, self->window)) != NULL) { + if ((hints = XGetWMHints(render_plugin->ob_display, self->window)) != NULL) { gboolean ur; if (hints->flags & InputHint) @@ -1935,7 +1935,7 @@ void client_update_title(ObClient *self) self->title = visible; if (self->frame) - frame_adjust_title(self->frame); + render_plugin->frame_adjust_title(self->frame); /* update the icon title */ data = NULL; @@ -2066,12 +2066,12 @@ void client_update_icons(ObClient *self) } else { XWMHints *hints; - if ((hints = XGetWMHints(ob_display, self->window))) { + if ((hints = XGetWMHints(render_plugin->ob_display, self->window))) { if (hints->flags & IconPixmapHint) { self->nicons = 1; self->icons = g_new(ObClientIcon, self->nicons); xerror_set_ignore(TRUE); - if (!RrPixmapToRGBA(ob_rr_inst, + if (!RrPixmapToRGBA(render_plugin->ob_rr_inst, hints->icon_pixmap, (hints->flags & IconMaskHint ? hints->icon_mask : None), @@ -2096,7 +2096,7 @@ void client_update_icons(ObClient *self) if it has parents, then one of them will have an icon already */ if (self->nicons == 0 && !self->parents) { - RrPixel32 *icon = ob_rr_theme->def_win_icon; + RrPixel32 *icon = render_plugin->ob_rr_theme->def_win_icon; gulong *data; data = g_new(gulong, 48*48+2); @@ -2111,7 +2111,7 @@ void client_update_icons(ObClient *self) } else if (self->frame) /* don't draw the icon empty if we're just setting one now anyways, we'll get the property change any second */ - frame_adjust_icon(self->frame); + render_plugin->frame_adjust_icon(self->frame); } void client_update_icon_geometry(ObClient *self) @@ -2281,7 +2281,7 @@ static void client_change_state(ObClient *self) PROP_SETA32(self->window, net_wm_state, atom, netstate, num); if (self->frame) - frame_adjust_state(self->frame); + render_plugin->frame_adjust_state(self->frame); } ObClient *client_search_focus_tree(ObClient *self) @@ -2420,7 +2420,7 @@ gboolean client_show(ObClient *self) gboolean show = FALSE; if (client_should_show(self)) { - frame_show(self->frame); + render_plugin->frame_show(self->frame); show = TRUE; /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, @@ -2461,7 +2461,7 @@ gboolean client_hide(ObClient *self) so trying to ignore them is futile in case 3 anyways */ - frame_hide(self->frame); + render_plugin->frame_hide(self->frame); hide = TRUE; /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, @@ -2651,15 +2651,15 @@ void client_try_configure(ObClient *self, gint *x, gint *y, gint *w, gint *h, gboolean user) { Rect desired = {*x, *y, *w, *h}; - frame_rect_to_frame(self->frame, &desired); + render_plugin->frame_rect_to_frame(self->frame, &desired); /* make the frame recalculate its dimentions n shit without changing anything visible for real, this way the constraints below can work with the updated frame dimensions. */ - frame_adjust_area(self->frame, FALSE, TRUE, TRUE); + render_plugin->frame_adjust_area(self->frame, FALSE, TRUE, TRUE); /* gets the frame's position */ - frame_client_gravity(self->frame, x, y); + render_plugin->frame_client_gravity(self->frame, x, y); /* these positions are frame positions, not client positions */ @@ -2706,7 +2706,7 @@ void client_try_configure(ObClient *self, gint *x, gint *y, gint *w, gint *h, } /* gets the client's position */ - frame_frame_gravity(self->frame, x, y); + render_plugin->frame_frame_gravity(self->frame, x, y); /* work within the prefered sizes given by the window */ if (!(*w == self->area.width && *h == self->area.height)) { @@ -2851,10 +2851,10 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, /* if the client is enlarging, then resize the client before the frame */ if (send_resize_client && (w > oldw || h > oldh)) { - XMoveResizeWindow(ob_display, self->window, + XMoveResizeWindow(render_plugin->ob_display, self->window, self->frame->size.left, self->frame->size.top, MAX(w, oldw), MAX(h, oldh)); - frame_adjust_client_area(self->frame); + render_plugin->frame_adjust_client_area(self->frame); } /* find the frame's dimensions and move/resize it */ @@ -2874,7 +2874,7 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, if (!user) ignore_start = event_start_ignore_all_enters(); - frame_adjust_area(self->frame, fmoved, fresized, FALSE); + render_plugin->frame_adjust_area(self->frame, fmoved, fresized, FALSE); if (!user) event_end_ignore_all_enters(ignore_start); @@ -2913,7 +2913,7 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, XEvent event; event.type = ConfigureNotify; - event.xconfigure.display = ob_display; + event.xconfigure.display = render_plugin->ob_display; event.xconfigure.event = self->window; event.xconfigure.window = self->window; @@ -2938,12 +2938,12 @@ void client_configure(ObClient *self, gint x, gint y, gint w, gint h, in the direction that is growing */ if (send_resize_client && (w <= oldw || h <= oldh)) { - frame_adjust_client_area(self->frame); - XMoveResizeWindow(ob_display, self->window, + render_plugin->frame_adjust_client_area(self->frame); + XMoveResizeWindow(render_plugin->ob_display, self->window, self->frame->size.left, self->frame->size.top, w, h); } - XFlush(ob_display); + XFlush(render_plugin->ob_display); } void client_fullscreen(ObClient *self, gboolean fs) @@ -3045,7 +3045,7 @@ static void client_iconify_recursive(ObClient *self, if (changed) { client_change_state(self); if (config_animate_iconify && !hide_animation) - frame_begin_iconify_animation(self->frame, iconic); + render_plugin->frame_begin_iconify_animation(self->frame, iconic); /* do this after starting the animation so it doesn't flash */ client_showhide(self); } @@ -3147,7 +3147,7 @@ void client_shade(ObClient *self, gboolean shade) client_change_state(self); client_change_wm_state(self); /* the window is being hidden/shown */ /* resize the frame to just the titlebar */ - frame_adjust_area(self->frame, FALSE, TRUE, FALSE); + render_plugin->frame_adjust_area(self->frame, FALSE, TRUE, FALSE); } void client_close(ObClient *self) @@ -3171,7 +3171,7 @@ void client_close(ObClient *self) ce.xclient.type = ClientMessage; ce.xclient.message_type = prop_atoms.wm_protocols; - ce.xclient.display = ob_display; + ce.xclient.display = render_plugin->ob_display; ce.xclient.window = self->window; ce.xclient.format = 32; ce.xclient.data.l[0] = prop_atoms.wm_delete_window; @@ -3179,12 +3179,12 @@ void client_close(ObClient *self) ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; - XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce); + XSendEvent(render_plugin->ob_display, self->window, FALSE, NoEventMask, &ce); } void client_kill(ObClient *self) { - XKillClient(ob_display, self->window); + XKillClient(render_plugin->ob_display, self->window); } void client_hilite(ObClient *self, gboolean hilite) @@ -3196,9 +3196,9 @@ void client_hilite(ObClient *self, gboolean hilite) self->demands_attention = hilite && !client_focused(self); if (self->frame != NULL) { /* if we're mapping, just set the state */ if (self->demands_attention) - frame_flash_start(self->frame); + render_plugin->frame_flash_start(self->frame); else - frame_flash_stop(self->frame); + render_plugin->frame_flash_stop(self->frame); client_change_state(self); } } @@ -3221,7 +3221,7 @@ void client_set_desktop_recursive(ObClient *self, self->desktop = target; PROP_SET32(self->window, net_wm_desktop, cardinal, target); /* the frame can display the current desktop state */ - frame_adjust_state(self->frame); + render_plugin->frame_adjust_state(self->frame); /* 'move' the window to the new desktop */ if (!donthide) client_hide(self); @@ -3275,11 +3275,11 @@ gboolean client_validate(ObClient *self) { XEvent e; - XSync(ob_display, FALSE); /* get all events on the server */ + XSync(render_plugin->ob_display, FALSE); /* get all events on the server */ - if (XCheckTypedWindowEvent(ob_display, self->window, DestroyNotify, &e) || - XCheckTypedWindowEvent(ob_display, self->window, UnmapNotify, &e)) { - XPutBackEvent(ob_display, &e); + if (XCheckTypedWindowEvent(render_plugin->ob_display, self->window, DestroyNotify, &e) || + XCheckTypedWindowEvent(render_plugin->ob_display, self->window, UnmapNotify, &e)) { + XPutBackEvent(render_plugin->ob_display, &e); return FALSE; } @@ -3541,7 +3541,7 @@ gboolean client_focus(ObClient *self) if (self->can_focus) { /* This can cause a BadMatch error with CurrentTime, or if an app passed in a bad time for _NET_WM_ACTIVE_WINDOW. */ - XSetInputFocus(ob_display, self->window, RevertToPointerRoot, + XSetInputFocus(render_plugin->ob_display, self->window, RevertToPointerRoot, event_curtime); } @@ -3549,7 +3549,7 @@ gboolean client_focus(ObClient *self) XEvent ce; ce.xclient.type = ClientMessage; ce.xclient.message_type = prop_atoms.wm_protocols; - ce.xclient.display = ob_display; + ce.xclient.display = render_plugin->ob_display; ce.xclient.window = self->window; ce.xclient.format = 32; ce.xclient.data.l[0] = prop_atoms.wm_take_focus; @@ -3557,7 +3557,7 @@ gboolean client_focus(ObClient *self) ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; - XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce); + XSendEvent(render_plugin->ob_display, self->window, FALSE, NoEventMask, &ce); } xerror_set_ignore(FALSE); @@ -3681,7 +3681,7 @@ const ObClientIcon* client_icon(ObClient *self, gint w, gint h) if (!(ret = client_icon_recursive(self, w, h))) { deficon.width = deficon.height = 48; - deficon.data = ob_rr_theme->def_win_icon; + deficon.data = render_plugin->ob_rr_theme->def_win_icon; ret = &deficon; } return ret; @@ -4035,7 +4035,7 @@ void client_find_move_directional(ObClient *self, ObDirection dir, default: g_assert_not_reached(); } - frame_frame_gravity(self->frame, x, y); + render_plugin->frame_frame_gravity(self->frame, x, y); } void client_find_resize_directional(ObClient *self, ObDirection side, @@ -4114,7 +4114,7 @@ void client_find_resize_directional(ObClient *self, ObDirection side, default: g_assert_not_reached(); } - frame_frame_gravity(self->frame, x, y); + render_plugin->frame_frame_gravity(self->frame, x, y); *w -= self->frame->size.left + self->frame->size.right; *h -= self->frame->size.top + self->frame->size.bottom; } @@ -4136,7 +4136,7 @@ ObClient* client_under_pointer() (c->desktop == screen_desktop || c->desktop == DESKTOP_ALL) && /* ignore all animating windows */ - !frame_iconify_animating(c->frame) && + !(render_plugin->frame_iconify_animating(c->frame)) && RECT_CONTAINS(c->frame->area, x, y)) { ret = c; diff --git a/openbox/client.h b/openbox/client.h index b4b165f..b41b2ee 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -20,6 +20,7 @@ #ifndef __client_h #define __client_h +#include "frame.h" #include "misc.h" #include "mwm.h" #include "geom.h" diff --git a/openbox/client_menu.c b/openbox/client_menu.c index 203d93a..c8fde89 100644 --- a/openbox/client_menu.c +++ b/openbox/client_menu.c @@ -23,7 +23,7 @@ #include "screen.h" #include "client.h" #include "openbox.h" -#include "frame.h" +#include "plugin.h" #include "moveresize.h" #include "event.h" #include "prop.h" @@ -262,14 +262,14 @@ static gboolean send_to_menu_update(ObMenuFrame *frame, gpointer data) e = menu_add_normal(menu, desk, name, NULL, FALSE); e->id = desk; if (desk == DESKTOP_ALL) { - e->data.normal.mask = ob_rr_theme->desk_mask; - e->data.normal.mask_normal_color = ob_rr_theme->menu_color; + e->data.normal.mask = render_plugin->ob_rr_theme->desk_mask; + e->data.normal.mask_normal_color = render_plugin->ob_rr_theme->menu_color; e->data.normal.mask_selected_color = - ob_rr_theme->menu_selected_color; + render_plugin->ob_rr_theme->menu_selected_color; e->data.normal.mask_disabled_color = - ob_rr_theme->menu_disabled_color; + render_plugin->ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_selected_color = - ob_rr_theme->menu_disabled_selected_color; + render_plugin->ob_rr_theme->menu_disabled_selected_color; } if (frame->client->desktop == desk) @@ -382,32 +382,32 @@ void client_menu_startup() menu_add_submenu(menu, CLIENT_LAYER, LAYER_MENU_NAME); e = menu_add_normal(menu, CLIENT_RESTORE, _("R_estore"), NULL, TRUE); - e->data.normal.mask = ob_rr_theme->max_toggled_mask; - e->data.normal.mask_normal_color = ob_rr_theme->menu_color; - e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color; - e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color; + e->data.normal.mask = render_plugin->ob_rr_theme->max_toggled_mask; + e->data.normal.mask_normal_color = render_plugin->ob_rr_theme->menu_color; + e->data.normal.mask_selected_color = render_plugin->ob_rr_theme->menu_selected_color; + e->data.normal.mask_disabled_color = render_plugin->ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_selected_color = - ob_rr_theme->menu_disabled_selected_color; + render_plugin->ob_rr_theme->menu_disabled_selected_color; menu_add_normal(menu, CLIENT_MOVE, _("_Move"), NULL, TRUE); menu_add_normal(menu, CLIENT_RESIZE, _("Resi_ze"), NULL, TRUE); e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico_nify"), NULL, TRUE); - e->data.normal.mask = ob_rr_theme->iconify_mask; - e->data.normal.mask_normal_color = ob_rr_theme->menu_color; - e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color; - e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color; + e->data.normal.mask = render_plugin->ob_rr_theme->iconify_mask; + e->data.normal.mask_normal_color = render_plugin->ob_rr_theme->menu_color; + e->data.normal.mask_selected_color = render_plugin->ob_rr_theme->menu_selected_color; + e->data.normal.mask_disabled_color = render_plugin->ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_selected_color = - ob_rr_theme->menu_disabled_selected_color; + render_plugin->ob_rr_theme->menu_disabled_selected_color; e = menu_add_normal(menu, CLIENT_MAXIMIZE, _("Ma_ximize"), NULL, TRUE); - e->data.normal.mask = ob_rr_theme->max_mask; - e->data.normal.mask_normal_color = ob_rr_theme->menu_color; - e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color; - e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color; + e->data.normal.mask = render_plugin->ob_rr_theme->max_mask; + e->data.normal.mask_normal_color = render_plugin->ob_rr_theme->menu_color; + e->data.normal.mask_selected_color = render_plugin->ob_rr_theme->menu_selected_color; + e->data.normal.mask_disabled_color = render_plugin->ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_selected_color = - ob_rr_theme->menu_disabled_selected_color; + render_plugin->ob_rr_theme->menu_disabled_selected_color; menu_add_normal(menu, CLIENT_SHADE, _("_Roll up/down"), NULL, TRUE); @@ -416,10 +416,10 @@ void client_menu_startup() menu_add_separator(menu, -1, NULL); e = menu_add_normal(menu, CLIENT_CLOSE, _("_Close"), NULL, TRUE); - e->data.normal.mask = ob_rr_theme->close_mask; - e->data.normal.mask_normal_color = ob_rr_theme->menu_color; - e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color; - e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color; + e->data.normal.mask = render_plugin->ob_rr_theme->close_mask; + e->data.normal.mask_normal_color = render_plugin->ob_rr_theme->menu_color; + e->data.normal.mask_selected_color = render_plugin->ob_rr_theme->menu_selected_color; + e->data.normal.mask_disabled_color = render_plugin->ob_rr_theme->menu_disabled_color; e->data.normal.mask_disabled_selected_color = - ob_rr_theme->menu_disabled_selected_color; + render_plugin->ob_rr_theme->menu_disabled_selected_color; } diff --git a/openbox/client_menu.h b/openbox/client_menu.h index fe14502..001473e 100644 --- a/openbox/client_menu.h +++ b/openbox/client_menu.h @@ -19,6 +19,8 @@ #ifndef ob__client_menu_h #define ob__client_menu_h +#include "frame.h" + void client_menu_startup(); #endif diff --git a/openbox/config.c b/openbox/config.c index 6da7989..044e636 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -42,9 +42,9 @@ gboolean config_place_center; StrutPartial config_margins; gchar *config_theme; -gboolean config_theme_keepborder; +//gboolean config_theme_keepborder; -gchar *config_title_layout; +//gchar *config_title_layout; gboolean config_animate_iconify; @@ -537,16 +537,16 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, if ((n = parse_find_node("titleLayout", node))) { gchar *c, *d; - g_free(config_title_layout); - config_title_layout = parse_string(doc, n); + g_free(render_plugin->config_title_layout); + render_plugin->config_title_layout = parse_string(doc, n); /* replace duplicates with spaces */ - for (c = config_title_layout; *c != '\0'; ++c) + for (c = render_plugin->config_title_layout; *c != '\0'; ++c) for (d = c+1; *d != '\0'; ++d) if (*c == *d) *d = ' '; } if ((n = parse_find_node("keepBorder", node))) - config_theme_keepborder = parse_bool(doc, n); + render_plugin->config_theme_keepborder = parse_bool(doc, n); if ((n = parse_find_node("animateIconify", node))) config_animate_iconify = parse_bool(doc, n); @@ -595,7 +595,7 @@ static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, g_free(s); } - *font = RrFontOpen(ob_rr_inst, name, size, weight, slant); + *font = RrFontOpen(render_plugin->ob_rr_inst, name, size, weight, slant); g_free(name); next_font: n = parse_find_node("font", n->next); @@ -890,8 +890,8 @@ void config_startup(ObParseInst *i) config_theme = NULL; config_animate_iconify = TRUE; - config_title_layout = g_strdup("NLIMC"); - config_theme_keepborder = TRUE; + render_plugin->config_title_layout = g_strdup("NLIMC"); + render_plugin->config_theme_keepborder = TRUE; config_font_activewindow = NULL; config_font_inactivewindow = NULL; @@ -968,7 +968,7 @@ void config_shutdown() g_free(config_theme); - g_free(config_title_layout); + g_free(render_plugin->config_title_layout); RrFontClose(config_font_activewindow); RrFontClose(config_font_inactivewindow); diff --git a/openbox/config.h b/openbox/config.h index 9d0602e..a704029 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -122,9 +122,9 @@ extern guint config_dock_app_move_modifiers; extern gchar *config_theme; /*! Show the one-pixel border after toggleDecor */ -extern gboolean config_theme_keepborder; +//extern gboolean config_theme_keepborder; /*! Titlebar button layout */ -extern gchar *config_title_layout; +//extern gchar *config_title_layout; /*! Animate windows iconifying and restoring */ extern gboolean config_animate_iconify; diff --git a/openbox/dock.c b/openbox/dock.c index 3b32758..3dad0ca 100644 --- a/openbox/dock.c +++ b/openbox/dock.c @@ -58,12 +58,12 @@ void dock_startup(gboolean reconfig) if (reconfig) { GList *it; - XSetWindowBorder(ob_display, dock->frame, - RrColorPixel(ob_rr_theme->osd_border_color)); - XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->obwidth); + XSetWindowBorder(render_plugin->ob_display, dock->frame, + RrColorPixel(render_plugin->ob_rr_theme->osd_border_color)); + XSetWindowBorderWidth(render_plugin->ob_display, dock->frame, render_plugin->ob_rr_theme->obwidth); RrAppearanceFree(dock->a_frame); - dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); + dock->a_frame = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_bg); stacking_add(DOCK_AS_WINDOW(dock)); @@ -86,17 +86,17 @@ void dock_startup(gboolean reconfig) attrib.event_mask = DOCK_EVENT_MASK; attrib.override_redirect = True; attrib.do_not_propagate_mask = DOCK_NOPROPAGATEMASK; - dock->frame = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen), + dock->frame = XCreateWindow(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), 0, 0, 1, 1, 0, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), + RrDepth(render_plugin->ob_rr_inst), InputOutput, + RrVisual(render_plugin->ob_rr_inst), CWOverrideRedirect | CWEventMask | CWDontPropagate, &attrib); - dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); - XSetWindowBorder(ob_display, dock->frame, - RrColorPixel(ob_rr_theme->osd_border_color)); - XSetWindowBorderWidth(ob_display, dock->frame, ob_rr_theme->obwidth); + dock->a_frame = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_bg); + XSetWindowBorder(render_plugin->ob_display, dock->frame, + RrColorPixel(render_plugin->ob_rr_theme->osd_border_color)); + XSetWindowBorderWidth(render_plugin->ob_display, dock->frame, render_plugin->ob_rr_theme->obwidth); /* Setting the window type so xcompmgr can tell what it is */ PROP_SET32(dock->frame, net_wm_window_type, atom, @@ -118,7 +118,7 @@ void dock_shutdown(gboolean reconfig) return; } - XDestroyWindow(ob_display, dock->frame); + XDestroyWindow(render_plugin->ob_display, dock->frame); RrAppearanceFree(dock->a_frame); g_hash_table_remove(window_map, &dock->frame); stacking_remove(dock); @@ -148,7 +148,7 @@ void dock_add(Window win, XWMHints *wmhints) if (app->name == NULL) app->name = g_strdup(""); if (app->class == NULL) app->class = g_strdup(""); - if (XGetWindowAttributes(ob_display, app->icon_win, &attrib)) { + if (XGetWindowAttributes(render_plugin->ob_display, app->icon_win, &attrib)) { app->w = attrib.width; app->h = attrib.height; } else { @@ -158,7 +158,7 @@ void dock_add(Window win, XWMHints *wmhints) dock->dock_apps = g_list_append(dock->dock_apps, app); dock_configure(); - XReparentWindow(ob_display, app->icon_win, dock->frame, app->x, app->y); + XReparentWindow(render_plugin->ob_display, app->icon_win, dock->frame, app->x, app->y); /* This is the same case as in frame.c for client windows. When Openbox is starting, the window is already mapped so we see unmap events occur for @@ -171,16 +171,16 @@ void dock_add(Window win, XWMHints *wmhints) if (app->win != app->icon_win) { /* have to map it so that it can be re-managed on a restart */ - XMoveWindow(ob_display, app->win, -1000, -1000); - XMapWindow(ob_display, app->win); + XMoveWindow(render_plugin->ob_display, app->win, -1000, -1000); + XMapWindow(render_plugin->ob_display, app->win); } - XMapWindow(ob_display, app->icon_win); - XSync(ob_display, False); + XMapWindow(render_plugin->ob_display, app->icon_win); + XSync(render_plugin->ob_display, False); /* specify that if we exit, the window should not be destroyed and should be reparented back to root automatically */ - XChangeSaveSet(ob_display, app->icon_win, SetModeInsert); - XSelectInput(ob_display, app->icon_win, DOCKAPP_EVENT_MASK); + XChangeSaveSet(render_plugin->ob_display, app->icon_win, SetModeInsert); + XSelectInput(render_plugin->ob_display, app->icon_win, DOCKAPP_EVENT_MASK); dock_app_grab_button(app, TRUE); @@ -198,16 +198,16 @@ void dock_remove_all() void dock_remove(ObDockApp *app, gboolean reparent) { dock_app_grab_button(app, FALSE); - XSelectInput(ob_display, app->icon_win, NoEventMask); + XSelectInput(render_plugin->ob_display, app->icon_win, NoEventMask); /* remove the window from our save set */ - XChangeSaveSet(ob_display, app->icon_win, SetModeDelete); - XSync(ob_display, False); + XChangeSaveSet(render_plugin->ob_display, app->icon_win, SetModeDelete); + XSync(render_plugin->ob_display, False); g_hash_table_remove(window_map, &app->icon_win); if (reparent) - XReparentWindow(ob_display, app->icon_win, - RootWindow(ob_display, ob_screen), app->x, app->y); + XReparentWindow(render_plugin->ob_display, app->icon_win, + RootWindow(render_plugin->ob_display, render_plugin->ob_screen), app->x, app->y); dock->dock_apps = g_list_remove(dock->dock_apps, app); dock_configure(); @@ -269,12 +269,12 @@ void dock_configure() break; } - XMoveWindow(ob_display, app->icon_win, app->x, app->y); + XMoveWindow(render_plugin->ob_display, app->icon_win, app->x, app->y); } /* used for calculating offsets */ - dock->area.width += ob_rr_theme->obwidth * 2; - dock->area.height += ob_rr_theme->obwidth * 2; + dock->area.width += render_plugin->ob_rr_theme->obwidth * 2; + dock->area.height += render_plugin->ob_rr_theme->obwidth * 2; a = screen_physical_area_all_monitors(); @@ -361,51 +361,51 @@ void dock_configure() case OB_DIRECTION_NORTHWEST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->area.y -= dock->area.height - ob_rr_theme->obwidth; + dock->area.y -= dock->area.height - render_plugin->ob_rr_theme->obwidth; break; case OB_ORIENTATION_VERT: - dock->area.x -= dock->area.width - ob_rr_theme->obwidth; + dock->area.x -= dock->area.width - render_plugin->ob_rr_theme->obwidth; break; } break; case OB_DIRECTION_NORTH: - dock->area.y -= dock->area.height - ob_rr_theme->obwidth; + dock->area.y -= dock->area.height - render_plugin->ob_rr_theme->obwidth; break; case OB_DIRECTION_NORTHEAST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->area.y -= dock->area.height - ob_rr_theme->obwidth; + dock->area.y -= dock->area.height - render_plugin->ob_rr_theme->obwidth; break; case OB_ORIENTATION_VERT: - dock->area.x += dock->area.width - ob_rr_theme->obwidth; + dock->area.x += dock->area.width - render_plugin->ob_rr_theme->obwidth; break; } break; case OB_DIRECTION_WEST: - dock->area.x -= dock->area.width - ob_rr_theme->obwidth; + dock->area.x -= dock->area.width - render_plugin->ob_rr_theme->obwidth; break; case OB_DIRECTION_EAST: - dock->area.x += dock->area.width - ob_rr_theme->obwidth; + dock->area.x += dock->area.width - render_plugin->ob_rr_theme->obwidth; break; case OB_DIRECTION_SOUTHWEST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->area.y += dock->area.height - ob_rr_theme->obwidth; + dock->area.y += dock->area.height - render_plugin->ob_rr_theme->obwidth; break; case OB_ORIENTATION_VERT: - dock->area.x -= dock->area.width - ob_rr_theme->obwidth; + dock->area.x -= dock->area.width - render_plugin->ob_rr_theme->obwidth; break; } break; case OB_DIRECTION_SOUTH: - dock->area.y += dock->area.height - ob_rr_theme->obwidth; + dock->area.y += dock->area.height - render_plugin->ob_rr_theme->obwidth; break; case OB_DIRECTION_SOUTHEAST: switch (config_dock_orient) { case OB_ORIENTATION_HORZ: - dock->area.y += dock->area.height - ob_rr_theme->obwidth; + dock->area.y += dock->area.height - render_plugin->ob_rr_theme->obwidth; break; case OB_ORIENTATION_VERT: - dock->area.x += dock->area.width - ob_rr_theme->obwidth; + dock->area.x += dock->area.width - render_plugin->ob_rr_theme->obwidth; break; } break; @@ -414,8 +414,8 @@ void dock_configure() } if (!config_dock_floating && config_dock_hide) { - strw = ob_rr_theme->obwidth; - strh = ob_rr_theme->obwidth; + strw = render_plugin->ob_rr_theme->obwidth; + strh = render_plugin->ob_rr_theme->obwidth; } else { strw = dock->area.width; strh = dock->area.height; @@ -511,25 +511,25 @@ void dock_configure() } /* not used for actually sizing shit */ - dock->area.width -= ob_rr_theme->obwidth * 2; - dock->area.height -= ob_rr_theme->obwidth * 2; + dock->area.width -= render_plugin->ob_rr_theme->obwidth * 2; + dock->area.height -= render_plugin->ob_rr_theme->obwidth * 2; if (dock->dock_apps) { g_assert(dock->area.width > 0); g_assert(dock->area.height > 0); - XMoveResizeWindow(ob_display, dock->frame, dock->area.x, dock->area.y, + XMoveResizeWindow(render_plugin->ob_display, dock->frame, dock->area.x, dock->area.y, dock->area.width, dock->area.height); RrPaint(dock->a_frame, dock->frame, dock->area.width, dock->area.height); - XMapWindow(ob_display, dock->frame); + XMapWindow(render_plugin->ob_display, dock->frame); } else - XUnmapWindow(ob_display, dock->frame); + XUnmapWindow(render_plugin->ob_display, dock->frame); /* but they are useful outside of this function! */ - dock->area.width += ob_rr_theme->obwidth * 2; - dock->area.height += ob_rr_theme->obwidth * 2; + dock->area.width += render_plugin->ob_rr_theme->obwidth * 2; + dock->area.height += render_plugin->ob_rr_theme->obwidth * 2; screen_update_areas(); @@ -628,19 +628,19 @@ void dock_hide(gboolean hide) { if (!hide) { if (dock->hidden && config_dock_hide) { - ob_main_loop_timeout_add(ob_main_loop, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_dock_show_delay * 1000, show_timeout, NULL, g_direct_equal, NULL); } else if (!dock->hidden && config_dock_hide) { - ob_main_loop_timeout_remove(ob_main_loop, hide_timeout); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, hide_timeout); } } else { if (!dock->hidden && config_dock_hide) { - ob_main_loop_timeout_add(ob_main_loop, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_dock_hide_delay * 1000, hide_timeout, NULL, g_direct_equal, NULL); } else if (dock->hidden && config_dock_hide) { - ob_main_loop_timeout_remove(ob_main_loop, show_timeout); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, show_timeout); } } } diff --git a/openbox/event.c b/openbox/event.c index 9c47c04..5667f1f 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -28,7 +28,7 @@ #include "prop.h" #include "config.h" #include "screen.h" -#include "frame.h" +#include "plugin.h" #include "grab.h" #include "menu.h" #include "menuframe.h" @@ -118,9 +118,9 @@ static void ice_watch(IceConn conn, IcePointer data, Bool opening, if (opening) { fd = IceConnectionNumber(conn); - ob_main_loop_fd_add(ob_main_loop, fd, ice_handler, conn, NULL); + ob_main_loop_fd_add(render_plugin->ob_main_loop, fd, ice_handler, conn, NULL); } else { - ob_main_loop_fd_remove(ob_main_loop, fd); + ob_main_loop_fd_remove(render_plugin->ob_main_loop, fd); fd = -1; } } @@ -130,7 +130,7 @@ void event_startup(gboolean reconfig) { if (reconfig) return; - ob_main_loop_x_add(ob_main_loop, event_process, NULL, NULL); + ob_main_loop_x_add(render_plugin->ob_main_loop, event_process, NULL, NULL); #ifdef USE_SM IceAddConnectionWatch(ice_watch, NULL); @@ -157,7 +157,7 @@ static Window event_get_window(XEvent *e) /* pick a window */ switch (e->type) { case SelectionClear: - window = RootWindow(ob_display, ob_screen); + window = RootWindow(render_plugin->ob_display, render_plugin->ob_screen); break; case MapRequest: window = e->xmap.window; @@ -266,7 +266,7 @@ static void event_hack_mods(XEvent *e) /* compress events */ { XEvent ce; - while (XCheckTypedWindowEvent(ob_display, e->xmotion.window, + while (XCheckTypedWindowEvent(render_plugin->ob_display, e->xmotion.window, e->type, &ce)) { e->xmotion.x = ce.xmotion.x; e->xmotion.y = ce.xmotion.y; @@ -296,7 +296,7 @@ static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only) /* These are the ones we want.. */ - if (win == RootWindow(ob_display, ob_screen)) { + if (win == RootWindow(render_plugin->ob_display, render_plugin->ob_screen)) { /* If looking for a focus in on a client, then always return FALSE for focus in's to the root window */ if (in_client_only) @@ -350,7 +350,7 @@ static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only) return FALSE; /* Focus left the root window revertedto state */ - if (win == RootWindow(ob_display, ob_screen)) + if (win == RootWindow(render_plugin->ob_display, render_plugin->ob_screen)) return FALSE; /* These are the ones we want.. */ @@ -494,7 +494,7 @@ static void event_process(const XEvent *ec, gpointer data) /* We don't get a FocusOut for this case, because it's just moving from our Inferior up to us. This happens when iconifying a window with RevertToParent focus */ - frame_adjust_focus(client->frame, FALSE); + render_plugin->frame_adjust_focus(client->frame, FALSE); /* focus_set_client(NULL) has already been called */ client_calc_layer(client); } @@ -527,10 +527,10 @@ static void event_process(const XEvent *ec, gpointer data) But if the other focus in is something like PointerRoot then we still want to fall back. */ - if (XCheckIfEvent(ob_display, &ce, event_look_for_focusin_client, + if (XCheckIfEvent(render_plugin->ob_display, &ce, event_look_for_focusin_client, NULL)) { - XPutBackEvent(ob_display, &ce); + XPutBackEvent(render_plugin->ob_display, &ce); ob_debug_type(OB_DEBUG_FOCUS, " but another FocusIn is coming\n"); } else { @@ -558,7 +558,7 @@ static void event_process(const XEvent *ec, gpointer data) } else if (client != focus_client) { focus_left_screen = FALSE; - frame_adjust_focus(client->frame, TRUE); + render_plugin->frame_adjust_focus(client->frame, TRUE); focus_set_client(client); client_calc_layer(client); client_bring_helper_windows(client); @@ -567,16 +567,16 @@ static void event_process(const XEvent *ec, gpointer data) XEvent ce; /* Look for the followup FocusIn */ - if (!XCheckIfEvent(ob_display, &ce, event_look_for_focusin, NULL)) { + if (!XCheckIfEvent(render_plugin->ob_display, &ce, event_look_for_focusin, NULL)) { /* There is no FocusIn, this means focus went to a window that is not being managed, or a window on another screen. */ Window win, root; gint i; guint u; xerror_set_ignore(TRUE); - if (XGetInputFocus(ob_display, &win, &i) != 0 && - XGetGeometry(ob_display, win, &root, &i,&i,&u,&u,&u,&u) != 0 && - root != RootWindow(ob_display, ob_screen)) + if (XGetInputFocus(render_plugin->ob_display, &win, &i) != 0 && + XGetGeometry(render_plugin->ob_display, win, &root, &i,&i,&u,&u,&u,&u) != 0 && + root != RootWindow(render_plugin->ob_display, render_plugin->ob_screen)) { ob_debug_type(OB_DEBUG_FOCUS, "Focus went to another screen !\n"); @@ -603,7 +603,7 @@ static void event_process(const XEvent *ec, gpointer data) } if (client && client != focus_client) { - frame_adjust_focus(client->frame, FALSE); + render_plugin->frame_adjust_focus(client->frame, FALSE); /* focus_set_client(NULL) has already been called in this section or by focus_fallback */ client_calc_layer(client); @@ -615,7 +615,7 @@ static void event_process(const XEvent *ec, gpointer data) event_handle_dockapp(dockapp, e); else if (dock) event_handle_dock(dock, e); - else if (window == RootWindow(ob_display, ob_screen)) + else if (window == RootWindow(render_plugin->ob_display, render_plugin->ob_screen)) event_handle_root(e); else if (e->type == MapRequest) client_manage(window); @@ -656,7 +656,7 @@ static void event_process(const XEvent *ec, gpointer data) /* we are not to be held responsible if someone sends us an invalid request! */ xerror_set_ignore(TRUE); - XConfigureWindow(ob_display, window, + XConfigureWindow(render_plugin->ob_display, window, e->xconfigurerequest.value_mask, &xwc); xerror_set_ignore(FALSE); } @@ -665,7 +665,7 @@ static void event_process(const XEvent *ec, gpointer data) e->type == extensions_sync_event_basep + XSyncAlarmNotify) { XSyncAlarmNotifyEvent *se = (XSyncAlarmNotifyEvent*)e; - if (se->alarm == moveresize_alarm && moveresize_in_progress) + if (se->alarm == moveresize_alarm && render_plugin->moveresize_in_progress) moveresize_event(e); } #endif @@ -747,13 +747,13 @@ void event_enter_client(ObClient *client) if (config_focus_delay) { ObFocusDelayData *data; - ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, focus_delay_func); data = g_new(ObFocusDelayData, 1); data->client = client; data->time = event_curtime; - ob_main_loop_timeout_add(ob_main_loop, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_focus_delay * 1000, focus_delay_func, data, focus_delay_cmp, focus_delay_dest); @@ -793,7 +793,7 @@ static void event_handle_client(ObClient *client, XEvent *e) !grab_on_keyboard()) { /* use where the press occured */ - con = frame_context(client, e->xbutton.window, px, py); + con = render_plugin->frame_context(client, e->xbutton.window, px, py); con = mouse_button_frame_context(con, e->xbutton.button, e->xbutton.state); @@ -803,23 +803,23 @@ static void event_handle_client(ObClient *client, XEvent *e) switch (con) { case OB_FRAME_CONTEXT_MAXIMIZE: client->frame->max_press = (e->type == ButtonPress); - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_CLOSE: client->frame->close_press = (e->type == ButtonPress); - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ICONIFY: client->frame->iconify_press = (e->type == ButtonPress); - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ALLDESKTOPS: client->frame->desk_press = (e->type == ButtonPress); - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_SHADE: client->frame->shade_press = (e->type == ButtonPress); - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; default: /* nothing changes with clicks for any other contexts */ @@ -832,7 +832,7 @@ static void event_handle_client(ObClient *client, XEvent *e) notifies, but we still get motion events */ if (grab_on_pointer()) break; - con = frame_context(client, e->xmotion.window, + con = render_plugin->frame_context(client, e->xmotion.window, e->xmotion.x, e->xmotion.y); switch (con) { case OB_FRAME_CONTEXT_TITLEBAR: @@ -848,37 +848,37 @@ static void event_handle_client(ObClient *client, XEvent *e) client->frame->shade_hover = FALSE; client->frame->iconify_hover = FALSE; client->frame->close_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; case OB_FRAME_CONTEXT_MAXIMIZE: if (!client->frame->max_hover) { client->frame->max_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; case OB_FRAME_CONTEXT_ALLDESKTOPS: if (!client->frame->desk_hover) { client->frame->desk_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; case OB_FRAME_CONTEXT_SHADE: if (!client->frame->shade_hover) { client->frame->shade_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; case OB_FRAME_CONTEXT_ICONIFY: if (!client->frame->iconify_hover) { client->frame->iconify_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; case OB_FRAME_CONTEXT_CLOSE: if (!client->frame->close_hover) { client->frame->close_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; default: @@ -886,7 +886,7 @@ static void event_handle_client(ObClient *client, XEvent *e) } break; case LeaveNotify: - con = frame_context(client, e->xcrossing.window, + con = render_plugin->frame_context(client, e->xcrossing.window, e->xcrossing.x, e->xcrossing.y); switch (con) { case OB_FRAME_CONTEXT_TITLEBAR: @@ -902,34 +902,34 @@ static void event_handle_client(ObClient *client, XEvent *e) client->frame->shade_hover = FALSE; client->frame->iconify_hover = FALSE; client->frame->close_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); } break; case OB_FRAME_CONTEXT_MAXIMIZE: client->frame->max_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ALLDESKTOPS: client->frame->desk_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_SHADE: client->frame->shade_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ICONIFY: client->frame->iconify_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_CLOSE: client->frame->close_hover = FALSE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_FRAME: /* When the mouse leaves an animating window, don't use the corresponding enter events. Pretend like the animating window doesn't even exist..! */ - if (frame_iconify_animating(client->frame)) + if (render_plugin->frame_iconify_animating(client->frame)) event_end_ignore_all_enters(event_start_ignore_all_enters()); ob_debug_type(OB_DEBUG_FOCUS, @@ -945,7 +945,7 @@ static void event_handle_client(ObClient *client, XEvent *e) delay is up */ e->xcrossing.detail != NotifyInferior) { - ob_main_loop_timeout_remove_data(ob_main_loop, + ob_main_loop_timeout_remove_data(render_plugin->ob_main_loop, focus_delay_func, client, FALSE); } @@ -956,28 +956,28 @@ static void event_handle_client(ObClient *client, XEvent *e) break; case EnterNotify: { - con = frame_context(client, e->xcrossing.window, + con = render_plugin->frame_context(client, e->xcrossing.window, e->xcrossing.x, e->xcrossing.y); switch (con) { case OB_FRAME_CONTEXT_MAXIMIZE: client->frame->max_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ALLDESKTOPS: client->frame->desk_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_SHADE: client->frame->shade_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_ICONIFY: client->frame->iconify_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_CLOSE: client->frame->close_hover = TRUE; - frame_adjust_state(client->frame); + render_plugin->frame_adjust_state(client->frame); break; case OB_FRAME_CONTEXT_FRAME: if (grab_on_keyboard()) @@ -1198,7 +1198,7 @@ static void event_handle_client(ObClient *client, XEvent *e) /* we don't want the reparent event, put it back on the stack for the X server to deal with after we unmanage the window */ - XPutBackEvent(ob_display, e); + XPutBackEvent(render_plugin->ob_display, e); ob_debug("ReparentNotify for window 0x%x\n", client->window); client_unmanage(client); @@ -1221,13 +1221,13 @@ static void event_handle_client(ObClient *client, XEvent *e) msgtype = e->xclient.message_type; if (msgtype == prop_atoms.wm_change_state) { /* compress changes into a single change */ - while (XCheckTypedWindowEvent(ob_display, client->window, + while (XCheckTypedWindowEvent(render_plugin->ob_display, client->window, e->type, &ce)) { /* XXX: it would be nice to compress ALL messages of a type, not just messages in a row without other message types between. */ if (ce.xclient.message_type != msgtype) { - XPutBackEvent(ob_display, &ce); + XPutBackEvent(render_plugin->ob_display, &ce); break; } e->xclient = ce.xclient; @@ -1235,13 +1235,13 @@ static void event_handle_client(ObClient *client, XEvent *e) client_set_wm_state(client, e->xclient.data.l[0]); } else if (msgtype == prop_atoms.net_wm_desktop) { /* compress changes into a single change */ - while (XCheckTypedWindowEvent(ob_display, client->window, + while (XCheckTypedWindowEvent(render_plugin->ob_display, client->window, e->type, &ce)) { /* XXX: it would be nice to compress ALL messages of a type, not just messages in a row without other message types between. */ if (ce.xclient.message_type != msgtype) { - XPutBackEvent(ob_display, &ce); + XPutBackEvent(render_plugin->ob_display, &ce); break; } e->xclient = ce.xclient; @@ -1432,7 +1432,7 @@ static void event_handle_client(ObClient *client, XEvent *e) if (!client_validate(client)) break; /* compress changes to a single property into a single change */ - while (XCheckTypedWindowEvent(ob_display, client->window, + while (XCheckTypedWindowEvent(render_plugin->ob_display, client->window, e->type, &ce)) { Atom a, b; @@ -1459,7 +1459,7 @@ static void event_handle_client(ObClient *client, XEvent *e) b == prop_atoms.net_wm_icon) continue; - XPutBackEvent(ob_display, &ce); + XPutBackEvent(render_plugin->ob_display, &ce); break; } @@ -1528,7 +1528,7 @@ static void event_handle_client(ObClient *client, XEvent *e) #ifdef SHAPE if (extensions_shape && e->type == extensions_shape_event_basep) { client->shaped = ((XShapeEvent*)e)->shaped; - frame_adjust_shape(client->frame); + render_plugin->frame_adjust_shape(client->frame); } #endif } @@ -1804,7 +1804,7 @@ static void event_handle_user_input(ObClient *client, XEvent *e) /* if the keyboard interactive action uses the event then dont use it for bindings. likewise is moveresize uses the event. */ if (!actions_interactive_input_event(e) && !moveresize_event(e)) { - if (moveresize_in_progress) + if (render_plugin->moveresize_in_progress) /* make further actions work on the client being moved/resized */ client = moveresize_client; @@ -1815,10 +1815,10 @@ static void event_handle_user_input(ObClient *client, XEvent *e) { /* the frame may not be "visible" but they can still click on it in the case where it is animating before disappearing */ - if (!client || !frame_iconify_animating(client->frame)) + if (!client || !render_plugin->frame_iconify_animating(client->frame)) mouse_event(client, e); } else - keyboard_event((focus_cycle_target ? focus_cycle_target : + keyboard_event((render_plugin->focus_cycle_target ? render_plugin->focus_cycle_target : (client ? client : focus_client)), e); } } @@ -1840,7 +1840,7 @@ static gboolean focus_delay_func(gpointer data) Time old = event_curtime; /* don't move focus and kill the menu or the move/resize */ - if (menu_frame_visible || moveresize_in_progress) return FALSE; + if (menu_frame_visible || render_plugin->moveresize_in_progress) return FALSE; event_curtime = d->time; if (focus_client != d->client) { @@ -1853,19 +1853,19 @@ static gboolean focus_delay_func(gpointer data) static void focus_delay_client_dest(ObClient *client, gpointer data) { - ob_main_loop_timeout_remove_data(ob_main_loop, focus_delay_func, + ob_main_loop_timeout_remove_data(render_plugin->ob_main_loop, focus_delay_func, client, FALSE); } void event_halt_focus_delay() { - ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, focus_delay_func); } gulong event_start_ignore_all_enters() { - XSync(ob_display, FALSE); - return LastKnownRequestProcessed(ob_display); + XSync(render_plugin->ob_display, FALSE); + return LastKnownRequestProcessed(render_plugin->ob_display); } void event_end_ignore_all_enters(gulong start) @@ -1873,15 +1873,15 @@ void event_end_ignore_all_enters(gulong start) ObSerialRange *r; g_assert(start != 0); - XSync(ob_display, FALSE); + XSync(render_plugin->ob_display, FALSE); r = g_new(ObSerialRange, 1); r->start = start; - r->end = LastKnownRequestProcessed(ob_display); + r->end = LastKnownRequestProcessed(render_plugin->ob_display); ignore_serials = g_slist_prepend(ignore_serials, r); /* increment the serial so we don't ignore events we weren't meant to */ - XSync(ob_display, FALSE); + XSync(render_plugin->ob_display, FALSE); } static gboolean is_enter_focus_event_ignored(XEvent *e) @@ -1919,7 +1919,7 @@ void event_cancel_all_key_grabs() menu_frame_hide_all(); ob_debug("KILLED open menus\n"); } - else if (moveresize_in_progress) { + else if (render_plugin->moveresize_in_progress) { moveresize_end(TRUE); ob_debug("KILLED interactive moveresize\n"); } @@ -1961,9 +1961,9 @@ Time event_get_server_time() /* Generate a timestamp */ XEvent event; - XChangeProperty(ob_display, screen_support_win, + XChangeProperty(render_plugin->ob_display, screen_support_win, prop_atoms.wm_class, prop_atoms.string, 8, PropModeAppend, NULL, 0); - XWindowEvent(ob_display, screen_support_win, PropertyChangeMask, &event); + XWindowEvent(render_plugin->ob_display, screen_support_win, PropertyChangeMask, &event); return event.xproperty.time; } diff --git a/openbox/extensions.c b/openbox/extensions.c index 89a9657..15664f5 100644 --- a/openbox/extensions.c +++ b/openbox/extensions.c @@ -41,7 +41,7 @@ void extensions_query_all() #ifdef XKB extensions_xkb = - XkbQueryExtension(ob_display, &junk, &extensions_xkb_event_basep, + XkbQueryExtension(render_plugin->ob_display, &junk, &extensions_xkb_event_basep, &junk, NULL, NULL); if (!extensions_xkb) ob_debug("XKB extension is not present on the server\n"); @@ -49,7 +49,7 @@ void extensions_query_all() #ifdef SHAPE extensions_shape = - XShapeQueryExtension(ob_display, &extensions_shape_event_basep, + XShapeQueryExtension(render_plugin->ob_display, &extensions_shape_event_basep, &junk); if (!extensions_shape) ob_debug("X Shape extension is not present on the server\n"); @@ -57,15 +57,15 @@ void extensions_query_all() #ifdef XINERAMA extensions_xinerama = - XineramaQueryExtension(ob_display, &extensions_xinerama_event_basep, - &junk) && XineramaIsActive(ob_display); + XineramaQueryExtension(render_plugin->ob_display, &extensions_xinerama_event_basep, + &junk) && XineramaIsActive(render_plugin->ob_display); if (!extensions_xinerama) ob_debug("Xinerama extension is not present on the server\n"); #endif #ifdef XRANDR extensions_randr = - XRRQueryExtension(ob_display, &extensions_randr_event_basep, + XRRQueryExtension(render_plugin->ob_display, &extensions_randr_event_basep, &junk); if (!extensions_randr) ob_debug("XRandR extension is not present on the server\n"); @@ -73,9 +73,9 @@ void extensions_query_all() #ifdef SYNC extensions_sync = - XSyncQueryExtension(ob_display, &extensions_sync_event_basep, + XSyncQueryExtension(render_plugin->ob_display, &extensions_sync_event_basep, &junk) && - XSyncInitialize(ob_display, &junk, &junk); + XSyncInitialize(render_plugin->ob_display, &junk, &junk); if (!extensions_sync) ob_debug("X Sync extension is not present on the server or is an " "incompatible version\n"); @@ -90,7 +90,7 @@ void extensions_xinerama_screens(Rect **xin_areas, guint *nxin) if (extensions_xinerama) { guint i; gint n; - XineramaScreenInfo *info = XineramaQueryScreens(ob_display, &n); + XineramaScreenInfo *info = XineramaQueryScreens(render_plugin->ob_display, &n); *nxin = n; *xin_areas = g_new(Rect, *nxin + 1); for (i = 0; i < *nxin; ++i) @@ -100,8 +100,8 @@ void extensions_xinerama_screens(Rect **xin_areas, guint *nxin) } else #endif if (ob_debug_xinerama) { - gint w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)); - gint h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen)); + gint w = WidthOfScreen(ScreenOfDisplay(render_plugin->ob_display, render_plugin->ob_screen)); + gint h = HeightOfScreen(ScreenOfDisplay(render_plugin->ob_display, render_plugin->ob_screen)); *nxin = 2; *xin_areas = g_new(Rect, *nxin + 1); RECT_SET((*xin_areas)[0], 0, 0, w/2, h); @@ -111,8 +111,8 @@ void extensions_xinerama_screens(Rect **xin_areas, guint *nxin) *nxin = 1; *xin_areas = g_new(Rect, *nxin + 1); RECT_SET((*xin_areas)[0], 0, 0, - WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)), - HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen))); + WidthOfScreen(ScreenOfDisplay(render_plugin->ob_display, render_plugin->ob_screen)), + HeightOfScreen(ScreenOfDisplay(render_plugin->ob_display, render_plugin->ob_screen))); } /* returns one extra with the total area in it */ diff --git a/openbox/focus.c b/openbox/focus.c index b056db7..dcbde88 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -52,7 +52,7 @@ void focus_shutdown(gboolean reconfig) if (reconfig) return; /* reset focus to root */ - XSetInputFocus(ob_display, PointerRoot, RevertToNone, CurrentTime); + XSetInputFocus(render_plugin->ob_display, PointerRoot, RevertToNone, CurrentTime); } static void push_to_top(ObClient *client) @@ -91,7 +91,7 @@ void focus_set_client(ObClient *client) /* set the NET_ACTIVE_WINDOW hint, but preserve it on shutdown */ if (ob_state() != OB_STATE_EXITING) { active = client ? client->window : None; - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_active_window, window, active); } } @@ -199,7 +199,7 @@ void focus_nothing() event_cancel_all_key_grabs(); /* when nothing will be focused, send focus to the backup target */ - XSetInputFocus(ob_display, screen_support_win, RevertToPointerRoot, + XSetInputFocus(render_plugin->ob_display, screen_support_win, RevertToPointerRoot, event_curtime); } diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index 85cdf48..5e6f9e1 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -21,7 +21,7 @@ #include "focus_cycle_indicator.h" #include "focus_cycle_popup.h" #include "client.h" -#include "frame.h" +#include "plugin.h" #include "focus.h" #include "screen.h" #include "openbox.h" @@ -30,7 +30,7 @@ #include #include -ObClient *focus_cycle_target = NULL; +//ObClient *focus_cycle_target = NULL; static gboolean focus_cycle_iconic_windows; static gboolean focus_cycle_all_desktops; static gboolean focus_cycle_dock_windows; @@ -55,7 +55,7 @@ void focus_cycle_stop(ObClient *ifclient) { /* stop focus cycling if the given client is a valid focus target, and so the cycling is being disrupted */ - if (focus_cycle_target && ifclient && + if (render_plugin->focus_cycle_target && ifclient && focus_valid_target(ifclient, TRUE, focus_cycle_iconic_windows, focus_cycle_all_desktops, @@ -80,7 +80,7 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, if (interactive) { if (cancel) { - focus_cycle_target = NULL; + render_plugin->focus_cycle_target = NULL; goto done_cycle; } else if (done) goto done_cycle; @@ -97,14 +97,14 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, } - if (focus_cycle_target == NULL) { + if (render_plugin->focus_cycle_target == NULL) { focus_cycle_iconic_windows = TRUE; focus_cycle_all_desktops = all_desktops; focus_cycle_dock_windows = dock_windows; focus_cycle_desktop_windows = desktop_windows; start = it = g_list_find(list, focus_client); } else - start = it = g_list_find(list, focus_cycle_target); + start = it = g_list_find(list, render_plugin->focus_cycle_target); if (!start) /* switched desktops or something? */ start = it = forward ? g_list_last(list) : g_list_first(list); @@ -126,8 +126,8 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, focus_cycle_desktop_windows)) { if (interactive) { - if (ft != focus_cycle_target) { /* prevents flicker */ - focus_cycle_target = ft; + if (ft != render_plugin->focus_cycle_target) { /* prevents flicker */ + render_plugin->focus_cycle_target = ft; focus_cycle_draw_indicator(ft); } if (dialog) @@ -137,9 +137,9 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, focus_cycle_all_desktops, focus_cycle_dock_windows, focus_cycle_desktop_windows); - return focus_cycle_target; - } else if (ft != focus_cycle_target) { - focus_cycle_target = ft; + return render_plugin->focus_cycle_target; + } else if (ft != render_plugin->focus_cycle_target) { + render_plugin->focus_cycle_target = ft; done = TRUE; break; } @@ -147,10 +147,10 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, } while (it != start); done_cycle: - if (done && !cancel) ret = focus_cycle_target; + if (done && !cancel) ret = render_plugin->focus_cycle_target; t = NULL; - focus_cycle_target = NULL; + render_plugin->focus_cycle_target = NULL; g_list_free(order); order = NULL; @@ -269,7 +269,7 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, ObClient *ret = NULL; if (cancel) { - focus_cycle_target = NULL; + render_plugin->focus_cycle_target = NULL; goto done_cycle; } else if (done && interactive) goto done_cycle; @@ -277,7 +277,7 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, if (!focus_order) goto done_cycle; - if (focus_cycle_target == NULL) { + if (render_plugin->focus_cycle_target == NULL) { focus_cycle_iconic_windows = FALSE; focus_cycle_all_desktops = FALSE; focus_cycle_dock_windows = dock_windows; @@ -286,8 +286,8 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, if (!first) first = focus_client; - if (focus_cycle_target) - ft = focus_find_directional(focus_cycle_target, dir, dock_windows, + if (render_plugin->focus_cycle_target) + ft = focus_find_directional(render_plugin->focus_cycle_target, dir, dock_windows, desktop_windows); else if (first) ft = focus_find_directional(first, dir, dock_windows, desktop_windows); @@ -303,26 +303,26 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, ft = it->data; } - if (ft && ft != focus_cycle_target) {/* prevents flicker */ - focus_cycle_target = ft; + if (ft && ft != render_plugin->focus_cycle_target) {/* prevents flicker */ + render_plugin->focus_cycle_target = ft; if (!interactive) goto done_cycle; focus_cycle_draw_indicator(ft); } - if (focus_cycle_target && dialog) + if (render_plugin->focus_cycle_target && dialog) /* same arguments as focus_target_valid */ - focus_cycle_popup_single_show(focus_cycle_target, + focus_cycle_popup_single_show(render_plugin->focus_cycle_target, focus_cycle_iconic_windows, focus_cycle_all_desktops, focus_cycle_dock_windows, focus_cycle_desktop_windows); - return focus_cycle_target; + return render_plugin->focus_cycle_target; done_cycle: - if (done && !cancel) ret = focus_cycle_target; + if (done && !cancel) ret = render_plugin->focus_cycle_target; first = NULL; - focus_cycle_target = NULL; + render_plugin->focus_cycle_target = NULL; focus_cycle_draw_indicator(NULL); focus_cycle_popup_single_hide(); diff --git a/openbox/focus_cycle.h b/openbox/focus_cycle.h index 68b8d92..ee81a48 100644 --- a/openbox/focus_cycle.h +++ b/openbox/focus_cycle.h @@ -28,7 +28,7 @@ struct _ObClient; /*! The client which appears focused during a focus cycle operation */ -extern struct _ObClient *focus_cycle_target; +//extern struct _ObClient *focus_cycle_target; void focus_cycle_startup(gboolean reconfig); void focus_cycle_shutdown(gboolean reconfig); diff --git a/openbox/focus_cycle_indicator.c b/openbox/focus_cycle_indicator.c index 7907131..53b62f9 100644 --- a/openbox/focus_cycle_indicator.c +++ b/openbox/focus_cycle_indicator.c @@ -20,7 +20,7 @@ #include "focus_cycle.h" #include "client.h" #include "openbox.h" -#include "frame.h" +#include "plugin.h" #include "event.h" #include "render/render.h" @@ -43,9 +43,9 @@ static RrColor *color_white; static Window create_window(Window parent, gulong mask, XSetWindowAttributes *attrib) { - return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), mask, attrib); + return XCreateWindow(render_plugin->ob_display, parent, 0, 0, 1, 1, 0, + RrDepth(render_plugin->ob_rr_inst), InputOutput, + RrVisual(render_plugin->ob_rr_inst), mask, attrib); } @@ -61,18 +61,18 @@ void focus_cycle_indicator_startup(gboolean reconfig) focus_indicator.bottom.obwin.type = Window_Internal; attr.override_redirect = True; - attr.background_pixel = BlackPixel(ob_display, ob_screen); + attr.background_pixel = BlackPixel(render_plugin->ob_display, render_plugin->ob_screen); focus_indicator.top.win = - create_window(RootWindow(ob_display, ob_screen), + create_window(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), CWOverrideRedirect | CWBackPixel, &attr); focus_indicator.left.win = - create_window(RootWindow(ob_display, ob_screen), + create_window(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), CWOverrideRedirect | CWBackPixel, &attr); focus_indicator.right.win = - create_window(RootWindow(ob_display, ob_screen), + create_window(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), CWOverrideRedirect | CWBackPixel, &attr); focus_indicator.bottom.win = - create_window(RootWindow(ob_display, ob_screen), + create_window(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), CWOverrideRedirect | CWBackPixel, &attr); stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.top)); @@ -80,12 +80,12 @@ void focus_cycle_indicator_startup(gboolean reconfig) stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.right)); stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.bottom)); - color_white = RrColorNew(ob_rr_inst, 0xff, 0xff, 0xff); + color_white = RrColorNew(render_plugin->ob_rr_inst, 0xff, 0xff, 0xff); - a_focus_indicator = RrAppearanceNew(ob_rr_inst, 4); + a_focus_indicator = RrAppearanceNew(render_plugin->ob_rr_inst, 4); a_focus_indicator->surface.grad = RR_SURFACE_SOLID; a_focus_indicator->surface.relief = RR_RELIEF_FLAT; - a_focus_indicator->surface.primary = RrColorNew(ob_rr_inst, + a_focus_indicator->surface.primary = RrColorNew(render_plugin->ob_rr_inst, 0, 0, 0); a_focus_indicator->texture[0].type = RR_TEXTURE_LINE_ART; a_focus_indicator->texture[0].data.lineart.color = color_white; @@ -110,10 +110,10 @@ void focus_cycle_indicator_shutdown(gboolean reconfig) stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.right)); stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.bottom)); - XDestroyWindow(ob_display, focus_indicator.top.win); - XDestroyWindow(ob_display, focus_indicator.left.win); - XDestroyWindow(ob_display, focus_indicator.right.win); - XDestroyWindow(ob_display, focus_indicator.bottom.win); + XDestroyWindow(render_plugin->ob_display, focus_indicator.top.win); + XDestroyWindow(render_plugin->ob_display, focus_indicator.left.win); + XDestroyWindow(render_plugin->ob_display, focus_indicator.right.win); + XDestroyWindow(render_plugin->ob_display, focus_indicator.bottom.win); } void focus_cycle_draw_indicator(ObClient *c) @@ -124,10 +124,10 @@ void focus_cycle_draw_indicator(ObClient *c) /* kill enter events cause by this unmapping */ ignore_start = event_start_ignore_all_enters(); - XUnmapWindow(ob_display, focus_indicator.top.win); - XUnmapWindow(ob_display, focus_indicator.left.win); - XUnmapWindow(ob_display, focus_indicator.right.win); - XUnmapWindow(ob_display, focus_indicator.bottom.win); + XUnmapWindow(render_plugin->ob_display, focus_indicator.top.win); + XUnmapWindow(render_plugin->ob_display, focus_indicator.left.win); + XUnmapWindow(render_plugin->ob_display, focus_indicator.right.win); + XUnmapWindow(render_plugin->ob_display, focus_indicator.bottom.win); event_end_ignore_all_enters(ignore_start); } else { @@ -146,7 +146,7 @@ void focus_cycle_draw_indicator(ObClient *c) w = c->frame->area.width; h = wt; - XMoveResizeWindow(ob_display, focus_indicator.top.win, + XMoveResizeWindow(render_plugin->ob_display, focus_indicator.top.win, x, y, w, h); a_focus_indicator->texture[0].data.lineart.x1 = 0; a_focus_indicator->texture[0].data.lineart.y1 = h-1; @@ -172,7 +172,7 @@ void focus_cycle_draw_indicator(ObClient *c) w = wl; h = c->frame->area.height; - XMoveResizeWindow(ob_display, focus_indicator.left.win, + XMoveResizeWindow(render_plugin->ob_display, focus_indicator.left.win, x, y, w, h); a_focus_indicator->texture[0].data.lineart.x1 = w-1; a_focus_indicator->texture[0].data.lineart.y1 = 0; @@ -198,7 +198,7 @@ void focus_cycle_draw_indicator(ObClient *c) w = wr; h = c->frame->area.height ; - XMoveResizeWindow(ob_display, focus_indicator.right.win, + XMoveResizeWindow(render_plugin->ob_display, focus_indicator.right.win, x, y, w, h); a_focus_indicator->texture[0].data.lineart.x1 = 0; a_focus_indicator->texture[0].data.lineart.y1 = 0; @@ -224,7 +224,7 @@ void focus_cycle_draw_indicator(ObClient *c) w = c->frame->area.width; h = wb; - XMoveResizeWindow(ob_display, focus_indicator.bottom.win, + XMoveResizeWindow(render_plugin->ob_display, focus_indicator.bottom.win, x, y, w, h); a_focus_indicator->texture[0].data.lineart.x1 = 0; a_focus_indicator->texture[0].data.lineart.y1 = 0; @@ -245,9 +245,9 @@ void focus_cycle_draw_indicator(ObClient *c) RrPaint(a_focus_indicator, focus_indicator.bottom.win, w, h); - XMapWindow(ob_display, focus_indicator.top.win); - XMapWindow(ob_display, focus_indicator.left.win); - XMapWindow(ob_display, focus_indicator.right.win); - XMapWindow(ob_display, focus_indicator.bottom.win); + XMapWindow(render_plugin->ob_display, focus_indicator.top.win); + XMapWindow(render_plugin->ob_display, focus_indicator.left.win); + XMapWindow(render_plugin->ob_display, focus_indicator.right.win); + XMapWindow(render_plugin->ob_display, focus_indicator.bottom.win); } } diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index e0a8080..13afb37 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -87,9 +87,9 @@ static void popup_render (ObFocusCyclePopup *p, static Window create_window(Window parent, guint bwidth, gulong mask, XSetWindowAttributes *attr) { - return XCreateWindow(ob_display, parent, 0, 0, 1, 1, bwidth, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), mask, attr); + return XCreateWindow(render_plugin->ob_display, parent, 0, 0, 1, 1, bwidth, + RrDepth(render_plugin->ob_rr_inst), InputOutput, + RrVisual(render_plugin->ob_rr_inst), mask, attr); } void focus_cycle_popup_startup(gboolean reconfig) @@ -99,9 +99,9 @@ void focus_cycle_popup_startup(gboolean reconfig) single_popup = icon_popup_new(TRUE); popup.obwin.type = Window_Internal; - popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); - popup.a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); - popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex); + popup.a_bg = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_bg); + popup.a_text = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_label); + popup.a_icon = RrAppearanceCopy(render_plugin->ob_rr_theme->a_clear_tex); popup.a_text->surface.parent = popup.a_bg; popup.a_icon->surface.parent = popup.a_bg; @@ -112,9 +112,9 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.a_bg->texture[0].type = RR_TEXTURE_RGBA; attrib.override_redirect = True; - attrib.border_pixel=RrColorPixel(ob_rr_theme->osd_border_color); - popup.bg = create_window(RootWindow(ob_display, ob_screen), - ob_rr_theme->obwidth, + attrib.border_pixel=RrColorPixel(render_plugin->ob_rr_theme->osd_border_color); + popup.bg = create_window(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), + render_plugin->ob_rr_theme->obwidth, CWOverrideRedirect | CWBorderPixel, &attrib); popup.text = create_window(popup.bg, 0, 0, NULL); @@ -125,7 +125,7 @@ void focus_cycle_popup_startup(gboolean reconfig) popup.hilite_rgba = NULL; - XMapWindow(ob_display, popup.text); + XMapWindow(render_plugin->ob_display, popup.text); stacking_add(INTERNAL_AS_WINDOW(&popup)); } @@ -140,15 +140,15 @@ void focus_cycle_popup_shutdown(gboolean reconfig) ObFocusCyclePopupTarget *t = popup.targets->data; g_free(t->text); - XDestroyWindow(ob_display, t->win); + XDestroyWindow(render_plugin->ob_display, t->win); popup.targets = g_list_delete_link(popup.targets, popup.targets); } g_free(popup.hilite_rgba); - XDestroyWindow(ob_display, popup.text); - XDestroyWindow(ob_display, popup.bg); + XDestroyWindow(render_plugin->ob_display, popup.text); + XDestroyWindow(render_plugin->ob_display, popup.bg); RrAppearanceFree(popup.a_icon); RrAppearanceFree(popup.a_text); @@ -195,7 +195,7 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets, t->text = text; t->win = create_window(p->bg, 0, 0, NULL); - XMapWindow(ob_display, t->win); + XMapWindow(render_plugin->ob_display, t->win); p->targets = g_list_prepend(p->targets, t); ++n; @@ -292,9 +292,9 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) /* find the position for the popup (include the outer borders) */ x = screen_area->x + (screen_area->width - - (w + ob_rr_theme->obwidth * 2)) / 2; + (w + render_plugin->ob_rr_theme->obwidth * 2)) / 2; y = screen_area->y + (screen_area->height - - (h + ob_rr_theme->obwidth * 2)) / 2; + (h + render_plugin->ob_rr_theme->obwidth * 2)) / 2; /* get the dimensions of the target hilite texture */ rgbax = ml; @@ -310,7 +310,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) if (!p->mapped) { /* position the background but don't draw it*/ - XMoveResizeWindow(ob_display, p->bg, x, y, w, h); + XMoveResizeWindow(render_plugin->ob_display, p->bg, x, y, w, h); /* set up the hilite texture for the background */ p->a_bg->texture[0].data.rgba.width = rgbaw; @@ -320,7 +320,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) p->a_bg->texture[0].data.rgba.data = p->hilite_rgba; /* position the text, but don't draw it */ - XMoveResizeWindow(ob_display, p->text, textx, texty, textw, texth); + XMoveResizeWindow(render_plugin->ob_display, p->text, textx, texty, textw, texth); p->a_text->surface.parentx = textx; p->a_text->surface.parenty = texty; } @@ -349,9 +349,9 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) RrPixel32 color; gint i, j, o; - color = ((ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) + - ((ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) + - ((ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); + color = ((render_plugin->ob_rr_theme->osd_color->r & 0xff) << RrDefaultRedOffset) + + ((render_plugin->ob_rr_theme->osd_color->g & 0xff) << RrDefaultGreenOffset) + + ((render_plugin->ob_rr_theme->osd_color->b & 0xff) << RrDefaultBlueOffset); o = 0; for (i = 0; i < rgbah; ++i) @@ -408,7 +408,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) innery += ICON_HILITE_WIDTH + ICON_HILITE_MARGIN; /* move the icon */ - XMoveResizeWindow(ob_display, target->win, + XMoveResizeWindow(render_plugin->ob_display, target->win, innerx, innery, innerw, innerh); /* get the icon from the client */ @@ -453,8 +453,8 @@ void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, if (!popup.mapped) { /* show the dialog */ - XMapWindow(ob_display, popup.bg); - XFlush(ob_display); + XMapWindow(render_plugin->ob_display, popup.bg); + XFlush(render_plugin->ob_display); popup.mapped = TRUE; } } @@ -465,8 +465,8 @@ void focus_cycle_popup_hide() ignore_start = event_start_ignore_all_enters(); - XUnmapWindow(ob_display, popup.bg); - XFlush(ob_display); + XUnmapWindow(render_plugin->ob_display, popup.bg); + XFlush(render_plugin->ob_display); event_end_ignore_all_enters(ignore_start); @@ -476,7 +476,7 @@ void focus_cycle_popup_hide() ObFocusCyclePopupTarget *t = popup.targets->data; g_free(t->text); - XDestroyWindow(ob_display, t->win); + XDestroyWindow(render_plugin->ob_display, t->win); popup.targets = g_list_delete_link(popup.targets, popup.targets); } diff --git a/openbox/frame.h b/openbox/frame.h index 3e7b2c6..29247b7 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -1,35 +1,13 @@ -/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- - - frame.h for the Openbox window manager - Copyright (c) 2006 Mikael Magnusson - Copyright (c) 2003-2007 Dana Jansens - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - See the COPYING file for a copy of the GNU General Public License. -*/ - -#ifndef __frame_h -#define __frame_h +#ifndef FRAME_H_ +#define FRAME_H_ #include "geom.h" #include "render/render.h" -typedef struct _ObFrame ObFrame; - struct _ObClient; -typedef void (*ObFrameIconifyAnimateFunc)(gpointer data); - -typedef enum { +typedef enum + { OB_FRAME_CONTEXT_NONE, OB_FRAME_CONTEXT_DESKTOP, OB_FRAME_CONTEXT_ROOT, @@ -51,209 +29,60 @@ typedef enum { OB_FRAME_CONTEXT_ICON, OB_FRAME_CONTEXT_CLOSE, /*! This is a special context, which occurs while dragging a window in - a move/resize */ + a move/resize */ OB_FRAME_CONTEXT_MOVE_RESIZE, OB_FRAME_NUM_CONTEXTS -} ObFrameContext; + } ObFrameContext; /*! The decorations the client window wants to be displayed on it */ -typedef enum { - OB_FRAME_DECOR_TITLEBAR = 1 << 0, /*!< Display a titlebar */ - OB_FRAME_DECOR_HANDLE = 1 << 1, /*!< Display a handle (bottom) */ - OB_FRAME_DECOR_GRIPS = 1 << 2, /*!< Display grips in the handle */ - OB_FRAME_DECOR_BORDER = 1 << 3, /*!< Display a border */ - OB_FRAME_DECOR_ICON = 1 << 4, /*!< Display the window's icon */ - OB_FRAME_DECOR_ICONIFY = 1 << 5, /*!< Display an iconify button */ - OB_FRAME_DECOR_MAXIMIZE = 1 << 6, /*!< Display a maximize button */ +typedef enum + { + OB_FRAME_DECOR_TITLEBAR = 1 << 0, /*!< Display a titlebar */ + OB_FRAME_DECOR_HANDLE = 1 << 1, /*!< Display a handle (bottom) */ + OB_FRAME_DECOR_GRIPS = 1 << 2, /*!< Display grips in the handle */ + OB_FRAME_DECOR_BORDER = 1 << 3, /*!< Display a border */ + OB_FRAME_DECOR_ICON = 1 << 4, /*!< Display the window's icon */ + OB_FRAME_DECOR_ICONIFY = 1 << 5, /*!< Display an iconify button */ + OB_FRAME_DECOR_MAXIMIZE = 1 << 6, /*!< Display a maximize button */ /*! Display a button to toggle the window's placement on - all desktops */ + all desktops */ OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7, - OB_FRAME_DECOR_SHADE = 1 << 8, /*!< Displays a shade button */ - OB_FRAME_DECOR_CLOSE = 1 << 9 /*!< Display a close button */ -} ObFrameDecorations; + OB_FRAME_DECOR_SHADE = 1 << 8, /*!< Displays a shade button */ + OB_FRAME_DECOR_CLOSE = 1 << 9 /*!< Display a close button */ + } ObFrameDecorations; struct _ObFrame -{ + { struct _ObClient *client; - Window window; - - Strut size; - Rect area; - gboolean visible; - - guint functions; - guint decorations; - - Window title; - Window label; - Window max; - Window close; - Window desk; - Window shade; - Window icon; - Window iconify; - Window handle; - Window lgrip; - Window rgrip; - - /* These are borders of the frame and its elements */ - Window titleleft; - Window titletop; - Window titletopleft; - Window titletopright; - Window titleright; - Window titlebottom; - Window left; - Window right; - Window handleleft; - Window handletop; - Window handleright; - Window handlebottom; - Window lgriptop; - Window lgripleft; - Window lgripbottom; - Window rgriptop; - Window rgripright; - Window rgripbottom; - Window innerleft; /*!< For drawing the inner client border */ - Window innertop; /*!< For drawing the inner client border */ - Window innerright; /*!< For drawing the inner client border */ - Window innerbottom; /*!< For drawing the inner client border */ - Window innerblb; - Window innerbll; - Window innerbrb; - Window innerbrr; - Window backback; /*!< A colored window shown while resizing */ - Window backfront; /*!< An undrawn-in window, to prevent flashing on - unmap */ - - /* These are resize handles inside the titlebar */ - Window topresize; - Window tltresize; - Window tllresize; - Window trtresize; - Window trrresize; - - Colormap colormap; + Window window; // public attributes - RrAppearance *a_unfocused_title; - RrAppearance *a_focused_title; - RrAppearance *a_unfocused_label; - RrAppearance *a_focused_label; - RrAppearance *a_icon; - RrAppearance *a_unfocused_handle; - RrAppearance *a_focused_handle; + Strut size; // public (read, write) size update ? + Rect area; // public (read, write) size_update ? + gint bwidth; // public /* border width */ + guint decorations; // public - GSList *clients; + gboolean visible; // public (read only) - gint icon_on; /* if the window icon button is on */ - gint label_on; /* if the window title is on */ - gint iconify_on; /* if the window iconify button is on */ - gint desk_on; /* if the window all-desktops button is on */ - gint shade_on; /* if the window shade button is on */ - gint max_on; /* if the window maximize button is on */ - gint close_on; /* if the window close button is on */ + gboolean max_horz;// public /* when maxed some decorations are hidden */ + gboolean max_vert;// public /* when maxed some decorations are hidden */ - gint width; /* width of the titlebar and handle */ - gint label_width; /* width of the label in the titlebar */ - gint icon_x; /* x-position of the window icon button */ - gint label_x; /* x-position of the window title */ - gint iconify_x; /* x-position of the window iconify button */ - gint desk_x; /* x-position of the window all-desktops button */ - gint shade_x; /* x-position of the window shade button */ - gint max_x; /* x-position of the window maximize button */ - gint close_x; /* x-position of the window close button */ - gint bwidth; /* border width */ - gint cbwidth_l; /* client border width */ - gint cbwidth_t; /* client border width */ - gint cbwidth_r; /* client border width */ - gint cbwidth_b; /* client border width */ - gboolean max_horz; /* when maxed some decorations are hidden */ - gboolean max_vert; /* when maxed some decorations are hidden */ - gboolean shaded; /* decorations adjust when shaded */ + gboolean max_press;// public (read, write) + gboolean close_press;// public (read, write) + gboolean desk_press;// public (read, write) + gboolean shade_press;// public (read, write) + gboolean iconify_press;// public (read, write) - /* the leftmost and rightmost elements in the titlebar */ - ObFrameContext leftmost; - ObFrameContext rightmost; + gboolean max_hover;// public (read, write) + gboolean close_hover;// public (read, write) + gboolean desk_hover;// public (read, write) + gboolean shade_hover;// public (read, write) + gboolean iconify_hover;// public (read, write) - gboolean max_press; - gboolean close_press; - gboolean desk_press; - gboolean shade_press; - gboolean iconify_press; - gboolean max_hover; - gboolean close_hover; - gboolean desk_hover; - gboolean shade_hover; - gboolean iconify_hover; + gint iconify_animation_going;// public - gboolean focused; - gboolean need_render; + }; - gboolean flashing; - gboolean flash_on; - GTimeVal flash_end; - - /*! Is the frame currently in an animation for iconify or restore. - 0 means that it is not animating. > 0 means it is animating an iconify. - < 0 means it is animating a restore. - */ - gint iconify_animation_going; - GTimeVal iconify_animation_end; -}; - -ObFrame *frame_new(struct _ObClient *c); -void frame_free(ObFrame *self); - -void frame_show(ObFrame *self); -void frame_hide(ObFrame *self); -void frame_adjust_theme(ObFrame *self); -void frame_adjust_shape(ObFrame *self); -void frame_adjust_area(ObFrame *self, gboolean moved, - gboolean resized, gboolean fake); -void frame_adjust_client_area(ObFrame *self); -void frame_adjust_state(ObFrame *self); -void frame_adjust_focus(ObFrame *self, gboolean hilite); -void frame_adjust_title(ObFrame *self); -void frame_adjust_icon(ObFrame *self); -void frame_grab_client(ObFrame *self); -void frame_release_client(ObFrame *self); - -ObFrameContext frame_context_from_string(const gchar *name); - -ObFrameContext frame_context(struct _ObClient *self, Window win, - gint x, gint y); - -/*! Applies gravity to the client's position to find where the frame should - be positioned. - @return The proper coordinates for the frame, based on the client. -*/ -void frame_client_gravity(ObFrame *self, gint *x, gint *y); - -/*! Reversly applies gravity to the frame's position to find where the client - should be positioned. - @return The proper coordinates for the client, based on the frame. -*/ -void frame_frame_gravity(ObFrame *self, gint *x, gint *y); - -/*! Convert a rectangle in client coordinates/sizes to what it would be - for the frame, given its current decorations sizes */ -void frame_rect_to_frame(ObFrame *self, Rect *r); - -/*! Convert a rectangle in frame coordinates/sizes to what it would be for the - client, given its current decorations sizes */ -void frame_rect_to_client(ObFrame *self, Rect *r); - -void frame_flash_start(ObFrame *self); -void frame_flash_stop(ObFrame *self); - -/*! Start an animation for iconifying or restoring a frame. The callback - will be called when the animation finishes. But if another animation is - started in the meantime, the callback will never get called. */ -void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying); -void frame_end_iconify_animation(ObFrame *self); - -#define frame_iconify_animating(f) (f->iconify_animation_going != 0) +typedef struct _ObFrame ObFrame; -#endif +#endif /*FRAME_H_*/ diff --git a/openbox/grab.c b/openbox/grab.c index 3fa45b7..9aa2993 100644 --- a/openbox/grab.c +++ b/openbox/grab.c @@ -74,7 +74,7 @@ gboolean grab_keyboard_full(gboolean grab) if (grab) { if (kgrabs++ == 0) { - ret = XGrabKeyboard(ob_display, RootWindow(ob_display, ob_screen), + ret = XGrabKeyboard(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), False, GrabModeAsync, GrabModeAsync, event_curtime) == Success; if (!ret) @@ -87,7 +87,7 @@ gboolean grab_keyboard_full(gboolean grab) ret = TRUE; } else if (kgrabs > 0) { if (--kgrabs == 0) { - XUngrabKeyboard(ob_display, ungrab_time()); + XUngrabKeyboard(render_plugin->ob_display, ungrab_time()); } ret = TRUE; } @@ -102,10 +102,10 @@ gboolean grab_pointer_full(gboolean grab, gboolean owner_events, if (grab) { if (pgrabs++ == 0) { - ret = XGrabPointer(ob_display, screen_support_win, owner_events, + ret = XGrabPointer(render_plugin->ob_display, screen_support_win, owner_events, GRAB_PTR_MASK, GrabModeAsync, GrabModeAsync, - (confine ? RootWindow(ob_display, ob_screen) : + (confine ? RootWindow(render_plugin->ob_display, render_plugin->ob_screen) : None), ob_cursor(cur), event_curtime) == Success; if (!ret) @@ -116,7 +116,7 @@ gboolean grab_pointer_full(gboolean grab, gboolean owner_events, ret = TRUE; } else if (pgrabs > 0) { if (--pgrabs == 0) { - XUngrabPointer(ob_display, ungrab_time()); + XUngrabPointer(render_plugin->ob_display, ungrab_time()); } ret = TRUE; } @@ -128,13 +128,13 @@ gint grab_server(gboolean grab) static guint sgrabs = 0; if (grab) { if (sgrabs++ == 0) { - XGrabServer(ob_display); - XSync(ob_display, FALSE); + XGrabServer(render_plugin->ob_display); + XSync(render_plugin->ob_display, FALSE); } } else if (sgrabs > 0) { if (--sgrabs == 0) { - XUngrabServer(ob_display); - XFlush(ob_display); + XUngrabServer(render_plugin->ob_display); + XFlush(render_plugin->ob_display); } } return sgrabs; @@ -177,7 +177,7 @@ void grab_button_full(guint button, guint state, Window win, guint mask, xerror_set_ignore(TRUE); /* can get BadAccess from these */ xerror_occured = FALSE; for (i = 0; i < MASK_LIST_SIZE; ++i) - XGrabButton(ob_display, button, state | mask_list[i], win, False, mask, + XGrabButton(render_plugin->ob_display, button, state | mask_list[i], win, False, mask, pointer_mode, GrabModeAsync, None, ob_cursor(cur)); xerror_set_ignore(FALSE); if (xerror_occured) @@ -189,7 +189,7 @@ void ungrab_button(guint button, guint state, Window win) guint i; for (i = 0; i < MASK_LIST_SIZE; ++i) - XUngrabButton(ob_display, button, state | mask_list[i], win); + XUngrabButton(render_plugin->ob_display, button, state | mask_list[i], win); } void grab_key(guint keycode, guint state, Window win, gint keyboard_mode) @@ -199,7 +199,7 @@ void grab_key(guint keycode, guint state, Window win, gint keyboard_mode) xerror_set_ignore(TRUE); /* can get BadAccess' from these */ xerror_occured = FALSE; for (i = 0; i < MASK_LIST_SIZE; ++i) - XGrabKey(ob_display, keycode, state | mask_list[i], win, FALSE, + XGrabKey(render_plugin->ob_display, keycode, state | mask_list[i], win, FALSE, GrabModeAsync, keyboard_mode); xerror_set_ignore(FALSE); if (xerror_occured) @@ -208,7 +208,7 @@ void grab_key(guint keycode, guint state, Window win, gint keyboard_mode) void ungrab_all_keys(Window win) { - XUngrabKey(ob_display, AnyKey, AnyModifier, win); + XUngrabKey(render_plugin->ob_display, AnyKey, AnyModifier, win); } void grab_key_passive_count(int change) @@ -223,7 +223,7 @@ void ungrab_passive_key() /*ob_debug("ungrabbing %d passive grabs\n", passive_count);*/ if (passive_count) { /* kill out passive grab */ - XUngrabKeyboard(ob_display, event_curtime); + XUngrabKeyboard(render_plugin->ob_display, event_curtime); passive_count = 0; } } diff --git a/openbox/keyboard.c b/openbox/keyboard.c index 6e45e5c..56fb2bf 100644 --- a/openbox/keyboard.c +++ b/openbox/keyboard.c @@ -20,7 +20,7 @@ #include "mainloop.h" #include "focus.h" #include "screen.h" -#include "frame.h" +#include "plugin.h" #include "openbox.h" #include "event.h" #include "grab.h" @@ -46,19 +46,19 @@ static void grab_keys(gboolean grab) { KeyBindingTree *p; - ungrab_all_keys(RootWindow(ob_display, ob_screen)); + ungrab_all_keys(RootWindow(render_plugin->ob_display, render_plugin->ob_screen)); if (grab) { p = curpos ? curpos->first_child : keyboard_firstnode; while (p) { - grab_key(p->key, p->state, RootWindow(ob_display, ob_screen), + grab_key(p->key, p->state, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), GrabModeAsync); p = p->next_sibling; } if (curpos) grab_key(config_keyboard_reset_keycode, config_keyboard_reset_state, - RootWindow(ob_display, ob_screen), GrabModeAsync); + RootWindow(render_plugin->ob_display, render_plugin->ob_screen), GrabModeAsync); } } @@ -220,7 +220,7 @@ void keyboard_event(ObClient *client, const XEvent *e) if (e->xkey.keycode == config_keyboard_reset_keycode && e->xkey.state == config_keyboard_reset_state) { - ob_main_loop_timeout_remove(ob_main_loop, chain_timeout); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, chain_timeout); keyboard_reset_chains(-1); return; } @@ -238,9 +238,9 @@ void keyboard_event(ObClient *client, const XEvent *e) menu_frame_hide_all(); if (p->first_child != NULL) { /* part of a chain */ - ob_main_loop_timeout_remove(ob_main_loop, chain_timeout); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, chain_timeout); /* 3 second timeout for chains */ - ob_main_loop_timeout_add(ob_main_loop, 3 * G_USEC_PER_SEC, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, 3 * G_USEC_PER_SEC, chain_timeout, NULL, g_direct_equal, NULL); set_curpos(p); @@ -273,7 +273,7 @@ void keyboard_startup(gboolean reconfig) void keyboard_shutdown(gboolean reconfig) { - ob_main_loop_timeout_remove(ob_main_loop, chain_timeout); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, chain_timeout); keyboard_unbind_all(); set_curpos(NULL); diff --git a/openbox/keyboard.h b/openbox/keyboard.h index 1c55e05..50ca35d 100644 --- a/openbox/keyboard.h +++ b/openbox/keyboard.h @@ -21,7 +21,7 @@ #define ob__keybaord_h #include "keytree.h" -#include "frame.h" +#include "plugin.h" #include #include diff --git a/openbox/menu.c b/openbox/menu.c index b69b7a3..d595b16 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -464,7 +464,7 @@ void menu_show(gchar *name, gint x, gint y, gboolean mouse, ObClient *client) menu_can_hide = TRUE; else { menu_can_hide = FALSE; - ob_main_loop_timeout_add(ob_main_loop, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_menu_hide_delay * 1000, menu_hide_delay_func, NULL, g_direct_equal, NULL); diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 2c666e3..628751a 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -32,7 +32,7 @@ #define SEPARATOR_HEIGHT 3 #define MAX_MENU_WIDTH 400 -#define ITEM_HEIGHT (ob_rr_theme->menu_font_height + 2*PADDING) +#define ITEM_HEIGHT (render_plugin->ob_rr_theme->menu_font_height + 2*PADDING) #define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask |\ LeaveWindowMask) @@ -51,9 +51,9 @@ static void menu_frame_hide(ObMenuFrame *self); static Window createWindow(Window parent, gulong mask, XSetWindowAttributes *attrib) { - return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), mask, attrib); + return XCreateWindow(render_plugin->ob_display, parent, 0, 0, 1, 1, 0, + RrDepth(render_plugin->ob_rr_inst), InputOutput, + RrVisual(render_plugin->ob_rr_inst), mask, attrib); } GHashTable *menu_frame_map; @@ -86,15 +86,15 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *client) self->show_from = show_from; attr.event_mask = FRAME_EVENTMASK; - self->window = createWindow(RootWindow(ob_display, ob_screen), + self->window = createWindow(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), CWEventMask, &attr); - XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->mbwidth); - XSetWindowBorder(ob_display, self->window, - RrColorPixel(ob_rr_theme->menu_border_color)); + XSetWindowBorderWidth(render_plugin->ob_display, self->window, render_plugin->ob_rr_theme->mbwidth); + XSetWindowBorder(render_plugin->ob_display, self->window, + RrColorPixel(render_plugin->ob_rr_theme->menu_border_color)); - self->a_title = RrAppearanceCopy(ob_rr_theme->a_menu_title); - self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu); + self->a_title = RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_title); + self->a_items = RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu); stacking_add(MENU_AS_WINDOW(self)); @@ -111,7 +111,7 @@ void menu_frame_free(ObMenuFrame *self) stacking_remove(MENU_AS_WINDOW(self)); - XDestroyWindow(ob_display, self->window); + XDestroyWindow(render_plugin->ob_display, self->window); RrAppearanceFree(self->a_items); RrAppearanceFree(self->a_title); @@ -146,39 +146,39 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry, g_hash_table_insert(menu_frame_map, &self->bullet, self); } - XMapWindow(ob_display, self->window); - XMapWindow(ob_display, self->text); + XMapWindow(render_plugin->ob_display, self->window); + XMapWindow(render_plugin->ob_display, self->text); - self->a_normal = RrAppearanceCopy(ob_rr_theme->a_menu_normal); - self->a_selected = RrAppearanceCopy(ob_rr_theme->a_menu_selected); - self->a_disabled = RrAppearanceCopy(ob_rr_theme->a_menu_disabled); + self->a_normal = RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_normal); + self->a_selected = RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_selected); + self->a_disabled = RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_disabled); self->a_disabled_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_disabled_selected); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_disabled_selected); if (entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR) { - self->a_separator = RrAppearanceCopy(ob_rr_theme->a_clear_tex); + self->a_separator = RrAppearanceCopy(render_plugin->ob_rr_theme->a_clear_tex); self->a_separator->texture[0].type = RR_TEXTURE_LINE_ART; } else { - self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex); + self->a_icon = RrAppearanceCopy(render_plugin->ob_rr_theme->a_clear_tex); self->a_icon->texture[0].type = RR_TEXTURE_RGBA; - self->a_mask = RrAppearanceCopy(ob_rr_theme->a_clear_tex); + self->a_mask = RrAppearanceCopy(render_plugin->ob_rr_theme->a_clear_tex); self->a_mask->texture[0].type = RR_TEXTURE_MASK; self->a_bullet_normal = - RrAppearanceCopy(ob_rr_theme->a_menu_bullet_normal); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_bullet_normal); self->a_bullet_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_bullet_selected); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_bullet_selected); } self->a_text_normal = - RrAppearanceCopy(ob_rr_theme->a_menu_text_normal); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_text_normal); self->a_text_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_text_selected); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_text_selected); self->a_text_disabled = - RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_text_disabled); self->a_text_disabled_selected = - RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled_selected); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_text_disabled_selected); self->a_text_title = - RrAppearanceCopy(ob_rr_theme->a_menu_text_title); + RrAppearanceCopy(render_plugin->ob_rr_theme->a_menu_text_title); return self; } @@ -188,16 +188,16 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self) if (self) { menu_entry_unref(self->entry); - XDestroyWindow(ob_display, self->text); - XDestroyWindow(ob_display, self->window); + XDestroyWindow(render_plugin->ob_display, self->text); + XDestroyWindow(render_plugin->ob_display, self->window); g_hash_table_remove(menu_frame_map, &self->text); g_hash_table_remove(menu_frame_map, &self->window); if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) { - XDestroyWindow(ob_display, self->icon); + XDestroyWindow(render_plugin->ob_display, self->icon); g_hash_table_remove(menu_frame_map, &self->icon); } if (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) { - XDestroyWindow(ob_display, self->bullet); + XDestroyWindow(render_plugin->ob_display, self->bullet); g_hash_table_remove(menu_frame_map, &self->bullet); } @@ -224,7 +224,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self) void menu_frame_move(ObMenuFrame *self, gint x, gint y) { RECT_SET_POINT(self->area, x, y); - XMoveWindow(ob_display, self->window, self->area.x, self->area.y); + XMoveWindow(render_plugin->ob_display, self->window, self->area.x, self->area.y); } static void menu_frame_place_topmenu(ObMenuFrame *self, gint *x, gint *y) @@ -301,8 +301,8 @@ static void menu_frame_place_submenu(ObMenuFrame *self, gint *x, gint *y) gint overlap; gint bwidth; - overlap = ob_rr_theme->menu_overlap; - bwidth = ob_rr_theme->mbwidth; + overlap = render_plugin->ob_rr_theme->menu_overlap; + bwidth = render_plugin->ob_rr_theme->mbwidth; if (self->direction_right) *x = self->parent->area.x + self->parent->area.width - @@ -371,7 +371,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label) { item_a = self->frame->a_title; - th = ob_rr_theme->menu_title_height; + th = render_plugin->ob_rr_theme->menu_title_height; } else { item_a = self->a_normal; th = SEPARATOR_HEIGHT + 2*PADDING; @@ -381,7 +381,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) g_assert_not_reached(); } RECT_SET_SIZE(self->area, self->frame->inner_w, th); - XResizeWindow(ob_display, self->window, + XResizeWindow(render_plugin->ob_display, self->window, self->area.width, self->area.height); item_a->surface.parent = self->frame->a_items; item_a->surface.parentx = self->area.x; @@ -435,7 +435,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) switch (self->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: - XMoveResizeWindow(ob_display, self->text, + XMoveResizeWindow(render_plugin->ob_display, self->text, self->frame->text_x, PADDING, self->frame->text_w, ITEM_HEIGHT - 2*PADDING); @@ -446,7 +446,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) ITEM_HEIGHT - 2*PADDING); break; case OB_MENU_ENTRY_TYPE_SUBMENU: - XMoveResizeWindow(ob_display, self->text, + XMoveResizeWindow(render_plugin->ob_display, self->text, self->frame->text_x, PADDING, self->frame->text_w - ITEM_HEIGHT, ITEM_HEIGHT - 2*PADDING); @@ -459,21 +459,21 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label != NULL) { /* labeled separator */ - XMoveResizeWindow(ob_display, self->text, - ob_rr_theme->paddingx, ob_rr_theme->paddingy, - self->area.width - 2*ob_rr_theme->paddingx, - ob_rr_theme->menu_title_height - - 2*ob_rr_theme->paddingy); + XMoveResizeWindow(render_plugin->ob_display, self->text, + render_plugin->ob_rr_theme->paddingx, render_plugin->ob_rr_theme->paddingy, + self->area.width - 2*render_plugin->ob_rr_theme->paddingx, + render_plugin->ob_rr_theme->menu_title_height - + 2*render_plugin->ob_rr_theme->paddingy); text_a->surface.parent = item_a; - text_a->surface.parentx = ob_rr_theme->paddingx; - text_a->surface.parenty = ob_rr_theme->paddingy; + text_a->surface.parentx = render_plugin->ob_rr_theme->paddingx; + text_a->surface.parenty = render_plugin->ob_rr_theme->paddingy; RrPaint(text_a, self->text, - self->area.width - 2*ob_rr_theme->paddingx, - ob_rr_theme->menu_title_height - - 2*ob_rr_theme->paddingy); + self->area.width - 2*render_plugin->ob_rr_theme->paddingx, + render_plugin->ob_rr_theme->menu_title_height - + 2*render_plugin->ob_rr_theme->paddingy); } else { /* unlabeled separaator */ - XMoveResizeWindow(ob_display, self->text, PADDING, PADDING, + XMoveResizeWindow(render_plugin->ob_display, self->text, PADDING, PADDING, self->area.width - 2*PADDING, SEPARATOR_HEIGHT); self->a_separator->surface.parent = item_a; self->a_separator->surface.parentx = PADDING; @@ -494,7 +494,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && self->entry->data.normal.icon_data) { - XMoveResizeWindow(ob_display, self->icon, + XMoveResizeWindow(render_plugin->ob_display, self->icon, PADDING, frame->item_margin.top, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, @@ -516,13 +516,13 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); - XMapWindow(ob_display, self->icon); + XMapWindow(render_plugin->ob_display, self->icon); } else if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && self->entry->data.normal.mask) { RrColor *c; - XMoveResizeWindow(ob_display, self->icon, + XMoveResizeWindow(render_plugin->ob_display, self->icon, PADDING, frame->item_margin.top, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, @@ -551,13 +551,13 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); - XMapWindow(ob_display, self->icon); + XMapWindow(render_plugin->ob_display, self->icon); } else - XUnmapWindow(ob_display, self->icon); + XUnmapWindow(render_plugin->ob_display, self->icon); if (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) { RrAppearance *bullet_a; - XMoveResizeWindow(ob_display, self->bullet, + XMoveResizeWindow(render_plugin->ob_display, self->bullet, self->frame->text_x + self->frame->text_w - ITEM_HEIGHT + PADDING, PADDING, ITEM_HEIGHT - 2*PADDING, @@ -572,11 +572,11 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) RrPaint(bullet_a, self->bullet, ITEM_HEIGHT - 2*PADDING, ITEM_HEIGHT - 2*PADDING); - XMapWindow(ob_display, self->bullet); + XMapWindow(render_plugin->ob_display, self->bullet); } else - XUnmapWindow(ob_display, self->bullet); + XUnmapWindow(render_plugin->ob_display, self->bullet); - XFlush(ob_display); + XFlush(render_plugin->ob_display); } /*! this code is taken from the menu_frame_render. if that changes, this won't @@ -599,21 +599,21 @@ static gint menu_entry_frame_get_height(ObMenuEntryFrame *self, switch (t) { case OB_MENU_ENTRY_TYPE_NORMAL: case OB_MENU_ENTRY_TYPE_SUBMENU: - h += ob_rr_theme->menu_font_height; + h += render_plugin->ob_rr_theme->menu_font_height; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label != NULL) { - h += ob_rr_theme->menu_title_height + - (ob_rr_theme->mbwidth - PADDING) * 2; + h += render_plugin->ob_rr_theme->menu_title_height + + (render_plugin->ob_rr_theme->mbwidth - PADDING) * 2; /* if the first entry is a labeled separator, then make its border overlap with the menu's outside border */ if (first_entry) - h -= ob_rr_theme->mbwidth; + h -= render_plugin->ob_rr_theme->mbwidth; /* if the last entry is a labeled separator, then make its border overlap with the menu's outside border */ if (last_entry) - h -= ob_rr_theme->mbwidth; + h -= render_plugin->ob_rr_theme->mbwidth; } else { h += SEPARATOR_HEIGHT; } @@ -684,21 +684,21 @@ void menu_frame_render(ObMenuFrame *self) e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { - h -= ob_rr_theme->mbwidth; + h -= render_plugin->ob_rr_theme->mbwidth; } if (e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { - e->border = ob_rr_theme->mbwidth; + e->border = render_plugin->ob_rr_theme->mbwidth; } RECT_SET_POINT(e->area, 0, h+e->border); - XMoveWindow(ob_display, e->window, + XMoveWindow(render_plugin->ob_display, e->window, e->area.x-e->border, e->area.y-e->border); - XSetWindowBorderWidth(ob_display, e->window, e->border); - XSetWindowBorder(ob_display, e->window, - RrColorPixel(ob_rr_theme->menu_border_color)); + XSetWindowBorderWidth(render_plugin->ob_display, e->window, e->border); + XSetWindowBorder(render_plugin->ob_display, e->window, + RrColorPixel(render_plugin->ob_rr_theme->menu_border_color)); text_a = (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && @@ -714,7 +714,7 @@ void menu_frame_render(ObMenuFrame *self) text_a->texture[0].data.text.string = e->entry->data.normal.label; tw = RrMinWidth(text_a); tw = MIN(tw, MAX_MENU_WIDTH); - th = ob_rr_theme->menu_font_height; + th = render_plugin->ob_rr_theme->menu_font_height; if (e->entry->data.normal.icon_data || e->entry->data.normal.mask) @@ -725,7 +725,7 @@ void menu_frame_render(ObMenuFrame *self) text_a->texture[0].data.text.string = sub ? sub->title : ""; tw = RrMinWidth(text_a); tw = MIN(tw, MAX_MENU_WIDTH); - th = ob_rr_theme->menu_font_height; + th = render_plugin->ob_rr_theme->menu_font_height; if (e->entry->data.normal.icon_data || e->entry->data.normal.mask) @@ -737,10 +737,10 @@ void menu_frame_render(ObMenuFrame *self) if (e->entry->data.separator.label != NULL) { e->a_text_title->texture[0].data.text.string = e->entry->data.separator.label; - tw = RrMinWidth(e->a_text_title) + 2*ob_rr_theme->paddingx; + tw = RrMinWidth(e->a_text_title) + 2*render_plugin->ob_rr_theme->paddingx; tw = MIN(tw, MAX_MENU_WIDTH); - th = ob_rr_theme->menu_title_height + - (ob_rr_theme->mbwidth - PADDING) *2; + th = render_plugin->ob_rr_theme->menu_title_height + + (render_plugin->ob_rr_theme->mbwidth - PADDING) *2; } else { tw = 0; th = SEPARATOR_HEIGHT; @@ -760,7 +760,7 @@ void menu_frame_render(ObMenuFrame *self) if (e && e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { - h -= ob_rr_theme->mbwidth; + h -= render_plugin->ob_rr_theme->mbwidth; } self->text_x = PADDING; @@ -776,7 +776,7 @@ void menu_frame_render(ObMenuFrame *self) if (!w) w = 10; if (!h) h = 3; - XResizeWindow(ob_display, self->window, w, h); + XResizeWindow(render_plugin->ob_display, self->window, w, h); self->inner_w = w; @@ -785,12 +785,12 @@ void menu_frame_render(ObMenuFrame *self) for (it = self->entries; it; it = g_list_next(it)) menu_entry_frame_render(it->data); - w += ob_rr_theme->mbwidth * 2; - h += ob_rr_theme->mbwidth * 2; + w += render_plugin->ob_rr_theme->mbwidth * 2; + h += render_plugin->ob_rr_theme->mbwidth * 2; RECT_SET_SIZE(self->area, w, h); - XFlush(ob_display); + XFlush(render_plugin->ob_display); } static void menu_frame_update(ObMenuFrame *self) @@ -841,7 +841,7 @@ static void menu_frame_update(ObMenuFrame *self) fit == self->entries, g_list_next(fit) == NULL); /* add the border at the top and bottom */ - h += ob_rr_theme->mbwidth * 2; + h += render_plugin->ob_rr_theme->mbwidth * 2; a = screen_physical_area_monitor(self->monitor); @@ -972,7 +972,7 @@ gboolean menu_frame_show_topmenu(ObMenuFrame *self, gint x, gint y, menu_frame_move(self, x, y); - XMapWindow(ob_display, self->window); + XMapWindow(render_plugin->ob_display, self->window); if (screen_pointer_pos(&px, &py)) { ObMenuEntryFrame *e = menu_entry_frame_under(px, py); @@ -1015,7 +1015,7 @@ gboolean menu_frame_show_submenu(ObMenuFrame *self, ObMenuFrame *parent, } menu_frame_move(self, x + dx, y + dy); - XMapWindow(ob_display, self->window); + XMapWindow(render_plugin->ob_display, self->window); if (screen_pointer_pos(&px, &py)) { ObMenuEntryFrame *e = menu_entry_frame_under(px, py); @@ -1052,7 +1052,7 @@ static void menu_frame_hide(ObMenuFrame *self) ungrab_keyboard(); } - XUnmapWindow(ob_display, self->window); + XUnmapWindow(render_plugin->ob_display, self->window); menu_frame_free(self); } @@ -1063,7 +1063,7 @@ void menu_frame_hide_all() if (config_submenu_show_delay) { /* remove any submenu open requests */ - ob_main_loop_timeout_remove(ob_main_loop, + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, menu_entry_frame_submenu_timeout); } if ((it = g_list_last(menu_frame_visible))) @@ -1078,7 +1078,7 @@ void menu_frame_hide_all_client(ObClient *client) if (f->client == client) { if (config_submenu_show_delay) { /* remove any submenu open requests */ - ob_main_loop_timeout_remove(ob_main_loop, + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, menu_entry_frame_submenu_timeout); } menu_frame_hide(f); @@ -1110,8 +1110,8 @@ ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y) GList *it; if ((frame = menu_frame_under(x, y))) { - x -= ob_rr_theme->mbwidth + frame->area.x; - y -= ob_rr_theme->mbwidth + frame->area.y; + x -= render_plugin->ob_rr_theme->mbwidth + frame->area.x; + y -= render_plugin->ob_rr_theme->mbwidth + frame->area.y; for (it = frame->entries; it; it = g_list_next(it)) { ObMenuEntryFrame *e = it->data; @@ -1145,7 +1145,7 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry, if (config_submenu_show_delay) { /* remove any submenu open requests */ - ob_main_loop_timeout_remove(ob_main_loop, + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, menu_entry_frame_submenu_timeout); } @@ -1162,6 +1162,6 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry, if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) { if (config_submenu_show_delay && !immediate) { /* initiate a new submenu open request */ - ob_main_loop_timeout_add(ob_main_loop, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_submenu_show_delay * 1000, menu_entry_frame_submenu_timeout, \ No newline at end of file diff --git a/openbox/modkeys.c b/openbox/modkeys.c index c993cfc..b0c7fda 100644 --- a/openbox/modkeys.c +++ b/openbox/modkeys.c @@ -69,11 +69,11 @@ void modkeys_startup(gboolean reconfigure) for (i = 0; i < OB_MODKEY_NUM_KEYS; ++i) modkeys_keys[i] = 0; - xmodmap = XGetModifierMapping(ob_display); + xmodmap = XGetModifierMapping(render_plugin->ob_display); g_assert(xmodmap->max_keypermod > 0); - XDisplayKeycodes(ob_display, &min_keycode, &max_keycode); - keymap = XGetKeyboardMapping(ob_display, min_keycode, + XDisplayKeycodes(render_plugin->ob_display, &min_keycode, &max_keycode); + keymap = XGetKeyboardMapping(render_plugin->ob_display, min_keycode, max_keycode - min_keycode + 1, &keysyms_per_keycode); diff --git a/openbox/mouse.c b/openbox/mouse.c index 9761609..e1e2a55 100644 --- a/openbox/mouse.c +++ b/openbox/mouse.c @@ -25,7 +25,7 @@ #include "client.h" #include "prop.h" #include "grab.h" -#include "frame.h" +#include "plugin.h" #include "translate.h" #include "mouse.h" #include "gettext.h" @@ -213,7 +213,7 @@ void mouse_event(ObClient *client, XEvent *e) switch (e->type) { case ButtonPress: - context = frame_context(client, e->xbutton.window, + context = render_plugin->frame_context(client, e->xbutton.window, e->xbutton.x, e->xbutton.y); context = mouse_button_frame_context(context, e->xbutton.button, e->xbutton.state); @@ -237,14 +237,14 @@ void mouse_event(ObClient *client, XEvent *e) if (CLIENT_CONTEXT(context, client)) { /* Replay the event, so it goes to the client*/ - XAllowEvents(ob_display, ReplayPointer, event_curtime); + XAllowEvents(render_plugin->ob_display, ReplayPointer, event_curtime); /* Fall through to the release case! */ } else break; case ButtonRelease: /* use where the press occured in the window */ - context = frame_context(client, e->xbutton.window, pwx, pwy); + context = render_plugin->frame_context(client, e->xbutton.window, pwx, pwy); context = mouse_button_frame_context(context, e->xbutton.button, e->xbutton.state); @@ -258,7 +258,7 @@ void mouse_event(ObClient *client, XEvent *e) guint ujunk, b, w, h; /* this can cause errors to occur when the window closes */ xerror_set_ignore(TRUE); - junk1 = XGetGeometry(ob_display, e->xbutton.window, + junk1 = XGetGeometry(render_plugin->ob_display, e->xbutton.window, &wjunk, &junk1, &junk2, &w, &h, &b, &ujunk); xerror_set_ignore(FALSE); if (junk1) { @@ -309,7 +309,7 @@ void mouse_event(ObClient *client, XEvent *e) case MotionNotify: if (button) { - context = frame_context(client, e->xmotion.window, pwx, pwy); + context = render_plugin->frame_context(client, e->xmotion.window, pwx, pwy); context = mouse_button_frame_context(context, button, state); if (ABS(e->xmotion.x_root - px) >= config_mouse_threshold || @@ -350,7 +350,7 @@ gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr, return FALSE; } - context = frame_context_from_string(contextstr); + context = render_plugin->frame_context_from_string(contextstr); if (!context) { g_message(_("Invalid context '%s' in mouse binding"), contextstr); return FALSE; diff --git a/openbox/mouse.h b/openbox/mouse.h index 44d563a..4e1302e 100644 --- a/openbox/mouse.h +++ b/openbox/mouse.h @@ -19,7 +19,7 @@ #ifndef ob__mouse_h #define ob__mouse_h -#include "frame.h" +#include "plugin.h" #include "misc.h" #include diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 1a8550a..813b317 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -18,11 +18,10 @@ */ #include "grab.h" -#include "framerender.h" #include "screen.h" #include "prop.h" #include "client.h" -#include "frame.h" +#include "plugin.h" #include "openbox.h" #include "resist.h" #include "mainloop.h" @@ -42,7 +41,7 @@ /* how far windows move and resize with the keyboard arrows */ #define KEY_DIST 8 -gboolean moveresize_in_progress = FALSE; +//gboolean moveresize_in_progress = FALSE; ObClient *moveresize_client = NULL; #ifdef SYNC XSyncAlarm moveresize_alarm = None; @@ -87,7 +86,7 @@ void moveresize_startup(gboolean reconfig) void moveresize_shutdown(gboolean reconfig) { if (!reconfig) { - if (moveresize_in_progress) + if (render_plugin->moveresize_in_progress) moveresize_end(FALSE); client_remove_destroy_notify(client_dest); } @@ -105,7 +104,7 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b) popup_position(popup, SouthGravity, c->frame->area.x + c->frame->area.width/2, - c->frame->area.y - ob_rr_theme->fbwidth); + c->frame->area.y - render_plugin->ob_rr_theme->fbwidth); else /* == "Center" */ popup_position(popup, CenterGravity, c->frame->area.x + c->frame->size.left + @@ -124,7 +123,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) gint up = 1; gint left = 1; - if (moveresize_in_progress || !c->frame->visible || + if (render_plugin->moveresize_in_progress || !c->frame->visible || !(mv ? (c->functions & OB_CLIENT_FUNC_MOVE) : (c->functions & OB_CLIENT_FUNC_RESIZE))) @@ -168,7 +167,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) return; } - frame_end_iconify_animation(c->frame); + render_plugin->frame_end_iconify_animation(c->frame); moving = mv; moveresize_client = c; @@ -190,7 +189,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) have to change start_cx and start_cy if going to do this.. if (corner == prop_atoms.net_wm_moveresize_move_keyboard || corner == prop_atoms.net_wm_moveresize_size_keyboard) - XWarpPointer(ob_display, None, c->window, 0, 0, 0, 0, + XWarpPointer(render_plugin->ob_display, None, c->window, 0, 0, 0, 0, c->area.width / 2, c->area.height / 2); */ @@ -199,7 +198,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) cur_w = start_cw; cur_h = start_ch; - moveresize_in_progress = TRUE; + render_plugin->moveresize_in_progress = TRUE; #ifdef SYNC if (config_resize_redraw && !moving && extensions_sync && @@ -213,7 +212,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) /* set the counter to an initial value */ XSyncIntToValue(&val, 0); - XSyncSetCounter(ob_display, moveresize_client->sync_counter, val); + XSyncSetCounter(render_plugin->ob_display, moveresize_client->sync_counter, val); /* this will be incremented when we tell the client what we're looking for */ @@ -229,7 +228,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) aa.trigger.test_type = XSyncPositiveTransition; aa.events = True; XSyncIntToValue(&aa.delta, 1); - moveresize_alarm = XSyncCreateAlarm(ob_display, + moveresize_alarm = XSyncCreateAlarm(render_plugin->ob_display, XSyncCACounter | XSyncCAValue | XSyncCAValueType | @@ -258,11 +257,11 @@ void moveresize_end(gboolean cancel) #ifdef SYNC /* turn off the alarm */ if (moveresize_alarm != None) { - XSyncDestroyAlarm(ob_display, moveresize_alarm); + XSyncDestroyAlarm(render_plugin->ob_display, moveresize_alarm); moveresize_alarm = None; } - ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, sync_timeout_func); #endif client_configure(moveresize_client, @@ -276,7 +275,7 @@ void moveresize_end(gboolean cancel) /* dont edge warp after its ended */ cancel_edge_warp(); - moveresize_in_progress = FALSE; + render_plugin->moveresize_in_progress = FALSE; moveresize_client = NULL; } @@ -334,7 +333,7 @@ static void do_resize() /* tell the client what we're waiting for */ ce.xclient.type = ClientMessage; ce.xclient.message_type = prop_atoms.wm_protocols; - ce.xclient.display = ob_display; + ce.xclient.display = render_plugin->ob_display; ce.xclient.window = moveresize_client->window; ce.xclient.format = 32; ce.xclient.data.l[0] = prop_atoms.net_wm_sync_request; @@ -342,13 +341,13 @@ static void do_resize() ce.xclient.data.l[2] = XSyncValueLow32(val); ce.xclient.data.l[3] = XSyncValueHigh32(val); ce.xclient.data.l[4] = 0l; - XSendEvent(ob_display, moveresize_client->window, FALSE, + XSendEvent(render_plugin->ob_display, moveresize_client->window, FALSE, NoEventMask, &ce); waiting_for_sync = TRUE; - ob_main_loop_timeout_remove(ob_main_loop, sync_timeout_func); - ob_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 2, + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, sync_timeout_func); + ob_main_loop_timeout_add(render_plugin->ob_main_loop, G_USEC_PER_SEC * 2, sync_timeout_func, NULL, NULL, NULL); } @@ -529,7 +528,7 @@ static void do_edge_warp(gint x, gint y) cancel_edge_warp(); if (dir != (ObDirection)-1) { edge_warp_odd = TRUE; /* switch on the first timeout */ - ob_main_loop_timeout_add(ob_main_loop, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_mouse_screenedgetime * 1000, edge_warp_delay_func, NULL, NULL, NULL); @@ -540,7 +539,7 @@ static void do_edge_warp(gint x, gint y) static void cancel_edge_warp() { - ob_main_loop_timeout_remove(ob_main_loop, edge_warp_delay_func); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, edge_warp_delay_func); } static void move_with_keys(gint keycode, gint state) @@ -584,12 +583,12 @@ static void move_with_keys(gint keycode, gint state) } screen_pointer_pos(&opx, &opy); - XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy); + XWarpPointer(render_plugin->ob_display, None, None, 0, 0, 0, 0, dx, dy); /* steal the motion events this causes */ - XSync(ob_display, FALSE); + XSync(render_plugin->ob_display, FALSE); { XEvent ce; - while (XCheckTypedEvent(ob_display, MotionNotify, &ce)); + while (XCheckTypedEvent(render_plugin->ob_display, MotionNotify, &ce)); } screen_pointer_pos(&px, &py); @@ -741,12 +740,12 @@ static void resize_with_keys(gint keycode, gint state) pdy = dh; screen_pointer_pos(&opx, &opy); - XWarpPointer(ob_display, None, None, 0, 0, 0, 0, pdx, pdy); + XWarpPointer(render_plugin->ob_display, None, None, 0, 0, 0, 0, pdx, pdy); /* steal the motion events this causes */ - XSync(ob_display, FALSE); + XSync(render_plugin->ob_display, FALSE); { XEvent ce; - while (XCheckTypedEvent(ob_display, MotionNotify, &ce)); + while (XCheckTypedEvent(render_plugin->ob_display, MotionNotify, &ce)); } screen_pointer_pos(&px, &py); @@ -765,7 +764,7 @@ gboolean moveresize_event(XEvent *e) { gboolean used = FALSE; - if (!moveresize_in_progress) return FALSE; + if (!render_plugin->moveresize_in_progress) return FALSE; if (e->type == ButtonPress) { if (!button) { diff --git a/openbox/moveresize.h b/openbox/moveresize.h index 2f8d3e6..3a63862 100644 --- a/openbox/moveresize.h +++ b/openbox/moveresize.h @@ -27,7 +27,7 @@ struct _ObClient; -extern gboolean moveresize_in_progress; +//extern gboolean moveresize_in_progress; extern struct _ObClient *moveresize_client; #ifdef SYNC extern XSyncAlarm moveresize_alarm; diff --git a/openbox/openbox.c b/openbox/openbox.c index 06afffc..65d586e 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -36,6 +36,7 @@ #include "focus_cycle_popup.h" #include "moveresize.h" #include "frame.h" +#include "plugin.h" #include "keyboard.h" #include "mouse.h" #include "extensions.h" @@ -83,11 +84,12 @@ #include -RrInstance *ob_rr_inst; -RrTheme *ob_rr_theme; -ObMainLoop *ob_main_loop; -Display *ob_display; -gint ob_screen; +//RrInstance *ob_rr_inst; +//RrTheme *ob_rr_theme; +//ObMainLoop *ob_main_loop; +//Display *ob_display; +ObFramePlugin *render_plugin; +//gint ob_screen; gboolean ob_replace_wm = FALSE; gboolean ob_sm_use = TRUE; gchar *ob_sm_id = NULL; @@ -124,7 +126,7 @@ gint main(gint argc, gchar **argv) bindtextdomain(PACKAGE_NAME, LOCALEDIR); bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); textdomain(PACKAGE_NAME); - + if (chdir(g_get_home_dir()) == -1) g_message(_("Unable to change to home directory '%s': %s"), g_get_home_dir(), g_strerror(errno)); @@ -141,13 +143,16 @@ gint main(gint argc, gchar **argv) parse_paths_startup(); session_startup(argc, argv); + ob_debug_type (OB_DEBUG_SM, "Start Load Frame\n"); + render_plugin = init_render ("/home/gschwind/workspace/new_openbox/build/openbox/libobframe.la"); + ob_debug_type (OB_DEBUG_SM, "End Load Frame\n"); } - ob_display = XOpenDisplay(NULL); - if (ob_display == NULL) + render_plugin->ob_display = XOpenDisplay(NULL); + if (render_plugin->ob_display == NULL) ob_exit_with_error(_("Failed to open the display from the DISPLAY environment variable.")); - if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1) + if (fcntl(ConnectionNumber(render_plugin->ob_display), F_SETFD, 1) == -1) ob_exit_with_error("Failed to set display as close-on-exec"); if (remote_control) { @@ -156,30 +161,30 @@ gint main(gint argc, gchar **argv) /* Send client message telling the OB process to: * remote_control = 1 -> reconfigure * remote_control = 2 -> restart */ - PROP_MSG(RootWindow(ob_display, ob_screen), + PROP_MSG(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), ob_control, remote_control, 0, 0, 0); - XCloseDisplay(ob_display); + XCloseDisplay(render_plugin->ob_display); exit(EXIT_SUCCESS); } - ob_main_loop = ob_main_loop_new(ob_display); + render_plugin->ob_main_loop = ob_main_loop_new(render_plugin->ob_display); /* set up signal handler */ - ob_main_loop_signal_add(ob_main_loop, SIGUSR1, signal_handler, NULL, NULL); - ob_main_loop_signal_add(ob_main_loop, SIGUSR2, signal_handler, NULL, NULL); - ob_main_loop_signal_add(ob_main_loop, SIGTERM, signal_handler, NULL, NULL); - ob_main_loop_signal_add(ob_main_loop, SIGINT, signal_handler, NULL, NULL); - ob_main_loop_signal_add(ob_main_loop, SIGHUP, signal_handler, NULL, NULL); - ob_main_loop_signal_add(ob_main_loop, SIGPIPE, signal_handler, NULL, NULL); - ob_main_loop_signal_add(ob_main_loop, SIGCHLD, signal_handler, NULL, NULL); - - ob_screen = DefaultScreen(ob_display); - - ob_rr_inst = RrInstanceNew(ob_display, ob_screen); - if (ob_rr_inst == NULL) + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGUSR1, signal_handler, NULL, NULL); + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGUSR2, signal_handler, NULL, NULL); + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGTERM, signal_handler, NULL, NULL); + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGINT, signal_handler, NULL, NULL); + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGHUP, signal_handler, NULL, NULL); + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGPIPE, signal_handler, NULL, NULL); + ob_main_loop_signal_add(render_plugin->ob_main_loop, SIGCHLD, signal_handler, NULL, NULL); + + render_plugin->ob_screen = DefaultScreen(render_plugin->ob_display); + + render_plugin->ob_rr_inst = RrInstanceNew(render_plugin->ob_display,render_plugin-> ob_screen); + if (render_plugin->ob_rr_inst == NULL) ob_exit_with_error(_("Failed to initialize the obrender library.")); - XSynchronize(ob_display, xsync); + XSynchronize(render_plugin->ob_display, xsync); /* check for locale support */ if (!XSupportsLocale()) @@ -192,7 +197,7 @@ gint main(gint argc, gchar **argv) /* set the DISPLAY environment variable for any lauched children, to the display we're using, so they open in the right place. */ - putenv(g_strdup_printf("DISPLAY=%s", DisplayString(ob_display))); + putenv(g_strdup_printf("DISPLAY=%s", DisplayString(render_plugin->ob_display))); /* create available cursors */ cursors[OB_CURSOR_NONE] = None; @@ -252,7 +257,7 @@ gint main(gint argc, gchar **argv) /* if (config_type != NULL) - PROP_SETS(RootWindow(ob_display, ob_screen), + PROP_SETS(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), ob_config, config_type); */ @@ -263,21 +268,21 @@ gint main(gint argc, gchar **argv) /* load the theme specified in the rc file */ { RrTheme *theme; - if ((theme = RrThemeNew(ob_rr_inst, config_theme, TRUE, + if ((theme = RrThemeNew(render_plugin->ob_rr_inst, config_theme, TRUE, config_font_activewindow, config_font_inactivewindow, config_font_menutitle, config_font_menuitem, config_font_osd))) { - RrThemeFree(ob_rr_theme); - ob_rr_theme = theme; + RrThemeFree(render_plugin->ob_rr_theme); + render_plugin->ob_rr_theme = theme; } - if (ob_rr_theme == NULL) + if (render_plugin->ob_rr_theme == NULL) ob_exit_with_error(_("Unable to load a theme.")); - PROP_SETS(RootWindow(ob_display, ob_screen), - ob_theme, ob_rr_theme->name); + PROP_SETS(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), + ob_theme, render_plugin->ob_rr_theme->name); } if (reconfigure) { @@ -286,7 +291,7 @@ gint main(gint argc, gchar **argv) /* update all existing windows for the new theme */ for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; - frame_adjust_theme(c->frame); + render_plugin->frame_adjust_theme(c->frame); } } event_startup(reconfigure); @@ -318,7 +323,7 @@ gint main(gint argc, gchar **argv) focus_nothing(); /* focus what was focused if a wm was already running */ - if (PROP_GET32(RootWindow(ob_display, ob_screen), + if (PROP_GET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_active_window, window, &xid) && (w = g_hash_table_lookup(window_map, &xid)) && WINDOW_IS_CLIENT(w)) @@ -335,7 +340,7 @@ gint main(gint argc, gchar **argv) /* the new config can change the window's decorations */ client_setup_decor_and_functions(c, FALSE); /* redraw the frames */ - frame_adjust_area(c->frame, TRUE, TRUE, FALSE); + render_plugin->frame_adjust_area(c->frame, TRUE, TRUE, FALSE); /* the decor sizes may have changed, so the windows may end up in new positions */ client_reconfigure(c, FALSE); @@ -345,7 +350,7 @@ gint main(gint argc, gchar **argv) reconfigure = FALSE; state = OB_STATE_RUNNING; - ob_main_loop_run(ob_main_loop); + ob_main_loop_run(render_plugin->ob_main_loop); state = OB_STATE_EXITING; if (!reconfigure) { @@ -376,14 +381,14 @@ gint main(gint argc, gchar **argv) } while (reconfigure); } - XSync(ob_display, FALSE); + XSync(render_plugin->ob_display, FALSE); - RrThemeFree(ob_rr_theme); - RrInstanceFree(ob_rr_inst); + RrThemeFree(render_plugin->ob_rr_theme); + RrInstanceFree(render_plugin->ob_rr_inst); session_shutdown(being_replaced); - XCloseDisplay(ob_display); + XCloseDisplay(render_plugin->ob_display); parse_paths_shutdown(); @@ -602,10 +607,10 @@ static Cursor load_cursor(const gchar *name, guint fontval) Cursor c = None; #if USE_XCURSOR - c = XcursorLibraryLoadCursor(ob_display, name); + c = XcursorLibraryLoadCursor(render_plugin->ob_display, name); #endif if (c == None) - c = XCreateFontCursor(ob_display, fontval); + c = XCreateFontCursor(render_plugin->ob_display, fontval); return c; } @@ -637,14 +642,14 @@ void ob_reconfigure() void ob_exit(gint code) { exitcode = code; - ob_main_loop_exit(ob_main_loop); + ob_main_loop_exit(render_plugin->ob_main_loop); } void ob_exit_replace() { exitcode = 0; being_replaced = TRUE; - ob_main_loop_exit(ob_main_loop); + ob_main_loop_exit(render_plugin->ob_main_loop); } Cursor ob_cursor(ObCursor cursor) @@ -663,3 +668,7 @@ ObState ob_state() { return state; } + + + + diff --git a/openbox/openbox.h b/openbox/openbox.h index b768fee..bc4395c 100644 --- a/openbox/openbox.h +++ b/openbox/openbox.h @@ -23,22 +23,23 @@ #include "render/render.h" #include "render/theme.h" +#include "plugin.h" #include #include struct _ObMainLoop; -extern RrInstance *ob_rr_inst; -extern RrTheme *ob_rr_theme; +//extern RrInstance *ob_rr_inst; +//extern RrTheme *ob_rr_theme; -extern struct _ObMainLoop *ob_main_loop; +//extern struct _ObMainLoop *ob_main_loop; /*! The X display */ -extern Display *ob_display; +//extern Display *ob_display; /*! The number of the screen on which we're running */ -extern gint ob_screen; +//extern gint ob_screen; extern gboolean ob_sm_use; extern gchar *ob_sm_id; @@ -49,6 +50,10 @@ extern gboolean ob_sm_restore; extern gboolean ob_replace_wm; extern gboolean ob_debug_xinerama; +/* render function */ + +extern ObFramePlugin *render_plugin; + /* The state of execution of the window manager */ ObState ob_state(); diff --git a/openbox/place.c b/openbox/place.c index 7c20c79..2fd59b8 100644 --- a/openbox/place.c +++ b/openbox/place.c @@ -20,12 +20,14 @@ #include "client.h" #include "group.h" #include "screen.h" -#include "frame.h" +#include "plugin.h" #include "focus.h" #include "config.h" #include "dock.h" #include "debug.h" +#include "openbox.h" + extern ObDock *dock; static void add_choice(guint *choice, guint mychoice) @@ -497,6 +499,6 @@ gboolean place_client(ObClient *client, gint *x, gint *y, g_assert(ret); /* get where the client should be */ - frame_frame_gravity(client->frame, x, y); + render_plugin->frame_frame_gravity(client->frame, x, y); return !userplaced; } diff --git a/openbox/plugin.c b/openbox/plugin.c new file mode 100644 index 0000000..09826f1 --- /dev/null +++ b/openbox/plugin.c @@ -0,0 +1,28 @@ +#include "plugin.h" +#include "debug.h" + +ObFramePlugin * init_render(const gchar * filename) { + GModule *module; + gpointer func; + + if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) { + ob_debug_type(OB_DEBUG_SM, "Failed to load plugin (%s): %s\n", + filename, g_module_error()); + return; + } + + if (g_module_symbol(module, "get_info", &func)) { + ObFramePlugin *plugin = (ObFramePlugin *) ((ObFramePluginFunc) func)(); + return plugin; + } + else + { + ob_debug_type(OB_DEBUG_SM, "Failed to get \"get_info\" function (%s): %s\n", + filename, g_module_error()); + exit(1); + } + + ob_debug_type(OB_DEBUG_SM, "Invalid plugin (%s)\n", filename); + g_module_close(module); +} + diff --git a/openbox/plugin.h b/openbox/plugin.h new file mode 100644 index 0000000..eecc1e4 --- /dev/null +++ b/openbox/plugin.h @@ -0,0 +1,96 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + plugin.h for the Openbox window manager + Copyright (c) 2003-2007 Dana Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ +#ifndef FRAME_PLUGIN_H_ +#define FRAME_PLUGIN_H_ +/* Thanks to BMP, XMMS, Audacious and glib project to enable plugin */ +#include "geom.h" +#include "render/render.h" +#include "render/theme.h" +#include "frame.h" + +#include + +struct _ObFramePlugin + { + gpointer handler; // Currently not used. + + gchar * filename; + gchar * name; + + // Function to init module + gint (*init)(Display * display, gint screen); + + gpointer (*frame_new)(struct _ObClient *c); + void (*frame_free)(gpointer self); + void (*frame_show)(gpointer self); + void (*frame_hide)(gpointer self); + void (*frame_adjust_theme)(gpointer self); + void (*frame_adjust_shape)(gpointer self); + void (*frame_adjust_area)(gpointer self, gboolean moved, gboolean resized, + gboolean fake); + void (*frame_adjust_client_area)(gpointer self); + void (*frame_adjust_state)(gpointer self); + void (*frame_adjust_focus)(gpointer self, gboolean hilite); + void (*frame_adjust_title)(gpointer self); + void (*frame_adjust_icon)(gpointer self); + void (*frame_grab_client)(gpointer self); + void (*frame_release_client)(gpointer self); + ObFrameContext (*frame_context_from_string)(const gchar *name); + ObFrameContext (*frame_context)(struct _ObClient *self, Window win, gint x, + gint y); + void (*frame_client_gravity)(gpointer self, gint *x, gint *y); + void (*frame_frame_gravity)(gpointer self, gint *x, gint *y); + void (*frame_rect_to_frame)(gpointer self, Rect *r); + void (*frame_rect_to_client)(gpointer self, Rect *r); + void (*frame_flash_start)(gpointer self); + void (*frame_flash_stop)(gpointer self); + void (*frame_begin_iconify_animation)(gpointer self, gboolean iconifying); + void (*frame_end_iconify_animation)(gpointer self); + gboolean (*frame_iconify_animating)(gpointer p); + + /* Filled by openbox-core */ + Display * ob_display; + gint ob_screen; + RrInstance *ob_rr_inst; + RrTheme *ob_rr_theme; + gboolean config_theme_keepborder; + struct _ObClient *focus_cycle_target; + gchar *config_title_layout; + gboolean moveresize_in_progress; + struct _ObMainLoop *ob_main_loop; + }; +/* Define how to draw the current windows */ +enum _ObStyle { + OBSTYLE_DECOR, + OBSTYLE_NODECOR, + OBSTYLE_SHADE, + OBSTYLE_ICON, + OBSTYLE_MAXVERT, + OBSTYLE_MAXHORIZ, + OBSTYLE_MAX, +}; + +typedef enum _ObStyle ObStyle; +typedef struct _ObFramePlugin ObFramePlugin; +typedef ObFramePlugin * (*ObFramePluginFunc)(void); + +#define OBFRAME(x) (ObFrame *) (x); + +ObFramePlugin * init_render(const gchar * filename); + +#endif /*FRAME_PLUGIN_H_*/ diff --git a/openbox/popup.c b/openbox/popup.c index d49148f..1d274e3 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -20,7 +20,7 @@ #include "popup.h" #include "openbox.h" -#include "frame.h" +#include "plugin.h" #include "client.h" #include "stacking.h" #include "event.h" @@ -37,25 +37,25 @@ ObPopup *popup_new() self->obwin.type = Window_Internal; self->gravity = NorthWestGravity; self->x = self->y = self->textw = self->h = 0; - self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg); - self->a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label); + self->a_bg = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_bg); + self->a_text = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_label); self->iconwm = self->iconhm = 1; attrib.override_redirect = True; - self->bg = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen), - 0, 0, 1, 1, 0, RrDepth(ob_rr_inst), - InputOutput, RrVisual(ob_rr_inst), + self->bg = XCreateWindow(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), + 0, 0, 1, 1, 0, RrDepth(render_plugin->ob_rr_inst), + InputOutput, RrVisual(render_plugin->ob_rr_inst), CWOverrideRedirect, &attrib); - self->text = XCreateWindow(ob_display, self->bg, - 0, 0, 1, 1, 0, RrDepth(ob_rr_inst), - InputOutput, RrVisual(ob_rr_inst), 0, NULL); + self->text = XCreateWindow(render_plugin->ob_display, self->bg, + 0, 0, 1, 1, 0, RrDepth(render_plugin->ob_rr_inst), + InputOutput, RrVisual(render_plugin->ob_rr_inst), 0, NULL); - XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->obwidth); - XSetWindowBorder(ob_display, self->bg, - RrColorPixel(ob_rr_theme->osd_border_color)); + XSetWindowBorderWidth(render_plugin->ob_display, self->bg, render_plugin->ob_rr_theme->obwidth); + XSetWindowBorder(render_plugin->ob_display, self->bg, + RrColorPixel(render_plugin->ob_rr_theme->osd_border_color)); - XMapWindow(ob_display, self->text); + XMapWindow(render_plugin->ob_display, self->text); stacking_add(INTERNAL_AS_WINDOW(self)); return self; @@ -64,8 +64,8 @@ ObPopup *popup_new() void popup_free(ObPopup *self) { if (self) { - XDestroyWindow(ob_display, self->bg); - XDestroyWindow(ob_display, self->text); + XDestroyWindow(render_plugin->ob_display, self->bg); + XDestroyWindow(render_plugin->ob_display, self->text); RrAppearanceFree(self->a_bg); RrAppearanceFree(self->a_text); stacking_remove(self); @@ -100,7 +100,7 @@ void popup_height(ObPopup *self, gint h) gint texth; /* don't let the height be smaller than the text */ - texth = RrMinHeight(self->a_text) + ob_rr_theme->paddingy * 2; + texth = RrMinHeight(self->a_text) + render_plugin->ob_rr_theme->paddingy * 2; self->h = MAX(h, texth); } @@ -115,7 +115,7 @@ void popup_text_width_to_string(ObPopup *self, gchar *text) void popup_height_to_string(ObPopup *self, gchar *text) { - self->h = RrMinHeight(self->a_text) + ob_rr_theme->paddingy * 2; + self->h = RrMinHeight(self->a_text) + render_plugin->ob_rr_theme->paddingy * 2; } void popup_text_width_to_strings(ObPopup *self, gchar **strings, gint num) @@ -139,7 +139,7 @@ static gboolean popup_show_timeout(gpointer data) { ObPopup *self = data; - XMapWindow(ob_display, self->bg); + XMapWindow(render_plugin->ob_display, self->bg); stacking_raise(INTERNAL_AS_WINDOW(self)); self->mapped = TRUE; self->delay_mapped = FALSE; @@ -179,7 +179,7 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) } /* get the height, which is also used for the icon width */ - emptyy = t + b + ob_rr_theme->paddingy * 2; + emptyy = t + b + render_plugin->ob_rr_theme->paddingy * 2; if (self->h) texth = self->h - emptyy; h = texth * self->iconhm + emptyy; @@ -187,20 +187,20 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) if (self->textw) textw = self->textw; - iconx = textx = l + ob_rr_theme->paddingx; + iconx = textx = l + render_plugin->ob_rr_theme->paddingx; - emptyx = l + r + ob_rr_theme->paddingx * 2; + emptyx = l + r + render_plugin->ob_rr_theme->paddingx * 2; if (self->hasicon) { iconw = texth * self->iconwm; iconh = texth * self->iconhm; - textx += iconw + ob_rr_theme->paddingx; + textx += iconw + render_plugin->ob_rr_theme->paddingx; if (textw) - emptyx += ob_rr_theme->paddingx; /* between the icon and text */ + emptyx += render_plugin->ob_rr_theme->paddingx; /* between the icon and text */ } else iconw = 0; - texty = (h - texth - emptyy) / 2 + t + ob_rr_theme->paddingy; - icony = (h - iconh - emptyy) / 2 + t + ob_rr_theme->paddingy; + texty = (h - texth - emptyy) / 2 + t + render_plugin->ob_rr_theme->paddingy; + icony = (h - iconh - emptyy) / 2 + t + render_plugin->ob_rr_theme->paddingy; /* when there is no icon, then fill the whole dialog with the text appearance @@ -250,7 +250,7 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) y=MAX(MIN(y, area->height-h),0); /* set the windows/appearances up */ - XMoveResizeWindow(ob_display, self->bg, x, y, w, h); + XMoveResizeWindow(render_plugin->ob_display, self->bg, x, y, w, h); /* when there is no icon and the text is not parent relative, then fill the whole dialog with the text appearance, don't use the bg at all */ @@ -261,7 +261,7 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) self->a_text->surface.parent = self->a_bg; self->a_text->surface.parentx = textx; self->a_text->surface.parenty = texty; - XMoveResizeWindow(ob_display, self->text, textx, texty, textw, texth); + XMoveResizeWindow(render_plugin->ob_display, self->text, textx, texty, textw, texth); RrPaint(self->a_text, self->text, textw, texth); } @@ -273,7 +273,7 @@ void popup_delay_show(ObPopup *self, gulong usec, gchar *text) if (usec) { /* don't kill previous show timers */ if (!self->delay_mapped) { - ob_main_loop_timeout_add(ob_main_loop, usec, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, usec, popup_show_timeout, self, g_direct_equal, NULL); self->delay_mapped = TRUE; @@ -294,12 +294,12 @@ void popup_hide(ObPopup *self) /* kill enter events cause by this unmapping */ ignore_start = event_start_ignore_all_enters(); - XUnmapWindow(ob_display, self->bg); + XUnmapWindow(render_plugin->ob_display, self->bg); self->mapped = FALSE; event_end_ignore_all_enters(ignore_start); } else if (self->delay_mapped) { - ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout); + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, popup_show_timeout); self->delay_mapped = FALSE; } } @@ -311,7 +311,7 @@ static void icon_popup_draw_icon(gint x, gint y, gint w, gint h, gpointer data) self->a_icon->surface.parent = self->popup->a_bg; self->a_icon->surface.parentx = x; self->a_icon->surface.parenty = y; - XMoveResizeWindow(ob_display, self->icon, x, y, w, h); + XMoveResizeWindow(render_plugin->ob_display, self->icon, x, y, w, h); RrPaint(self->a_icon, self->icon, w, h); } @@ -321,12 +321,12 @@ ObIconPopup *icon_popup_new() self = g_new0(ObIconPopup, 1); self->popup = popup_new(TRUE); - self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex); - self->icon = XCreateWindow(ob_display, self->popup->bg, + self->a_icon = RrAppearanceCopy(render_plugin->ob_rr_theme->a_clear_tex); + self->icon = XCreateWindow(render_plugin->ob_display, self->popup->bg, 0, 0, 1, 1, 0, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), 0, NULL); - XMapWindow(ob_display, self->icon); + RrDepth(render_plugin->ob_rr_inst), InputOutput, + RrVisual(render_plugin->ob_rr_inst), 0, NULL); + XMapWindow(render_plugin->ob_display, self->icon); self->popup->hasicon = TRUE; self->popup->draw_icon = icon_popup_draw_icon; @@ -338,7 +338,7 @@ ObIconPopup *icon_popup_new() void icon_popup_free(ObIconPopup *self) { if (self) { - XDestroyWindow(ob_display, self->icon); + XDestroyWindow(render_plugin->ob_display, self->icon); RrAppearanceFree(self->a_icon); popup_free(self->popup); g_free(self); @@ -379,7 +379,7 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, gint eachw, eachh; const guint cols = screen_desktop_layout.columns; const guint rows = screen_desktop_layout.rows; - const gint linewidth = ob_rr_theme->obwidth; + const gint linewidth = render_plugin->ob_rr_theme->obwidth; eachw = (w - ((cols + 1) * linewidth)) / cols; eachh = (h - ((rows + 1) * linewidth)) / rows; @@ -463,7 +463,7 @@ static void pager_popup_draw_icon(gint px, gint py, gint w, gint h, a->surface.parent = self->popup->a_bg; a->surface.parentx = x + px; a->surface.parenty = y + py; - XMoveResizeWindow(ob_display, self->wins[n], + XMoveResizeWindow(render_plugin->ob_display, self->wins[n], x + px, y + py, eachw, eachh); RrPaint(a, self->wins[n], eachw, eachh); } @@ -482,8 +482,8 @@ ObPagerPopup *pager_popup_new() self->desks = 0; self->wins = g_new(Window, self->desks); - self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_fg); - self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_fg); + self->hilight = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_hilite_fg); + self->unhilight = RrAppearanceCopy(render_plugin->ob_rr_theme->osd_unhilite_fg); self->popup->hasicon = TRUE; self->popup->draw_icon = pager_popup_draw_icon; @@ -498,7 +498,7 @@ void pager_popup_free(ObPagerPopup *self) guint i; for (i = 0; i < self->desks; ++i) - XDestroyWindow(ob_display, self->wins[i]); + XDestroyWindow(render_plugin->ob_display, self->wins[i]); g_free(self->wins); RrAppearanceFree(self->hilight); RrAppearanceFree(self->unhilight); @@ -514,7 +514,7 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec, if (screen_num_desktops < self->desks) for (i = screen_num_desktops; i < self->desks; ++i) - XDestroyWindow(ob_display, self->wins[i]); + XDestroyWindow(render_plugin->ob_display, self->wins[i]); if (screen_num_desktops != self->desks) self->wins = g_renew(Window, self->wins, screen_num_desktops); @@ -524,13 +524,13 @@ void pager_popup_delay_show(ObPagerPopup *self, gulong usec, XSetWindowAttributes attr; attr.border_pixel = - RrColorPixel(ob_rr_theme->osd_border_color); - self->wins[i] = XCreateWindow(ob_display, self->popup->bg, - 0, 0, 1, 1, ob_rr_theme->obwidth, - RrDepth(ob_rr_inst), InputOutput, - RrVisual(ob_rr_inst), CWBorderPixel, + RrColorPixel(render_plugin->ob_rr_theme->osd_border_color); + self->wins[i] = XCreateWindow(render_plugin->ob_display, self->popup->bg, + 0, 0, 1, 1, render_plugin->ob_rr_theme->obwidth, + RrDepth(render_plugin->ob_rr_inst), InputOutput, + RrVisual(render_plugin->ob_rr_inst), CWBorderPixel, &attr); - XMapWindow(ob_display, self->wins[i]); + XMapWindow(render_plugin->ob_display, self->wins[i]); } self->desks = screen_num_desktops; diff --git a/openbox/prop.c b/openbox/prop.c index 40ae6ef..475c86e 100644 --- a/openbox/prop.c +++ b/openbox/prop.c @@ -25,7 +25,7 @@ Atoms prop_atoms; #define CREATE(var, name) (prop_atoms.var = \ - XInternAtom(ob_display, name, FALSE)) + XInternAtom(render_plugin->ob_display, name, FALSE)) void prop_startup() { @@ -218,7 +218,7 @@ static gboolean get_prealloc(Window win, Atom prop, Atom type, gint size, gulong ret_items, bytes_left; glong num32 = 32 / size * num; /* num in 32-bit elements */ - res = XGetWindowProperty(ob_display, win, prop, 0l, num32, + res = XGetWindowProperty(render_plugin->ob_display, win, prop, 0l, num32, FALSE, type, &ret_type, &ret_size, &ret_items, &bytes_left, &xdata); if (res == Success && ret_items && xdata) { @@ -255,7 +255,7 @@ static gboolean get_all(Window win, Atom prop, Atom type, gint size, gint ret_size; gulong ret_items, bytes_left; - res = XGetWindowProperty(ob_display, win, prop, 0l, G_MAXLONG, + res = XGetWindowProperty(render_plugin->ob_display, win, prop, 0l, G_MAXLONG, FALSE, type, &ret_type, &ret_size, &ret_items, &bytes_left, &xdata); if (res == Success) { @@ -290,7 +290,7 @@ static gboolean get_stringlist(Window win, Atom prop, gchar ***list, gint *nstr) XTextProperty tprop; gboolean ret = FALSE; - if (XGetTextProperty(ob_display, win, &tprop, prop) && tprop.nitems) { + if (XGetTextProperty(render_plugin->ob_display, win, &tprop, prop) && tprop.nitems) { if (XTextPropertyToStringList(&tprop, list, nstr)) ret = TRUE; XFree(tprop.value); @@ -407,20 +407,20 @@ gboolean prop_get_strings_utf8(Window win, Atom prop, gchar ***ret) void prop_set32(Window win, Atom prop, Atom type, gulong val) { - XChangeProperty(ob_display, win, prop, type, 32, PropModeReplace, + XChangeProperty(render_plugin->ob_display, win, prop, type, 32, PropModeReplace, (guchar*)&val, 1); } void prop_set_array32(Window win, Atom prop, Atom type, gulong *val, guint num) { - XChangeProperty(ob_display, win, prop, type, 32, PropModeReplace, + XChangeProperty(render_plugin->ob_display, win, prop, type, 32, PropModeReplace, (guchar*)val, num); } void prop_set_string_utf8(Window win, Atom prop, const gchar *val) { - XChangeProperty(ob_display, win, prop, prop_atoms.utf8, 8, + XChangeProperty(render_plugin->ob_display, win, prop, prop_atoms.utf8, 8, PropModeReplace, (const guchar*)val, strlen(val)); } @@ -434,14 +434,14 @@ void prop_set_strings_utf8(Window win, Atom prop, gchar **strs) str = g_string_append(str, *s); str = g_string_append_c(str, '\0'); } - XChangeProperty(ob_display, win, prop, prop_atoms.utf8, 8, + XChangeProperty(render_plugin->ob_display, win, prop, prop_atoms.utf8, 8, PropModeReplace, (guchar*)str->str, str->len); g_string_free(str, TRUE); } void prop_erase(Window win, Atom prop) { - XDeleteProperty(ob_display, win, prop); + XDeleteProperty(render_plugin->ob_display, win, prop); } void prop_message(Window about, Atom messagetype, glong data0, glong data1, @@ -450,7 +450,7 @@ void prop_message(Window about, Atom messagetype, glong data0, glong data1, XEvent ce; ce.xclient.type = ClientMessage; ce.xclient.message_type = messagetype; - ce.xclient.display = ob_display; + ce.xclient.display = render_plugin->ob_display; ce.xclient.window = about; ce.xclient.format = 32; ce.xclient.data.l[0] = data0; @@ -458,6 +458,6 @@ void prop_message(Window about, Atom messagetype, glong data0, glong data1, ce.xclient.data.l[2] = data2; ce.xclient.data.l[3] = data3; ce.xclient.data.l[4] = 0; - XSendEvent(ob_display, RootWindow(ob_display, ob_screen), FALSE, + XSendEvent(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), FALSE, mask, &ce); } diff --git a/openbox/resist.c b/openbox/resist.c index 62c2b29..8864774 100644 --- a/openbox/resist.c +++ b/openbox/resist.c @@ -18,13 +18,15 @@ */ #include "client.h" -#include "frame.h" +#include "plugin.h" #include "stacking.h" #include "screen.h" #include "dock.h" #include "config.h" #include "parser/parse.h" +#include "openbox.h" + #include static gboolean resist_move_window(Rect window, @@ -106,7 +108,7 @@ void resist_move_windows(ObClient *c, gint resist, gint *x, gint *y) if (!resist) return; - frame_client_gravity(c->frame, x, y); + render_plugin->frame_client_gravity(c->frame, x, y); for (it = stacking_list; it; it = g_list_next(it)) { @@ -130,7 +132,7 @@ void resist_move_windows(ObClient *c, gint resist, gint *x, gint *y) dock_get_area(&dock_area); resist_move_window(c->frame->area, dock_area, resist, x, y); - frame_frame_gravity(c->frame, x, y); + render_plugin->frame_frame_gravity(c->frame, x, y); } void resist_move_monitors(ObClient *c, gint resist, gint *x, gint *y) @@ -146,7 +148,7 @@ void resist_move_monitors(ObClient *c, gint resist, gint *x, gint *y) if (!resist) return; - frame_client_gravity(c->frame, x, y); + render_plugin->frame_client_gravity(c->frame, x, y); w = c->frame->area.width; h = c->frame->area.height; @@ -205,7 +207,7 @@ void resist_move_monitors(ObClient *c, gint resist, gint *x, gint *y) g_free(parea); } - frame_frame_gravity(c->frame, x, y); + render_plugin->frame_frame_gravity(c->frame, x, y); } static gboolean resist_size_window(Rect window, Rect target, gint resist, diff --git a/openbox/screen.c b/openbox/screen.c index 93ec57f..248fb57 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -30,7 +30,7 @@ #include "screen.h" #include "client.h" #include "session.h" -#include "frame.h" +#include "plugin.h" #include "event.h" #include "focus.h" #include "popup.h" @@ -84,25 +84,25 @@ static gboolean replace_wm() Window current_wm_sn_owner; Time timestamp; - wm_sn = g_strdup_printf("WM_S%d", ob_screen); - wm_sn_atom = XInternAtom(ob_display, wm_sn, FALSE); + wm_sn = g_strdup_printf("WM_S%d", render_plugin->ob_screen); + wm_sn_atom = XInternAtom(render_plugin->ob_display, wm_sn, FALSE); g_free(wm_sn); - current_wm_sn_owner = XGetSelectionOwner(ob_display, wm_sn_atom); + current_wm_sn_owner = XGetSelectionOwner(render_plugin->ob_display, wm_sn_atom); if (current_wm_sn_owner == screen_support_win) current_wm_sn_owner = None; if (current_wm_sn_owner) { if (!ob_replace_wm) { g_message(_("A window manager is already running on screen %d"), - ob_screen); + render_plugin->ob_screen); return FALSE; } xerror_set_ignore(TRUE); xerror_occured = FALSE; /* We want to find out when the current selection owner dies */ - XSelectInput(ob_display, current_wm_sn_owner, StructureNotifyMask); - XSync(ob_display, FALSE); + XSelectInput(render_plugin->ob_display, current_wm_sn_owner, StructureNotifyMask); + XSync(render_plugin->ob_display, FALSE); xerror_set_ignore(FALSE); if (xerror_occured) @@ -111,12 +111,12 @@ static gboolean replace_wm() timestamp = event_get_server_time(); - XSetSelectionOwner(ob_display, wm_sn_atom, screen_support_win, + XSetSelectionOwner(render_plugin->ob_display, wm_sn_atom, screen_support_win, timestamp); - if (XGetSelectionOwner(ob_display, wm_sn_atom) != screen_support_win) { + if (XGetSelectionOwner(render_plugin->ob_display, wm_sn_atom) != screen_support_win) { g_message(_("Could not acquire window manager selection on screen %d"), - ob_screen); + render_plugin->ob_screen); return FALSE; } @@ -127,7 +127,7 @@ static gboolean replace_wm() const gulong timeout = G_USEC_PER_SEC * 15; /* wait for 15s max */ while (wait < timeout) { - if (XCheckWindowEvent(ob_display, current_wm_sn_owner, + if (XCheckWindowEvent(render_plugin->ob_display, current_wm_sn_owner, StructureNotifyMask, &event) && event.type == DestroyNotify) break; @@ -136,13 +136,13 @@ static gboolean replace_wm() } if (wait >= timeout) { - g_message(_("The WM on screen %d is not exiting"), ob_screen); + g_message(_("The WM on screen %d is not exiting"), render_plugin->ob_screen); return FALSE; } } /* Send client message indicating that we are now the WM */ - prop_message(RootWindow(ob_display, ob_screen), prop_atoms.manager, + prop_message(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), prop_atoms.manager, timestamp, wm_sn_atom, screen_support_win, 0, SubstructureNotifyMask); @@ -160,31 +160,31 @@ gboolean screen_annex() /* create the netwm support window */ attrib.override_redirect = TRUE; attrib.event_mask = PropertyChangeMask; - screen_support_win = XCreateWindow(ob_display, - RootWindow(ob_display, ob_screen), + screen_support_win = XCreateWindow(render_plugin->ob_display, + RootWindow(render_plugin->ob_display, render_plugin->ob_screen), -100, -100, 1, 1, 0, CopyFromParent, InputOutput, CopyFromParent, CWEventMask | CWOverrideRedirect, &attrib); - XMapWindow(ob_display, screen_support_win); - XLowerWindow(ob_display, screen_support_win); + XMapWindow(render_plugin->ob_display, screen_support_win); + XLowerWindow(render_plugin->ob_display, screen_support_win); if (!replace_wm()) { - XDestroyWindow(ob_display, screen_support_win); + XDestroyWindow(render_plugin->ob_display, screen_support_win); return FALSE; } xerror_set_ignore(TRUE); xerror_occured = FALSE; - XSelectInput(ob_display, RootWindow(ob_display, ob_screen), + XSelectInput(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), ROOT_EVENTMASK); xerror_set_ignore(FALSE); if (xerror_occured) { g_message(_("A window manager is already running on screen %d"), - ob_screen); + render_plugin->ob_screen); - XDestroyWindow(ob_display, screen_support_win); + XDestroyWindow(render_plugin->ob_display, screen_support_win); return FALSE; } @@ -192,11 +192,11 @@ gboolean screen_annex() /* set the OPENBOX_PID hint */ pid = getpid(); - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), openbox_pid, cardinal, pid); /* set supporting window */ - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_supporting_wm_check, window, screen_support_win); /* set properties on the supporting window */ @@ -295,7 +295,7 @@ gboolean screen_annex() supported[i++] = prop_atoms.ob_control; g_assert(i == num_support); - PROP_SETA32(RootWindow(ob_display, ob_screen), + PROP_SETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_supported, atom, supported, num_support); g_free(supported); @@ -328,13 +328,13 @@ static void screen_tell_ksplash() hear it anyways. perhaps it is for old ksplash. or new ksplash. or something. oh well. */ e.xclient.type = ClientMessage; - e.xclient.display = ob_display; - e.xclient.window = RootWindow(ob_display, ob_screen); + e.xclient.display = render_plugin->ob_display; + e.xclient.window = RootWindow(render_plugin->ob_display, render_plugin->ob_screen); e.xclient.message_type = - XInternAtom(ob_display, "_KDE_SPLASH_PROGRESS", False ); + XInternAtom(render_plugin->ob_display, "_KDE_SPLASH_PROGRESS", False ); e.xclient.format = 8; strcpy(e.xclient.data.b, "wm started"); - XSendEvent(ob_display, RootWindow(ob_display, ob_screen), + XSendEvent(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), False, SubstructureNotifyMask, &e ); } @@ -359,7 +359,7 @@ void screen_startup(gboolean reconfig) screen_resize(); /* have names already been set for the desktops? */ - if (PROP_GETSS(RootWindow(ob_display, ob_screen), + if (PROP_GETSS(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_names, utf8, &names)) { g_strfreev(names); @@ -382,7 +382,7 @@ void screen_startup(gboolean reconfig) names[i] = g_strdup(it->data); /* set the root window property */ - PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names,names); + PROP_SETSS(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_names,names); g_strfreev(names); } @@ -392,7 +392,7 @@ void screen_startup(gboolean reconfig) this will also set the default names from the config file up for desktops that don't have names yet */ screen_num_desktops = 0; - if (PROP_GET32(RootWindow(ob_display, ob_screen), + if (PROP_GET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_number_of_desktops, cardinal, &d)) screen_set_num_desktops(d); /* restore from session if possible */ @@ -403,7 +403,7 @@ void screen_startup(gboolean reconfig) screen_desktop = screen_num_desktops; /* something invalid */ /* start on the current desktop when a wm was already running */ - if (PROP_GET32(RootWindow(ob_display, ob_screen), + if (PROP_GET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_current_desktop, cardinal, &d) && d < screen_num_desktops) { @@ -418,7 +418,7 @@ void screen_startup(gboolean reconfig) /* don't start in showing-desktop mode */ screen_showing_desktop = FALSE; - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_showing_desktop, cardinal, screen_showing_desktop); if (session_desktop_layout_present && @@ -437,17 +437,17 @@ void screen_shutdown(gboolean reconfig) if (reconfig) return; - XSelectInput(ob_display, RootWindow(ob_display, ob_screen), + XSelectInput(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), NoEventMask); /* we're not running here no more! */ - PROP_ERASE(RootWindow(ob_display, ob_screen), openbox_pid); + PROP_ERASE(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), openbox_pid); /* not without us */ - PROP_ERASE(RootWindow(ob_display, ob_screen), net_supported); + PROP_ERASE(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_supported); /* don't keep this mode */ - PROP_ERASE(RootWindow(ob_display, ob_screen), net_showing_desktop); + PROP_ERASE(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_showing_desktop); - XDestroyWindow(ob_display, screen_support_win); + XDestroyWindow(render_plugin->ob_display, screen_support_win); g_strfreev(screen_desktop_names); screen_desktop_names = NULL; @@ -460,8 +460,8 @@ void screen_resize() GList *it; gulong geometry[2]; - w = WidthOfScreen(ScreenOfDisplay(ob_display, ob_screen)); - h = HeightOfScreen(ScreenOfDisplay(ob_display, ob_screen)); + w = WidthOfScreen(ScreenOfDisplay(render_plugin->ob_display, render_plugin->ob_screen)); + h = HeightOfScreen(ScreenOfDisplay(render_plugin->ob_display, render_plugin->ob_screen)); if (w == oldw && h == oldh) return; @@ -470,7 +470,7 @@ void screen_resize() /* Set the _NET_DESKTOP_GEOMETRY hint */ screen_physical_size.width = geometry[0] = w; screen_physical_size.height = geometry[1] = h; - PROP_SETA32(RootWindow(ob_display, ob_screen), + PROP_SETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_geometry, cardinal, geometry, 2); if (ob_state() == OB_STATE_STARTING) @@ -495,12 +495,12 @@ void screen_set_num_desktops(guint num) old = screen_num_desktops; screen_num_desktops = num; - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_number_of_desktops, cardinal, num); /* set the viewport hint */ viewport = g_new0(gulong, num * 2); - PROP_SETA32(RootWindow(ob_display, ob_screen), + PROP_SETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_viewport, cardinal, viewport, num * 2); g_free(viewport); @@ -569,7 +569,7 @@ static void screen_fallback_focus() if (c->can_focus) { /* reduce flicker by hiliting now rather than waiting for the server FocusIn event */ - frame_adjust_focus(c->frame, TRUE); + render_plugin->frame_adjust_focus(c->frame, TRUE); /* do this here so that if you switch desktops to a window with helper windows then the helper windows won't flash */ client_bring_helper_windows(c); @@ -590,7 +590,7 @@ void screen_set_desktop(guint num, gboolean dofocus) if (old == num) return; - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_current_desktop, cardinal, num); screen_last_desktop = old; @@ -852,8 +852,8 @@ void screen_show_desktop_popup(guint d) MAX(a->width/3, POPUP_WIDTH)); pager_popup_show(desktop_popup, screen_desktop_names[d], d); - ob_main_loop_timeout_remove(ob_main_loop, hide_desktop_popup_func); - ob_main_loop_timeout_add(ob_main_loop, config_desktop_popup_time * 1000, + ob_main_loop_timeout_remove(render_plugin->ob_main_loop, hide_desktop_popup_func); + ob_main_loop_timeout_add(render_plugin->ob_main_loop, config_desktop_popup_time * 1000, hide_desktop_popup_func, NULL, NULL, NULL); } @@ -1012,7 +1012,7 @@ void screen_update_layout() screen_desktop_layout.rows = 1; screen_desktop_layout.columns = screen_num_desktops; - if (PROP_GETA32(RootWindow(ob_display, ob_screen), + if (PROP_GETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_layout, cardinal, &data, &num)) { if (num == 3 || num == 4) { @@ -1057,7 +1057,7 @@ void screen_update_desktop_names() g_strfreev(screen_desktop_names); screen_desktop_names = NULL; - if (PROP_GETSS(RootWindow(ob_display, ob_screen), + if (PROP_GETSS(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_names, utf8, &screen_desktop_names)) for (i = 0; screen_desktop_names[i] && i < screen_num_desktops; ++i); else @@ -1084,7 +1084,7 @@ void screen_update_desktop_names() /* if we changed any names, then set the root property so we can all agree on the names */ - PROP_SETSS(RootWindow(ob_display, ob_screen), net_desktop_names, + PROP_SETSS(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_desktop_names, screen_desktop_names); } @@ -1146,13 +1146,13 @@ void screen_show_desktop(gboolean show, ObClient *show_only) if (c->can_focus) { /* reduce flicker by hiliting now rather than waiting for the server FocusIn event */ - frame_adjust_focus(c->frame, TRUE); + render_plugin->frame_adjust_focus(c->frame, TRUE); } } } show = !!show; /* make it boolean */ - PROP_SET32(RootWindow(ob_display, ob_screen), + PROP_SET32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_showing_desktop, cardinal, show); } @@ -1160,15 +1160,15 @@ void screen_install_colormap(ObClient *client, gboolean install) { if (client == NULL || client->colormap == None) { if (install) - XInstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst)); + XInstallColormap(RrDisplay(render_plugin->ob_rr_inst), RrColormap(render_plugin->ob_rr_inst)); else - XUninstallColormap(RrDisplay(ob_rr_inst), RrColormap(ob_rr_inst)); + XUninstallColormap(RrDisplay(render_plugin->ob_rr_inst), RrColormap(render_plugin->ob_rr_inst)); } else { xerror_set_ignore(TRUE); if (install) - XInstallColormap(RrDisplay(ob_rr_inst), client->colormap); + XInstallColormap(RrDisplay(render_plugin->ob_rr_inst), client->colormap); else - XUninstallColormap(RrDisplay(ob_rr_inst), client->colormap); + XUninstallColormap(RrDisplay(render_plugin->ob_rr_inst), client->colormap); xerror_set_ignore(FALSE); } } @@ -1328,7 +1328,7 @@ void screen_update_areas() /* all the work areas are not used here, only the ones for the first monitor are */ - PROP_SETA32(RootWindow(ob_display, ob_screen), net_workarea, cardinal, + PROP_SETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_workarea, cardinal, dims, 4 * screen_num_desktops); /* the area has changed, adjust all the windows if they need it */ @@ -1570,10 +1570,10 @@ Rect* screen_physical_area_active() void screen_set_root_cursor() { if (sn_app_starting()) - XDefineCursor(ob_display, RootWindow(ob_display, ob_screen), + XDefineCursor(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), ob_cursor(OB_CURSOR_BUSYPOINTER)); else - XDefineCursor(ob_display, RootWindow(ob_display, ob_screen), + XDefineCursor(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), ob_cursor(OB_CURSOR_POINTER)); } @@ -1584,12 +1584,12 @@ gboolean screen_pointer_pos(gint *x, gint *y) guint u; gboolean ret; - ret = !!XQueryPointer(ob_display, RootWindow(ob_display, ob_screen), + ret = !!XQueryPointer(render_plugin->ob_display, RootWindow(render_plugin->ob_display, render_plugin->ob_screen), &w, &w, x, y, &i, &i, &u); if (!ret) { - for (i = 0; i < ScreenCount(ob_display); ++i) - if (i != ob_screen) - if (XQueryPointer(ob_display, RootWindow(ob_display, i), + for (i = 0; i < ScreenCount(render_plugin->ob_display); ++i) + if (i != render_plugin->ob_screen) + if (XQueryPointer(render_plugin->ob_display, RootWindow(render_plugin->ob_display, i), &w, &w, x, y, &i, &i, &u)) break; } diff --git a/openbox/stacking.c b/openbox/stacking.c index 2280b87..a591c0a 100644 --- a/openbox/stacking.c +++ b/openbox/stacking.c @@ -23,7 +23,7 @@ #include "focus.h" #include "client.h" #include "group.h" -#include "frame.h" +#include "plugin.h" #include "window.h" #include "debug.h" @@ -50,7 +50,7 @@ void stacking_set_list() } } - PROP_SETA32(RootWindow(ob_display, ob_screen), + PROP_SETA32(RootWindow(render_plugin->ob_display, render_plugin->ob_screen), net_client_list_stacking, window, (gulong*)windows, i); g_free(windows); @@ -99,7 +99,7 @@ static void do_restack(GList *wins, GList *before) } #endif - XRestackWindows(ob_display, win, i); + XRestackWindows(render_plugin->ob_display, win, i); g_free(win); stacking_set_list(); diff --git a/openbox/startupnotify.c b/openbox/startupnotify.c index 1cf8da6..d8ac20e 100644 --- a/openbox/startupnotify.c +++ b/openbox/startupnotify.c @@ -63,12 +63,12 @@ void sn_startup(gboolean reconfig) /* unset this so we don't pass it on unknowingly */ unsetenv("DESKTOP_STARTUP_ID"); - sn_display = sn_display_new(ob_display, NULL, NULL); - sn_context = sn_monitor_context_new(sn_display, ob_screen, + sn_display = sn_display_new(render_plugin->ob_display, NULL, NULL); + sn_context = sn_monitor_context_new(sn_display, render_plugin->ob_screen, sn_event_func, NULL, NULL); - sn_launcher = sn_launcher_context_new(sn_display, ob_screen); + sn_launcher = sn_launcher_context_new(sn_display, render_plugin->ob_screen); - ob_main_loop_x_add(ob_main_loop, sn_handler, NULL, NULL); + ob_main_loop_x_add(render_plugin->ob_main_loop, sn_handler, NULL, NULL); } void sn_shutdown(gboolean reconfig) @@ -77,7 +77,7 @@ void sn_shutdown(gboolean reconfig) if (reconfig) return; - ob_main_loop_x_remove(ob_main_loop, sn_handler); + ob_main_loop_x_remove(render_plugin->ob_main_loop, sn_handler); for (it = sn_waits; it; it = g_slist_next(it)) sn_startup_sequence_unref((SnStartupSequence*)it->data); @@ -140,7 +140,7 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data) sn_waits = g_slist_prepend(sn_waits, seq); /* 20 second timeout for apps to start if the launcher doesn't have a timeout */ - ob_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, 20 * G_USEC_PER_SEC, sn_wait_timeout, seq, g_direct_equal, (GDestroyNotify)sn_startup_sequence_unref); @@ -154,7 +154,7 @@ static void sn_event_func(SnMonitorEvent *ev, gpointer data) case SN_MONITOR_EVENT_CANCELED: if ((seq = sequence_find(sn_startup_sequence_get_id(seq)))) { sn_waits = g_slist_remove(sn_waits, seq); - ob_main_loop_timeout_remove_data(ob_main_loop, sn_wait_timeout, + ob_main_loop_timeout_remove_data(render_plugin->ob_main_loop, sn_wait_timeout, seq, FALSE); change = TRUE; } @@ -238,7 +238,7 @@ void sn_setup_spawn_environment(gchar *program, gchar *name, if (sn_launcher_context_get_initiated(sn_launcher)) { sn_launcher_context_unref(sn_launcher); - sn_launcher = sn_launcher_context_new(sn_display, ob_screen); + sn_launcher = sn_launcher_context_new(sn_display, render_plugin->ob_screen); } sn_launcher_context_set_name(sn_launcher, name ? name : program); @@ -254,7 +254,7 @@ void sn_setup_spawn_environment(gchar *program, gchar *name, /* 20 second timeout for apps to start */ sn_launcher_context_ref(sn_launcher); - ob_main_loop_timeout_add(ob_main_loop, 20 * G_USEC_PER_SEC, + ob_main_loop_timeout_add(render_plugin->ob_main_loop, 20 * G_USEC_PER_SEC, sn_launch_wait_timeout, sn_launcher, g_direct_equal, (GDestroyNotify)sn_launcher_context_unref); diff --git a/openbox/translate.c b/openbox/translate.c index 5b2b4eb..8052eb6 100644 --- a/openbox/translate.c +++ b/openbox/translate.c @@ -142,7 +142,7 @@ gboolean translate_key(const gchar *str, guint *state, guint *keycode) g_message(_("Invalid key name '%s' in key binding"), l); goto translation_fail; } - *keycode = XKeysymToKeycode(ob_display, sym); + *keycode = XKeysymToKeycode(render_plugin->ob_display, sym); } if (!*keycode) { g_message(_("Requested key '%s' does not exist on the display"), l); @@ -161,7 +161,7 @@ const gchar *translate_keycode(guint keycode) KeySym sym; const gchar *ret = NULL; - if ((sym = XKeycodeToKeysym(ob_display, keycode, 0)) != NoSymbol) + if ((sym = XKeycodeToKeysym(render_plugin->ob_display, keycode, 0)) != NoSymbol) ret = XKeysymToString(sym); return g_locale_to_utf8(ret, -1, NULL, NULL, NULL); } diff --git a/openbox/window.c b/openbox/window.c index 19b39c0..9b687ec 100644 --- a/openbox/window.c +++ b/openbox/window.c @@ -21,7 +21,7 @@ #include "config.h" #include "dock.h" #include "client.h" -#include "frame.h" +#include "plugin.h" GHashTable *window_map; diff --git a/openbox/xerror.c b/openbox/xerror.c index 6e88460..7918231 100644 --- a/openbox/xerror.c +++ b/openbox/xerror.c @@ -49,6 +49,6 @@ gint xerror_handler(Display *d, XErrorEvent *e) void xerror_set_ignore(gboolean ignore) { - XSync(ob_display, FALSE); + XSync(render_plugin->ob_display, FALSE); xerror_ignore = ignore; }