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
,
69 #ifdef DRAWSTRING_PLUGIN
72 GC
*gc
, WMFont
**font
)
76 fwin
= wmalloc(sizeof(WFrameWindow
));
77 memset(fwin
, 0, sizeof(WFrameWindow
));
79 fwin
->screen_ptr
= scr
;
81 fwin
->flags
.single_texture
= (flags
& WFF_SINGLE_STATE
) ? 1 : 0;
83 fwin
->title_texture
= title_texture
;
84 fwin
->resizebar_texture
= resize_texture
;
85 fwin
->title_pixel
= color
;
86 #ifdef DRAWSTRING_PLUGIN
87 fwin
->drawstring_proc_offset
= function_offset
;
91 #ifdef KEEP_XKB_LOCK_STATUS
92 fwin
->languagemode
= XkbGroup1Index
;
93 fwin
->last_languagemode
= XkbGroup2Index
;
96 fwin
->core
= wCoreCreateTopLevel(scr
, x
, y
, width
, height
,
98 if (wPreferences
.use_saveunders
) {
100 XSetWindowAttributes attribs
;
103 attribs
.save_under
= True
;
104 XChangeWindowAttributes(dpy
, fwin
->core
->window
, vmask
, &attribs
);
107 /* setup stacking information */
108 fwin
->core
->stacking
= wmalloc(sizeof(WStacking
));
109 fwin
->core
->stacking
->above
= NULL
;
110 fwin
->core
->stacking
->under
= NULL
;
111 fwin
->core
->stacking
->child_of
= NULL
;
112 fwin
->core
->stacking
->window_level
= wlevel
;
114 AddToStackList(fwin
->core
);
116 wFrameWindowUpdateBorders(fwin
, flags
);
124 wFrameWindowUpdateBorders(WFrameWindow
*fwin
, int flags
)
130 WScreen
*scr
= fwin
->screen_ptr
;
132 width
= fwin
->core
->width
;
133 if (flags
& WFF_IS_SHADED
)
136 height
= fwin
->core
->height
- fwin
->top_width
- fwin
->bottom_width
;
138 if (flags
& WFF_TITLEBAR
)
139 theight
= WMFontHeight(*fwin
->font
) + TITLEBAR_EXTRA_HEIGHT
;
143 if (wPreferences
.new_style
) {
149 if (fwin
->titlebar
) {
150 /* if we had a titlebar and is requesting for one,
151 * check if the size has changed and resize it */
152 if (flags
& WFF_TITLEBAR
) {
153 fwin
->top_width
= theight
;
155 fwin
->flags
.need_texture_remake
= 1;
157 if (wPreferences
.new_style
) {
158 if (fwin
->left_button
) {
159 wCoreConfigure(fwin
->left_button
, 0, 0, bsize
, bsize
);
161 #ifdef XKB_BUTTON_HINT
162 if (fwin
->language_button
)
163 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
164 || fwin
->flags
.lbutton_dont_fit
) {
165 wCoreConfigure(fwin
->language_button
, 0, 0, bsize
, bsize
);
167 wCoreConfigure(fwin
->language_button
, bsize
, 0, bsize
, bsize
);
172 if (fwin
->right_button
) {
173 wCoreConfigure(fwin
->right_button
, width
-bsize
+1,
176 } else { /* !new_style */
177 if (fwin
->left_button
) {
178 wCoreConfigure(fwin
->left_button
, 3, (theight
-bsize
)/2,
182 #ifdef XKB_BUTTON_HINT
183 if (fwin
->language_button
) {
184 wCoreConfigure(fwin
->language_button
, 6 + bsize
, (theight
-bsize
)/2,
190 if (fwin
->right_button
) {
191 wCoreConfigure(fwin
->right_button
, width
-bsize
-3,
192 (theight
-bsize
)/2, bsize
, bsize
);
195 updateTitlebar(fwin
);
197 /* we had a titlebar, but now we don't need it anymore */
198 for (i
=0; i
< (fwin
->flags
.single_texture
? 1 : 3); i
++) {
199 FREE_PIXMAP(fwin
->title_back
[i
]);
200 if (wPreferences
.new_style
) {
201 FREE_PIXMAP(fwin
->lbutton_back
[i
]);
202 FREE_PIXMAP(fwin
->rbutton_back
[i
]);
203 #ifdef XKB_BUTTON_HINT
204 FREE_PIXMAP(fwin
->languagebutton_back
[i
]);
208 if (fwin
->left_button
)
209 wCoreDestroy(fwin
->left_button
);
210 fwin
->left_button
= NULL
;
212 #ifdef XKB_BUTTON_HINT
213 if (fwin
->language_button
)
214 wCoreDestroy(fwin
->language_button
);
215 fwin
->language_button
= NULL
;
218 if (fwin
->right_button
)
219 wCoreDestroy(fwin
->right_button
);
220 fwin
->right_button
= NULL
;
222 wCoreDestroy(fwin
->titlebar
);
223 fwin
->titlebar
= NULL
;
228 /* if we didn't have a titlebar and are being requested for
230 if (flags
& WFF_TITLEBAR
) {
231 fwin
->top_width
= theight
;
233 fwin
->flags
.titlebar
= 1;
234 fwin
->titlebar
= wCoreCreate(fwin
->core
, 0, 0, width
+1, theight
);
236 if (flags
& WFF_LEFT_BUTTON
) {
237 fwin
->flags
.left_button
= 1;
238 if (wPreferences
.new_style
) {
239 fwin
->left_button
= wCoreCreate(fwin
->core
, 0, 0,
241 if (width
< theight
*4) {
242 fwin
->flags
.lbutton_dont_fit
= 1;
244 XMapRaised(dpy
, fwin
->left_button
->window
);
248 wCoreCreate(fwin
->titlebar
, 3, (theight
-bsize
)/2,
251 XSetWindowBackground(dpy
, fwin
->left_button
->window
,
252 scr
->widget_texture
->normal
.pixel
);
254 if (width
< theight
*3) {
255 fwin
->flags
.lbutton_dont_fit
= 1;
257 XMapRaised(dpy
, fwin
->left_button
->window
);
262 #ifdef XKB_BUTTON_HINT
263 if (flags
& WFF_LANGUAGE_BUTTON
) {
264 fwin
->flags
.language_button
= 1;
265 if (wPreferences
.new_style
) {
266 fwin
->language_button
= wCoreCreate(fwin
->core
,
267 bsize
, 0, bsize
, bsize
);
269 if (width
< theight
*4) {
270 fwin
->flags
.languagebutton_dont_fit
= 1;
272 XMapRaised(dpy
, fwin
->language_button
->window
);
275 fwin
->language_button
=
276 wCoreCreate(fwin
->titlebar
, bsize
+ 6, (theight
-bsize
)/2,
279 XSetWindowBackground(dpy
, fwin
->language_button
->window
,
280 scr
->widget_texture
->normal
.pixel
);
282 if (width
< theight
*3) {
283 fwin
->flags
.languagebutton_dont_fit
= 1;
285 XMapRaised(dpy
, fwin
->language_button
->window
);
291 if (flags
& WFF_RIGHT_BUTTON
) {
292 fwin
->flags
.right_button
= 1;
293 if (wPreferences
.new_style
) {
295 wCoreCreate(fwin
->core
, width
-bsize
+1, 0,
299 wCoreCreate(fwin
->titlebar
, width
-bsize
-3,
300 (theight
-bsize
)/2, bsize
, bsize
);
301 XSetWindowBackground(dpy
, fwin
->right_button
->window
,
302 scr
->widget_texture
->normal
.pixel
);
305 if (width
< theight
*2) {
306 fwin
->flags
.rbutton_dont_fit
= 1;
308 XMapRaised(dpy
, fwin
->right_button
->window
);
312 if (wPreferences
.new_style
)
313 updateTitlebar(fwin
);
315 XMapRaised(dpy
, fwin
->titlebar
->window
);
317 fwin
->flags
.need_texture_remake
= 1;
320 checkTitleSize(fwin
);
322 if (flags
& WFF_RESIZEBAR
) {
323 fwin
->bottom_width
= RESIZEBAR_HEIGHT
;
325 fwin
->bottom_width
= 0;
328 if (flags
& WFF_RESIZEBAR
) {
329 if (!fwin
->resizebar
) {
330 fwin
->flags
.resizebar
= 1;
331 fwin
->resizebar
= wCoreCreate(fwin
->core
, 0,
332 height
+ fwin
->top_width
,
333 width
, RESIZEBAR_HEIGHT
);
334 fwin
->resizebar_corner_width
= RESIZEBAR_CORNER_WIDTH
;
335 if (width
< RESIZEBAR_CORNER_WIDTH
*2 + RESIZEBAR_MIN_WIDTH
) {
336 fwin
->resizebar_corner_width
= (width
- RESIZEBAR_MIN_WIDTH
)/2;
337 if (fwin
->resizebar_corner_width
< 0)
338 fwin
->resizebar_corner_width
= 0;
341 XMapWindow(dpy
, fwin
->resizebar
->window
);
342 XLowerWindow(dpy
, fwin
->resizebar
->window
);
344 fwin
->flags
.need_texture_remake
= 1;
346 if (height
+fwin
->top_width
+fwin
->bottom_width
!= fwin
->core
->height
) {
347 wCoreConfigure(fwin
->resizebar
, 0, height
+ fwin
->top_width
,
348 width
, RESIZEBAR_HEIGHT
);
352 if (fwin
->resizebar
) {
353 fwin
->bottom_width
= 0;
354 wCoreDestroy(fwin
->resizebar
);
355 fwin
->resizebar
= NULL
;
359 if (height
+ fwin
->top_width
+ fwin
->bottom_width
!= fwin
->core
->height
360 && !(flags
& WFF_IS_SHADED
)) {
361 wFrameWindowResize(fwin
, width
,
362 height
+ fwin
->top_width
+ fwin
->bottom_width
);
365 /* setup object descriptors */
367 if (fwin
->titlebar
) {
368 fwin
->titlebar
->descriptor
.handle_expose
= handleExpose
;
369 fwin
->titlebar
->descriptor
.parent
= fwin
;
370 fwin
->titlebar
->descriptor
.parent_type
= WCLASS_FRAME
;
371 fwin
->titlebar
->descriptor
.handle_mousedown
= titlebarMouseDown
;
374 if (fwin
->resizebar
) {
375 fwin
->resizebar
->descriptor
.handle_expose
= handleExpose
;
376 fwin
->resizebar
->descriptor
.parent
= fwin
;
377 fwin
->resizebar
->descriptor
.parent_type
= WCLASS_FRAME
;
378 fwin
->resizebar
->descriptor
.handle_mousedown
= resizebarMouseDown
;
381 if (fwin
->left_button
) {
382 fwin
->left_button
->descriptor
.handle_expose
= handleButtonExpose
;
383 fwin
->left_button
->descriptor
.parent
= fwin
;
384 fwin
->left_button
->descriptor
.parent_type
= WCLASS_FRAME
;
385 fwin
->left_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
388 #ifdef XKB_BUTTON_HINT
389 if (fwin
->language_button
) {
390 fwin
->language_button
->descriptor
.handle_expose
= handleButtonExpose
;
391 fwin
->language_button
->descriptor
.parent
= fwin
;
392 fwin
->language_button
->descriptor
.parent_type
= WCLASS_FRAME
;
393 fwin
->language_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
398 if (fwin
->right_button
) {
399 fwin
->right_button
->descriptor
.parent
= fwin
;
400 fwin
->right_button
->descriptor
.parent_type
= WCLASS_FRAME
;
401 fwin
->right_button
->descriptor
.handle_expose
= handleButtonExpose
;
402 fwin
->right_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
405 checkTitleSize(fwin
);
411 wFrameWindowDestroy(WFrameWindow
*fwin
)
415 if (fwin
->left_button
)
416 wCoreDestroy(fwin
->left_button
);
418 #ifdef XKB_BUTTON_HINT
419 if (fwin
->language_button
)
420 wCoreDestroy(fwin
->language_button
);
423 if (fwin
->right_button
)
424 wCoreDestroy(fwin
->right_button
);
427 wCoreDestroy(fwin
->resizebar
);
430 wCoreDestroy(fwin
->titlebar
);
432 RemoveFromStackList(fwin
->core
);
434 wCoreDestroy(fwin
->core
);
439 for (i
=0; i
< (fwin
->flags
.single_texture
? 1 : 3); i
++) {
440 FREE_PIXMAP(fwin
->title_back
[i
]);
441 if (wPreferences
.new_style
) {
442 FREE_PIXMAP(fwin
->lbutton_back
[i
]);
443 #ifdef XKB_BUTTON_HINT
444 FREE_PIXMAP(fwin
->languagebutton_back
[i
]);
446 FREE_PIXMAP(fwin
->rbutton_back
[i
]);
455 wFrameWindowChangeState(WFrameWindow
*fwin
, int state
)
457 if (fwin
->flags
.state
==state
)
460 fwin
->flags
.state
= state
;
461 fwin
->flags
.need_texture_change
= 1;
463 wFrameWindowPaint(fwin
);
468 updateTitlebar(WFrameWindow
*fwin
)
473 theight
= WMFontHeight(*fwin
->font
) + TITLEBAR_EXTRA_HEIGHT
;
476 w
= fwin
->core
->width
+ 1;
478 if (wPreferences
.new_style
) {
479 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
480 || fwin
->flags
.lbutton_dont_fit
) {
482 #ifdef XKB_BUTTON_HINT
483 if(fwin
->language_button
)
484 wCoreConfigure(fwin
->language_button
, 0, 0,
485 fwin
->language_button
->width
,
486 fwin
->language_button
->width
);
489 #ifdef XKB_BUTTON_HINT
490 if(fwin
->language_button
)
491 wCoreConfigure(fwin
->language_button
, fwin
->left_button
->width
, 0,
492 fwin
->language_button
->width
,
493 fwin
->language_button
->width
);
495 x
= fwin
->left_button
->width
;
496 w
-= fwin
->left_button
->width
;
498 #ifdef XKB_BUTTON_HINT
499 if (fwin
->flags
.hide_language_button
|| !fwin
->language_button
500 || fwin
->flags
.languagebutton_dont_fit
) {
502 x
+= fwin
->language_button
->width
;
503 w
-= fwin
->language_button
->width
;
507 #ifdef XKB_BUTTON_HINT
509 int bsize
= theight
- 7;
510 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
511 || fwin
->flags
.lbutton_dont_fit
) {
512 if(fwin
->language_button
)
513 wCoreConfigure(fwin
->language_button
, 3, (theight
-bsize
)/2,
514 fwin
->language_button
->width
,
515 fwin
->language_button
->width
);
518 if(fwin
->language_button
)
519 wCoreConfigure(fwin
->language_button
,
520 6 + fwin
->left_button
->width
, (theight
-bsize
)/2,
521 fwin
->language_button
->width
,
522 fwin
->language_button
->width
);
527 if (wPreferences
.new_style
) {
528 if (!fwin
->flags
.hide_right_button
&& fwin
->right_button
529 && !fwin
->flags
.rbutton_dont_fit
) {
530 w
-= fwin
->right_button
->width
;
534 if (wPreferences
.new_style
|| fwin
->titlebar
->width
!=w
)
535 fwin
->flags
.need_texture_remake
= 1;
537 wCoreConfigure(fwin
->titlebar
, x
, 0, w
, theight
);
542 wFrameWindowHideButton(WFrameWindow
*fwin
, int flags
)
544 if ((flags
& WFF_RIGHT_BUTTON
) && fwin
->right_button
) {
545 XUnmapWindow(dpy
, fwin
->right_button
->window
);
546 fwin
->flags
.hide_right_button
= 1;
549 if ((flags
& WFF_LEFT_BUTTON
) && fwin
->left_button
) {
550 XUnmapWindow(dpy
, fwin
->left_button
->window
);
551 fwin
->flags
.hide_left_button
= 1;
554 #ifdef XKB_BUTTON_HINT
555 if ((flags
& WFF_LANGUAGE_BUTTON
) && fwin
->language_button
) {
556 XUnmapWindow(dpy
, fwin
->language_button
->window
);
557 fwin
->flags
.hide_language_button
= 1;
561 if (fwin
->titlebar
) {
562 if (wPreferences
.new_style
) {
563 updateTitlebar(fwin
);
565 #ifdef XKB_BUTTON_HINT
566 updateTitlebar(fwin
);
568 XClearWindow(dpy
, fwin
->titlebar
->window
);
569 wFrameWindowPaint(fwin
);
572 checkTitleSize(fwin
);
578 wFrameWindowShowButton(WFrameWindow
*fwin
, int flags
)
580 if ((flags
& WFF_RIGHT_BUTTON
) && fwin
->right_button
581 && fwin
->flags
.hide_right_button
) {
583 if (!fwin
->flags
.rbutton_dont_fit
)
584 XMapWindow(dpy
, fwin
->right_button
->window
);
586 fwin
->flags
.hide_right_button
= 0;
589 #ifdef XKB_BUTTON_HINT
590 if ((flags
& WFF_LANGUAGE_BUTTON
) && fwin
->language_button
591 && fwin
->flags
.hide_language_button
) {
593 if (!fwin
->flags
.languagebutton_dont_fit
)
594 XMapWindow(dpy
, fwin
->language_button
->window
);
596 fwin
->flags
.hide_language_button
= 0;
600 if ((flags
& WFF_LEFT_BUTTON
) && fwin
->left_button
601 && fwin
->flags
.hide_left_button
) {
603 if (!fwin
->flags
.lbutton_dont_fit
)
604 XMapWindow(dpy
, fwin
->left_button
->window
);
606 fwin
->flags
.hide_left_button
= 0;
610 if (fwin
->titlebar
) {
611 if (wPreferences
.new_style
) {
612 updateTitlebar(fwin
);
614 XClearWindow(dpy
, fwin
->titlebar
->window
);
615 wFrameWindowPaint(fwin
);
617 checkTitleSize(fwin
);
623 #ifdef XKB_BUTTON_HINT
624 renderTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
625 int bwidth
, int bheight
, int left
, int language
, int right
,
626 Pixmap
*title
, Pixmap
*lbutton
, Pixmap
*languagebutton
, Pixmap
*rbutton
)
628 renderTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
629 int bwidth
, int bheight
, int left
, int right
,
630 Pixmap
*title
, Pixmap
*lbutton
, Pixmap
*rbutton
)
634 RImage
*limg
, *rimg
, *mimg
;
635 #ifdef XKB_BUTTON_HINT
643 #ifdef XKB_BUTTON_HINT
644 *languagebutton
= None
;
647 img
= wTextureRenderImage(texture
, width
, height
, WREL_FLAT
);
649 wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode
));
653 if (wPreferences
.new_style
) {
655 limg
= RGetSubImage(img
, 0, 0, bwidth
, bheight
);
662 #ifdef XKB_BUTTON_HINT
664 timg
= RGetSubImage(img
, bwidth
* left
, 0, bwidth
, bheight
);
670 RBevelImage(limg
, RBEV_RAISED2
);
671 if (!RConvertImage(scr
->rcontext
, limg
, lbutton
)) {
672 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
679 #ifdef XKB_BUTTON_HINT
681 RBevelImage(timg
, RBEV_RAISED2
);
682 if (!RConvertImage(scr
->rcontext
, timg
, languagebutton
)) {
683 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
692 rimg
= RGetSubImage(img
, width
- bwidth
, 0, bwidth
, bheight
);
697 RBevelImage(rimg
, RBEV_RAISED2
);
698 if (!RConvertImage(scr
->rcontext
, rimg
, rbutton
)) {
699 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
706 mimg
= RGetSubImage(img
, x
, 0, w
, img
->height
);
707 RBevelImage(mimg
, RBEV_RAISED2
);
709 if (!RConvertImage(scr
->rcontext
, mimg
, 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
));
721 RBevelImage(img
, RBEV_RAISED2
);
723 if (!RConvertImage(scr
->rcontext
, img
, title
)) {
724 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
733 renderResizebarTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
734 int cwidth
, Pixmap
*pmap
)
742 img
= wTextureRenderImage(texture
, width
, height
, WREL_FLAT
);
744 wwarning(_("could not render texture: %s"),
745 RMessageForError(RErrorCode
));
750 light
.red
= light
.green
= light
.blue
= 80;
753 dark
.red
= dark
.green
= dark
.blue
= 40;
755 ROperateLine(img
, RSubtractOperation
, 0, 0, width
-1, 0, &dark
);
756 ROperateLine(img
, RAddOperation
, 0, 1, width
-1, 1, &light
);
758 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
-1, &dark
);
759 ROperateLine(img
, RAddOperation
, cwidth
+1, 2, cwidth
+1, height
-1, &light
);
762 ROperateLine(img
, RSubtractOperation
, width
-cwidth
-2, 2,
763 width
-cwidth
-2, height
-1, &dark
);
764 ROperateLine(img
, RAddOperation
, width
-cwidth
-1, 2, width
-cwidth
-1,
767 #ifdef SHADOW_RESIZEBAR
768 ROperateLine(img
, RAddOperation
, 0, 1, 0, height
-1, &light
);
769 ROperateLine(img
, RSubtractOperation
, width
-1, 1, width
-1, height
-1,
771 ROperateLine(img
, RSubtractOperation
, 0, height
-1, width
-1, height
-1,
773 #endif /* SHADOW_RESIZEBAR */
776 if (!RConvertImage(scr
->rcontext
, img
, pmap
)) {
777 wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode
));
786 updateTexture(WFrameWindow
*fwin
)
791 i
= fwin
->flags
.state
;
792 if (fwin
->titlebar
) {
793 if (fwin
->title_texture
[i
]->any
.type
!=WTEX_SOLID
) {
794 XSetWindowBackgroundPixmap(dpy
, fwin
->titlebar
->window
,
795 fwin
->title_back
[i
]);
796 if (wPreferences
.new_style
) {
797 if (fwin
->left_button
&& fwin
->lbutton_back
[i
])
798 XSetWindowBackgroundPixmap(dpy
, fwin
->left_button
->window
,
799 fwin
->lbutton_back
[i
]);
801 #ifdef XKB_BUTTON_HINT
802 if (fwin
->language_button
&& fwin
->languagebutton_back
[i
]) {
803 XSetWindowBackgroundPixmap(dpy
, fwin
->language_button
->window
,
804 fwin
->languagebutton_back
[i
]);
808 if (fwin
->right_button
&& fwin
->rbutton_back
[i
])
809 XSetWindowBackgroundPixmap(dpy
, fwin
->right_button
->window
,
810 fwin
->rbutton_back
[i
]);
813 pixel
= fwin
->title_texture
[i
]->solid
.normal
.pixel
;
814 XSetWindowBackground(dpy
, fwin
->titlebar
->window
, pixel
);
815 if (wPreferences
.new_style
) {
816 if (fwin
->left_button
)
817 XSetWindowBackground(dpy
, fwin
->left_button
->window
,
819 #ifdef XKB_BUTTON_HINT
820 if (fwin
->language_button
)
821 XSetWindowBackground(dpy
, fwin
->language_button
->window
,
824 if (fwin
->right_button
)
825 XSetWindowBackground(dpy
, fwin
->right_button
->window
,
829 XClearWindow(dpy
, fwin
->titlebar
->window
);
831 if (fwin
->left_button
) {
832 XClearWindow(dpy
, fwin
->left_button
->window
);
833 handleButtonExpose(&fwin
->left_button
->descriptor
, NULL
);
835 #ifdef XKB_BUTTON_HINT
836 if (fwin
->language_button
) {
837 XClearWindow(dpy
, fwin
->language_button
->window
);
838 handleButtonExpose(&fwin
->language_button
->descriptor
, NULL
);
841 if (fwin
->right_button
) {
842 XClearWindow(dpy
, fwin
->right_button
->window
);
843 handleButtonExpose(&fwin
->right_button
->descriptor
, NULL
);
851 remakeTexture(WFrameWindow
*fwin
, int state
)
853 Pixmap pmap
, lpmap
, rpmap
;
854 #ifdef XKB_BUTTON_HINT
858 if (fwin
->title_texture
[state
] && fwin
->titlebar
) {
859 FREE_PIXMAP(fwin
->title_back
[state
]);
860 if (wPreferences
.new_style
) {
861 FREE_PIXMAP(fwin
->lbutton_back
[state
]);
862 FREE_PIXMAP(fwin
->rbutton_back
[state
]);
863 #ifdef XKB_BUTTON_HINT
864 FREE_PIXMAP(fwin
->languagebutton_back
[state
]);
868 if (fwin
->title_texture
[state
]->any
.type
!=WTEX_SOLID
) {
870 #ifdef XKB_BUTTON_HINT
875 /* eventually surrounded by if new_style */
876 left
= fwin
->left_button
&& !fwin
->flags
.hide_left_button
877 && !fwin
->flags
.lbutton_dont_fit
;
878 #ifdef XKB_BUTTON_HINT
879 language
= fwin
->language_button
&& !fwin
->flags
.hide_language_button
880 && !fwin
->flags
.languagebutton_dont_fit
;
882 right
= fwin
->right_button
&& !fwin
->flags
.hide_right_button
883 && !fwin
->flags
.rbutton_dont_fit
;
885 width
= fwin
->core
->width
+1;
887 #ifdef XKB_BUTTON_HINT
888 renderTexture(fwin
->screen_ptr
, fwin
->title_texture
[state
],
889 width
, fwin
->titlebar
->height
,
890 fwin
->titlebar
->height
, fwin
->titlebar
->height
,
891 left
, language
, right
, &pmap
, &lpmap
, &tpmap
, &rpmap
);
893 renderTexture(fwin
->screen_ptr
, fwin
->title_texture
[state
],
894 width
, fwin
->titlebar
->height
,
895 fwin
->titlebar
->height
, fwin
->titlebar
->height
,
896 left
, right
, &pmap
, &lpmap
, &rpmap
);
899 fwin
->title_back
[state
] = pmap
;
900 if (wPreferences
.new_style
) {
901 fwin
->lbutton_back
[state
] = lpmap
;
902 fwin
->rbutton_back
[state
] = rpmap
;
903 #ifdef XKB_BUTTON_HINT
904 fwin
->languagebutton_back
[state
] = tpmap
;
909 if (fwin
->resizebar_texture
&& fwin
->resizebar_texture
[0]
910 && fwin
->resizebar
&& state
== 0) {
912 FREE_PIXMAP(fwin
->resizebar_back
[0]);
914 if (fwin
->resizebar_texture
[0]->any
.type
!=WTEX_SOLID
) {
916 renderResizebarTexture(fwin
->screen_ptr
,
917 fwin
->resizebar_texture
[0],
918 fwin
->resizebar
->width
,
919 fwin
->resizebar
->height
,
920 fwin
->resizebar_corner_width
,
923 fwin
->resizebar_back
[0] = pmap
;
926 /* this part should be in updateTexture() */
927 if (fwin
->resizebar_texture
[0]->any
.type
!=WTEX_SOLID
) {
928 XSetWindowBackgroundPixmap(dpy
, fwin
->resizebar
->window
,
929 fwin
->resizebar_back
[0]);
931 XSetWindowBackground(dpy
, fwin
->resizebar
->window
,
932 fwin
->resizebar_texture
[0]->solid
.normal
.pixel
);
934 XClearWindow(dpy
, fwin
->resizebar
->window
);
940 wFrameWindowPaint(WFrameWindow
*fwin
)
942 WScreen
*scr
= fwin
->screen_ptr
;
944 if (fwin
->flags
.is_client_window_frame
)
945 fwin
->flags
.justification
= wPreferences
.title_justification
;
947 if (fwin
->flags
.need_texture_remake
) {
950 fwin
->flags
.need_texture_remake
= 0;
951 fwin
->flags
.need_texture_change
= 0;
953 if (fwin
->flags
.single_texture
) {
954 remakeTexture(fwin
, 0);
957 /* first render the texture for the current state... */
958 remakeTexture(fwin
, fwin
->flags
.state
);
959 /* ... and paint it */
962 for (i
=0; i
< 3; i
++) {
963 if (i
!=fwin
->flags
.state
)
964 remakeTexture(fwin
, i
);
969 if (fwin
->flags
.need_texture_change
) {
970 fwin
->flags
.need_texture_change
= 0;
975 if (fwin
->titlebar
&& !fwin
->flags
.repaint_only_resizebar
976 && fwin
->title_texture
[fwin
->flags
.state
]->any
.type
==WTEX_SOLID
) {
977 wDrawBevel(fwin
->titlebar
->window
, fwin
->titlebar
->width
,
978 fwin
->titlebar
->height
,
979 (WTexSolid
*)fwin
->title_texture
[fwin
->flags
.state
],
983 if (fwin
->resizebar
&& !fwin
->flags
.repaint_only_titlebar
984 && fwin
->resizebar_texture
[0]->any
.type
== WTEX_SOLID
) {
989 WTexSolid
*texture
= (WTexSolid
*)fwin
->resizebar_texture
[0];
991 w
= fwin
->resizebar
->width
;
992 h
= fwin
->resizebar
->height
;
993 cw
= fwin
->resizebar_corner_width
;
994 light_gc
= texture
->light_gc
;
995 dim_gc
= texture
->dim_gc
;
996 win
= fwin
->resizebar
->window
;
998 XDrawLine(dpy
, win
, dim_gc
, 0, 0, w
, 0);
999 XDrawLine(dpy
, win
, light_gc
, 0, 1, w
, 1);
1001 XDrawLine(dpy
, win
, dim_gc
, cw
, 2, cw
, h
);
1002 XDrawLine(dpy
, win
, light_gc
, cw
+1, 2, cw
+1, h
);
1004 XDrawLine(dpy
, win
, dim_gc
, w
-cw
-2, 2, w
-cw
-2, h
);
1005 XDrawLine(dpy
, win
, light_gc
, w
-cw
-1, 2, w
-cw
-1, h
);
1007 #ifdef SHADOW_RESIZEBAR
1008 XDrawLine(dpy
, win
, light_gc
, 0, 1, 0, h
-1);
1009 XDrawLine(dpy
, win
, dim_gc
, w
-1, 2, w
-1, h
-1);
1010 XDrawLine(dpy
, win
, dim_gc
, 1, h
-1, cw
, h
-1);
1011 XDrawLine(dpy
, win
, dim_gc
, cw
+2, h
-1, w
-cw
-2, h
-1);
1012 XDrawLine(dpy
, win
, dim_gc
, w
-cw
, h
-1, w
-1, h
-1);
1013 #endif /* SHADOW_RESIZEBAR */
1017 if (fwin
->title
&& fwin
->titlebar
&& !fwin
->flags
.repaint_only_resizebar
) {
1019 int lofs
= 6, rofs
= 6;
1025 if (!wPreferences
.new_style
) {
1026 if (fwin
->left_button
&& !fwin
->flags
.hide_left_button
1027 && !fwin
->flags
.lbutton_dont_fit
)
1028 lofs
+= fwin
->left_button
->width
+ 3;
1032 #ifdef XKB_BUTTON_HINT
1033 if (fwin
->language_button
&& !fwin
->flags
.hide_language_button
1034 && !fwin
->flags
.languagebutton_dont_fit
)
1035 lofs
+= fwin
->language_button
->width
;
1040 if (fwin
->right_button
&& !fwin
->flags
.hide_right_button
1041 && !fwin
->flags
.rbutton_dont_fit
)
1042 rofs
+= fwin
->right_button
->width
+ 3;
1047 #ifdef XKB_BUTTON_HINT
1048 fwin
->languagebutton_image
=
1049 scr
->b_pixmaps
[WBUT_XKBGROUP1
+ fwin
->languagemode
];
1052 title
= ShrinkString(*fwin
->font
, fwin
->title
,
1053 fwin
->titlebar
->width
- lofs
- rofs
);
1054 titlelen
= strlen(title
);
1055 w
= WMWidthOfString(*fwin
->font
, title
, titlelen
);
1057 switch (fwin
->flags
.justification
) {
1063 x
= fwin
->titlebar
->width
- w
- rofs
;
1068 x
= lofs
+ (fwin
->titlebar
->width
- w
- lofs
- rofs
) / 2;
1070 x
= (fwin
->titlebar
->width
- w
) / 2;
1075 XSetForeground(dpy
, *fwin
->title_gc
,
1076 fwin
->title_pixel
[fwin
->flags
.state
]);
1078 #ifdef DRAWSTRING_PLUGIN
1079 if (scr
->drawstring_func
[fwin
->flags
.state
+ fwin
->drawstring_proc_offset
]) {
1080 scr
->drawstring_func
[fwin
->flags
.state
+ fwin
->drawstring_proc_offset
]->
1081 proc
.drawString(scr
->drawstring_func
[fwin
->flags
.state
1082 + fwin
->drawstring_proc_offset
]->arg
,
1083 fwin
->titlebar
->window
, *fwin
->title_gc
,
1084 *fwin
->font
, x
, TITLEBAR_EXTRA_HEIGHT
/2,
1085 fwin
->titlebar
->width
, fwin
->top_width
, title
, titlelen
);
1087 WMDrawString(scr
->wmscreen
, fwin
->titlebar
->window
,
1088 *fwin
->title_gc
, *fwin
->font
, x
, TITLEBAR_EXTRA_HEIGHT
/2,
1092 WMDrawString(scr
->wmscreen
, fwin
->titlebar
->window
,
1093 *fwin
->title_gc
, *fwin
->font
, x
, TITLEBAR_EXTRA_HEIGHT
/2,
1095 #endif /* DRAWSTRING_PLUGIN */
1099 if (fwin
->left_button
)
1100 handleButtonExpose(&fwin
->left_button
->descriptor
, NULL
);
1101 if (fwin
->right_button
)
1102 handleButtonExpose(&fwin
->right_button
->descriptor
, NULL
);
1103 #ifdef XKB_BUTTON_HINT
1104 if (fwin
->language_button
)
1105 handleButtonExpose(&fwin
->language_button
->descriptor
, NULL
);
1112 reconfigure(WFrameWindow
*fwin
, int x
, int y
, int width
, int height
,
1115 int k
= (wPreferences
.new_style
? 4 : 3);
1116 int resizedHorizontally
= 0;
1119 XResizeWindow(dpy
, fwin
->core
->window
, width
, height
);
1121 XMoveResizeWindow(dpy
, fwin
->core
->window
, x
, y
, width
, height
);
1124 if (fwin->core->height != height && fwin->resizebar)
1125 XMoveWindow(dpy, fwin->resizebar->window, 0,
1126 height - fwin->resizebar->height);
1128 if (fwin
->core
->width
!= width
) {
1129 fwin
->flags
.need_texture_remake
= 1;
1130 resizedHorizontally
= 1;
1133 fwin
->core
->width
= width
;
1134 fwin
->core
->height
= height
;
1136 if (fwin
->titlebar
&& resizedHorizontally
) {
1137 /* Check if the titlebar is wide enough to hold the buttons.
1138 * Temporarily remove them if can't
1140 if (fwin
->left_button
) {
1141 if (width
< fwin
->top_width
*k
&& !fwin
->flags
.lbutton_dont_fit
) {
1143 if (!fwin
->flags
.hide_left_button
) {
1144 XUnmapWindow(dpy
, fwin
->left_button
->window
);
1146 fwin
->flags
.lbutton_dont_fit
= 1;
1147 } else if (width
>= fwin
->top_width
*k
&& fwin
->flags
.lbutton_dont_fit
) {
1149 if (!fwin
->flags
.hide_left_button
) {
1150 XMapWindow(dpy
, fwin
->left_button
->window
);
1152 fwin
->flags
.lbutton_dont_fit
= 0;
1156 #ifdef XKB_BUTTON_HINT
1157 if (fwin
->language_button
) {
1158 if (width
< fwin
->top_width
*k
&& !fwin
->flags
.languagebutton_dont_fit
) {
1160 if (!fwin
->flags
.hide_language_button
) {
1161 XUnmapWindow(dpy
, fwin
->language_button
->window
);
1163 fwin
->flags
.languagebutton_dont_fit
= 1;
1164 } else if (width
>= fwin
->top_width
*k
&& fwin
->flags
.languagebutton_dont_fit
) {
1166 if (!fwin
->flags
.hide_language_button
) {
1167 XMapWindow(dpy
, fwin
->language_button
->window
);
1169 fwin
->flags
.languagebutton_dont_fit
= 0;
1174 if (fwin
->right_button
) {
1175 if (width
< fwin
->top_width
*2 && !fwin
->flags
.rbutton_dont_fit
) {
1177 if (!fwin
->flags
.hide_right_button
) {
1178 XUnmapWindow(dpy
, fwin
->right_button
->window
);
1180 fwin
->flags
.rbutton_dont_fit
= 1;
1181 } else if (width
>= fwin
->top_width
*2 && fwin
->flags
.rbutton_dont_fit
) {
1183 if (!fwin
->flags
.hide_right_button
) {
1184 XMapWindow(dpy
, fwin
->right_button
->window
);
1186 fwin
->flags
.rbutton_dont_fit
= 0;
1190 if (wPreferences
.new_style
) {
1191 if (fwin
->right_button
)
1192 XMoveWindow(dpy
, fwin
->right_button
->window
,
1193 width
- fwin
->right_button
->width
+ 1, 0);
1195 if (fwin
->right_button
)
1196 XMoveWindow(dpy
, fwin
->right_button
->window
,
1197 width
- fwin
->right_button
->width
- 3,
1198 (fwin
->titlebar
->height
- fwin
->right_button
->height
)/2);
1200 updateTitlebar(fwin
);
1201 checkTitleSize(fwin
);
1204 if (fwin
->resizebar
) {
1205 wCoreConfigure(fwin
->resizebar
, 0,
1206 fwin
->core
->height
- fwin
->resizebar
->height
,
1207 fwin
->core
->width
, fwin
->resizebar
->height
);
1209 fwin
->resizebar_corner_width
= RESIZEBAR_CORNER_WIDTH
;
1210 if (fwin
->core
->width
< RESIZEBAR_CORNER_WIDTH
*2 + RESIZEBAR_MIN_WIDTH
) {
1211 fwin
->resizebar_corner_width
= fwin
->core
->width
/2;
1217 wFrameWindowConfigure(WFrameWindow
*fwin
, int x
, int y
, int width
, int height
)
1219 reconfigure(fwin
, x
, y
, width
, height
, False
);
1223 wFrameWindowResize(WFrameWindow
*fwin
, int width
, int height
)
1225 reconfigure(fwin
, 0, 0, width
, height
, True
);
1231 wFrameWindowChangeTitle(WFrameWindow
*fwin
, char *new_title
)
1233 /* check if the title is the same as before */
1235 if (new_title
&& (strcmp(fwin
->title
, new_title
) == 0)) {
1246 fwin
->title
= wstrdup(new_title
);
1248 if (fwin
->titlebar
) {
1249 XClearWindow(dpy
, fwin
->titlebar
->window
);
1251 wFrameWindowPaint(fwin
);
1253 checkTitleSize(fwin
);
1261 wFrameWindowUpdatePushButton(WFrameWindow
*fwin
, Bool pushed
)
1263 fwin
->flags
.right_button_pushed_in
= pushed
;
1265 paintButton(fwin
->right_button
, fwin
->title_texture
[fwin
->flags
.state
],
1266 fwin
->title_pixel
[fwin
->flags
.state
],
1267 fwin
->rbutton_image
, pushed
);
1269 #endif /* OLWM_HINTS */
1272 #ifdef XKB_BUTTON_HINT
1274 wFrameWindowUpdateLanguageButton(WFrameWindow
*fwin
)
1276 paintButton(fwin
->language_button
, fwin
->title_texture
[fwin
->flags
.state
],
1277 fwin
->title_pixel
[fwin
->flags
.state
],
1278 fwin
->languagebutton_image
, True
);
1280 #endif /* XKB_BUTTON_HINT */
1283 /*********************************************************************/
1286 handleExpose(WObjDescriptor
*desc
, XEvent
*event
)
1288 WFrameWindow
*fwin
= (WFrameWindow
*)desc
->parent
;
1291 if (fwin
->titlebar
&& fwin
->titlebar
->window
== event
->xexpose
.window
)
1292 fwin
->flags
.repaint_only_titlebar
= 1;
1293 if (fwin
->resizebar
&& fwin
->resizebar
->window
== event
->xexpose
.window
)
1294 fwin
->flags
.repaint_only_resizebar
= 1;
1295 wFrameWindowPaint(fwin
);
1296 fwin
->flags
.repaint_only_titlebar
= 0;
1297 fwin
->flags
.repaint_only_resizebar
= 0;
1302 checkTitleSize(WFrameWindow
*fwin
)
1307 fwin
->flags
.incomplete_title
= 0;
1311 if (!fwin
->titlebar
) {
1312 fwin
->flags
.incomplete_title
= 1;
1315 width
= fwin
->titlebar
->width
- 6 - 6;
1318 if (!wPreferences
.new_style
) {
1319 if (fwin
->left_button
&& !fwin
->flags
.hide_left_button
1320 && !fwin
->flags
.lbutton_dont_fit
)
1321 width
-= fwin
->left_button
->width
+ 3;
1323 #ifdef XKB_BUTTON_HINT
1324 if (fwin
->language_button
&& !fwin
->flags
.hide_language_button
1325 && !fwin
->flags
.languagebutton_dont_fit
)
1326 width
-= fwin
->language_button
->width
+ 3;
1329 if (fwin
->right_button
&& !fwin
->flags
.hide_right_button
1330 && !fwin
->flags
.rbutton_dont_fit
)
1331 width
-= fwin
->right_button
->width
+ 3;
1333 if (WMWidthOfString(*fwin
->font
, fwin
->title
, strlen(fwin
->title
)) > width
) {
1334 fwin
->flags
.incomplete_title
= 1;
1336 fwin
->flags
.incomplete_title
= 0;
1342 paintButton(WCoreWindow
*button
, WTexture
*texture
, unsigned long color
,
1343 WPixmap
*image
, int pushed
)
1345 WScreen
*scr
= button
->screen_ptr
;
1346 GC copy_gc
= scr
->copy_gc
;
1348 int left
=0, width
=0;
1350 /* setup stuff according to the state */
1353 if (image
->width
>=image
->height
*2) {
1354 /* the image contains 2 pictures: the second is for the
1356 width
= image
->width
/2;
1357 left
= image
->width
/2;
1359 width
= image
->width
;
1362 XSetClipMask(dpy
, copy_gc
, None
);
1363 XSetForeground(dpy
, copy_gc
, scr
->white_pixel
);
1365 if (wPreferences
.new_style
) {
1366 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1367 button
->width
-1, button
->height
-1);
1368 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1369 XDrawRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1370 button
->width
-1, button
->height
-1);
1372 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1373 button
->width
, button
->height
);
1374 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1375 XDrawRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1376 button
->width
, button
->height
);
1379 XClearWindow(dpy
, button
->window
);
1382 if (image
->width
>=image
->height
*2)
1383 width
= image
->width
/2;
1385 width
= image
->width
;
1389 if (wPreferences
.new_style
) {
1390 if (texture
->any
.type
==WTEX_SOLID
|| pushed
) {
1391 wDrawBevel(button
->window
, button
->width
, button
->height
,
1392 (WTexSolid
*)texture
, WREL_RAISED
);
1395 wDrawBevel(button
->window
, button
->width
, button
->height
,
1396 scr
->widget_texture
, WREL_RAISED
);
1402 XSetClipMask(dpy
, copy_gc
, image
->mask
);
1403 x
= (button
->width
- width
)/2 + d
;
1404 y
= (button
->height
- image
->height
)/2 + d
;
1405 XSetClipOrigin(dpy
, copy_gc
, x
-left
, y
);
1406 if (!wPreferences
.new_style
) {
1407 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1409 if (image
->depth
==1)
1410 XCopyPlane(dpy
, image
->image
, button
->window
, copy_gc
,
1411 left
, 0, width
, image
->height
, x
, y
, 1);
1413 XCopyArea(dpy
, image
->image
, button
->window
, copy_gc
,
1414 left
, 0, width
, image
->height
, x
, y
);
1416 XSetForeground(dpy
, copy_gc
, scr
->dark_pixel
);
1417 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1418 button
->width
, button
->height
);
1422 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1424 XSetForeground(dpy
, copy_gc
, color
);
1425 XSetBackground(dpy
, copy_gc
, texture
->any
.color
.pixel
);
1427 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1428 button
->width
, button
->height
);
1435 handleButtonExpose(WObjDescriptor
*desc
, XEvent
*event
)
1437 WFrameWindow
*fwin
= (WFrameWindow
*)desc
->parent
;
1438 WCoreWindow
*button
= (WCoreWindow
*)desc
->self
;
1440 #ifdef XKB_BUTTON_HINT
1441 if (button
== fwin
->language_button
) {
1442 if (wPreferences
.modelock
){
1443 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1444 fwin
->title_pixel
[fwin
->flags
.state
],
1445 fwin
->languagebutton_image
, False
);
1449 if (button
== fwin
->left_button
) {
1450 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1451 fwin
->title_pixel
[fwin
->flags
.state
],
1452 fwin
->lbutton_image
, False
);
1454 Bool pushed
= False
;
1457 if (fwin
->flags
.right_button_pushed_in
)
1460 /* emulate the olwm pushpin in the "out" state */
1461 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1462 fwin
->title_pixel
[fwin
->flags
.state
],
1463 fwin
->rbutton_image
, pushed
);
1469 titlebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1471 WFrameWindow
*fwin
= desc
->parent
;
1472 WCoreWindow
*titlebar
= desc
->self
;
1474 if (IsDoubleClick(fwin
->core
->screen_ptr
, event
)) {
1475 if (fwin
->on_dblclick_titlebar
)
1476 (*fwin
->on_dblclick_titlebar
)(titlebar
, fwin
->child
, event
);
1478 if (fwin
->on_mousedown_titlebar
)
1479 (*fwin
->on_mousedown_titlebar
)(titlebar
, fwin
->child
, event
);
1485 resizebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1487 WFrameWindow
*fwin
= desc
->parent
;
1488 WCoreWindow
*resizebar
= desc
->self
;
1490 if (fwin
->on_mousedown_resizebar
)
1491 (*fwin
->on_mousedown_resizebar
)(resizebar
, fwin
->child
, event
);
1496 buttonMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1498 WFrameWindow
*fwin
= desc
->parent
;
1499 WCoreWindow
*button
= desc
->self
;
1502 int done
=0, execute
=1;
1504 unsigned long pixel
;
1505 int clickButton
= event
->xbutton
.button
;
1507 if (IsDoubleClick(fwin
->core
->screen_ptr
, event
)) {
1508 if (button
== fwin
->right_button
&& fwin
->on_dblclick_right
) {
1509 (*fwin
->on_dblclick_right
)(button
, fwin
->child
, event
);
1514 if (button
== fwin
->left_button
) {
1515 image
= fwin
->lbutton_image
;
1517 image
= fwin
->rbutton_image
;
1519 #ifdef XKB_BUTTON_HINT
1520 if (button
== fwin
->language_button
) {
1521 if (!wPreferences
.modelock
) return;
1522 image
= fwin
->languagebutton_image
;
1526 pixel
= fwin
->title_pixel
[fwin
->flags
.state
];
1527 texture
= fwin
->title_texture
[fwin
->flags
.state
];
1528 paintButton(button
, texture
, pixel
, image
, True
);
1531 WMMaskEvent(dpy
, LeaveWindowMask
|EnterWindowMask
|ButtonReleaseMask
1532 |ButtonPressMask
|ExposureMask
, &ev
);
1536 paintButton(button
, texture
, pixel
, image
, False
);
1541 paintButton(button
, texture
, pixel
, image
, True
);
1548 if (ev
.xbutton
.button
== clickButton
)
1556 paintButton(button
, texture
, pixel
, image
, False
);
1559 if (button
== fwin
->left_button
) {
1560 if (fwin
->on_click_left
)
1561 (*fwin
->on_click_left
)(button
, fwin
->child
, &ev
);
1562 } else if (button
== fwin
->right_button
) {
1563 if (fwin
->on_click_right
)
1564 (*fwin
->on_click_right
)(button
, fwin
->child
, &ev
);
1566 #ifdef XKB_BUTTON_HINT
1567 else if (button
== fwin
->language_button
) {
1568 if (fwin
->on_click_language
)
1569 (*fwin
->on_click_language
)(button
, fwin
->child
, &ev
);