2 * Window Maker window manager
4 * Copyright (c) 1997, 1998 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 #include <X11/Xutil.h>
26 #ifdef KEEP_XKB_LOCK_STATUS
27 #include <X11/XKBlib.h>
28 #endif /* KEEP_XKB_LOCK_STATUS */
35 #include "WindowMaker.h"
44 #define DBLCLICK_TIME wPreferences.dblclick_time
46 extern WPreferences wPreferences
;
48 static void handleExpose(WObjDescriptor
*desc
, XEvent
*event
);
49 static void handleButtonExpose(WObjDescriptor
*desc
, XEvent
*event
);
51 static void buttonMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
52 static void titlebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
53 static void resizebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
55 static void checkTitleSize(WFrameWindow
*fwin
);
58 static void paintButton(WCoreWindow
*button
, WTexture
*texture
,
59 unsigned long color
, WPixmap
*image
, int pushed
);
61 static void updateTitlebar(WFrameWindow
*fwin
);
65 wFrameWindowCreate(WScreen
*scr
, int wlevel
, int x
, int y
,
66 int width
, int height
, int flags
,
67 WTexture
**title_texture
, WTexture
**resize_texture
,
68 unsigned long *color
, GC
*gc
, WFont
**font
)
72 fwin
= wmalloc(sizeof(WFrameWindow
));
73 memset(fwin
, 0, sizeof(WFrameWindow
));
75 fwin
->screen_ptr
= scr
;
77 fwin
->flags
.single_texture
= (flags
& WFF_SINGLE_STATE
) ? 1 : 0;
79 fwin
->title_texture
= title_texture
;
80 fwin
->resizebar_texture
= resize_texture
;
81 fwin
->title_pixel
= color
;
84 #ifdef KEEP_XKB_LOCK_STATUS
85 fwin
->languagemode
= XkbGroup1Index
;
86 fwin
->last_languagemode
= XkbGroup2Index
;
89 fwin
->core
= wCoreCreateTopLevel(scr
, x
, y
, width
, height
,
91 if (wPreferences
.use_saveunders
) {
93 XSetWindowAttributes attribs
;
96 attribs
.save_under
= True
;
97 XChangeWindowAttributes(dpy
, fwin
->core
->window
, vmask
, &attribs
);
100 /* setup stacking information */
101 fwin
->core
->stacking
= wmalloc(sizeof(WStacking
));
102 fwin
->core
->stacking
->above
= NULL
;
103 fwin
->core
->stacking
->under
= NULL
;
104 fwin
->core
->stacking
->child_of
= NULL
;
105 fwin
->core
->stacking
->window_level
= wlevel
;
107 AddToStackList(fwin
->core
);
109 wFrameWindowUpdateBorders(fwin
, flags
);
117 wFrameWindowUpdateBorders(WFrameWindow
*fwin
, int flags
)
123 WScreen
*scr
= fwin
->screen_ptr
;
125 width
= fwin
->core
->width
;
126 if (flags
& WFF_IS_SHADED
)
129 height
= fwin
->core
->height
- fwin
->top_width
- fwin
->bottom_width
;
131 if (flags
& WFF_TITLEBAR
)
132 theight
= (*fwin
->font
)->height
+ TITLEBAR_EXTRA_HEIGHT
;
136 if (wPreferences
.new_style
) {
142 if (fwin
->titlebar
) {
143 /* if we had a titlebar and is requesting for one,
144 * check if the size has changed and resize it */
145 if (flags
& WFF_TITLEBAR
) {
146 fwin
->top_width
= theight
;
148 fwin
->flags
.need_texture_remake
= 1;
150 if (wPreferences
.new_style
) {
151 if (fwin
->left_button
) {
152 wCoreConfigure(fwin
->left_button
, 0, 0, bsize
, bsize
);
154 #ifdef XKB_BUTTON_HINT
155 if (fwin
->language_button
)
156 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
157 || fwin
->flags
.lbutton_dont_fit
) {
158 wCoreConfigure(fwin
->language_button
, 0, 0, bsize
, bsize
);
160 wCoreConfigure(fwin
->language_button
, bsize
, 0, bsize
, bsize
);
165 if (fwin
->right_button
) {
166 wCoreConfigure(fwin
->right_button
, width
-bsize
+1,
169 } else { /* !new_style */
170 if (fwin
->left_button
) {
171 wCoreConfigure(fwin
->left_button
, 3, (theight
-bsize
)/2,
175 #ifdef XKB_BUTTON_HINT
176 if (fwin
->language_button
) {
177 wCoreConfigure(fwin
->language_button
, 6 + bsize
, (theight
-bsize
)/2,
183 if (fwin
->right_button
) {
184 wCoreConfigure(fwin
->right_button
, width
-bsize
-3,
185 (theight
-bsize
)/2, bsize
, bsize
);
188 updateTitlebar(fwin
);
190 /* we had a titlebar, but now we don't need it anymore */
191 for (i
=0; i
< (fwin
->flags
.single_texture
? 1 : 3); i
++) {
192 FREE_PIXMAP(fwin
->title_back
[i
]);
193 if (wPreferences
.new_style
) {
194 FREE_PIXMAP(fwin
->lbutton_back
[i
]);
195 FREE_PIXMAP(fwin
->rbutton_back
[i
]);
196 #ifdef XKB_BUTTON_HINT
197 FREE_PIXMAP(fwin
->languagebutton_back
[i
]);
201 if (fwin
->left_button
)
202 wCoreDestroy(fwin
->left_button
);
203 fwin
->left_button
= NULL
;
205 #ifdef XKB_BUTTON_HINT
206 if (fwin
->language_button
)
207 wCoreDestroy(fwin
->language_button
);
208 fwin
->language_button
= NULL
;
211 if (fwin
->right_button
)
212 wCoreDestroy(fwin
->right_button
);
213 fwin
->right_button
= NULL
;
215 wCoreDestroy(fwin
->titlebar
);
216 fwin
->titlebar
= NULL
;
221 /* if we didn't have a titlebar and are being requested for
223 if (flags
& WFF_TITLEBAR
) {
224 fwin
->top_width
= theight
;
226 fwin
->flags
.titlebar
= 1;
227 fwin
->titlebar
= wCoreCreate(fwin
->core
, 0, 0, width
+1, theight
);
229 if (flags
& WFF_LEFT_BUTTON
) {
230 fwin
->flags
.left_button
= 1;
231 if (wPreferences
.new_style
) {
232 fwin
->left_button
= wCoreCreate(fwin
->core
, 0, 0,
234 if (width
< theight
*4) {
235 fwin
->flags
.lbutton_dont_fit
= 1;
237 XMapRaised(dpy
, fwin
->left_button
->window
);
241 wCoreCreate(fwin
->titlebar
, 3, (theight
-bsize
)/2,
244 XSetWindowBackground(dpy
, fwin
->left_button
->window
,
245 scr
->widget_texture
->normal
.pixel
);
247 if (width
< theight
*3) {
248 fwin
->flags
.lbutton_dont_fit
= 1;
250 XMapRaised(dpy
, fwin
->left_button
->window
);
255 #ifdef XKB_BUTTON_HINT
256 if (flags
& WFF_LANGUAGE_BUTTON
) {
257 fwin
->flags
.language_button
= 1;
258 if (wPreferences
.new_style
) {
259 fwin
->language_button
= wCoreCreate(fwin
->core
,
260 bsize
, 0, bsize
, bsize
);
262 if (width
< theight
*4) {
263 fwin
->flags
.languagebutton_dont_fit
= 1;
265 XMapRaised(dpy
, fwin
->language_button
->window
);
268 fwin
->language_button
=
269 wCoreCreate(fwin
->titlebar
, bsize
+ 6, (theight
-bsize
)/2,
272 XSetWindowBackground(dpy
, fwin
->language_button
->window
,
273 scr
->widget_texture
->normal
.pixel
);
275 if (width
< theight
*3) {
276 fwin
->flags
.languagebutton_dont_fit
= 1;
278 XMapRaised(dpy
, fwin
->language_button
->window
);
284 if (flags
& WFF_RIGHT_BUTTON
) {
285 fwin
->flags
.right_button
= 1;
286 if (wPreferences
.new_style
) {
288 wCoreCreate(fwin
->core
, width
-bsize
+1, 0,
292 wCoreCreate(fwin
->titlebar
, width
-bsize
-3,
293 (theight
-bsize
)/2, bsize
, bsize
);
294 XSetWindowBackground(dpy
, fwin
->right_button
->window
,
295 scr
->widget_texture
->normal
.pixel
);
298 if (width
< theight
*2) {
299 fwin
->flags
.rbutton_dont_fit
= 1;
301 XMapRaised(dpy
, fwin
->right_button
->window
);
305 if (wPreferences
.new_style
)
306 updateTitlebar(fwin
);
308 XMapRaised(dpy
, fwin
->titlebar
->window
);
310 fwin
->flags
.need_texture_remake
= 1;
313 checkTitleSize(fwin
);
315 if (flags
& WFF_RESIZEBAR
) {
316 fwin
->bottom_width
= RESIZEBAR_HEIGHT
;
318 fwin
->bottom_width
= 0;
321 if (flags
& WFF_RESIZEBAR
) {
322 if (!fwin
->resizebar
) {
323 fwin
->flags
.resizebar
= 1;
324 fwin
->resizebar
= wCoreCreate(fwin
->core
, 0,
325 height
+ fwin
->top_width
,
326 width
, RESIZEBAR_HEIGHT
);
327 fwin
->resizebar_corner_width
= RESIZEBAR_CORNER_WIDTH
;
328 if (width
< RESIZEBAR_CORNER_WIDTH
*2 + RESIZEBAR_MIN_WIDTH
) {
329 fwin
->resizebar_corner_width
= (width
- RESIZEBAR_MIN_WIDTH
)/2;
330 if (fwin
->resizebar_corner_width
< 0)
331 fwin
->resizebar_corner_width
= 0;
334 XMapWindow(dpy
, fwin
->resizebar
->window
);
335 XLowerWindow(dpy
, fwin
->resizebar
->window
);
337 fwin
->flags
.need_texture_remake
= 1;
339 if (height
+fwin
->top_width
+fwin
->bottom_width
!= fwin
->core
->height
) {
340 wCoreConfigure(fwin
->resizebar
, 0, height
+ fwin
->top_width
,
341 width
, RESIZEBAR_HEIGHT
);
345 if (fwin
->resizebar
) {
346 fwin
->bottom_width
= 0;
347 wCoreDestroy(fwin
->resizebar
);
348 fwin
->resizebar
= NULL
;
352 if (height
+ fwin
->top_width
+ fwin
->bottom_width
!= fwin
->core
->height
353 && !(flags
& WFF_IS_SHADED
)) {
354 wFrameWindowResize(fwin
, width
,
355 height
+ fwin
->top_width
+ fwin
->bottom_width
);
358 /* setup object descriptors */
360 if (fwin
->titlebar
) {
361 fwin
->titlebar
->descriptor
.handle_expose
= handleExpose
;
362 fwin
->titlebar
->descriptor
.parent
= fwin
;
363 fwin
->titlebar
->descriptor
.parent_type
= WCLASS_FRAME
;
364 fwin
->titlebar
->descriptor
.handle_mousedown
= titlebarMouseDown
;
367 if (fwin
->resizebar
) {
368 fwin
->resizebar
->descriptor
.handle_expose
= handleExpose
;
369 fwin
->resizebar
->descriptor
.parent
= fwin
;
370 fwin
->resizebar
->descriptor
.parent_type
= WCLASS_FRAME
;
371 fwin
->resizebar
->descriptor
.handle_mousedown
= resizebarMouseDown
;
374 if (fwin
->left_button
) {
375 fwin
->left_button
->descriptor
.handle_expose
= handleButtonExpose
;
376 fwin
->left_button
->descriptor
.parent
= fwin
;
377 fwin
->left_button
->descriptor
.parent_type
= WCLASS_FRAME
;
378 fwin
->left_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
381 #ifdef XKB_BUTTON_HINT
382 if (fwin
->language_button
) {
383 fwin
->language_button
->descriptor
.handle_expose
= handleButtonExpose
;
384 fwin
->language_button
->descriptor
.parent
= fwin
;
385 fwin
->language_button
->descriptor
.parent_type
= WCLASS_FRAME
;
386 fwin
->language_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
391 if (fwin
->right_button
) {
392 fwin
->right_button
->descriptor
.parent
= fwin
;
393 fwin
->right_button
->descriptor
.parent_type
= WCLASS_FRAME
;
394 fwin
->right_button
->descriptor
.handle_expose
= handleButtonExpose
;
395 fwin
->right_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
398 checkTitleSize(fwin
);
404 wFrameWindowDestroy(WFrameWindow
*fwin
)
408 if (fwin
->left_button
)
409 wCoreDestroy(fwin
->left_button
);
411 #ifdef XKB_BUTTON_HINT
412 if (fwin
->language_button
)
413 wCoreDestroy(fwin
->language_button
);
416 if (fwin
->right_button
)
417 wCoreDestroy(fwin
->right_button
);
420 wCoreDestroy(fwin
->resizebar
);
423 wCoreDestroy(fwin
->titlebar
);
425 RemoveFromStackList(fwin
->core
);
427 wCoreDestroy(fwin
->core
);
432 for (i
=0; i
< (fwin
->flags
.single_texture
? 1 : 3); i
++) {
433 FREE_PIXMAP(fwin
->title_back
[i
]);
434 if (wPreferences
.new_style
) {
435 FREE_PIXMAP(fwin
->lbutton_back
[i
]);
436 #ifdef XKB_BUTTON_HINT
437 FREE_PIXMAP(fwin
->languagebutton_back
[i
]);
439 FREE_PIXMAP(fwin
->rbutton_back
[i
]);
448 wFrameWindowChangeState(WFrameWindow
*fwin
, int state
)
450 if (fwin
->flags
.state
==state
)
453 fwin
->flags
.state
= state
;
454 fwin
->flags
.need_texture_change
= 1;
456 wFrameWindowPaint(fwin
);
461 updateTitlebar(WFrameWindow
*fwin
)
466 theight
= (*fwin
->font
)->height
+ TITLEBAR_EXTRA_HEIGHT
;
469 w
= fwin
->core
->width
+ 1;
471 if (wPreferences
.new_style
) {
472 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
473 || fwin
->flags
.lbutton_dont_fit
) {
475 #ifdef XKB_BUTTON_HINT
476 if(fwin
->language_button
)
477 wCoreConfigure(fwin
->language_button
, 0, 0,
478 fwin
->language_button
->width
,
479 fwin
->language_button
->width
);
482 #ifdef XKB_BUTTON_HINT
483 if(fwin
->language_button
)
484 wCoreConfigure(fwin
->language_button
, fwin
->left_button
->width
, 0,
485 fwin
->language_button
->width
,
486 fwin
->language_button
->width
);
488 x
= fwin
->left_button
->width
;
489 w
-= fwin
->left_button
->width
;
491 #ifdef XKB_BUTTON_HINT
492 if (fwin
->flags
.hide_language_button
|| !fwin
->language_button
493 || fwin
->flags
.languagebutton_dont_fit
) {
495 x
+= fwin
->language_button
->width
;
496 w
-= fwin
->language_button
->width
;
500 #ifdef XKB_BUTTON_HINT
502 int bsize
= theight
- 7;
503 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
504 || fwin
->flags
.lbutton_dont_fit
) {
505 if(fwin
->language_button
)
506 wCoreConfigure(fwin
->language_button
, 3, (theight
-bsize
)/2,
507 fwin
->language_button
->width
,
508 fwin
->language_button
->width
);
511 if(fwin
->language_button
)
512 wCoreConfigure(fwin
->language_button
,
513 6 + fwin
->left_button
->width
, (theight
-bsize
)/2,
514 fwin
->language_button
->width
,
515 fwin
->language_button
->width
);
520 if (wPreferences
.new_style
) {
521 if (!fwin
->flags
.hide_right_button
&& fwin
->right_button
522 && !fwin
->flags
.rbutton_dont_fit
) {
523 w
-= fwin
->right_button
->width
;
527 if (wPreferences
.new_style
|| fwin
->titlebar
->width
!=w
)
528 fwin
->flags
.need_texture_remake
= 1;
530 wCoreConfigure(fwin
->titlebar
, x
, 0, w
, theight
);
535 wFrameWindowHideButton(WFrameWindow
*fwin
, int flags
)
537 if ((flags
& WFF_RIGHT_BUTTON
) && fwin
->right_button
) {
538 XUnmapWindow(dpy
, fwin
->right_button
->window
);
539 fwin
->flags
.hide_right_button
= 1;
542 if ((flags
& WFF_LEFT_BUTTON
) && fwin
->left_button
) {
543 XUnmapWindow(dpy
, fwin
->left_button
->window
);
544 fwin
->flags
.hide_left_button
= 1;
547 #ifdef XKB_BUTTON_HINT
548 if ((flags
& WFF_LANGUAGE_BUTTON
) && fwin
->language_button
) {
549 XUnmapWindow(dpy
, fwin
->language_button
->window
);
550 fwin
->flags
.hide_language_button
= 1;
554 if (fwin
->titlebar
) {
555 if (wPreferences
.new_style
) {
556 updateTitlebar(fwin
);
558 #ifdef XKB_BUTTON_HINT
559 updateTitlebar(fwin
);
561 XClearWindow(dpy
, fwin
->titlebar
->window
);
562 wFrameWindowPaint(fwin
);
565 checkTitleSize(fwin
);
571 wFrameWindowShowButton(WFrameWindow
*fwin
, int flags
)
573 if ((flags
& WFF_RIGHT_BUTTON
) && fwin
->right_button
574 && fwin
->flags
.hide_right_button
) {
576 if (!fwin
->flags
.rbutton_dont_fit
)
577 XMapWindow(dpy
, fwin
->right_button
->window
);
579 fwin
->flags
.hide_right_button
= 0;
582 #ifdef XKB_BUTTON_HINT
583 if ((flags
& WFF_LANGUAGE_BUTTON
) && fwin
->language_button
584 && fwin
->flags
.hide_language_button
) {
586 if (!fwin
->flags
.languagebutton_dont_fit
)
587 XMapWindow(dpy
, fwin
->language_button
->window
);
589 fwin
->flags
.hide_language_button
= 0;
593 if ((flags
& WFF_LEFT_BUTTON
) && fwin
->left_button
594 && fwin
->flags
.hide_left_button
) {
596 if (!fwin
->flags
.lbutton_dont_fit
)
597 XMapWindow(dpy
, fwin
->left_button
->window
);
599 fwin
->flags
.hide_left_button
= 0;
603 if (fwin
->titlebar
) {
604 if (wPreferences
.new_style
) {
605 updateTitlebar(fwin
);
607 XClearWindow(dpy
, fwin
->titlebar
->window
);
608 wFrameWindowPaint(fwin
);
610 checkTitleSize(fwin
);
616 #ifdef XKB_BUTTON_HINT
617 renderTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
618 int bwidth
, int bheight
, int left
, int language
, int right
,
619 Pixmap
*title
, Pixmap
*lbutton
, Pixmap
*languagebutton
, Pixmap
*rbutton
)
621 renderTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
622 int bwidth
, int bheight
, int left
, int right
,
623 Pixmap
*title
, Pixmap
*lbutton
, Pixmap
*rbutton
)
627 RImage
*limg
, *rimg
, *mimg
;
628 #ifdef XKB_BUTTON_HINT
636 #ifdef XKB_BUTTON_HINT
637 *languagebutton
= None
;
640 img
= wTextureRenderImage(texture
, width
, height
, WREL_FLAT
);
642 wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode
));
646 if (wPreferences
.new_style
) {
648 limg
= RGetSubImage(img
, 0, 0, bwidth
, bheight
);
655 #ifdef XKB_BUTTON_HINT
657 timg
= RGetSubImage(img
, bwidth
, 0, bwidth
, bheight
);
663 RBevelImage(limg
, RBEV_RAISED2
);
664 if (!RConvertImage(scr
->rcontext
, limg
, lbutton
)) {
665 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
672 #ifdef XKB_BUTTON_HINT
674 RBevelImage(timg
, RBEV_RAISED2
);
675 if (!RConvertImage(scr
->rcontext
, timg
, languagebutton
)) {
676 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
685 rimg
= RGetSubImage(img
, width
- bwidth
, 0, bwidth
, bheight
);
690 RBevelImage(rimg
, RBEV_RAISED2
);
691 if (!RConvertImage(scr
->rcontext
, rimg
, rbutton
)) {
692 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
699 mimg
= RGetSubImage(img
, x
, 0, w
, img
->height
);
700 RBevelImage(mimg
, RBEV_RAISED2
);
702 if (!RConvertImage(scr
->rcontext
, mimg
, title
)) {
703 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
707 RBevelImage(img
, RBEV_RAISED2
);
709 if (!RConvertImage(scr
->rcontext
, img
, title
)) {
710 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
714 RBevelImage(img
, RBEV_RAISED2
);
716 if (!RConvertImage(scr
->rcontext
, img
, title
)) {
717 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
726 renderResizebarTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
727 int cwidth
, Pixmap
*pmap
)
735 img
= wTextureRenderImage(texture
, width
, height
, WREL_FLAT
);
737 wwarning(_("could not render texture: %s"),
738 RMessageForError(RErrorCode
));
743 light
.red
= light
.green
= light
.blue
= 80;
746 dark
.red
= dark
.green
= dark
.blue
= 40;
748 ROperateLine(img
, RSubtractOperation
, 0, 0, width
-1, 0, &dark
);
749 ROperateLine(img
, RAddOperation
, 0, 1, width
-1, 1, &light
);
751 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
-1, &dark
);
752 ROperateLine(img
, RAddOperation
, cwidth
+1, 2, cwidth
+1, height
-1, &light
);
755 ROperateLine(img
, RSubtractOperation
, width
-cwidth
-2, 2,
756 width
-cwidth
-2, height
-1, &dark
);
757 ROperateLine(img
, RAddOperation
, width
-cwidth
-1, 2, width
-cwidth
-1,
760 #ifdef SHADOW_RESIZEBAR
761 ROperateLine(img
, RAddOperation
, 0, 1, 0, height
-1, &light
);
762 ROperateLine(img
, RSubtractOperation
, width
-1, 1, width
-1, height
-1,
764 ROperateLine(img
, RSubtractOperation
, 0, height
-1, width
-1, height
-1,
766 #endif /* SHADOW_RESIZEBAR */
769 if (!RConvertImage(scr
->rcontext
, img
, pmap
)) {
770 wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode
));
779 updateTexture(WFrameWindow
*fwin
)
784 i
= fwin
->flags
.state
;
785 if (fwin
->titlebar
) {
786 if (fwin
->title_texture
[i
]->any
.type
!=WTEX_SOLID
) {
787 XSetWindowBackgroundPixmap(dpy
, fwin
->titlebar
->window
,
788 fwin
->title_back
[i
]);
789 if (wPreferences
.new_style
) {
790 if (fwin
->left_button
&& fwin
->lbutton_back
[i
])
791 XSetWindowBackgroundPixmap(dpy
, fwin
->left_button
->window
,
792 fwin
->lbutton_back
[i
]);
794 #ifdef XKB_BUTTON_HINT
795 if (fwin
->language_button
&& fwin
->languagebutton_back
[i
])
796 XSetWindowBackgroundPixmap(dpy
, fwin
->language_button
->window
,
797 fwin
->languagebutton_back
[i
]);
800 if (fwin
->right_button
&& fwin
->rbutton_back
[i
])
801 XSetWindowBackgroundPixmap(dpy
, fwin
->right_button
->window
,
802 fwin
->rbutton_back
[i
]);
805 pixel
= fwin
->title_texture
[i
]->solid
.normal
.pixel
;
806 XSetWindowBackground(dpy
, fwin
->titlebar
->window
, pixel
);
807 if (wPreferences
.new_style
) {
808 if (fwin
->left_button
)
809 XSetWindowBackground(dpy
, fwin
->left_button
->window
,
811 #ifdef XKB_BUTTON_HINT
812 if (fwin
->language_button
)
813 XSetWindowBackground(dpy
, fwin
->language_button
->window
,
816 if (fwin
->right_button
)
817 XSetWindowBackground(dpy
, fwin
->right_button
->window
,
821 XClearWindow(dpy
, fwin
->titlebar
->window
);
823 if (fwin
->left_button
) {
824 XClearWindow(dpy
, fwin
->left_button
->window
);
825 handleButtonExpose(&fwin
->left_button
->descriptor
, NULL
);
827 #ifdef XKB_BUTTON_HINT
828 if (fwin
->language_button
) {
829 XClearWindow(dpy
, fwin
->language_button
->window
);
830 handleButtonExpose(&fwin
->language_button
->descriptor
, NULL
);
833 if (fwin
->right_button
) {
834 XClearWindow(dpy
, fwin
->right_button
->window
);
835 handleButtonExpose(&fwin
->right_button
->descriptor
, NULL
);
843 remakeTexture(WFrameWindow
*fwin
, int state
)
845 Pixmap pmap
, lpmap
, rpmap
;
846 #ifdef XKB_BUTTON_HINT
850 if (fwin
->title_texture
[state
] && fwin
->titlebar
) {
851 FREE_PIXMAP(fwin
->title_back
[state
]);
852 if (wPreferences
.new_style
) {
853 FREE_PIXMAP(fwin
->lbutton_back
[state
]);
854 FREE_PIXMAP(fwin
->rbutton_back
[state
]);
855 #ifdef XKB_BUTTON_HINT
856 FREE_PIXMAP(fwin
->languagebutton_back
[state
]);
860 if (fwin
->title_texture
[state
]->any
.type
!=WTEX_SOLID
) {
862 #ifdef XKB_BUTTON_HINT
867 /* eventually surrounded by if new_style */
868 left
= fwin
->left_button
&& !fwin
->flags
.hide_left_button
869 && !fwin
->flags
.lbutton_dont_fit
;
870 #ifdef XKB_BUTTON_HINT
871 language
= fwin
->language_button
&& !fwin
->flags
.hide_language_button
872 && !fwin
->flags
.languagebutton_dont_fit
;
874 right
= fwin
->right_button
&& !fwin
->flags
.hide_right_button
875 && !fwin
->flags
.rbutton_dont_fit
;
877 width
= fwin
->core
->width
+1;
879 #ifdef XKB_BUTTON_HINT
880 renderTexture(fwin
->screen_ptr
, fwin
->title_texture
[state
],
881 width
, fwin
->titlebar
->height
,
882 fwin
->titlebar
->height
, fwin
->titlebar
->height
,
883 left
, language
, right
, &pmap
, &lpmap
, &tpmap
, &rpmap
);
885 renderTexture(fwin
->screen_ptr
, fwin
->title_texture
[state
],
886 width
, fwin
->titlebar
->height
,
887 fwin
->titlebar
->height
, fwin
->titlebar
->height
,
888 left
, right
, &pmap
, &lpmap
, &rpmap
);
891 fwin
->title_back
[state
] = pmap
;
892 if (wPreferences
.new_style
) {
893 fwin
->lbutton_back
[state
] = lpmap
;
894 fwin
->rbutton_back
[state
] = rpmap
;
895 #ifdef XKB_BUTTON_HINT
896 fwin
->languagebutton_back
[state
] = tpmap
;
901 if (fwin
->resizebar_texture
&& fwin
->resizebar_texture
[0]
902 && fwin
->resizebar
&& state
== 0) {
904 FREE_PIXMAP(fwin
->resizebar_back
[0]);
906 if (fwin
->resizebar_texture
[0]->any
.type
!=WTEX_SOLID
) {
908 renderResizebarTexture(fwin
->screen_ptr
,
909 fwin
->resizebar_texture
[0],
910 fwin
->resizebar
->width
,
911 fwin
->resizebar
->height
,
912 fwin
->resizebar_corner_width
,
915 fwin
->resizebar_back
[0] = pmap
;
918 /* this part should be in updateTexture() */
919 if (fwin
->resizebar_texture
[0]->any
.type
!=WTEX_SOLID
) {
920 XSetWindowBackgroundPixmap(dpy
, fwin
->resizebar
->window
,
921 fwin
->resizebar_back
[0]);
923 XSetWindowBackground(dpy
, fwin
->resizebar
->window
,
924 fwin
->resizebar_texture
[0]->solid
.normal
.pixel
);
926 XClearWindow(dpy
, fwin
->resizebar
->window
);
932 wFrameWindowPaint(WFrameWindow
*fwin
)
934 if (fwin
->flags
.is_client_window_frame
)
935 fwin
->flags
.justification
= wPreferences
.title_justification
;
937 if (fwin
->flags
.need_texture_remake
) {
940 fwin
->flags
.need_texture_remake
= 0;
941 fwin
->flags
.need_texture_change
= 0;
943 if (fwin
->flags
.single_texture
) {
944 remakeTexture(fwin
, 0);
947 /* first render the texture for the current state... */
948 remakeTexture(fwin
, fwin
->flags
.state
);
949 /* ... and paint it */
952 for (i
=0; i
< 3; i
++) {
953 if (i
!=fwin
->flags
.state
)
954 remakeTexture(fwin
, i
);
959 if (fwin
->flags
.need_texture_change
) {
960 fwin
->flags
.need_texture_change
= 0;
965 if (fwin
->titlebar
&& !fwin
->flags
.repaint_only_resizebar
966 && fwin
->title_texture
[fwin
->flags
.state
]->any
.type
==WTEX_SOLID
) {
967 wDrawBevel(fwin
->titlebar
->window
, fwin
->titlebar
->width
,
968 fwin
->titlebar
->height
,
969 (WTexSolid
*)fwin
->title_texture
[fwin
->flags
.state
],
973 if (fwin
->resizebar
&& !fwin
->flags
.repaint_only_titlebar
974 && fwin
->resizebar_texture
[0]->any
.type
== WTEX_SOLID
) {
979 WTexSolid
*texture
= (WTexSolid
*)fwin
->resizebar_texture
[0];
981 w
= fwin
->resizebar
->width
;
982 h
= fwin
->resizebar
->height
;
983 cw
= fwin
->resizebar_corner_width
;
984 light_gc
= texture
->light_gc
;
985 dim_gc
= texture
->dim_gc
;
986 win
= fwin
->resizebar
->window
;
988 XDrawLine(dpy
, win
, dim_gc
, 0, 0, w
, 0);
989 XDrawLine(dpy
, win
, light_gc
, 0, 1, w
, 1);
991 XDrawLine(dpy
, win
, dim_gc
, cw
, 2, cw
, h
);
992 XDrawLine(dpy
, win
, light_gc
, cw
+1, 2, cw
+1, h
);
994 XDrawLine(dpy
, win
, dim_gc
, w
-cw
-2, 2, w
-cw
-2, h
);
995 XDrawLine(dpy
, win
, light_gc
, w
-cw
-1, 2, w
-cw
-1, h
);
997 #ifdef SHADOW_RESIZEBAR
998 XDrawLine(dpy
, win
, light_gc
, 0, 1, 0, h
-1);
999 XDrawLine(dpy
, win
, dim_gc
, w
-1, 2, w
-1, h
-1);
1000 XDrawLine(dpy
, win
, dim_gc
, 1, h
-1, cw
, h
-1);
1001 XDrawLine(dpy
, win
, dim_gc
, cw
+2, h
-1, w
-cw
-2, h
-1);
1002 XDrawLine(dpy
, win
, dim_gc
, w
-cw
, h
-1, w
-1, h
-1);
1003 #endif /* SHADOW_RESIZEBAR */
1007 if (fwin
->title
&& fwin
->titlebar
&& !fwin
->flags
.repaint_only_resizebar
) {
1009 int lofs
= 6, rofs
= 6;
1015 if (!wPreferences
.new_style
) {
1016 if (fwin
->left_button
&& !fwin
->flags
.hide_left_button
1017 && !fwin
->flags
.lbutton_dont_fit
)
1018 lofs
+= fwin
->left_button
->width
+ 3;
1022 #ifdef XKB_BUTTON_HINT
1023 if (fwin
->language_button
&& !fwin
->flags
.hide_language_button
1024 && !fwin
->flags
.languagebutton_dont_fit
)
1025 lofs
+= fwin
->language_button
->width
;
1030 if (fwin
->right_button
&& !fwin
->flags
.hide_right_button
1031 && !fwin
->flags
.rbutton_dont_fit
)
1032 rofs
+= fwin
->right_button
->width
+ 3;
1037 #ifdef XKB_BUTTON_HINT
1038 fwin
->languagebutton_image
=
1039 fwin
->screen_ptr
->b_pixmaps
[WBUT_XKBGROUP1
+ fwin
->languagemode
];
1042 title
= ShrinkString(*fwin
->font
, fwin
->title
,
1043 fwin
->titlebar
->width
- lofs
- rofs
);
1044 titlelen
= strlen(title
);
1045 w
= wTextWidth((*fwin
->font
)->font
, title
, titlelen
);
1047 switch (fwin
->flags
.justification
) {
1053 x
= fwin
->titlebar
->width
- w
- rofs
;
1058 x
= lofs
+ (fwin
->titlebar
->width
- w
- lofs
- rofs
) / 2;
1060 x
= (fwin
->titlebar
->width
- w
) / 2;
1064 #ifdef TITLE_TEXT_SHADOW
1065 if(wPreferences
.title_shadow
){
1066 int shadowx
,shadowy
;
1067 XSetForeground(dpy
, *fwin
->title_gc
,
1068 fwin
->title_pixel
[fwin
->flags
.state
+3]);
1069 for(shadowx
=0;shadowx
<TITLE_TEXT_SHADOW_WIDTH
;shadowx
++)
1070 for(shadowy
=0;shadowy
<TITLE_TEXT_SHADOW_HEIGHT
;shadowy
++)
1071 wDrawString(fwin
->titlebar
->window
, *fwin
->font
,
1073 x
+ shadowx
+ TITLE_TEXT_SHADOW_X_OFFSET
,
1074 (*fwin
->font
)->y
+ TITLEBAR_EXTRA_HEIGHT
/2
1075 + shadowy
+ TITLE_TEXT_SHADOW_Y_OFFSET
, title
,
1078 #endif /* TITLE_TEXT_SHADOW */
1080 XSetForeground(dpy
, *fwin
->title_gc
,
1081 fwin
->title_pixel
[fwin
->flags
.state
]);
1083 wDrawString(fwin
->titlebar
->window
, *fwin
->font
,
1085 (*fwin
->font
)->y
+ TITLEBAR_EXTRA_HEIGHT
/2, title
,
1090 if (fwin
->left_button
)
1091 handleButtonExpose(&fwin
->left_button
->descriptor
, NULL
);
1092 #ifdef XKB_BUTTON_HINT
1093 if (fwin
->language_button
)
1094 handleButtonExpose(&fwin
->language_button
->descriptor
, NULL
);
1096 if (fwin
->right_button
)
1097 handleButtonExpose(&fwin
->right_button
->descriptor
, NULL
);
1103 reconfigure(WFrameWindow
*fwin
, int x
, int y
, int width
, int height
,
1106 int k
= (wPreferences
.new_style
? 4 : 3);
1107 int resizedHorizontally
= 0;
1110 XResizeWindow(dpy
, fwin
->core
->window
, width
, height
);
1112 XMoveResizeWindow(dpy
, fwin
->core
->window
, x
, y
, width
, height
);
1115 if (fwin->core->height != height && fwin->resizebar)
1116 XMoveWindow(dpy, fwin->resizebar->window, 0,
1117 height - fwin->resizebar->height);
1119 if (fwin
->core
->width
!= width
) {
1120 fwin
->flags
.need_texture_remake
= 1;
1121 resizedHorizontally
= 1;
1124 fwin
->core
->width
= width
;
1125 fwin
->core
->height
= height
;
1127 if (fwin
->titlebar
&& resizedHorizontally
) {
1128 /* Check if the titlebar is wide enough to hold the buttons.
1129 * Temporarily remove them if can't
1131 if (fwin
->left_button
) {
1132 if (width
< fwin
->top_width
*k
&& !fwin
->flags
.lbutton_dont_fit
) {
1134 if (!fwin
->flags
.hide_left_button
) {
1135 XUnmapWindow(dpy
, fwin
->left_button
->window
);
1137 fwin
->flags
.lbutton_dont_fit
= 1;
1138 } else if (width
>= fwin
->top_width
*k
&& fwin
->flags
.lbutton_dont_fit
) {
1140 if (!fwin
->flags
.hide_left_button
) {
1141 XMapWindow(dpy
, fwin
->left_button
->window
);
1143 fwin
->flags
.lbutton_dont_fit
= 0;
1147 #ifdef XKB_BUTTON_HINT
1148 if (fwin
->language_button
) {
1149 if (width
< fwin
->top_width
*k
&& !fwin
->flags
.languagebutton_dont_fit
) {
1151 if (!fwin
->flags
.hide_language_button
) {
1152 XUnmapWindow(dpy
, fwin
->language_button
->window
);
1154 fwin
->flags
.languagebutton_dont_fit
= 1;
1155 } else if (width
>= fwin
->top_width
*k
&& fwin
->flags
.languagebutton_dont_fit
) {
1157 if (!fwin
->flags
.hide_language_button
) {
1158 XMapWindow(dpy
, fwin
->language_button
->window
);
1160 fwin
->flags
.languagebutton_dont_fit
= 0;
1165 if (fwin
->right_button
) {
1166 if (width
< fwin
->top_width
*2 && !fwin
->flags
.rbutton_dont_fit
) {
1168 if (!fwin
->flags
.hide_right_button
) {
1169 XUnmapWindow(dpy
, fwin
->right_button
->window
);
1171 fwin
->flags
.rbutton_dont_fit
= 1;
1172 } else if (width
>= fwin
->top_width
*2 && fwin
->flags
.rbutton_dont_fit
) {
1174 if (!fwin
->flags
.hide_right_button
) {
1175 XMapWindow(dpy
, fwin
->right_button
->window
);
1177 fwin
->flags
.rbutton_dont_fit
= 0;
1181 if (wPreferences
.new_style
) {
1182 if (fwin
->right_button
)
1183 XMoveWindow(dpy
, fwin
->right_button
->window
,
1184 width
- fwin
->right_button
->width
+ 1, 0);
1186 if (fwin
->right_button
)
1187 XMoveWindow(dpy
, fwin
->right_button
->window
,
1188 width
- fwin
->right_button
->width
- 3,
1189 (fwin
->titlebar
->height
- fwin
->right_button
->height
)/2);
1191 updateTitlebar(fwin
);
1192 checkTitleSize(fwin
);
1195 if (fwin
->resizebar
) {
1196 wCoreConfigure(fwin
->resizebar
, 0,
1197 fwin
->core
->height
- fwin
->resizebar
->height
,
1198 fwin
->core
->width
, fwin
->resizebar
->height
);
1200 fwin
->resizebar_corner_width
= RESIZEBAR_CORNER_WIDTH
;
1201 if (fwin
->core
->width
< RESIZEBAR_CORNER_WIDTH
*2 + RESIZEBAR_MIN_WIDTH
) {
1202 fwin
->resizebar_corner_width
= fwin
->core
->width
/2;
1208 wFrameWindowConfigure(WFrameWindow
*fwin
, int x
, int y
, int width
, int height
)
1210 reconfigure(fwin
, x
, y
, width
, height
, False
);
1214 wFrameWindowResize(WFrameWindow
*fwin
, int width
, int height
)
1216 reconfigure(fwin
, 0, 0, width
, height
, True
);
1222 wFrameWindowChangeTitle(WFrameWindow
*fwin
, char *new_title
)
1224 /* check if the title is the same as before */
1226 if (new_title
&& (strcmp(fwin
->title
, new_title
) == 0)) {
1237 fwin
->title
= wstrdup(new_title
);
1239 if (fwin
->titlebar
) {
1240 XClearWindow(dpy
, fwin
->titlebar
->window
);
1242 wFrameWindowPaint(fwin
);
1244 checkTitleSize(fwin
);
1252 wFrameWindowUpdatePushButton(WFrameWindow
*fwin
, Bool pushed
)
1254 fwin
->flags
.right_button_pushed_in
= pushed
;
1256 paintButton(fwin
->right_button
, fwin
->title_texture
[fwin
->flags
.state
],
1257 fwin
->title_pixel
[fwin
->flags
.state
],
1258 fwin
->rbutton_image
, pushed
);
1260 #endif /* OLWM_HINTS */
1263 #ifdef XKB_BUTTON_HINT
1265 wFrameWindowUpdateLanguageButton(WFrameWindow
*fwin
)
1267 paintButton(fwin
->language_button
, fwin
->title_texture
[fwin
->flags
.state
],
1268 fwin
->title_pixel
[fwin
->flags
.state
],
1269 fwin
->languagebutton_image
, True
);
1271 #endif /* XKB_BUTTON_HINT */
1274 /*********************************************************************/
1277 handleExpose(WObjDescriptor
*desc
, XEvent
*event
)
1279 WFrameWindow
*fwin
= (WFrameWindow
*)desc
->parent
;
1282 if (fwin
->titlebar
&& fwin
->titlebar
->window
== event
->xexpose
.window
)
1283 fwin
->flags
.repaint_only_titlebar
= 1;
1284 if (fwin
->resizebar
&& fwin
->resizebar
->window
== event
->xexpose
.window
)
1285 fwin
->flags
.repaint_only_resizebar
= 1;
1286 wFrameWindowPaint(fwin
);
1287 fwin
->flags
.repaint_only_titlebar
= 0;
1288 fwin
->flags
.repaint_only_resizebar
= 0;
1293 checkTitleSize(WFrameWindow
*fwin
)
1298 fwin
->flags
.incomplete_title
= 0;
1302 if (!fwin
->titlebar
) {
1303 fwin
->flags
.incomplete_title
= 1;
1306 width
= fwin
->titlebar
->width
- 6 - 6;
1309 if (!wPreferences
.new_style
) {
1310 if (fwin
->left_button
&& !fwin
->flags
.hide_left_button
1311 && !fwin
->flags
.lbutton_dont_fit
)
1312 width
-= fwin
->left_button
->width
+ 3;
1314 #ifdef XKB_BUTTON_HINT
1315 if (fwin
->language_button
&& !fwin
->flags
.hide_language_button
1316 && !fwin
->flags
.languagebutton_dont_fit
)
1317 width
-= fwin
->language_button
->width
+ 3;
1320 if (fwin
->right_button
&& !fwin
->flags
.hide_right_button
1321 && !fwin
->flags
.rbutton_dont_fit
)
1322 width
-= fwin
->right_button
->width
+ 3;
1324 if (wTextWidth((*fwin
->font
)->font
, fwin
->title
,
1325 strlen(fwin
->title
)) > width
) {
1326 fwin
->flags
.incomplete_title
= 1;
1328 fwin
->flags
.incomplete_title
= 0;
1334 paintButton(WCoreWindow
*button
, WTexture
*texture
, unsigned long color
,
1335 WPixmap
*image
, int pushed
)
1337 WScreen
*scr
= button
->screen_ptr
;
1338 GC copy_gc
= scr
->copy_gc
;
1340 int left
=0, width
=0;
1342 /* setup stuff according to the state */
1345 if (image
->width
>=image
->height
*2) {
1346 /* the image contains 2 pictures: the second is for the
1348 width
= image
->width
/2;
1349 left
= image
->width
/2;
1351 width
= image
->width
;
1354 XSetClipMask(dpy
, copy_gc
, None
);
1355 XSetForeground(dpy
, copy_gc
, scr
->white_pixel
);
1357 if (wPreferences
.new_style
) {
1358 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1359 button
->width
-1, button
->height
-1);
1360 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1361 XDrawRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1362 button
->width
-1, button
->height
-1);
1364 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1365 button
->width
, button
->height
);
1366 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1367 XDrawRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1368 button
->width
, button
->height
);
1371 XClearWindow(dpy
, button
->window
);
1374 if (image
->width
>=image
->height
*2)
1375 width
= image
->width
/2;
1377 width
= image
->width
;
1381 if (wPreferences
.new_style
) {
1382 if (texture
->any
.type
==WTEX_SOLID
|| pushed
) {
1383 wDrawBevel(button
->window
, button
->width
, button
->height
,
1384 (WTexSolid
*)texture
, WREL_RAISED
);
1387 wDrawBevel(button
->window
, button
->width
, button
->height
,
1388 scr
->widget_texture
, WREL_RAISED
);
1394 XSetClipMask(dpy
, copy_gc
, image
->mask
);
1395 x
= (button
->width
- width
)/2 + d
;
1396 y
= (button
->height
- image
->height
)/2 + d
;
1397 XSetClipOrigin(dpy
, copy_gc
, x
-left
, y
);
1398 if (!wPreferences
.new_style
) {
1399 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1401 if (image
->depth
==1)
1402 XCopyPlane(dpy
, image
->image
, button
->window
, copy_gc
,
1403 left
, 0, width
, image
->height
, x
, y
, 1);
1405 XCopyArea(dpy
, image
->image
, button
->window
, copy_gc
,
1406 left
, 0, width
, image
->height
, x
, y
);
1408 XSetForeground(dpy
, copy_gc
, scr
->dark_pixel
);
1409 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1410 button
->width
, button
->height
);
1414 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1416 XSetForeground(dpy
, copy_gc
, color
);
1417 XSetBackground(dpy
, copy_gc
, texture
->any
.color
.pixel
);
1419 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1420 button
->width
, button
->height
);
1427 handleButtonExpose(WObjDescriptor
*desc
, XEvent
*event
)
1429 WFrameWindow
*fwin
= (WFrameWindow
*)desc
->parent
;
1430 WCoreWindow
*button
= (WCoreWindow
*)desc
->self
;
1432 #ifdef XKB_BUTTON_HINT
1433 if (button
== fwin
->language_button
) {
1434 if (wPreferences
.modelock
){
1435 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1436 fwin
->title_pixel
[fwin
->flags
.state
],
1437 fwin
->languagebutton_image
, False
);
1441 if (button
== fwin
->left_button
) {
1442 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1443 fwin
->title_pixel
[fwin
->flags
.state
],
1444 fwin
->lbutton_image
, False
);
1446 Bool pushed
= False
;
1449 if (fwin
->flags
.right_button_pushed_in
)
1452 /* emulate the olwm pushpin in the "out" state */
1453 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1454 fwin
->title_pixel
[fwin
->flags
.state
],
1455 fwin
->rbutton_image
, pushed
);
1461 titlebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1463 WFrameWindow
*fwin
= desc
->parent
;
1464 WCoreWindow
*titlebar
= desc
->self
;
1466 if (IsDoubleClick(fwin
->core
->screen_ptr
, event
)) {
1467 if (fwin
->on_dblclick_titlebar
)
1468 (*fwin
->on_dblclick_titlebar
)(titlebar
, fwin
->child
, event
);
1470 if (fwin
->on_mousedown_titlebar
)
1471 (*fwin
->on_mousedown_titlebar
)(titlebar
, fwin
->child
, event
);
1477 resizebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1479 WFrameWindow
*fwin
= desc
->parent
;
1480 WCoreWindow
*resizebar
= desc
->self
;
1482 if (fwin
->on_mousedown_resizebar
)
1483 (*fwin
->on_mousedown_resizebar
)(resizebar
, fwin
->child
, event
);
1488 buttonMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1490 WFrameWindow
*fwin
= desc
->parent
;
1491 WCoreWindow
*button
= desc
->self
;
1494 int done
=0, execute
=1;
1496 unsigned long pixel
;
1497 int clickButton
= event
->xbutton
.button
;
1499 if (IsDoubleClick(fwin
->core
->screen_ptr
, event
)) {
1500 if (button
== fwin
->right_button
&& fwin
->on_dblclick_right
) {
1501 (*fwin
->on_dblclick_right
)(button
, fwin
->child
, event
);
1506 if (button
== fwin
->left_button
) {
1507 image
= fwin
->lbutton_image
;
1509 image
= fwin
->rbutton_image
;
1511 #ifdef XKB_BUTTON_HINT
1512 if (button
== fwin
->language_button
) {
1513 if (!wPreferences
.modelock
) return;
1514 image
= fwin
->languagebutton_image
;
1518 pixel
= fwin
->title_pixel
[fwin
->flags
.state
];
1519 texture
= fwin
->title_texture
[fwin
->flags
.state
];
1520 paintButton(button
, texture
, pixel
, image
, True
);
1523 WMMaskEvent(dpy
, LeaveWindowMask
|EnterWindowMask
|ButtonReleaseMask
1524 |ButtonPressMask
|ExposureMask
, &ev
);
1528 paintButton(button
, texture
, pixel
, image
, False
);
1533 paintButton(button
, texture
, pixel
, image
, True
);
1540 if (ev
.xbutton
.button
== clickButton
)
1548 paintButton(button
, texture
, pixel
, image
, False
);
1551 if (button
== fwin
->left_button
) {
1552 if (fwin
->on_click_left
)
1553 (*fwin
->on_click_left
)(button
, fwin
->child
, &ev
);
1554 } else if (button
== fwin
->right_button
) {
1555 if (fwin
->on_click_right
)
1556 (*fwin
->on_click_right
)(button
, fwin
->child
, &ev
);
1558 #ifdef XKB_BUTTON_HINT
1559 else if (button
== fwin
->language_button
) {
1560 if (fwin
->on_click_language
)
1561 (*fwin
->on_click_language
)(button
, fwin
->child
, &ev
);