Files
wmaker/src/framewin.c
T

1516 lines
43 KiB
C
Raw Normal View History

2004-10-12 21:28:27 +00:00
/*
1998-10-21 14:43:47 +00:00
* Window Maker window manager
2004-10-12 21:28:27 +00:00
*
2003-01-16 23:30:45 +00:00
* Copyright (c) 1997-2003 Alfredo K. Kojima
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* 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.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1998-09-29 22:36:29 +00:00
*/
#include "wconfig.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
2004-10-12 21:28:27 +00:00
#ifdef KEEP_XKB_LOCK_STATUS
#include <X11/XKBlib.h>
2009-08-20 00:59:40 +02:00
#endif /* KEEP_XKB_LOCK_STATUS */
1998-09-29 22:36:29 +00:00
#include <stdlib.h>
#include <string.h>
#include <wraster.h>
#include "WindowMaker.h"
#include "GNUstep.h"
#include "texture.h"
#include "resources.h"
1998-09-29 22:36:29 +00:00
#include "screen.h"
#include "wcore.h"
2013-05-15 13:07:57 +02:00
#include "window.h"
1998-09-29 22:36:29 +00:00
#include "framewin.h"
#include "stacking.h"
2013-04-14 23:13:26 +02:00
#include "misc.h"
2013-05-15 13:07:52 +02:00
#include "event.h"
1998-09-29 22:36:29 +00:00
#define DBLCLICK_TIME wPreferences.dblclick_time
2009-08-20 00:59:40 +02:00
static void handleExpose(WObjDescriptor * desc, XEvent * event);
static void handleButtonExpose(WObjDescriptor * desc, XEvent * event);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
static void buttonMouseDown(WObjDescriptor * desc, XEvent * event);
static void titlebarMouseDown(WObjDescriptor * desc, XEvent * event);
static void resizebarMouseDown(WObjDescriptor * desc, XEvent * event);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
static void checkTitleSize(WFrameWindow * fwin);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
static void paintButton(WCoreWindow * button, WTexture * texture,
unsigned long color, WPixmap * image, int pushed);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
static void updateTitlebar(WFrameWindow * fwin);
1998-09-29 22:36:29 +00:00
static void allocFrameBorderPixel(Colormap colormap, const char *color_name, unsigned long **pixel);
2012-08-25 09:59:03 +01:00
static void allocFrameBorderPixel(Colormap colormap, const char *color_name, unsigned long **pixel) {
2012-08-25 09:59:03 +01:00
XColor xcol;
*pixel = NULL;
if (! wGetColorForColormap(colormap, color_name, &xcol))
2012-08-25 09:59:03 +01:00
return;
*pixel = wmalloc(sizeof(unsigned long));
if (*pixel)
**pixel = xcol.pixel;
}
2009-08-20 00:59:40 +02:00
WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
int width, int height, int *clearance,
int *title_min, int *title_max, int flags,
2009-08-20 00:59:40 +02:00
WTexture ** title_texture, WTexture ** resize_texture,
2012-08-20 15:18:21 +01:00
WMColor ** color, WMFont ** font,
int depth, Visual *visual, Colormap colormap)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WFrameWindow *fwin;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
fwin = wmalloc(sizeof(WFrameWindow));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
fwin->screen_ptr = scr;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
fwin->flags.single_texture = (flags & WFF_SINGLE_STATE) ? 1 : 0;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
fwin->title_texture = title_texture;
fwin->resizebar_texture = resize_texture;
fwin->title_color = color;
fwin->title_clearance = clearance;
fwin->title_min_height = title_min;
fwin->title_max_height = title_max;
2009-08-20 00:59:40 +02:00
fwin->font = font;
1999-05-30 05:10:54 +00:00
#ifdef KEEP_XKB_LOCK_STATUS
2009-08-20 00:59:40 +02:00
fwin->languagemode = XkbGroup1Index;
fwin->last_languagemode = XkbGroup2Index;
1999-05-30 05:10:54 +00:00
#endif
2000-01-14 16:30:56 +00:00
2012-08-20 15:18:21 +01:00
fwin->depth = depth;
fwin->visual = visual;
fwin->colormap = colormap;
2009-08-20 00:59:40 +02:00
fwin->core = wCoreCreateTopLevel(scr, x, y, width, height, (flags & WFF_BORDER)
2013-03-26 07:01:08 +00:00
? scr->frame_border_width : 0, fwin->depth, fwin->visual, fwin->colormap, scr->frame_border_pixel);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
/* setup stacking information */
fwin->core->stacking = wmalloc(sizeof(WStacking));
fwin->core->stacking->above = NULL;
fwin->core->stacking->under = NULL;
fwin->core->stacking->child_of = NULL;
fwin->core->stacking->window_level = wlevel;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
AddToStackList(fwin->core);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
wFrameWindowUpdateBorders(fwin, flags);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
return fwin;
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowUpdateBorders(WFrameWindow * fwin, int flags)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
int theight;
int bsize;
int width, height;
int i;
WScreen *scr = fwin->screen_ptr;
width = fwin->core->width;
if (flags & WFF_IS_SHADED)
height = -1;
else
height = fwin->core->height - fwin->top_width - fwin->bottom_width;
if (flags & WFF_TITLEBAR) {
2009-08-20 00:59:40 +02:00
theight = WMFontHeight(*fwin->font) + (*fwin->title_clearance + TITLEBAR_EXTEND_SPACE) * 2;
if (theight > *fwin->title_max_height)
theight = *fwin->title_max_height;
if (theight < *fwin->title_min_height)
theight = *fwin->title_min_height;
2012-10-02 22:16:18 +02:00
} else {
2009-08-20 00:59:40 +02:00
theight = 0;
2012-10-02 22:16:18 +02:00
}
2009-08-20 00:59:40 +02:00
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
bsize = theight;
2010-09-10 20:51:08 +04:00
} else if (wPreferences.new_style == TS_OLD) {
2009-08-20 00:59:40 +02:00
bsize = theight - 7;
2010-09-10 20:51:08 +04:00
} else {
bsize = theight - 8;
2009-08-20 00:59:40 +02:00
}
if (fwin->titlebar) {
/* if we had a titlebar and is requesting for one,
* check if the size has changed and resize it */
if (flags & WFF_TITLEBAR) {
fwin->top_width = theight;
fwin->flags.need_texture_remake = 1;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2012-10-02 22:16:18 +02:00
if (fwin->left_button)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->left_button, 0, 0, bsize, bsize);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2010-04-08 17:01:24 -04:00
if (fwin->language_button) {
2009-08-20 00:59:40 +02:00
if (fwin->flags.hide_left_button || !fwin->left_button
2012-10-02 22:16:18 +02:00
|| fwin->flags.lbutton_dont_fit)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->language_button, 0, 0, bsize, bsize);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->language_button, bsize, 0, bsize, bsize);
2010-04-08 17:01:24 -04:00
}
1999-05-30 05:10:54 +00:00
#endif
2012-10-02 22:16:18 +02:00
if (fwin->right_button)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->right_button, width - bsize + 1, 0, bsize, bsize);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
} else { /* !new_style */
2012-10-02 22:16:18 +02:00
if (fwin->left_button)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->left_button, 3, (theight - bsize) / 2, bsize, bsize);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2012-10-02 22:16:18 +02:00
if (fwin->language_button)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->language_button, 6 + bsize, (theight - bsize) / 2,
bsize, bsize);
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2012-10-02 22:16:18 +02:00
if (fwin->right_button)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->right_button, width - bsize - 3,
(theight - bsize) / 2, bsize, bsize);
}
updateTitlebar(fwin);
} else {
/* we had a titlebar, but now we don't need it anymore */
for (i = 0; i < (fwin->flags.single_texture ? 1 : 3); i++) {
FREE_PIXMAP(fwin->title_back[i]);
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->lbutton_back[i]);
FREE_PIXMAP(fwin->rbutton_back[i]);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->languagebutton_back[i]);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
}
if (fwin->left_button)
wCoreDestroy(fwin->left_button);
fwin->left_button = NULL;
2004-10-12 21:28:27 +00:00
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button)
wCoreDestroy(fwin->language_button);
fwin->language_button = NULL;
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
if (fwin->right_button)
wCoreDestroy(fwin->right_button);
fwin->right_button = NULL;
wCoreDestroy(fwin->titlebar);
fwin->titlebar = NULL;
fwin->top_width = 0;
}
} else {
/* if we didn't have a titlebar and are being requested for
* one, create it */
if (flags & WFF_TITLEBAR) {
fwin->top_width = theight;
fwin->flags.titlebar = 1;
fwin->titlebar = wCoreCreate(fwin->core, 0, 0, width + 1, theight);
if (flags & WFF_LEFT_BUTTON) {
fwin->flags.left_button = 1;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
fwin->left_button = wCoreCreate(fwin->core, 0, 0, bsize, bsize);
2012-10-02 22:16:18 +02:00
if (width < theight * 4)
2009-08-20 00:59:40 +02:00
fwin->flags.lbutton_dont_fit = 1;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XMapRaised(dpy, fwin->left_button->window);
2012-10-02 22:16:18 +02:00
2010-09-10 20:51:08 +04:00
} else if (wPreferences.new_style == TS_OLD) {
2009-08-20 00:59:40 +02:00
fwin->left_button =
wCoreCreate(fwin->titlebar, 3, (theight - bsize) / 2, bsize, bsize);
XSetWindowBackground(dpy, fwin->left_button->window,
scr->widget_texture->normal.pixel);
2012-10-02 22:16:18 +02:00
if (width < theight * 3)
2009-08-20 00:59:40 +02:00
fwin->flags.lbutton_dont_fit = 1;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XMapRaised(dpy, fwin->left_button->window);
2012-10-02 22:16:18 +02:00
2010-09-10 20:51:08 +04:00
} else {
fwin->left_button =
wCoreCreate(fwin->titlebar, 3, (theight-bsize)/2,
bsize, bsize);
XSetWindowBackground(dpy, fwin->left_button->window,
scr->widget_texture->dark.pixel);
2012-10-02 22:16:18 +02:00
if (width < theight * 3)
2010-09-10 20:51:08 +04:00
fwin->flags.lbutton_dont_fit = 1;
2012-10-02 22:16:18 +02:00
else
2010-09-10 20:51:08 +04:00
XMapRaised(dpy, fwin->left_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
}
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (flags & WFF_LANGUAGE_BUTTON) {
fwin->flags.language_button = 1;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
fwin->language_button = wCoreCreate(fwin->core, bsize, 0, bsize, bsize);
2012-10-02 22:16:18 +02:00
if (width < theight * 4)
2009-08-20 00:59:40 +02:00
fwin->flags.languagebutton_dont_fit = 1;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XMapRaised(dpy, fwin->language_button->window);
} else {
fwin->language_button =
wCoreCreate(fwin->titlebar, bsize + 6, (theight - bsize) / 2,
bsize, bsize);
XSetWindowBackground(dpy, fwin->language_button->window,
scr->widget_texture->normal.pixel);
2012-10-02 22:16:18 +02:00
if (width < theight * 3)
2009-08-20 00:59:40 +02:00
fwin->flags.languagebutton_dont_fit = 1;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XMapRaised(dpy, fwin->language_button->window);
}
}
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (flags & WFF_RIGHT_BUTTON) {
fwin->flags.right_button = 1;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
fwin->right_button =
wCoreCreate(fwin->core, width - bsize + 1, 0, bsize, bsize);
2010-09-10 20:51:08 +04:00
} else if (wPreferences.new_style == TS_OLD) {
2009-08-20 00:59:40 +02:00
fwin->right_button =
wCoreCreate(fwin->titlebar, width - bsize - 3,
(theight - bsize) / 2, bsize, bsize);
XSetWindowBackground(dpy, fwin->right_button->window,
scr->widget_texture->normal.pixel);
2010-09-10 20:51:08 +04:00
} else {
fwin->right_button =
wCoreCreate(fwin->titlebar, width-bsize-3,
(theight-bsize)/2, bsize, bsize);
XSetWindowBackground(dpy, fwin->right_button->window,
scr->widget_texture->dark.pixel);
2009-08-20 00:59:40 +02:00
}
2012-10-02 22:16:18 +02:00
if (width < theight * 2)
2009-08-20 00:59:40 +02:00
fwin->flags.rbutton_dont_fit = 1;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XMapRaised(dpy, fwin->right_button->window);
}
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW)
2009-08-20 00:59:40 +02:00
updateTitlebar(fwin);
XMapRaised(dpy, fwin->titlebar->window);
fwin->flags.need_texture_remake = 1;
}
}
checkTitleSize(fwin);
if (flags & WFF_RESIZEBAR) {
fwin->bottom_width = RESIZEBAR_HEIGHT;
if (!fwin->resizebar) {
fwin->flags.resizebar = 1;
fwin->resizebar = wCoreCreate(fwin->core, 0,
height + fwin->top_width, width, RESIZEBAR_HEIGHT);
fwin->resizebar_corner_width = RESIZEBAR_CORNER_WIDTH;
if (width < RESIZEBAR_CORNER_WIDTH * 2 + RESIZEBAR_MIN_WIDTH) {
fwin->resizebar_corner_width = (width - RESIZEBAR_MIN_WIDTH) / 2;
if (fwin->resizebar_corner_width < 0)
fwin->resizebar_corner_width = 0;
}
XMapWindow(dpy, fwin->resizebar->window);
XLowerWindow(dpy, fwin->resizebar->window);
fwin->flags.need_texture_remake = 1;
} else {
2012-10-02 22:16:18 +02:00
if (height + fwin->top_width + fwin->bottom_width != fwin->core->height)
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->resizebar, 0, height + fwin->top_width,
width, RESIZEBAR_HEIGHT);
}
} else {
fwin->bottom_width = 0;
if (fwin->resizebar) {
fwin->bottom_width = 0;
wCoreDestroy(fwin->resizebar);
fwin->resizebar = NULL;
}
}
2012-10-02 22:16:18 +02:00
if (height + fwin->top_width + fwin->bottom_width != fwin->core->height && !(flags & WFF_IS_SHADED))
2009-08-20 00:59:40 +02:00
wFrameWindowResize(fwin, width, height + fwin->top_width + fwin->bottom_width);
2012-10-02 22:16:18 +02:00
if (flags & WFF_BORDER)
2013-03-26 07:01:08 +00:00
XSetWindowBorderWidth(dpy, fwin->core->window, scr->frame_border_width);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XSetWindowBorderWidth(dpy, fwin->core->window, 0);
/* setup object descriptors */
if (fwin->titlebar) {
fwin->titlebar->descriptor.handle_expose = handleExpose;
fwin->titlebar->descriptor.parent = fwin;
fwin->titlebar->descriptor.parent_type = WCLASS_FRAME;
fwin->titlebar->descriptor.handle_mousedown = titlebarMouseDown;
}
if (fwin->resizebar) {
fwin->resizebar->descriptor.handle_expose = handleExpose;
fwin->resizebar->descriptor.parent = fwin;
fwin->resizebar->descriptor.parent_type = WCLASS_FRAME;
fwin->resizebar->descriptor.handle_mousedown = resizebarMouseDown;
}
if (fwin->left_button) {
fwin->left_button->descriptor.handle_expose = handleButtonExpose;
fwin->left_button->descriptor.parent = fwin;
fwin->left_button->descriptor.parent_type = WCLASS_FRAME;
fwin->left_button->descriptor.handle_mousedown = buttonMouseDown;
}
2012-10-02 22:16:18 +02:00
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button) {
fwin->language_button->descriptor.handle_expose = handleButtonExpose;
fwin->language_button->descriptor.parent = fwin;
fwin->language_button->descriptor.parent_type = WCLASS_FRAME;
fwin->language_button->descriptor.handle_mousedown = buttonMouseDown;
}
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
if (fwin->right_button) {
fwin->right_button->descriptor.parent = fwin;
fwin->right_button->descriptor.parent_type = WCLASS_FRAME;
fwin->right_button->descriptor.handle_expose = handleButtonExpose;
fwin->right_button->descriptor.handle_mousedown = buttonMouseDown;
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
checkTitleSize(fwin);
2012-08-25 09:59:03 +01:00
2013-03-25 22:14:30 +00:00
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_border_color), &fwin->border_pixel);
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_focused_border_color), &fwin->focused_border_pixel);
2013-03-25 22:14:30 +00:00
allocFrameBorderPixel(fwin->colormap, WMGetColorRGBDescription(scr->frame_selected_border_color), &fwin->selected_border_pixel);
if (flags & WFF_SELECTED) {
if (fwin->selected_border_pixel)
XSetWindowBorder(dpy, fwin->core->window, *fwin->selected_border_pixel);
}
else {
if (fwin->flags.state == WS_FOCUSED) {
if (fwin->focused_border_pixel)
XSetWindowBorder(dpy, fwin->core->window, *fwin->focused_border_pixel);
} else {
if (fwin->border_pixel)
XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel);
}
2013-03-25 22:14:30 +00:00
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowDestroy(WFrameWindow * fwin)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
int i;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->left_button)
wCoreDestroy(fwin->left_button);
2004-10-12 21:28:27 +00:00
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button)
wCoreDestroy(fwin->language_button);
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->right_button)
wCoreDestroy(fwin->right_button);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->resizebar)
wCoreDestroy(fwin->resizebar);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->titlebar)
wCoreDestroy(fwin->titlebar);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
RemoveFromStackList(fwin->core);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
wCoreDestroy(fwin->core);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->title)
wfree(fwin->title);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
for (i = 0; i < (fwin->flags.single_texture ? 1 : 3); i++) {
FREE_PIXMAP(fwin->title_back[i]);
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->lbutton_back[i]);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->languagebutton_back[i]);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->rbutton_back[i]);
}
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
wfree(fwin);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowChangeState(WFrameWindow * fwin, int state)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
if (fwin->flags.state == state)
return;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
fwin->flags.state = state;
fwin->flags.need_texture_change = 1;
2004-10-12 21:28:27 +00:00
if (fwin->flags.state == WS_FOCUSED) {
if (fwin->focused_border_pixel)
XSetWindowBorder(dpy, fwin->core->window, *fwin->focused_border_pixel);
} else {
if (fwin->border_pixel)
XSetWindowBorder(dpy, fwin->core->window, *fwin->border_pixel);
}
2009-08-20 00:59:40 +02:00
wFrameWindowPaint(fwin);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void updateTitlebar(WFrameWindow * fwin)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
int x, w;
int theight;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
theight = WMFontHeight(*fwin->font) + (*fwin->title_clearance + TITLEBAR_EXTEND_SPACE) * 2;
1998-09-29 22:36:29 +00:00
if (theight > *fwin->title_max_height)
theight = *fwin->title_max_height;
if (theight < *fwin->title_min_height)
theight = *fwin->title_min_height;
2009-08-20 00:59:40 +02:00
x = 0;
w = fwin->core->width + 1;
1998-09-29 22:36:29 +00:00
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
if (fwin->flags.hide_left_button || !fwin->left_button || fwin->flags.lbutton_dont_fit) {
x = 0;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button)
wCoreConfigure(fwin->language_button, 0, 0,
fwin->language_button->width, fwin->language_button->width);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
} else {
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button)
wCoreConfigure(fwin->language_button, fwin->left_button->width, 0,
fwin->language_button->width, fwin->language_button->width);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
x = fwin->left_button->width;
w -= fwin->left_button->width;
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->flags.hide_language_button || !fwin->language_button
|| fwin->flags.languagebutton_dont_fit) {
} else {
x += fwin->language_button->width;
w -= fwin->language_button->width;
}
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
else {
int bsize = theight - 7;
if (fwin->flags.hide_left_button || !fwin->left_button || fwin->flags.lbutton_dont_fit) {
if (fwin->language_button)
wCoreConfigure(fwin->language_button, 3, (theight - bsize) / 2,
fwin->language_button->width, fwin->language_button->width);
} else {
if (fwin->language_button)
wCoreConfigure(fwin->language_button,
6 + fwin->left_button->width, (theight - bsize) / 2,
fwin->language_button->width, fwin->language_button->width);
}
}
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_right_button && fwin->right_button && !fwin->flags.rbutton_dont_fit)
2009-08-20 00:59:40 +02:00
w -= fwin->right_button->width;
}
1998-09-29 22:36:29 +00:00
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW || fwin->titlebar->width != w)
2009-08-20 00:59:40 +02:00
fwin->flags.need_texture_remake = 1;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
wCoreConfigure(fwin->titlebar, x, 0, w, theight);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowHideButton(WFrameWindow * fwin, int flags)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
if ((flags & WFF_RIGHT_BUTTON) && fwin->right_button) {
XUnmapWindow(dpy, fwin->right_button->window);
fwin->flags.hide_right_button = 1;
}
if ((flags & WFF_LEFT_BUTTON) && fwin->left_button) {
XUnmapWindow(dpy, fwin->left_button->window);
fwin->flags.hide_left_button = 1;
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button) {
XUnmapWindow(dpy, fwin->language_button->window);
fwin->flags.hide_language_button = 1;
}
1999-05-30 05:10:54 +00:00
#endif
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->titlebar) {
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
updateTitlebar(fwin);
} else {
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
updateTitlebar(fwin);
1999-05-30 05:10:54 +00:00
#else
2009-08-20 00:59:40 +02:00
XClearWindow(dpy, fwin->titlebar->window);
wFrameWindowPaint(fwin);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
checkTitleSize(fwin);
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowShowButton(WFrameWindow * fwin, int flags)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
if ((flags & WFF_RIGHT_BUTTON) && fwin->right_button && fwin->flags.hide_right_button) {
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (!fwin->flags.rbutton_dont_fit)
XMapWindow(dpy, fwin->right_button->window);
1999-05-30 05:10:54 +00:00
2009-08-20 00:59:40 +02:00
fwin->flags.hide_right_button = 0;
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if ((flags & WFF_LANGUAGE_BUTTON) && fwin->language_button && fwin->flags.hide_language_button) {
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (!fwin->flags.languagebutton_dont_fit)
XMapWindow(dpy, fwin->language_button->window);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
fwin->flags.hide_language_button = 0;
}
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if ((flags & WFF_LEFT_BUTTON) && fwin->left_button && fwin->flags.hide_left_button) {
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (!fwin->flags.lbutton_dont_fit)
XMapWindow(dpy, fwin->left_button->window);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
fwin->flags.hide_left_button = 0;
}
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->titlebar) {
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
updateTitlebar(fwin);
} else {
XClearWindow(dpy, fwin->titlebar->window);
wFrameWindowPaint(fwin);
}
checkTitleSize(fwin);
}
1998-09-29 22:36:29 +00:00
}
static void
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
renderTexture(WScreen * scr, WTexture * texture, int width, int height,
int bwidth, int bheight, int left, int language, int right,
Pixmap * title, Pixmap * lbutton, Pixmap * languagebutton, Pixmap * rbutton)
1999-05-30 05:10:54 +00:00
#else
2009-08-20 00:59:40 +02:00
renderTexture(WScreen * scr, WTexture * texture, int width, int height,
int bwidth, int bheight, int left, int right, Pixmap * title, Pixmap * lbutton, Pixmap * rbutton)
1999-05-30 05:10:54 +00:00
#endif
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
RImage *img;
RImage *limg, *rimg, *mimg;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
RImage *timg;
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
int x, w;
1999-05-01 23:15:43 +00:00
2009-08-20 00:59:40 +02:00
*title = None;
*lbutton = None;
*rbutton = None;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
*languagebutton = None;
1999-05-30 05:10:54 +00:00
#endif
1999-01-06 15:22:33 +00:00
2009-08-20 00:59:40 +02:00
img = wTextureRenderImage(texture, width, height, WREL_FLAT);
if (!img) {
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
return;
}
2004-10-12 21:28:27 +00:00
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2012-10-02 22:16:18 +02:00
if (left)
2009-08-20 00:59:40 +02:00
limg = RGetSubImage(img, 0, 0, bwidth, bheight);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
limg = NULL;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
x = 0;
w = img->width;
2004-10-12 21:28:27 +00:00
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2012-10-02 22:16:18 +02:00
if (language)
2009-08-20 00:59:40 +02:00
timg = RGetSubImage(img, bwidth * left, 0, bwidth, bheight);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
timg = NULL;
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (limg) {
RBevelImage(limg, RBEV_RAISED2);
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, limg, lbutton))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
x += limg->width;
w -= limg->width;
RReleaseImage(limg);
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (timg) {
RBevelImage(timg, RBEV_RAISED2);
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, timg, languagebutton))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
x += timg->width;
w -= timg->width;
RReleaseImage(timg);
}
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2012-10-02 22:16:18 +02:00
if (right)
2009-08-20 00:59:40 +02:00
rimg = RGetSubImage(img, width - bwidth, 0, bwidth, bheight);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
rimg = NULL;
if (rimg) {
RBevelImage(rimg, RBEV_RAISED2);
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, rimg, rbutton))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
w -= rimg->width;
RReleaseImage(rimg);
}
if (w != width) {
mimg = RGetSubImage(img, x, 0, w, img->height);
RBevelImage(mimg, RBEV_RAISED2);
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, mimg, title))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
RReleaseImage(mimg);
} else {
RBevelImage(img, RBEV_RAISED2);
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, img, title))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
}
} else {
RBevelImage(img, RBEV_RAISED2);
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, img, title))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
}
RReleaseImage(img);
1998-09-29 22:36:29 +00:00
}
1999-04-12 02:03:58 +00:00
static void
2009-08-20 00:59:40 +02:00
renderResizebarTexture(WScreen * scr, WTexture * texture, int width, int height, int cwidth, Pixmap * pmap)
1999-04-12 02:03:58 +00:00
{
2009-08-20 00:59:40 +02:00
RImage *img;
RColor light;
RColor dark;
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
*pmap = None;
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
img = wTextureRenderImage(texture, width, height, WREL_FLAT);
if (!img) {
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
return;
}
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
light.alpha = 0;
light.red = light.green = light.blue = 80;
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
dark.alpha = 0;
dark.red = dark.green = dark.blue = 40;
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
ROperateLine(img, RSubtractOperation, 0, 0, width - 1, 0, &dark);
ROperateLine(img, RAddOperation, 0, 1, width - 1, 1, &light);
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height - 1, &dark);
ROperateLine(img, RAddOperation, cwidth + 1, 2, cwidth + 1, height - 1, &light);
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
if (width > 1)
ROperateLine(img, RSubtractOperation, width - cwidth - 2, 2,
width - cwidth - 2, height - 1, &dark);
ROperateLine(img, RAddOperation, width - cwidth - 1, 2, width - cwidth - 1, height - 1, &light);
1999-04-12 02:03:58 +00:00
#ifdef SHADOW_RESIZEBAR
2009-08-20 00:59:40 +02:00
ROperateLine(img, RAddOperation, 0, 1, 0, height - 1, &light);
ROperateLine(img, RSubtractOperation, width - 1, 1, width - 1, height - 1, &dark);
ROperateLine(img, RSubtractOperation, 0, height - 1, width - 1, height - 1, &dark);
#endif /* SHADOW_RESIZEBAR */
2012-10-02 22:16:18 +02:00
if (!RConvertImage(scr->rcontext, img, pmap))
2009-08-20 00:59:40 +02:00
wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode));
2009-08-20 00:59:40 +02:00
RReleaseImage(img);
1999-04-12 02:03:58 +00:00
}
2009-08-20 00:59:40 +02:00
static void updateTexture(WFrameWindow * fwin)
1998-10-21 14:43:47 +00:00
{
2009-08-20 00:59:40 +02:00
int i;
unsigned long pixel;
i = fwin->flags.state;
if (fwin->titlebar) {
if (fwin->title_texture[i]->any.type != WTEX_SOLID) {
XSetWindowBackgroundPixmap(dpy, fwin->titlebar->window, fwin->title_back[i]);
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
if (fwin->left_button && fwin->lbutton_back[i])
XSetWindowBackgroundPixmap(dpy, fwin->left_button->window,
fwin->lbutton_back[i]);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2012-10-02 22:16:18 +02:00
if (fwin->language_button && fwin->languagebutton_back[i])
2009-08-20 00:59:40 +02:00
XSetWindowBackgroundPixmap(dpy, fwin->language_button->window,
fwin->languagebutton_back[i]);
1999-05-30 05:10:54 +00:00
#endif
2002-10-18 02:56:59 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->right_button && fwin->rbutton_back[i])
XSetWindowBackgroundPixmap(dpy, fwin->right_button->window,
fwin->rbutton_back[i]);
}
} else {
pixel = fwin->title_texture[i]->solid.normal.pixel;
XSetWindowBackground(dpy, fwin->titlebar->window, pixel);
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
if (fwin->left_button)
XSetWindowBackground(dpy, fwin->left_button->window, pixel);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button)
XSetWindowBackground(dpy, fwin->language_button->window, pixel);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
if (fwin->right_button)
XSetWindowBackground(dpy, fwin->right_button->window, pixel);
}
}
XClearWindow(dpy, fwin->titlebar->window);
if (fwin->left_button) {
XClearWindow(dpy, fwin->left_button->window);
handleButtonExpose(&fwin->left_button->descriptor, NULL);
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button) {
XClearWindow(dpy, fwin->language_button->window);
handleButtonExpose(&fwin->language_button->descriptor, NULL);
}
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
if (fwin->right_button) {
XClearWindow(dpy, fwin->right_button->window);
handleButtonExpose(&fwin->right_button->descriptor, NULL);
}
}
1998-10-21 14:43:47 +00:00
}
2009-08-20 00:59:40 +02:00
static void remakeTexture(WFrameWindow * fwin, int state)
1998-10-21 14:43:47 +00:00
{
2009-08-20 00:59:40 +02:00
Pixmap pmap, lpmap, rpmap;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
Pixmap tpmap;
1999-05-30 05:10:54 +00:00
#endif
1998-10-21 14:43:47 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->title_texture[state] && fwin->titlebar) {
FREE_PIXMAP(fwin->title_back[state]);
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->lbutton_back[state]);
FREE_PIXMAP(fwin->rbutton_back[state]);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
FREE_PIXMAP(fwin->languagebutton_back[state]);
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
1998-10-21 14:43:47 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->title_texture[state]->any.type != WTEX_SOLID) {
int left, right;
int width;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
int language;
1999-05-30 05:10:54 +00:00
#endif
1998-10-21 14:43:47 +00:00
2009-08-20 00:59:40 +02:00
/* eventually surrounded by if new_style */
left = fwin->left_button && !fwin->flags.hide_left_button && !fwin->flags.lbutton_dont_fit;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
language = fwin->language_button && !fwin->flags.hide_language_button
&& !fwin->flags.languagebutton_dont_fit;
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
right = fwin->right_button && !fwin->flags.hide_right_button
&& !fwin->flags.rbutton_dont_fit;
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
width = fwin->core->width + 1;
1999-04-12 02:03:58 +00:00
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
renderTexture(fwin->screen_ptr, fwin->title_texture[state],
width, fwin->titlebar->height,
fwin->titlebar->height, fwin->titlebar->height,
left, language, right, &pmap, &lpmap, &tpmap, &rpmap);
1999-05-30 05:10:54 +00:00
#else
2009-08-20 00:59:40 +02:00
renderTexture(fwin->screen_ptr, fwin->title_texture[state],
width, fwin->titlebar->height,
fwin->titlebar->height, fwin->titlebar->height,
left, right, &pmap, &lpmap, &rpmap);
1999-05-30 05:10:54 +00:00
#endif
1999-04-12 02:03:58 +00:00
2009-08-20 00:59:40 +02:00
fwin->title_back[state] = pmap;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
fwin->lbutton_back[state] = lpmap;
fwin->rbutton_back[state] = rpmap;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
fwin->languagebutton_back[state] = tpmap;
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
}
}
if (fwin->resizebar_texture && fwin->resizebar_texture[0]
&& fwin->resizebar && state == 0) {
FREE_PIXMAP(fwin->resizebar_back[0]);
if (fwin->resizebar_texture[0]->any.type != WTEX_SOLID) {
renderResizebarTexture(fwin->screen_ptr,
fwin->resizebar_texture[0],
fwin->resizebar->width,
fwin->resizebar->height, fwin->resizebar_corner_width, &pmap);
fwin->resizebar_back[0] = pmap;
}
/* this part should be in updateTexture() */
2012-10-02 22:16:18 +02:00
if (fwin->resizebar_texture[0]->any.type != WTEX_SOLID)
2009-08-20 00:59:40 +02:00
XSetWindowBackgroundPixmap(dpy, fwin->resizebar->window, fwin->resizebar_back[0]);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
XSetWindowBackground(dpy, fwin->resizebar->window,
fwin->resizebar_texture[0]->solid.normal.pixel);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
XClearWindow(dpy, fwin->resizebar->window);
}
1998-10-21 14:43:47 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowPaint(WFrameWindow * fwin)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WScreen *scr = fwin->screen_ptr;
int state;
state = fwin->flags.state;
if (fwin->flags.is_client_window_frame)
fwin->flags.justification = wPreferences.title_justification;
if (fwin->flags.need_texture_remake) {
int i;
fwin->flags.need_texture_remake = 0;
fwin->flags.need_texture_change = 0;
if (fwin->flags.single_texture) {
remakeTexture(fwin, 0);
updateTexture(fwin);
} else {
/* first render the texture for the current state... */
remakeTexture(fwin, state);
/* ... and paint it */
updateTexture(fwin);
for (i = 0; i < 3; i++) {
2012-10-02 22:16:18 +02:00
if (i != state)
2009-08-20 00:59:40 +02:00
remakeTexture(fwin, i);
}
}
}
if (fwin->flags.need_texture_change) {
fwin->flags.need_texture_change = 0;
updateTexture(fwin);
}
if (fwin->titlebar && !fwin->flags.repaint_only_resizebar
&& fwin->title_texture[state]->any.type == WTEX_SOLID) {
wDrawBevel(fwin->titlebar->window, fwin->titlebar->width,
fwin->titlebar->height, (WTexSolid *) fwin->title_texture[state], WREL_RAISED);
}
if (fwin->resizebar && !fwin->flags.repaint_only_titlebar
&& fwin->resizebar_texture[0]->any.type == WTEX_SOLID) {
Window win;
int w, h;
int cw;
GC light_gc, dim_gc;
WTexSolid *texture = (WTexSolid *) fwin->resizebar_texture[0];
w = fwin->resizebar->width;
h = fwin->resizebar->height;
cw = fwin->resizebar_corner_width;
light_gc = texture->light_gc;
dim_gc = texture->dim_gc;
win = fwin->resizebar->window;
XDrawLine(dpy, win, dim_gc, 0, 0, w, 0);
XDrawLine(dpy, win, light_gc, 0, 1, w, 1);
XDrawLine(dpy, win, dim_gc, cw, 2, cw, h);
XDrawLine(dpy, win, light_gc, cw + 1, 2, cw + 1, h);
XDrawLine(dpy, win, dim_gc, w - cw - 2, 2, w - cw - 2, h);
XDrawLine(dpy, win, light_gc, w - cw - 1, 2, w - cw - 1, h);
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
#ifdef SHADOW_RESIZEBAR
2009-08-20 00:59:40 +02:00
XDrawLine(dpy, win, light_gc, 0, 1, 0, h - 1);
XDrawLine(dpy, win, dim_gc, w - 1, 2, w - 1, h - 1);
XDrawLine(dpy, win, dim_gc, 1, h - 1, cw, h - 1);
XDrawLine(dpy, win, dim_gc, cw + 2, h - 1, w - cw - 2, h - 1);
XDrawLine(dpy, win, dim_gc, w - cw, h - 1, w - 1, h - 1);
#endif /* SHADOW_RESIZEBAR */
}
if (fwin->titlebar && !fwin->flags.repaint_only_resizebar) {
int x, y, w, h;
int lofs = 6, rofs = 6;
int titlelen;
int allButtons = 1;
2010-09-10 20:51:08 +04:00
if (!wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
if (fwin->left_button && !fwin->flags.hide_left_button && !fwin->flags.lbutton_dont_fit)
lofs += fwin->left_button->width + 3;
else
allButtons = 0;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button && !fwin->flags.hide_language_button
&& !fwin->flags.languagebutton_dont_fit)
lofs += fwin->language_button->width;
else
allButtons = 0;
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
if (fwin->right_button && !fwin->flags.hide_right_button && !fwin->flags.rbutton_dont_fit)
rofs += fwin->right_button->width + 3;
else
allButtons = 0;
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
fwin->languagebutton_image = scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode];
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
if (fwin->title) {
Drawable buf;
char *title;
title = ShrinkString(*fwin->font, fwin->title, fwin->titlebar->width - lofs - rofs);
titlelen = strlen(title);
w = WMWidthOfString(*fwin->font, title, titlelen);
switch (fwin->flags.justification) {
case WTJ_LEFT:
x = lofs;
break;
case WTJ_RIGHT:
x = fwin->titlebar->width - w - rofs;
break;
default:
if (!allButtons)
x = lofs + (fwin->titlebar->width - w - lofs - rofs) / 2;
else
x = (fwin->titlebar->width - w) / 2;
break;
}
y = *fwin->title_clearance + TITLEBAR_EXTEND_SPACE;
h = WMFontHeight(*fwin->font);
if (y*2 + h > *fwin->title_max_height)
y = (*fwin->title_max_height - h) / 2;
if (y*2 + h < *fwin->title_min_height)
y = (*fwin->title_min_height - h) / 2;
2009-08-20 00:59:40 +02:00
/* We use a w+2 buffer to have an extra pixel on the left and
* another one on the right. This is because for some odd reason,
* sometimes when using AA fonts (when libfreetype2 is compiled
* with bytecode interpreter turned off), some fonts are drawn
* starting from x = -1 not from 0 as requested. Observed with
* capital A letter on the bold 'trebuchet ms' font. -Dan
*/
buf = XCreatePixmap(dpy, fwin->titlebar->window, w + 2, h, scr->w_depth);
XSetClipMask(dpy, scr->copy_gc, None);
if (fwin->title_texture[state]->any.type != WTEX_SOLID) {
XCopyArea(dpy, fwin->title_back[state], buf, scr->copy_gc,
x - 1, y, w + 2, h, 0, 0);
} else {
XSetForeground(dpy, scr->copy_gc, fwin->title_texture[state]->solid.normal.pixel);
XFillRectangle(dpy, buf, scr->copy_gc, 0, 0, w + 2, h);
}
/*XDrawRectangle(dpy, buf, WMColorGC(scr->white),1,0,w,h-1); */
WMDrawString(scr->wmscreen, buf, fwin->title_color[state],
*fwin->font, 1, 0, title, titlelen);
XCopyArea(dpy, buf, fwin->titlebar->window, scr->copy_gc, 0, 0, w + 2, h, x - 1, y);
XFreePixmap(dpy, buf);
wfree(title);
}
if (fwin->left_button)
handleButtonExpose(&fwin->left_button->descriptor, NULL);
if (fwin->right_button)
handleButtonExpose(&fwin->right_button->descriptor, NULL);
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button)
handleButtonExpose(&fwin->language_button->descriptor, NULL);
2002-10-17 20:26:30 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void reconfigure(WFrameWindow * fwin, int x, int y, int width, int height, Bool dontMove)
1998-09-29 22:36:29 +00:00
{
2010-09-10 20:51:08 +04:00
int k = (wPreferences.new_style == TS_NEW ? 4 : 3);
2009-08-20 00:59:40 +02:00
int resizedHorizontally = 0;
if (dontMove)
XResizeWindow(dpy, fwin->core->window, width, height);
else
XMoveResizeWindow(dpy, fwin->core->window, x, y, width, height);
if (fwin->core->width != width) {
fwin->flags.need_texture_remake = 1;
resizedHorizontally = 1;
}
fwin->core->width = width;
fwin->core->height = height;
if (fwin->titlebar && resizedHorizontally) {
/* Check if the titlebar is wide enough to hold the buttons.
* Temporarily remove them if can't
*/
if (fwin->left_button) {
if (width < fwin->top_width * k && !fwin->flags.lbutton_dont_fit) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_left_button)
2009-08-20 00:59:40 +02:00
XUnmapWindow(dpy, fwin->left_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
fwin->flags.lbutton_dont_fit = 1;
} else if (width >= fwin->top_width * k && fwin->flags.lbutton_dont_fit) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_left_button)
2009-08-20 00:59:40 +02:00
XMapWindow(dpy, fwin->left_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
fwin->flags.lbutton_dont_fit = 0;
}
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button) {
if (width < fwin->top_width * k && !fwin->flags.languagebutton_dont_fit) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_language_button)
2009-08-20 00:59:40 +02:00
XUnmapWindow(dpy, fwin->language_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
fwin->flags.languagebutton_dont_fit = 1;
} else if (width >= fwin->top_width * k && fwin->flags.languagebutton_dont_fit) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_language_button)
2009-08-20 00:59:40 +02:00
XMapWindow(dpy, fwin->language_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
fwin->flags.languagebutton_dont_fit = 0;
}
}
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->right_button) {
if (width < fwin->top_width * 2 && !fwin->flags.rbutton_dont_fit) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_right_button)
2009-08-20 00:59:40 +02:00
XUnmapWindow(dpy, fwin->right_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
fwin->flags.rbutton_dont_fit = 1;
} else if (width >= fwin->top_width * 2 && fwin->flags.rbutton_dont_fit) {
2012-10-02 22:16:18 +02:00
if (!fwin->flags.hide_right_button)
2009-08-20 00:59:40 +02:00
XMapWindow(dpy, fwin->right_button->window);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
fwin->flags.rbutton_dont_fit = 0;
}
}
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
if (fwin->right_button)
XMoveWindow(dpy, fwin->right_button->window,
width - fwin->right_button->width + 1, 0);
} else {
if (fwin->right_button)
XMoveWindow(dpy, fwin->right_button->window,
width - fwin->right_button->width - 3,
(fwin->titlebar->height - fwin->right_button->height) / 2);
}
updateTitlebar(fwin);
checkTitleSize(fwin);
}
if (fwin->resizebar) {
wCoreConfigure(fwin->resizebar, 0,
fwin->core->height - fwin->resizebar->height,
fwin->core->width, fwin->resizebar->height);
fwin->resizebar_corner_width = RESIZEBAR_CORNER_WIDTH;
2012-10-02 22:16:18 +02:00
if (fwin->core->width < RESIZEBAR_CORNER_WIDTH * 2 + RESIZEBAR_MIN_WIDTH)
2009-08-20 00:59:40 +02:00
fwin->resizebar_corner_width = fwin->core->width / 2;
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
void wFrameWindowConfigure(WFrameWindow * fwin, int x, int y, int width, int height)
1999-01-06 15:22:33 +00:00
{
2009-08-20 00:59:40 +02:00
reconfigure(fwin, x, y, width, height, False);
1999-01-06 15:22:33 +00:00
}
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
void wFrameWindowResize(WFrameWindow * fwin, int width, int height)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
reconfigure(fwin, 0, 0, width, height, True);
1998-09-29 22:36:29 +00:00
}
int wFrameWindowChangeTitle(WFrameWindow *fwin, const char *new_title)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
/* check if the title is the same as before */
if (fwin->title) {
2012-10-02 22:16:18 +02:00
if (new_title && (strcmp(fwin->title, new_title) == 0))
2009-08-20 00:59:40 +02:00
return 0;
} else {
if (!new_title)
return 0;
}
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->title)
wfree(fwin->title);
2009-08-20 00:59:40 +02:00
fwin->title = wstrdup(new_title);
2009-08-20 00:59:40 +02:00
if (fwin->titlebar) {
XClearWindow(dpy, fwin->titlebar->window);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
wFrameWindowPaint(fwin);
}
checkTitleSize(fwin);
2009-08-20 00:59:40 +02:00
return 1;
1998-09-29 22:36:29 +00:00
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
void wFrameWindowUpdateLanguageButton(WFrameWindow * fwin)
1999-05-30 05:10:54 +00:00
{
2009-08-20 00:59:40 +02:00
paintButton(fwin->language_button, fwin->title_texture[fwin->flags.state],
WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->languagebutton_image, True);
1999-05-30 05:10:54 +00:00
}
2009-08-20 00:59:40 +02:00
#endif /* XKB_BUTTON_HINT */
1999-01-25 19:06:50 +00:00
1998-09-29 22:36:29 +00:00
/*********************************************************************/
2009-08-20 00:59:40 +02:00
static void handleExpose(WObjDescriptor * desc, XEvent * event)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WFrameWindow *fwin = (WFrameWindow *) desc->parent;
if (fwin->titlebar && fwin->titlebar->window == event->xexpose.window)
fwin->flags.repaint_only_titlebar = 1;
if (fwin->resizebar && fwin->resizebar->window == event->xexpose.window)
fwin->flags.repaint_only_resizebar = 1;
wFrameWindowPaint(fwin);
fwin->flags.repaint_only_titlebar = 0;
fwin->flags.repaint_only_resizebar = 0;
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void checkTitleSize(WFrameWindow * fwin)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
int width;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (!fwin->title) {
fwin->flags.incomplete_title = 0;
return;
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (!fwin->titlebar) {
fwin->flags.incomplete_title = 1;
return;
} else {
width = fwin->titlebar->width - 6 - 6;
}
1998-09-29 22:36:29 +00:00
2010-09-10 20:51:08 +04:00
if (!wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
if (fwin->left_button && !fwin->flags.hide_left_button && !fwin->flags.lbutton_dont_fit)
width -= fwin->left_button->width + 3;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (fwin->language_button && !fwin->flags.hide_language_button
&& !fwin->flags.languagebutton_dont_fit)
width -= fwin->language_button->width + 3;
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->right_button && !fwin->flags.hide_right_button && !fwin->flags.rbutton_dont_fit)
width -= fwin->right_button->width + 3;
}
2012-10-02 22:16:18 +02:00
if (WMWidthOfString(*fwin->font, fwin->title, strlen(fwin->title)) > width)
2009-08-20 00:59:40 +02:00
fwin->flags.incomplete_title = 1;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
fwin->flags.incomplete_title = 0;
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void paintButton(WCoreWindow * button, WTexture * texture, unsigned long color, WPixmap * image, int pushed)
2004-10-12 21:28:27 +00:00
{
2009-08-20 00:59:40 +02:00
WScreen *scr = button->screen_ptr;
GC copy_gc = scr->copy_gc;
int x = 0, y = 0, d = 0;
int left = 0, width = 0;
/* setup stuff according to the state */
if (pushed) {
if (image) {
if (image->width >= image->height * 2) {
/* the image contains 2 pictures: the second is for the
* pushed state */
width = image->width / 2;
left = image->width / 2;
} else {
width = image->width;
}
}
XSetClipMask(dpy, copy_gc, None);
2012-10-02 22:16:18 +02:00
if (wPreferences.new_style == TS_NEXT)
2010-09-10 20:51:08 +04:00
XSetForeground(dpy, copy_gc, scr->black_pixel);
2012-10-02 22:16:18 +02:00
else
2010-09-10 20:51:08 +04:00
XSetForeground(dpy, copy_gc, scr->white_pixel);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
d = 1;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
XFillRectangle(dpy, button->window, copy_gc, 0, 0, button->width - 1, button->height - 1);
XSetForeground(dpy, copy_gc, scr->black_pixel);
XDrawRectangle(dpy, button->window, copy_gc, 0, 0, button->width - 1, button->height - 1);
2010-09-10 20:51:08 +04:00
} else if (wPreferences.new_style == TS_OLD) {
2009-08-20 00:59:40 +02:00
XFillRectangle(dpy, button->window, copy_gc, 0, 0, button->width, button->height);
XSetForeground(dpy, copy_gc, scr->black_pixel);
XDrawRectangle(dpy, button->window, copy_gc, 0, 0, button->width, button->height);
2010-09-10 20:51:08 +04:00
} else {
XFillRectangle(dpy, button->window, copy_gc, 0, 0, button->width-3, button->height-3);
XSetForeground(dpy, copy_gc, scr->black_pixel);
XDrawRectangle(dpy, button->window, copy_gc, 0, 0, button->width-3, button->height-3);
2009-08-20 00:59:40 +02:00
}
} else {
XClearWindow(dpy, button->window);
if (image) {
if (image->width >= image->height * 2)
width = image->width / 2;
else
width = image->width;
}
d = 0;
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_NEW) {
2012-10-02 22:16:18 +02:00
if (texture->any.type == WTEX_SOLID || pushed)
2009-08-20 00:59:40 +02:00
wDrawBevel(button->window, button->width, button->height,
(WTexSolid *) texture, WREL_RAISED);
} else {
wDrawBevel(button->window, button->width, button->height,
scr->widget_texture, WREL_RAISED);
}
}
if (image) {
/* display image */
XSetClipMask(dpy, copy_gc, image->mask);
x = (button->width - width) / 2 + d;
y = (button->height - image->height) / 2 + d;
XSetClipOrigin(dpy, copy_gc, x - left, y);
2010-09-10 20:51:08 +04:00
if (!wPreferences.new_style == TS_NEW) {
2009-08-20 00:59:40 +02:00
XSetForeground(dpy, copy_gc, scr->black_pixel);
if (!pushed) {
if (image->depth == 1)
XCopyPlane(dpy, image->image, button->window, copy_gc,
left, 0, width, image->height, x, y, 1);
else
XCopyArea(dpy, image->image, button->window, copy_gc,
left, 0, width, image->height, x, y);
} else {
2010-09-10 20:51:08 +04:00
if (wPreferences.new_style == TS_OLD) {
XSetForeground(dpy, copy_gc, scr->dark_pixel);
XFillRectangle(dpy, button->window, copy_gc, 0, 0,
button->width, button->height);
} else {
XSetForeground(dpy, copy_gc, scr->black_pixel);
XCopyArea(dpy, image->image, button->window, copy_gc,
left, 0, width, image->height, x, y);
}
2009-08-20 00:59:40 +02:00
}
} else {
if (pushed) {
XSetForeground(dpy, copy_gc, scr->black_pixel);
} else {
XSetForeground(dpy, copy_gc, color);
XSetBackground(dpy, copy_gc, texture->any.color.pixel);
}
XFillRectangle(dpy, button->window, copy_gc, 0, 0, button->width, button->height);
}
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void handleButtonExpose(WObjDescriptor * desc, XEvent * event)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WFrameWindow *fwin = (WFrameWindow *) desc->parent;
WCoreWindow *button = (WCoreWindow *) desc->self;
1999-01-25 19:06:50 +00:00
/* Parameter not used, but tell the compiler that it is ok */
(void) event;
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (button == fwin->language_button) {
2012-10-02 22:16:18 +02:00
if (wPreferences.modelock)
2009-08-20 00:59:40 +02:00
paintButton(button, fwin->title_texture[fwin->flags.state],
WMColorPixel(fwin->title_color[fwin->flags.state]),
fwin->languagebutton_image, False);
} else
1999-05-30 05:10:54 +00:00
#endif
2012-10-02 22:16:18 +02:00
if (button == fwin->left_button)
2009-08-20 00:59:40 +02:00
paintButton(button, fwin->title_texture[fwin->flags.state],
WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->lbutton_image, False);
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
paintButton(button, fwin->title_texture[fwin->flags.state],
WMColorPixel(fwin->title_color[fwin->flags.state]), fwin->rbutton_image, False);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void titlebarMouseDown(WObjDescriptor * desc, XEvent * event)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WFrameWindow *fwin = desc->parent;
WCoreWindow *titlebar = desc->self;
if (IsDoubleClick(fwin->core->screen_ptr, event)) {
2012-10-02 22:16:18 +02:00
if (fwin->on_dblclick_titlebar)
2009-08-20 00:59:40 +02:00
(*fwin->on_dblclick_titlebar) (titlebar, fwin->child, event);
} else {
2012-10-02 22:16:18 +02:00
if (fwin->on_mousedown_titlebar)
2009-08-20 00:59:40 +02:00
(*fwin->on_mousedown_titlebar) (titlebar, fwin->child, event);
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void resizebarMouseDown(WObjDescriptor * desc, XEvent * event)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WFrameWindow *fwin = desc->parent;
WCoreWindow *resizebar = desc->self;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (fwin->on_mousedown_resizebar)
(*fwin->on_mousedown_resizebar) (resizebar, fwin->child, event);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void buttonMouseDown(WObjDescriptor * desc, XEvent * event)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WFrameWindow *fwin = desc->parent;
WCoreWindow *button = desc->self;
WPixmap *image;
XEvent ev;
int done = 0, execute = 1;
WTexture *texture;
unsigned long pixel;
int clickButton = event->xbutton.button;
if (IsDoubleClick(fwin->core->screen_ptr, event)) {
2012-10-02 22:16:18 +02:00
if (button == fwin->right_button && fwin->on_dblclick_right)
2009-08-20 00:59:40 +02:00
(*fwin->on_dblclick_right) (button, fwin->child, event);
2012-10-02 22:16:18 +02:00
2009-08-20 00:59:40 +02:00
return;
}
2012-10-02 22:16:18 +02:00
if (button == fwin->left_button)
2009-08-20 00:59:40 +02:00
image = fwin->lbutton_image;
2012-10-02 22:16:18 +02:00
else
2009-08-20 00:59:40 +02:00
image = fwin->rbutton_image;
2012-10-02 22:16:18 +02:00
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
if (button == fwin->language_button) {
if (!wPreferences.modelock)
return;
image = fwin->languagebutton_image;
}
1999-05-30 05:10:54 +00:00
#endif
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
pixel = WMColorPixel(fwin->title_color[fwin->flags.state]);
texture = fwin->title_texture[fwin->flags.state];
paintButton(button, texture, pixel, image, True);
while (!done) {
WMMaskEvent(dpy, LeaveWindowMask | EnterWindowMask | ButtonReleaseMask
| ButtonPressMask | ExposureMask, &ev);
switch (ev.type) {
case LeaveNotify:
execute = 0;
paintButton(button, texture, pixel, image, False);
break;
case EnterNotify:
execute = 1;
paintButton(button, texture, pixel, image, True);
break;
case ButtonPress:
break;
case ButtonRelease:
if (ev.xbutton.button == clickButton)
done = 1;
break;
default:
WMHandleEvent(&ev);
}
}
paintButton(button, texture, pixel, image, False);
if (execute) {
if (button == fwin->left_button) {
if (fwin->on_click_left)
(*fwin->on_click_left) (button, fwin->child, &ev);
} else if (button == fwin->right_button) {
if (fwin->on_click_right)
(*fwin->on_click_right) (button, fwin->child, &ev);
}
1999-05-30 05:10:54 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
else if (button == fwin->language_button) {
if (fwin->on_click_language)
(*fwin->on_click_language) (button, fwin->child, &ev);
}
1999-05-30 05:10:54 +00:00
#endif
2009-08-20 00:59:40 +02:00
}
1998-09-29 22:36:29 +00:00
}