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 *clearance
, 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 fwin
->title_clearance
= clearance
;
87 #ifdef DRAWSTRING_PLUGIN
88 fwin
->drawstring_proc_offset
= function_offset
;
92 #ifdef KEEP_XKB_LOCK_STATUS
93 fwin
->languagemode
= XkbGroup1Index
;
94 fwin
->last_languagemode
= XkbGroup2Index
;
97 fwin
->core
= wCoreCreateTopLevel(scr
, x
, y
, width
, height
,
99 if (wPreferences
.use_saveunders
) {
101 XSetWindowAttributes attribs
;
104 attribs
.save_under
= True
;
105 XChangeWindowAttributes(dpy
, fwin
->core
->window
, vmask
, &attribs
);
108 /* setup stacking information */
109 fwin
->core
->stacking
= wmalloc(sizeof(WStacking
));
110 fwin
->core
->stacking
->above
= NULL
;
111 fwin
->core
->stacking
->under
= NULL
;
112 fwin
->core
->stacking
->child_of
= NULL
;
113 fwin
->core
->stacking
->window_level
= wlevel
;
115 AddToStackList(fwin
->core
);
117 wFrameWindowUpdateBorders(fwin
, flags
);
125 wFrameWindowUpdateBorders(WFrameWindow
*fwin
, int flags
)
131 WScreen
*scr
= fwin
->screen_ptr
;
133 width
= fwin
->core
->width
;
134 if (flags
& WFF_IS_SHADED
)
137 height
= fwin
->core
->height
- fwin
->top_width
- fwin
->bottom_width
;
139 if (flags
& WFF_TITLEBAR
)
140 theight
= WMFontHeight(*fwin
->font
) + TITLEBAR_EXTRA_HEIGHT
+ *fwin
->title_clearance
* 2;
144 if (wPreferences
.new_style
) {
150 if (fwin
->titlebar
) {
151 /* if we had a titlebar and is requesting for one,
152 * check if the size has changed and resize it */
153 if (flags
& WFF_TITLEBAR
) {
154 fwin
->top_width
= theight
;
156 fwin
->flags
.need_texture_remake
= 1;
158 if (wPreferences
.new_style
) {
159 if (fwin
->left_button
) {
160 wCoreConfigure(fwin
->left_button
, 0, 0, bsize
, bsize
);
162 #ifdef XKB_BUTTON_HINT
163 if (fwin
->language_button
)
164 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
165 || fwin
->flags
.lbutton_dont_fit
) {
166 wCoreConfigure(fwin
->language_button
, 0, 0, bsize
, bsize
);
168 wCoreConfigure(fwin
->language_button
, bsize
, 0, bsize
, bsize
);
173 if (fwin
->right_button
) {
174 wCoreConfigure(fwin
->right_button
, width
-bsize
+1,
177 } else { /* !new_style */
178 if (fwin
->left_button
) {
179 wCoreConfigure(fwin
->left_button
, 3, (theight
-bsize
)/2,
183 #ifdef XKB_BUTTON_HINT
184 if (fwin
->language_button
) {
185 wCoreConfigure(fwin
->language_button
, 6 + bsize
, (theight
-bsize
)/2,
191 if (fwin
->right_button
) {
192 wCoreConfigure(fwin
->right_button
, width
-bsize
-3,
193 (theight
-bsize
)/2, bsize
, bsize
);
196 updateTitlebar(fwin
);
198 /* we had a titlebar, but now we don't need it anymore */
199 for (i
=0; i
< (fwin
->flags
.single_texture
? 1 : 3); i
++) {
200 FREE_PIXMAP(fwin
->title_back
[i
]);
201 if (wPreferences
.new_style
) {
202 FREE_PIXMAP(fwin
->lbutton_back
[i
]);
203 FREE_PIXMAP(fwin
->rbutton_back
[i
]);
204 #ifdef XKB_BUTTON_HINT
205 FREE_PIXMAP(fwin
->languagebutton_back
[i
]);
209 if (fwin
->left_button
)
210 wCoreDestroy(fwin
->left_button
);
211 fwin
->left_button
= NULL
;
213 #ifdef XKB_BUTTON_HINT
214 if (fwin
->language_button
)
215 wCoreDestroy(fwin
->language_button
);
216 fwin
->language_button
= NULL
;
219 if (fwin
->right_button
)
220 wCoreDestroy(fwin
->right_button
);
221 fwin
->right_button
= NULL
;
223 wCoreDestroy(fwin
->titlebar
);
224 fwin
->titlebar
= NULL
;
229 /* if we didn't have a titlebar and are being requested for
231 if (flags
& WFF_TITLEBAR
) {
232 fwin
->top_width
= theight
;
234 fwin
->flags
.titlebar
= 1;
235 fwin
->titlebar
= wCoreCreate(fwin
->core
, 0, 0, width
+1, theight
);
237 if (flags
& WFF_LEFT_BUTTON
) {
238 fwin
->flags
.left_button
= 1;
239 if (wPreferences
.new_style
) {
240 fwin
->left_button
= wCoreCreate(fwin
->core
, 0, 0,
242 if (width
< theight
*4) {
243 fwin
->flags
.lbutton_dont_fit
= 1;
245 XMapRaised(dpy
, fwin
->left_button
->window
);
249 wCoreCreate(fwin
->titlebar
, 3, (theight
-bsize
)/2,
252 XSetWindowBackground(dpy
, fwin
->left_button
->window
,
253 scr
->widget_texture
->normal
.pixel
);
255 if (width
< theight
*3) {
256 fwin
->flags
.lbutton_dont_fit
= 1;
258 XMapRaised(dpy
, fwin
->left_button
->window
);
263 #ifdef XKB_BUTTON_HINT
264 if (flags
& WFF_LANGUAGE_BUTTON
) {
265 fwin
->flags
.language_button
= 1;
266 if (wPreferences
.new_style
) {
267 fwin
->language_button
= wCoreCreate(fwin
->core
,
268 bsize
, 0, bsize
, bsize
);
270 if (width
< theight
*4) {
271 fwin
->flags
.languagebutton_dont_fit
= 1;
273 XMapRaised(dpy
, fwin
->language_button
->window
);
276 fwin
->language_button
=
277 wCoreCreate(fwin
->titlebar
, bsize
+ 6, (theight
-bsize
)/2,
280 XSetWindowBackground(dpy
, fwin
->language_button
->window
,
281 scr
->widget_texture
->normal
.pixel
);
283 if (width
< theight
*3) {
284 fwin
->flags
.languagebutton_dont_fit
= 1;
286 XMapRaised(dpy
, fwin
->language_button
->window
);
292 if (flags
& WFF_RIGHT_BUTTON
) {
293 fwin
->flags
.right_button
= 1;
294 if (wPreferences
.new_style
) {
296 wCoreCreate(fwin
->core
, width
-bsize
+1, 0,
300 wCoreCreate(fwin
->titlebar
, width
-bsize
-3,
301 (theight
-bsize
)/2, bsize
, bsize
);
302 XSetWindowBackground(dpy
, fwin
->right_button
->window
,
303 scr
->widget_texture
->normal
.pixel
);
306 if (width
< theight
*2) {
307 fwin
->flags
.rbutton_dont_fit
= 1;
309 XMapRaised(dpy
, fwin
->right_button
->window
);
313 if (wPreferences
.new_style
)
314 updateTitlebar(fwin
);
316 XMapRaised(dpy
, fwin
->titlebar
->window
);
318 fwin
->flags
.need_texture_remake
= 1;
321 checkTitleSize(fwin
);
323 if (flags
& WFF_RESIZEBAR
) {
324 fwin
->bottom_width
= RESIZEBAR_HEIGHT
;
326 fwin
->bottom_width
= 0;
329 if (flags
& WFF_RESIZEBAR
) {
330 if (!fwin
->resizebar
) {
331 fwin
->flags
.resizebar
= 1;
332 fwin
->resizebar
= wCoreCreate(fwin
->core
, 0,
333 height
+ fwin
->top_width
,
334 width
, RESIZEBAR_HEIGHT
);
335 fwin
->resizebar_corner_width
= RESIZEBAR_CORNER_WIDTH
;
336 if (width
< RESIZEBAR_CORNER_WIDTH
*2 + RESIZEBAR_MIN_WIDTH
) {
337 fwin
->resizebar_corner_width
= (width
- RESIZEBAR_MIN_WIDTH
)/2;
338 if (fwin
->resizebar_corner_width
< 0)
339 fwin
->resizebar_corner_width
= 0;
342 XMapWindow(dpy
, fwin
->resizebar
->window
);
343 XLowerWindow(dpy
, fwin
->resizebar
->window
);
345 fwin
->flags
.need_texture_remake
= 1;
347 if (height
+fwin
->top_width
+fwin
->bottom_width
!= fwin
->core
->height
) {
348 wCoreConfigure(fwin
->resizebar
, 0, height
+ fwin
->top_width
,
349 width
, RESIZEBAR_HEIGHT
);
353 if (fwin
->resizebar
) {
354 fwin
->bottom_width
= 0;
355 wCoreDestroy(fwin
->resizebar
);
356 fwin
->resizebar
= NULL
;
360 if (height
+ fwin
->top_width
+ fwin
->bottom_width
!= fwin
->core
->height
361 && !(flags
& WFF_IS_SHADED
)) {
362 wFrameWindowResize(fwin
, width
,
363 height
+ fwin
->top_width
+ fwin
->bottom_width
);
366 /* setup object descriptors */
368 if (fwin
->titlebar
) {
369 fwin
->titlebar
->descriptor
.handle_expose
= handleExpose
;
370 fwin
->titlebar
->descriptor
.parent
= fwin
;
371 fwin
->titlebar
->descriptor
.parent_type
= WCLASS_FRAME
;
372 fwin
->titlebar
->descriptor
.handle_mousedown
= titlebarMouseDown
;
375 if (fwin
->resizebar
) {
376 fwin
->resizebar
->descriptor
.handle_expose
= handleExpose
;
377 fwin
->resizebar
->descriptor
.parent
= fwin
;
378 fwin
->resizebar
->descriptor
.parent_type
= WCLASS_FRAME
;
379 fwin
->resizebar
->descriptor
.handle_mousedown
= resizebarMouseDown
;
382 if (fwin
->left_button
) {
383 fwin
->left_button
->descriptor
.handle_expose
= handleButtonExpose
;
384 fwin
->left_button
->descriptor
.parent
= fwin
;
385 fwin
->left_button
->descriptor
.parent_type
= WCLASS_FRAME
;
386 fwin
->left_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
389 #ifdef XKB_BUTTON_HINT
390 if (fwin
->language_button
) {
391 fwin
->language_button
->descriptor
.handle_expose
= handleButtonExpose
;
392 fwin
->language_button
->descriptor
.parent
= fwin
;
393 fwin
->language_button
->descriptor
.parent_type
= WCLASS_FRAME
;
394 fwin
->language_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
399 if (fwin
->right_button
) {
400 fwin
->right_button
->descriptor
.parent
= fwin
;
401 fwin
->right_button
->descriptor
.parent_type
= WCLASS_FRAME
;
402 fwin
->right_button
->descriptor
.handle_expose
= handleButtonExpose
;
403 fwin
->right_button
->descriptor
.handle_mousedown
= buttonMouseDown
;
406 checkTitleSize(fwin
);
412 wFrameWindowDestroy(WFrameWindow
*fwin
)
416 if (fwin
->left_button
)
417 wCoreDestroy(fwin
->left_button
);
419 #ifdef XKB_BUTTON_HINT
420 if (fwin
->language_button
)
421 wCoreDestroy(fwin
->language_button
);
424 if (fwin
->right_button
)
425 wCoreDestroy(fwin
->right_button
);
428 wCoreDestroy(fwin
->resizebar
);
431 wCoreDestroy(fwin
->titlebar
);
433 RemoveFromStackList(fwin
->core
);
435 wCoreDestroy(fwin
->core
);
440 for (i
=0; i
< (fwin
->flags
.single_texture
? 1 : 3); i
++) {
441 FREE_PIXMAP(fwin
->title_back
[i
]);
442 if (wPreferences
.new_style
) {
443 FREE_PIXMAP(fwin
->lbutton_back
[i
]);
444 #ifdef XKB_BUTTON_HINT
445 FREE_PIXMAP(fwin
->languagebutton_back
[i
]);
447 FREE_PIXMAP(fwin
->rbutton_back
[i
]);
456 wFrameWindowChangeState(WFrameWindow
*fwin
, int state
)
458 if (fwin
->flags
.state
==state
)
461 fwin
->flags
.state
= state
;
462 fwin
->flags
.need_texture_change
= 1;
464 wFrameWindowPaint(fwin
);
469 updateTitlebar(WFrameWindow
*fwin
)
474 theight
= WMFontHeight(*fwin
->font
) + TITLEBAR_EXTRA_HEIGHT
+ *fwin
->title_clearance
* 2;
477 w
= fwin
->core
->width
+ 1;
479 if (wPreferences
.new_style
) {
480 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
481 || fwin
->flags
.lbutton_dont_fit
) {
483 #ifdef XKB_BUTTON_HINT
484 if(fwin
->language_button
)
485 wCoreConfigure(fwin
->language_button
, 0, 0,
486 fwin
->language_button
->width
,
487 fwin
->language_button
->width
);
490 #ifdef XKB_BUTTON_HINT
491 if(fwin
->language_button
)
492 wCoreConfigure(fwin
->language_button
, fwin
->left_button
->width
, 0,
493 fwin
->language_button
->width
,
494 fwin
->language_button
->width
);
496 x
= fwin
->left_button
->width
;
497 w
-= fwin
->left_button
->width
;
499 #ifdef XKB_BUTTON_HINT
500 if (fwin
->flags
.hide_language_button
|| !fwin
->language_button
501 || fwin
->flags
.languagebutton_dont_fit
) {
503 x
+= fwin
->language_button
->width
;
504 w
-= fwin
->language_button
->width
;
508 #ifdef XKB_BUTTON_HINT
510 int bsize
= theight
- 7;
511 if (fwin
->flags
.hide_left_button
|| !fwin
->left_button
512 || fwin
->flags
.lbutton_dont_fit
) {
513 if(fwin
->language_button
)
514 wCoreConfigure(fwin
->language_button
, 3, (theight
-bsize
)/2,
515 fwin
->language_button
->width
,
516 fwin
->language_button
->width
);
519 if(fwin
->language_button
)
520 wCoreConfigure(fwin
->language_button
,
521 6 + fwin
->left_button
->width
, (theight
-bsize
)/2,
522 fwin
->language_button
->width
,
523 fwin
->language_button
->width
);
528 if (wPreferences
.new_style
) {
529 if (!fwin
->flags
.hide_right_button
&& fwin
->right_button
530 && !fwin
->flags
.rbutton_dont_fit
) {
531 w
-= fwin
->right_button
->width
;
535 if (wPreferences
.new_style
|| fwin
->titlebar
->width
!=w
)
536 fwin
->flags
.need_texture_remake
= 1;
538 wCoreConfigure(fwin
->titlebar
, x
, 0, w
, theight
);
543 wFrameWindowHideButton(WFrameWindow
*fwin
, int flags
)
545 if ((flags
& WFF_RIGHT_BUTTON
) && fwin
->right_button
) {
546 XUnmapWindow(dpy
, fwin
->right_button
->window
);
547 fwin
->flags
.hide_right_button
= 1;
550 if ((flags
& WFF_LEFT_BUTTON
) && fwin
->left_button
) {
551 XUnmapWindow(dpy
, fwin
->left_button
->window
);
552 fwin
->flags
.hide_left_button
= 1;
555 #ifdef XKB_BUTTON_HINT
556 if ((flags
& WFF_LANGUAGE_BUTTON
) && fwin
->language_button
) {
557 XUnmapWindow(dpy
, fwin
->language_button
->window
);
558 fwin
->flags
.hide_language_button
= 1;
562 if (fwin
->titlebar
) {
563 if (wPreferences
.new_style
) {
564 updateTitlebar(fwin
);
566 #ifdef XKB_BUTTON_HINT
567 updateTitlebar(fwin
);
569 XClearWindow(dpy
, fwin
->titlebar
->window
);
570 wFrameWindowPaint(fwin
);
573 checkTitleSize(fwin
);
579 wFrameWindowShowButton(WFrameWindow
*fwin
, int flags
)
581 if ((flags
& WFF_RIGHT_BUTTON
) && fwin
->right_button
582 && fwin
->flags
.hide_right_button
) {
584 if (!fwin
->flags
.rbutton_dont_fit
)
585 XMapWindow(dpy
, fwin
->right_button
->window
);
587 fwin
->flags
.hide_right_button
= 0;
590 #ifdef XKB_BUTTON_HINT
591 if ((flags
& WFF_LANGUAGE_BUTTON
) && fwin
->language_button
592 && fwin
->flags
.hide_language_button
) {
594 if (!fwin
->flags
.languagebutton_dont_fit
)
595 XMapWindow(dpy
, fwin
->language_button
->window
);
597 fwin
->flags
.hide_language_button
= 0;
601 if ((flags
& WFF_LEFT_BUTTON
) && fwin
->left_button
602 && fwin
->flags
.hide_left_button
) {
604 if (!fwin
->flags
.lbutton_dont_fit
)
605 XMapWindow(dpy
, fwin
->left_button
->window
);
607 fwin
->flags
.hide_left_button
= 0;
611 if (fwin
->titlebar
) {
612 if (wPreferences
.new_style
) {
613 updateTitlebar(fwin
);
615 XClearWindow(dpy
, fwin
->titlebar
->window
);
616 wFrameWindowPaint(fwin
);
618 checkTitleSize(fwin
);
624 #ifdef XKB_BUTTON_HINT
625 renderTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
626 int bwidth
, int bheight
, int left
, int language
, int right
,
627 Pixmap
*title
, Pixmap
*lbutton
, Pixmap
*languagebutton
, Pixmap
*rbutton
)
629 renderTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
630 int bwidth
, int bheight
, int left
, int right
,
631 Pixmap
*title
, Pixmap
*lbutton
, Pixmap
*rbutton
)
635 RImage
*limg
, *rimg
, *mimg
;
636 #ifdef XKB_BUTTON_HINT
644 #ifdef XKB_BUTTON_HINT
645 *languagebutton
= None
;
648 img
= wTextureRenderImage(texture
, width
, height
, WREL_FLAT
);
650 wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode
));
654 if (wPreferences
.new_style
) {
656 limg
= RGetSubImage(img
, 0, 0, bwidth
, bheight
);
663 #ifdef XKB_BUTTON_HINT
665 timg
= RGetSubImage(img
, bwidth
* left
, 0, bwidth
, bheight
);
671 RBevelImage(limg
, RBEV_RAISED2
);
672 if (!RConvertImage(scr
->rcontext
, limg
, lbutton
)) {
673 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
680 #ifdef XKB_BUTTON_HINT
682 RBevelImage(timg
, RBEV_RAISED2
);
683 if (!RConvertImage(scr
->rcontext
, timg
, languagebutton
)) {
684 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
693 rimg
= RGetSubImage(img
, width
- bwidth
, 0, bwidth
, bheight
);
698 RBevelImage(rimg
, RBEV_RAISED2
);
699 if (!RConvertImage(scr
->rcontext
, rimg
, rbutton
)) {
700 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
707 mimg
= RGetSubImage(img
, x
, 0, w
, img
->height
);
708 RBevelImage(mimg
, RBEV_RAISED2
);
710 if (!RConvertImage(scr
->rcontext
, mimg
, title
)) {
711 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
715 RBevelImage(img
, RBEV_RAISED2
);
717 if (!RConvertImage(scr
->rcontext
, img
, title
)) {
718 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
722 RBevelImage(img
, RBEV_RAISED2
);
724 if (!RConvertImage(scr
->rcontext
, img
, title
)) {
725 wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode
));
734 renderResizebarTexture(WScreen
*scr
, WTexture
*texture
, int width
, int height
,
735 int cwidth
, Pixmap
*pmap
)
743 img
= wTextureRenderImage(texture
, width
, height
, WREL_FLAT
);
745 wwarning(_("could not render texture: %s"),
746 RMessageForError(RErrorCode
));
751 light
.red
= light
.green
= light
.blue
= 80;
754 dark
.red
= dark
.green
= dark
.blue
= 40;
756 ROperateLine(img
, RSubtractOperation
, 0, 0, width
-1, 0, &dark
);
757 ROperateLine(img
, RAddOperation
, 0, 1, width
-1, 1, &light
);
759 ROperateLine(img
, RSubtractOperation
, cwidth
, 2, cwidth
, height
-1, &dark
);
760 ROperateLine(img
, RAddOperation
, cwidth
+1, 2, cwidth
+1, height
-1, &light
);
763 ROperateLine(img
, RSubtractOperation
, width
-cwidth
-2, 2,
764 width
-cwidth
-2, height
-1, &dark
);
765 ROperateLine(img
, RAddOperation
, width
-cwidth
-1, 2, width
-cwidth
-1,
768 #ifdef SHADOW_RESIZEBAR
769 ROperateLine(img
, RAddOperation
, 0, 1, 0, height
-1, &light
);
770 ROperateLine(img
, RSubtractOperation
, width
-1, 1, width
-1, height
-1,
772 ROperateLine(img
, RSubtractOperation
, 0, height
-1, width
-1, height
-1,
774 #endif /* SHADOW_RESIZEBAR */
777 if (!RConvertImage(scr
->rcontext
, img
, pmap
)) {
778 wwarning(_("error rendering image: %s"), RMessageForError(RErrorCode
));
787 updateTexture(WFrameWindow
*fwin
)
792 i
= fwin
->flags
.state
;
793 if (fwin
->titlebar
) {
794 if (fwin
->title_texture
[i
]->any
.type
!=WTEX_SOLID
) {
795 XSetWindowBackgroundPixmap(dpy
, fwin
->titlebar
->window
,
796 fwin
->title_back
[i
]);
797 if (wPreferences
.new_style
) {
798 if (fwin
->left_button
&& fwin
->lbutton_back
[i
])
799 XSetWindowBackgroundPixmap(dpy
, fwin
->left_button
->window
,
800 fwin
->lbutton_back
[i
]);
802 #ifdef XKB_BUTTON_HINT
803 if (fwin
->language_button
&& fwin
->languagebutton_back
[i
]) {
804 XSetWindowBackgroundPixmap(dpy
, fwin
->language_button
->window
,
805 fwin
->languagebutton_back
[i
]);
809 if (fwin
->right_button
&& fwin
->rbutton_back
[i
])
810 XSetWindowBackgroundPixmap(dpy
, fwin
->right_button
->window
,
811 fwin
->rbutton_back
[i
]);
814 pixel
= fwin
->title_texture
[i
]->solid
.normal
.pixel
;
815 XSetWindowBackground(dpy
, fwin
->titlebar
->window
, pixel
);
816 if (wPreferences
.new_style
) {
817 if (fwin
->left_button
)
818 XSetWindowBackground(dpy
, fwin
->left_button
->window
,
820 #ifdef XKB_BUTTON_HINT
821 if (fwin
->language_button
)
822 XSetWindowBackground(dpy
, fwin
->language_button
->window
,
825 if (fwin
->right_button
)
826 XSetWindowBackground(dpy
, fwin
->right_button
->window
,
830 XClearWindow(dpy
, fwin
->titlebar
->window
);
832 if (fwin
->left_button
) {
833 XClearWindow(dpy
, fwin
->left_button
->window
);
834 handleButtonExpose(&fwin
->left_button
->descriptor
, NULL
);
836 #ifdef XKB_BUTTON_HINT
837 if (fwin
->language_button
) {
838 XClearWindow(dpy
, fwin
->language_button
->window
);
839 handleButtonExpose(&fwin
->language_button
->descriptor
, NULL
);
842 if (fwin
->right_button
) {
843 XClearWindow(dpy
, fwin
->right_button
->window
);
844 handleButtonExpose(&fwin
->right_button
->descriptor
, NULL
);
852 remakeTexture(WFrameWindow
*fwin
, int state
)
854 Pixmap pmap
, lpmap
, rpmap
;
855 #ifdef XKB_BUTTON_HINT
859 if (fwin
->title_texture
[state
] && fwin
->titlebar
) {
860 FREE_PIXMAP(fwin
->title_back
[state
]);
861 if (wPreferences
.new_style
) {
862 FREE_PIXMAP(fwin
->lbutton_back
[state
]);
863 FREE_PIXMAP(fwin
->rbutton_back
[state
]);
864 #ifdef XKB_BUTTON_HINT
865 FREE_PIXMAP(fwin
->languagebutton_back
[state
]);
869 if (fwin
->title_texture
[state
]->any
.type
!=WTEX_SOLID
) {
871 #ifdef XKB_BUTTON_HINT
876 /* eventually surrounded by if new_style */
877 left
= fwin
->left_button
&& !fwin
->flags
.hide_left_button
878 && !fwin
->flags
.lbutton_dont_fit
;
879 #ifdef XKB_BUTTON_HINT
880 language
= fwin
->language_button
&& !fwin
->flags
.hide_language_button
881 && !fwin
->flags
.languagebutton_dont_fit
;
883 right
= fwin
->right_button
&& !fwin
->flags
.hide_right_button
884 && !fwin
->flags
.rbutton_dont_fit
;
886 width
= fwin
->core
->width
+1;
888 #ifdef XKB_BUTTON_HINT
889 renderTexture(fwin
->screen_ptr
, fwin
->title_texture
[state
],
890 width
, fwin
->titlebar
->height
,
891 fwin
->titlebar
->height
, fwin
->titlebar
->height
,
892 left
, language
, right
, &pmap
, &lpmap
, &tpmap
, &rpmap
);
894 renderTexture(fwin
->screen_ptr
, fwin
->title_texture
[state
],
895 width
, fwin
->titlebar
->height
,
896 fwin
->titlebar
->height
, fwin
->titlebar
->height
,
897 left
, right
, &pmap
, &lpmap
, &rpmap
);
900 fwin
->title_back
[state
] = pmap
;
901 if (wPreferences
.new_style
) {
902 fwin
->lbutton_back
[state
] = lpmap
;
903 fwin
->rbutton_back
[state
] = rpmap
;
904 #ifdef XKB_BUTTON_HINT
905 fwin
->languagebutton_back
[state
] = tpmap
;
910 if (fwin
->resizebar_texture
&& fwin
->resizebar_texture
[0]
911 && fwin
->resizebar
&& state
== 0) {
913 FREE_PIXMAP(fwin
->resizebar_back
[0]);
915 if (fwin
->resizebar_texture
[0]->any
.type
!=WTEX_SOLID
) {
917 renderResizebarTexture(fwin
->screen_ptr
,
918 fwin
->resizebar_texture
[0],
919 fwin
->resizebar
->width
,
920 fwin
->resizebar
->height
,
921 fwin
->resizebar_corner_width
,
924 fwin
->resizebar_back
[0] = pmap
;
927 /* this part should be in updateTexture() */
928 if (fwin
->resizebar_texture
[0]->any
.type
!=WTEX_SOLID
) {
929 XSetWindowBackgroundPixmap(dpy
, fwin
->resizebar
->window
,
930 fwin
->resizebar_back
[0]);
932 XSetWindowBackground(dpy
, fwin
->resizebar
->window
,
933 fwin
->resizebar_texture
[0]->solid
.normal
.pixel
);
935 XClearWindow(dpy
, fwin
->resizebar
->window
);
941 wFrameWindowPaint(WFrameWindow
*fwin
)
943 WScreen
*scr
= fwin
->screen_ptr
;
945 if (fwin
->flags
.is_client_window_frame
)
946 fwin
->flags
.justification
= wPreferences
.title_justification
;
948 if (fwin
->flags
.need_texture_remake
) {
951 fwin
->flags
.need_texture_remake
= 0;
952 fwin
->flags
.need_texture_change
= 0;
954 if (fwin
->flags
.single_texture
) {
955 remakeTexture(fwin
, 0);
958 /* first render the texture for the current state... */
959 remakeTexture(fwin
, fwin
->flags
.state
);
960 /* ... and paint it */
963 for (i
=0; i
< 3; i
++) {
964 if (i
!=fwin
->flags
.state
)
965 remakeTexture(fwin
, i
);
970 if (fwin
->flags
.need_texture_change
) {
971 fwin
->flags
.need_texture_change
= 0;
976 if (fwin
->titlebar
&& !fwin
->flags
.repaint_only_resizebar
977 && fwin
->title_texture
[fwin
->flags
.state
]->any
.type
==WTEX_SOLID
) {
978 wDrawBevel(fwin
->titlebar
->window
, fwin
->titlebar
->width
,
979 fwin
->titlebar
->height
,
980 (WTexSolid
*)fwin
->title_texture
[fwin
->flags
.state
],
984 if (fwin
->resizebar
&& !fwin
->flags
.repaint_only_titlebar
985 && fwin
->resizebar_texture
[0]->any
.type
== WTEX_SOLID
) {
990 WTexSolid
*texture
= (WTexSolid
*)fwin
->resizebar_texture
[0];
992 w
= fwin
->resizebar
->width
;
993 h
= fwin
->resizebar
->height
;
994 cw
= fwin
->resizebar_corner_width
;
995 light_gc
= texture
->light_gc
;
996 dim_gc
= texture
->dim_gc
;
997 win
= fwin
->resizebar
->window
;
999 XDrawLine(dpy
, win
, dim_gc
, 0, 0, w
, 0);
1000 XDrawLine(dpy
, win
, light_gc
, 0, 1, w
, 1);
1002 XDrawLine(dpy
, win
, dim_gc
, cw
, 2, cw
, h
);
1003 XDrawLine(dpy
, win
, light_gc
, cw
+1, 2, cw
+1, h
);
1005 XDrawLine(dpy
, win
, dim_gc
, w
-cw
-2, 2, w
-cw
-2, h
);
1006 XDrawLine(dpy
, win
, light_gc
, w
-cw
-1, 2, w
-cw
-1, h
);
1008 #ifdef SHADOW_RESIZEBAR
1009 XDrawLine(dpy
, win
, light_gc
, 0, 1, 0, h
-1);
1010 XDrawLine(dpy
, win
, dim_gc
, w
-1, 2, w
-1, h
-1);
1011 XDrawLine(dpy
, win
, dim_gc
, 1, h
-1, cw
, h
-1);
1012 XDrawLine(dpy
, win
, dim_gc
, cw
+2, h
-1, w
-cw
-2, h
-1);
1013 XDrawLine(dpy
, win
, dim_gc
, w
-cw
, h
-1, w
-1, h
-1);
1014 #endif /* SHADOW_RESIZEBAR */
1018 if (fwin
->title
&& fwin
->titlebar
&& !fwin
->flags
.repaint_only_resizebar
) {
1020 int lofs
= 6, rofs
= 6;
1026 if (!wPreferences
.new_style
) {
1027 if (fwin
->left_button
&& !fwin
->flags
.hide_left_button
1028 && !fwin
->flags
.lbutton_dont_fit
)
1029 lofs
+= fwin
->left_button
->width
+ 3;
1033 #ifdef XKB_BUTTON_HINT
1034 if (fwin
->language_button
&& !fwin
->flags
.hide_language_button
1035 && !fwin
->flags
.languagebutton_dont_fit
)
1036 lofs
+= fwin
->language_button
->width
;
1041 if (fwin
->right_button
&& !fwin
->flags
.hide_right_button
1042 && !fwin
->flags
.rbutton_dont_fit
)
1043 rofs
+= fwin
->right_button
->width
+ 3;
1048 #ifdef XKB_BUTTON_HINT
1049 fwin
->languagebutton_image
=
1050 scr
->b_pixmaps
[WBUT_XKBGROUP1
+ fwin
->languagemode
];
1053 title
= ShrinkString(*fwin
->font
, fwin
->title
,
1054 fwin
->titlebar
->width
- lofs
- rofs
);
1055 titlelen
= strlen(title
);
1056 w
= WMWidthOfString(*fwin
->font
, title
, titlelen
);
1058 switch (fwin
->flags
.justification
) {
1064 x
= fwin
->titlebar
->width
- w
- rofs
;
1069 x
= lofs
+ (fwin
->titlebar
->width
- w
- lofs
- rofs
) / 2;
1071 x
= (fwin
->titlebar
->width
- w
) / 2;
1076 XSetForeground(dpy
, *fwin
->title_gc
,
1077 fwin
->title_pixel
[fwin
->flags
.state
]);
1079 #ifdef DRAWSTRING_PLUGIN
1080 if (scr
->drawstring_func
[fwin
->flags
.state
+ fwin
->drawstring_proc_offset
]) {
1081 scr
->drawstring_func
[fwin
->flags
.state
+ fwin
->drawstring_proc_offset
]->
1082 proc
.drawString(scr
->drawstring_func
[fwin
->flags
.state
1083 + fwin
->drawstring_proc_offset
]->arg
,
1084 fwin
->titlebar
->window
, *fwin
->title_gc
,
1085 *fwin
->font
, x
, *fwin
->title_clearance
+ TITLEBAR_EXTRA_HEIGHT
/2,
1086 fwin
->titlebar
->width
, fwin
->top_width
, title
, titlelen
);
1088 WMDrawString(scr
->wmscreen
, fwin
->titlebar
->window
,
1089 *fwin
->title_gc
, *fwin
->font
, x
, *fwin
->title_clearance
+ TITLEBAR_EXTRA_HEIGHT
/2,
1093 WMDrawString(scr
->wmscreen
, fwin
->titlebar
->window
,
1094 *fwin
->title_gc
, *fwin
->font
, x
, *fwin
->title_clearance
+ TITLEBAR_EXTRA_HEIGHT
/2,
1096 #endif /* DRAWSTRING_PLUGIN */
1100 if (fwin
->left_button
)
1101 handleButtonExpose(&fwin
->left_button
->descriptor
, NULL
);
1102 if (fwin
->right_button
)
1103 handleButtonExpose(&fwin
->right_button
->descriptor
, NULL
);
1104 #ifdef XKB_BUTTON_HINT
1105 if (fwin
->language_button
)
1106 handleButtonExpose(&fwin
->language_button
->descriptor
, NULL
);
1113 reconfigure(WFrameWindow
*fwin
, int x
, int y
, int width
, int height
,
1116 int k
= (wPreferences
.new_style
? 4 : 3);
1117 int resizedHorizontally
= 0;
1120 XResizeWindow(dpy
, fwin
->core
->window
, width
, height
);
1122 XMoveResizeWindow(dpy
, fwin
->core
->window
, x
, y
, width
, height
);
1125 if (fwin->core->height != height && fwin->resizebar)
1126 XMoveWindow(dpy, fwin->resizebar->window, 0,
1127 height - fwin->resizebar->height);
1129 if (fwin
->core
->width
!= width
) {
1130 fwin
->flags
.need_texture_remake
= 1;
1131 resizedHorizontally
= 1;
1134 fwin
->core
->width
= width
;
1135 fwin
->core
->height
= height
;
1137 if (fwin
->titlebar
&& resizedHorizontally
) {
1138 /* Check if the titlebar is wide enough to hold the buttons.
1139 * Temporarily remove them if can't
1141 if (fwin
->left_button
) {
1142 if (width
< fwin
->top_width
*k
&& !fwin
->flags
.lbutton_dont_fit
) {
1144 if (!fwin
->flags
.hide_left_button
) {
1145 XUnmapWindow(dpy
, fwin
->left_button
->window
);
1147 fwin
->flags
.lbutton_dont_fit
= 1;
1148 } else if (width
>= fwin
->top_width
*k
&& fwin
->flags
.lbutton_dont_fit
) {
1150 if (!fwin
->flags
.hide_left_button
) {
1151 XMapWindow(dpy
, fwin
->left_button
->window
);
1153 fwin
->flags
.lbutton_dont_fit
= 0;
1157 #ifdef XKB_BUTTON_HINT
1158 if (fwin
->language_button
) {
1159 if (width
< fwin
->top_width
*k
&& !fwin
->flags
.languagebutton_dont_fit
) {
1161 if (!fwin
->flags
.hide_language_button
) {
1162 XUnmapWindow(dpy
, fwin
->language_button
->window
);
1164 fwin
->flags
.languagebutton_dont_fit
= 1;
1165 } else if (width
>= fwin
->top_width
*k
&& fwin
->flags
.languagebutton_dont_fit
) {
1167 if (!fwin
->flags
.hide_language_button
) {
1168 XMapWindow(dpy
, fwin
->language_button
->window
);
1170 fwin
->flags
.languagebutton_dont_fit
= 0;
1175 if (fwin
->right_button
) {
1176 if (width
< fwin
->top_width
*2 && !fwin
->flags
.rbutton_dont_fit
) {
1178 if (!fwin
->flags
.hide_right_button
) {
1179 XUnmapWindow(dpy
, fwin
->right_button
->window
);
1181 fwin
->flags
.rbutton_dont_fit
= 1;
1182 } else if (width
>= fwin
->top_width
*2 && fwin
->flags
.rbutton_dont_fit
) {
1184 if (!fwin
->flags
.hide_right_button
) {
1185 XMapWindow(dpy
, fwin
->right_button
->window
);
1187 fwin
->flags
.rbutton_dont_fit
= 0;
1191 if (wPreferences
.new_style
) {
1192 if (fwin
->right_button
)
1193 XMoveWindow(dpy
, fwin
->right_button
->window
,
1194 width
- fwin
->right_button
->width
+ 1, 0);
1196 if (fwin
->right_button
)
1197 XMoveWindow(dpy
, fwin
->right_button
->window
,
1198 width
- fwin
->right_button
->width
- 3,
1199 (fwin
->titlebar
->height
- fwin
->right_button
->height
)/2);
1201 updateTitlebar(fwin
);
1202 checkTitleSize(fwin
);
1205 if (fwin
->resizebar
) {
1206 wCoreConfigure(fwin
->resizebar
, 0,
1207 fwin
->core
->height
- fwin
->resizebar
->height
,
1208 fwin
->core
->width
, fwin
->resizebar
->height
);
1210 fwin
->resizebar_corner_width
= RESIZEBAR_CORNER_WIDTH
;
1211 if (fwin
->core
->width
< RESIZEBAR_CORNER_WIDTH
*2 + RESIZEBAR_MIN_WIDTH
) {
1212 fwin
->resizebar_corner_width
= fwin
->core
->width
/2;
1218 wFrameWindowConfigure(WFrameWindow
*fwin
, int x
, int y
, int width
, int height
)
1220 reconfigure(fwin
, x
, y
, width
, height
, False
);
1224 wFrameWindowResize(WFrameWindow
*fwin
, int width
, int height
)
1226 reconfigure(fwin
, 0, 0, width
, height
, True
);
1232 wFrameWindowChangeTitle(WFrameWindow
*fwin
, char *new_title
)
1234 /* check if the title is the same as before */
1236 if (new_title
&& (strcmp(fwin
->title
, new_title
) == 0)) {
1247 fwin
->title
= wstrdup(new_title
);
1249 if (fwin
->titlebar
) {
1250 XClearWindow(dpy
, fwin
->titlebar
->window
);
1252 wFrameWindowPaint(fwin
);
1254 checkTitleSize(fwin
);
1262 wFrameWindowUpdatePushButton(WFrameWindow
*fwin
, Bool pushed
)
1264 fwin
->flags
.right_button_pushed_in
= pushed
;
1266 paintButton(fwin
->right_button
, fwin
->title_texture
[fwin
->flags
.state
],
1267 fwin
->title_pixel
[fwin
->flags
.state
],
1268 fwin
->rbutton_image
, pushed
);
1270 #endif /* OLWM_HINTS */
1273 #ifdef XKB_BUTTON_HINT
1275 wFrameWindowUpdateLanguageButton(WFrameWindow
*fwin
)
1277 paintButton(fwin
->language_button
, fwin
->title_texture
[fwin
->flags
.state
],
1278 fwin
->title_pixel
[fwin
->flags
.state
],
1279 fwin
->languagebutton_image
, True
);
1281 #endif /* XKB_BUTTON_HINT */
1284 /*********************************************************************/
1287 handleExpose(WObjDescriptor
*desc
, XEvent
*event
)
1289 WFrameWindow
*fwin
= (WFrameWindow
*)desc
->parent
;
1292 if (fwin
->titlebar
&& fwin
->titlebar
->window
== event
->xexpose
.window
)
1293 fwin
->flags
.repaint_only_titlebar
= 1;
1294 if (fwin
->resizebar
&& fwin
->resizebar
->window
== event
->xexpose
.window
)
1295 fwin
->flags
.repaint_only_resizebar
= 1;
1296 wFrameWindowPaint(fwin
);
1297 fwin
->flags
.repaint_only_titlebar
= 0;
1298 fwin
->flags
.repaint_only_resizebar
= 0;
1303 checkTitleSize(WFrameWindow
*fwin
)
1308 fwin
->flags
.incomplete_title
= 0;
1312 if (!fwin
->titlebar
) {
1313 fwin
->flags
.incomplete_title
= 1;
1316 width
= fwin
->titlebar
->width
- 6 - 6;
1319 if (!wPreferences
.new_style
) {
1320 if (fwin
->left_button
&& !fwin
->flags
.hide_left_button
1321 && !fwin
->flags
.lbutton_dont_fit
)
1322 width
-= fwin
->left_button
->width
+ 3;
1324 #ifdef XKB_BUTTON_HINT
1325 if (fwin
->language_button
&& !fwin
->flags
.hide_language_button
1326 && !fwin
->flags
.languagebutton_dont_fit
)
1327 width
-= fwin
->language_button
->width
+ 3;
1330 if (fwin
->right_button
&& !fwin
->flags
.hide_right_button
1331 && !fwin
->flags
.rbutton_dont_fit
)
1332 width
-= fwin
->right_button
->width
+ 3;
1334 if (WMWidthOfString(*fwin
->font
, fwin
->title
, strlen(fwin
->title
)) > width
) {
1335 fwin
->flags
.incomplete_title
= 1;
1337 fwin
->flags
.incomplete_title
= 0;
1343 paintButton(WCoreWindow
*button
, WTexture
*texture
, unsigned long color
,
1344 WPixmap
*image
, int pushed
)
1346 WScreen
*scr
= button
->screen_ptr
;
1347 GC copy_gc
= scr
->copy_gc
;
1349 int left
=0, width
=0;
1351 /* setup stuff according to the state */
1354 if (image
->width
>=image
->height
*2) {
1355 /* the image contains 2 pictures: the second is for the
1357 width
= image
->width
/2;
1358 left
= image
->width
/2;
1360 width
= image
->width
;
1363 XSetClipMask(dpy
, copy_gc
, None
);
1364 XSetForeground(dpy
, copy_gc
, scr
->white_pixel
);
1366 if (wPreferences
.new_style
) {
1367 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1368 button
->width
-1, button
->height
-1);
1369 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1370 XDrawRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1371 button
->width
-1, button
->height
-1);
1373 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1374 button
->width
, button
->height
);
1375 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1376 XDrawRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1377 button
->width
, button
->height
);
1380 XClearWindow(dpy
, button
->window
);
1383 if (image
->width
>=image
->height
*2)
1384 width
= image
->width
/2;
1386 width
= image
->width
;
1390 if (wPreferences
.new_style
) {
1391 if (texture
->any
.type
==WTEX_SOLID
|| pushed
) {
1392 wDrawBevel(button
->window
, button
->width
, button
->height
,
1393 (WTexSolid
*)texture
, WREL_RAISED
);
1396 wDrawBevel(button
->window
, button
->width
, button
->height
,
1397 scr
->widget_texture
, WREL_RAISED
);
1403 XSetClipMask(dpy
, copy_gc
, image
->mask
);
1404 x
= (button
->width
- width
)/2 + d
;
1405 y
= (button
->height
- image
->height
)/2 + d
;
1406 XSetClipOrigin(dpy
, copy_gc
, x
-left
, y
);
1407 if (!wPreferences
.new_style
) {
1408 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1410 if (image
->depth
==1)
1411 XCopyPlane(dpy
, image
->image
, button
->window
, copy_gc
,
1412 left
, 0, width
, image
->height
, x
, y
, 1);
1414 XCopyArea(dpy
, image
->image
, button
->window
, copy_gc
,
1415 left
, 0, width
, image
->height
, x
, y
);
1417 XSetForeground(dpy
, copy_gc
, scr
->dark_pixel
);
1418 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1419 button
->width
, button
->height
);
1423 XSetForeground(dpy
, copy_gc
, scr
->black_pixel
);
1425 XSetForeground(dpy
, copy_gc
, color
);
1426 XSetBackground(dpy
, copy_gc
, texture
->any
.color
.pixel
);
1428 XFillRectangle(dpy
, button
->window
, copy_gc
, 0, 0,
1429 button
->width
, button
->height
);
1436 handleButtonExpose(WObjDescriptor
*desc
, XEvent
*event
)
1438 WFrameWindow
*fwin
= (WFrameWindow
*)desc
->parent
;
1439 WCoreWindow
*button
= (WCoreWindow
*)desc
->self
;
1441 #ifdef XKB_BUTTON_HINT
1442 if (button
== fwin
->language_button
) {
1443 if (wPreferences
.modelock
){
1444 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1445 fwin
->title_pixel
[fwin
->flags
.state
],
1446 fwin
->languagebutton_image
, False
);
1450 if (button
== fwin
->left_button
) {
1451 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1452 fwin
->title_pixel
[fwin
->flags
.state
],
1453 fwin
->lbutton_image
, False
);
1455 Bool pushed
= False
;
1458 if (fwin
->flags
.right_button_pushed_in
)
1461 /* emulate the olwm pushpin in the "out" state */
1462 paintButton(button
, fwin
->title_texture
[fwin
->flags
.state
],
1463 fwin
->title_pixel
[fwin
->flags
.state
],
1464 fwin
->rbutton_image
, pushed
);
1470 titlebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1472 WFrameWindow
*fwin
= desc
->parent
;
1473 WCoreWindow
*titlebar
= desc
->self
;
1475 if (IsDoubleClick(fwin
->core
->screen_ptr
, event
)) {
1476 if (fwin
->on_dblclick_titlebar
)
1477 (*fwin
->on_dblclick_titlebar
)(titlebar
, fwin
->child
, event
);
1479 if (fwin
->on_mousedown_titlebar
)
1480 (*fwin
->on_mousedown_titlebar
)(titlebar
, fwin
->child
, event
);
1486 resizebarMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1488 WFrameWindow
*fwin
= desc
->parent
;
1489 WCoreWindow
*resizebar
= desc
->self
;
1491 if (fwin
->on_mousedown_resizebar
)
1492 (*fwin
->on_mousedown_resizebar
)(resizebar
, fwin
->child
, event
);
1497 buttonMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
1499 WFrameWindow
*fwin
= desc
->parent
;
1500 WCoreWindow
*button
= desc
->self
;
1503 int done
=0, execute
=1;
1505 unsigned long pixel
;
1506 int clickButton
= event
->xbutton
.button
;
1508 if (IsDoubleClick(fwin
->core
->screen_ptr
, event
)) {
1509 if (button
== fwin
->right_button
&& fwin
->on_dblclick_right
) {
1510 (*fwin
->on_dblclick_right
)(button
, fwin
->child
, event
);
1515 if (button
== fwin
->left_button
) {
1516 image
= fwin
->lbutton_image
;
1518 image
= fwin
->rbutton_image
;
1520 #ifdef XKB_BUTTON_HINT
1521 if (button
== fwin
->language_button
) {
1522 if (!wPreferences
.modelock
) return;
1523 image
= fwin
->languagebutton_image
;
1527 pixel
= fwin
->title_pixel
[fwin
->flags
.state
];
1528 texture
= fwin
->title_texture
[fwin
->flags
.state
];
1529 paintButton(button
, texture
, pixel
, image
, True
);
1532 WMMaskEvent(dpy
, LeaveWindowMask
|EnterWindowMask
|ButtonReleaseMask
1533 |ButtonPressMask
|ExposureMask
, &ev
);
1537 paintButton(button
, texture
, pixel
, image
, False
);
1542 paintButton(button
, texture
, pixel
, image
, True
);
1549 if (ev
.xbutton
.button
== clickButton
)
1557 paintButton(button
, texture
, pixel
, image
, False
);
1560 if (button
== fwin
->left_button
) {
1561 if (fwin
->on_click_left
)
1562 (*fwin
->on_click_left
)(button
, fwin
->child
, &ev
);
1563 } else if (button
== fwin
->right_button
) {
1564 if (fwin
->on_click_right
)
1565 (*fwin
->on_click_right
)(button
, fwin
->child
, &ev
);
1567 #ifdef XKB_BUTTON_HINT
1568 else if (button
== fwin
->language_button
) {
1569 if (fwin
->on_click_language
)
1570 (*fwin
->on_click_language
)(button
, fwin
->child
, &ev
);