1 // Toolbar.cc for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
23 // stupid macros needed to access some functions in version 2 of the GNU C
30 # include "../config.h"
31 #endif // HAVE_CONFIG_H
35 #include "Clientmenu.h"
41 #include "Workspace.h"
42 #include "Workspacemenu.h"
44 #include <X11/keysym.h>
48 #endif // HAVE_STRING_H
52 #endif // HAVE_STDIO_H
54 #ifdef TIME_WITH_SYS_TIME
55 # include <sys/time.h>
57 #else // !TIME_WITH_SYS_TIME
58 # ifdef HAVE_SYS_TIME_H
59 # include <sys/time.h>
60 # else // !HAVE_SYS_TIME_H
62 # endif // HAVE_SYS_TIME_H
63 #endif // TIME_WITH_SYS_TIME
68 Toolbar::Toolbar(BScreen
&scrn
, Resource
&conf
) : screen(scrn
),
69 openbox(scrn
.getOpenbox()), config(conf
)
73 m_placement
= BottomCenter
;
75 m_hidden
= m_autohide
= false;
78 // get the clock updating every minute
79 clock_timer
= new BTimer(openbox
, *this);
81 gettimeofday(&now
, 0);
82 clock_timer
->setTimeout((60 - (now
.tv_sec
% 60)) * 1000);
85 hide_handler
.toolbar
= this;
86 hide_timer
= new BTimer(openbox
, hide_handler
);
87 hide_timer
->setTimeout(openbox
.getAutoRaiseDelay());
88 hide_timer
->fireOnce(True
);
90 image_ctrl
= screen
.getImageControl();
93 new_workspace_name
= (char *) 0;
95 frame
.grab_x
= frame
.grab_y
= 0;
97 toolbarmenu
= new Toolbarmenu(*this);
99 display
= openbox
.getXDisplay();
100 XSetWindowAttributes attrib
;
101 unsigned long create_mask
= CWBackPixmap
| CWBackPixel
| CWBorderPixel
|
102 CWColormap
| CWOverrideRedirect
| CWEventMask
;
103 attrib
.background_pixmap
= None
;
104 attrib
.background_pixel
= attrib
.border_pixel
=
105 screen
.getBorderColor()->getPixel();
106 attrib
.colormap
= screen
.getColormap();
107 attrib
.override_redirect
= True
;
108 attrib
.event_mask
= ButtonPressMask
| ButtonReleaseMask
|
109 EnterWindowMask
| LeaveWindowMask
;
112 XCreateWindow(display
, screen
.getRootWindow(), 0, 0, 1, 1, 0,
113 screen
.getDepth(), InputOutput
, screen
.getVisual(),
114 create_mask
, &attrib
);
115 openbox
.saveToolbarSearch(frame
.window
, this);
117 attrib
.event_mask
= ButtonPressMask
| ButtonReleaseMask
| ExposureMask
|
118 KeyPressMask
| EnterWindowMask
;
120 frame
.workspace_label
=
121 XCreateWindow(display
, frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
122 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
123 openbox
.saveToolbarSearch(frame
.workspace_label
, this);
126 XCreateWindow(display
, frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
127 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
128 openbox
.saveToolbarSearch(frame
.window_label
, this);
131 XCreateWindow(display
, frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
132 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
133 openbox
.saveToolbarSearch(frame
.clock
, this);
136 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
137 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
138 openbox
.saveToolbarSearch(frame
.psbutton
, this);
141 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
142 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
143 openbox
.saveToolbarSearch(frame
.nsbutton
, this);
146 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
147 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
148 openbox
.saveToolbarSearch(frame
.pwbutton
, this);
151 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
152 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
153 openbox
.saveToolbarSearch(frame
.nwbutton
, this);
155 frame
.base
= frame
.label
= frame
.wlabel
= frame
.clk
= frame
.button
=
156 frame
.pbutton
= None
;
162 int Toolbar::getX() const {
163 return ((m_hidden
) ? frame
.x_hidden
: frame
.x
);
166 int Toolbar::getY() const {
167 if (screen
.hideToolbar()) return screen
.size().h();
168 else if (m_hidden
) return frame
.y_hidden
;
172 unsigned int Toolbar::getExposedHeight() const {
173 if (screen
.hideToolbar()) return 0;
174 else if (m_autohide
) return frame
.bevel_w
;
175 else return frame
.height
;
178 void Toolbar::mapToolbar(){
179 if (!screen
.hideToolbar()) {
180 //not hidden, so windows should not maximize over the toolbar
181 XMapSubwindows(display
, frame
.window
);
182 XMapWindow(display
, frame
.window
);
186 void Toolbar::unMapToolbar(){
187 //hidden so we can maximize over the toolbar
188 XUnmapWindow(display
, frame
.window
);
191 Toolbar::~Toolbar() {
193 if (frame
.base
) image_ctrl
->removeImage(frame
.base
);
194 if (frame
.label
) image_ctrl
->removeImage(frame
.label
);
195 if (frame
.wlabel
) image_ctrl
->removeImage(frame
.wlabel
);
196 if (frame
.clk
) image_ctrl
->removeImage(frame
.clk
);
197 if (frame
.button
) image_ctrl
->removeImage(frame
.button
);
198 if (frame
.pbutton
) image_ctrl
->removeImage(frame
.pbutton
);
200 openbox
.removeToolbarSearch(frame
.window
);
201 openbox
.removeToolbarSearch(frame
.workspace_label
);
202 openbox
.removeToolbarSearch(frame
.window_label
);
203 openbox
.removeToolbarSearch(frame
.clock
);
204 openbox
.removeToolbarSearch(frame
.psbutton
);
205 openbox
.removeToolbarSearch(frame
.nsbutton
);
206 openbox
.removeToolbarSearch(frame
.pwbutton
);
207 openbox
.removeToolbarSearch(frame
.nwbutton
);
209 XDestroyWindow(display
, frame
.workspace_label
);
210 XDestroyWindow(display
, frame
.window_label
);
211 XDestroyWindow(display
, frame
.clock
);
213 XDestroyWindow(display
, frame
.window
);
221 void Toolbar::setOnTop(bool b
) {
224 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.onTop" << ends
;
225 config
.setValue(s
.str(), m_ontop
? "True" : "False");
228 void Toolbar::setAutoHide(bool b
) {
231 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.autoHide" <<
233 config
.setValue(s
.str(), m_autohide
? "True" : "False");
236 void Toolbar::setWidthPercent(int w
) {
239 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.widthPercent"
241 config
.setValue(s
.str(), m_width_percent
);
244 void Toolbar::setPlacement(int p
) {
247 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.placement" <<
249 const char *placement
;
250 switch (m_placement
) {
251 case TopLeft
: placement
= "TopLeft"; break;
252 case BottomLeft
: placement
= "BottomLeft"; break;
253 case TopCenter
: placement
= "TopCenter"; break;
254 case TopRight
: placement
= "TopRight"; break;
255 case BottomRight
: placement
= "BottomRight"; break;
256 case BottomCenter
: default: placement
= "BottomCenter"; break;
258 config
.setValue(s
.str(), placement
);
261 void Toolbar::save() {
263 setAutoHide(m_autohide
);
264 setWidthPercent(m_width_percent
);
265 setPlacement(m_placement
);
268 void Toolbar::load() {
269 std::ostrstream rscreen
, rname
, rclass
;
273 rscreen
<< "session.screen" << screen
.getScreenNumber() << '.' << ends
;
275 rname
<< rscreen
.str() << "toolbar.widthPercent" << ends
;
276 rclass
<< rscreen
.str() << "Toolbar.WidthPercent" << ends
;
277 if (config
.getValue(rname
.str(), rclass
.str(), l
) && (l
> 0 && l
<= 100))
280 rname
.seekp(0); rclass
.seekp(0);
281 rname
<< rscreen
.str() << "toolbar.placement" << ends
;
282 rclass
<< rscreen
.str() << "Toolbar.Placement" << ends
;
283 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
284 if (0 == strncasecmp(s
.c_str(), "TopLeft", s
.length()))
285 m_placement
= TopLeft
;
286 else if (0 == strncasecmp(s
.c_str(), "BottomLeft", s
.length()))
287 m_placement
= BottomLeft
;
288 else if (0 == strncasecmp(s
.c_str(), "TopCenter", s
.length()))
289 m_placement
= TopCenter
;
290 else if (0 == strncasecmp(s
.c_str(), "TopRight", s
.length()))
291 m_placement
= TopRight
;
292 else if ( 0 == strncasecmp(s
.c_str(), "BottomRight", s
.length()))
293 m_placement
= BottomRight
;
294 else if ( 0 == strncasecmp(s
.c_str(), "BottomCenter", s
.length()))
295 m_placement
= BottomCenter
;
298 rname
.seekp(0); rclass
.seekp(0);
299 rname
<< rscreen
.str() << "toolbar.onTop" << ends
;
300 rclass
<< rscreen
.str() << "Toolbar.OnTop" << ends
;
301 if (config
.getValue(rname
.str(), rclass
.str(), b
))
304 rname
.seekp(0); rclass
.seekp(0);
305 rname
<< rscreen
.str() << "toolbar.autoHide" << ends
;
306 rclass
<< rscreen
.str() << "Toolbar.AutoHide" << ends
;
307 if (config
.getValue(rname
.str(), rclass
.str(), b
))
308 m_hidden
= m_autohide
= b
;
311 void Toolbar::reconfigure() {
312 frame
.bevel_w
= screen
.getBevelWidth();
313 frame
.width
= screen
.size().w() * m_width_percent
/ 100;
315 if (i18n
->multibyte())
317 screen
.getToolbarStyle()->fontset_extents
->max_ink_extent
.height
;
319 frame
.height
= screen
.getToolbarStyle()->font
->ascent
+
320 screen
.getToolbarStyle()->font
->descent
;
321 frame
.button_w
= frame
.height
;
323 frame
.label_h
= frame
.height
;
324 frame
.height
+= (frame
.bevel_w
* 2);
326 switch (m_placement
) {
331 frame
.y_hidden
= screen
.getBevelWidth() - screen
.getBorderWidth()
337 frame
.y
= screen
.size().h() - frame
.height
338 - (screen
.getBorderWidth() * 2);
340 frame
.y_hidden
= screen
.size().h() - screen
.getBevelWidth()
341 - screen
.getBorderWidth();
345 frame
.x
= (screen
.size().w() - frame
.width
) / 2;
347 frame
.x_hidden
= frame
.x
;
348 frame
.y_hidden
= screen
.getBevelWidth() - screen
.getBorderWidth()
354 frame
.x
= (screen
.size().w() - frame
.width
) / 2;
355 frame
.y
= screen
.size().h() - frame
.height
356 - (screen
.getBorderWidth() * 2);
357 frame
.x_hidden
= frame
.x
;
358 frame
.y_hidden
= screen
.size().h() - screen
.getBevelWidth()
359 - screen
.getBorderWidth();
363 frame
.x
= screen
.size().w() - frame
.width
364 - (screen
.getBorderWidth() * 2);
366 frame
.x_hidden
= frame
.x
;
367 frame
.y_hidden
= screen
.getBevelWidth() - screen
.getBorderWidth()
372 frame
.x
= screen
.size().w() - frame
.width
373 - (screen
.getBorderWidth() * 2);
374 frame
.y
= screen
.size().h() - frame
.height
375 - (screen
.getBorderWidth() * 2);
376 frame
.x_hidden
= frame
.x
;
377 frame
.y_hidden
= screen
.size().h() - screen
.getBevelWidth()
378 - screen
.getBorderWidth();
383 time_t ttmp
= time(NULL
);
387 tt
= localtime(&ttmp
);
389 char t
[1025], *time_string
= (char *) 0;
390 int len
= strftime(t
, 1024, screen
.strftimeFormat(), tt
);
391 t
[len
++-1] = ' '; // add a space to the string for padding
394 if (i18n
->multibyte()) {
395 XRectangle ink
, logical
;
396 XmbTextExtents(screen
.getToolbarStyle()->fontset
, t
, len
, &ink
,
398 frame
.clock_w
= logical
.width
;
400 // ben's additional solution to pad some space beside the numbers
402 // screen.getToolbarStyle()->fontset_extents->max_logical_extent.width *
405 // brad's solution, which is currently buggy, too big
407 // screen.getToolbarStyle()->fontset_extents->max_logical_extent.width
410 frame
.clock_w
= XTextWidth(screen
.getToolbarStyle()->font
, t
, len
);
411 // ben's additional solution to pad some space beside the numbers
412 //frame.clock_w += screen.getToolbarStyle()->font->max_bounds.width * 4;
413 // brad's solution again, too big
414 //frame.clock_w = screen.getToolbarStyle()->font->max_bounds.width * len;
416 frame
.clock_w
+= (frame
.bevel_w
* 4);
418 delete [] time_string
;
425 #else // !HAVE_STRFTIME
427 XTextWidth(screen
.getToolbarStyle()->font
,
428 i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeLength
,
430 strlen(i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeLength
,
431 "00:00000"))) + (frame
.bevel_w
* 4);
432 #endif // HAVE_STRFTIME
436 frame
.workspace_label_w
= 0;
438 for (i
= 0; i
< screen
.getWorkspaceCount(); i
++) {
439 if (i18n
->multibyte()) {
440 XRectangle ink
, logical
;
441 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
442 screen
.getWorkspace(i
)->getName(),
443 strlen(screen
.getWorkspace(i
)->getName()),
447 w
= XTextWidth(screen
.getToolbarStyle()->font
,
448 screen
.getWorkspace(i
)->getName(),
449 strlen(screen
.getWorkspace(i
)->getName()));
451 w
+= (frame
.bevel_w
* 4);
453 if (w
> frame
.workspace_label_w
) frame
.workspace_label_w
= w
;
456 if (frame
.workspace_label_w
< frame
.clock_w
)
457 frame
.workspace_label_w
= frame
.clock_w
;
458 else if (frame
.workspace_label_w
> frame
.clock_w
)
459 frame
.clock_w
= frame
.workspace_label_w
;
461 frame
.window_label_w
=
462 (frame
.width
- (frame
.clock_w
+ (frame
.button_w
* 4) +
463 frame
.workspace_label_w
+ (frame
.bevel_w
* 8) + 6));
466 XMoveResizeWindow(display
, frame
.window
, frame
.x_hidden
, frame
.y_hidden
,
467 frame
.width
, frame
.height
);
469 XMoveResizeWindow(display
, frame
.window
, frame
.x
, frame
.y
,
470 frame
.width
, frame
.height
);
473 XMoveResizeWindow(display
, frame
.workspace_label
, frame
.bevel_w
,
474 frame
.bevel_w
, frame
.workspace_label_w
,
476 XMoveResizeWindow(display
, frame
.psbutton
, (frame
.bevel_w
* 2) +
477 frame
.workspace_label_w
+ 1, frame
.bevel_w
+ 1,
478 frame
.button_w
, frame
.button_w
);
479 XMoveResizeWindow(display
,frame
.nsbutton
, (frame
.bevel_w
* 3) +
480 frame
.workspace_label_w
+ frame
.button_w
+ 2,
481 frame
.bevel_w
+ 1, frame
.button_w
, frame
.button_w
);
482 XMoveResizeWindow(display
, frame
.window_label
, (frame
.bevel_w
* 4) +
483 (frame
.button_w
* 2) + frame
.workspace_label_w
+ 3,
484 frame
.bevel_w
, frame
.window_label_w
, frame
.label_h
);
485 XMoveResizeWindow(display
, frame
.pwbutton
, (frame
.bevel_w
* 5) +
486 (frame
.button_w
* 2) + frame
.workspace_label_w
+
487 frame
.window_label_w
+ 4, frame
.bevel_w
+ 1,
488 frame
.button_w
, frame
.button_w
);
489 XMoveResizeWindow(display
, frame
.nwbutton
, (frame
.bevel_w
* 6) +
490 (frame
.button_w
* 3) + frame
.workspace_label_w
+
491 frame
.window_label_w
+ 5, frame
.bevel_w
+ 1,
492 frame
.button_w
, frame
.button_w
);
493 XMoveResizeWindow(display
, frame
.clock
, frame
.width
- frame
.clock_w
-
494 frame
.bevel_w
, frame
.bevel_w
, frame
.clock_w
,
497 Pixmap tmp
= frame
.base
;
498 BTexture
*texture
= &(screen
.getToolbarStyle()->toolbar
);
499 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
501 XSetWindowBackground(display
, frame
.window
,
502 texture
->getColor()->getPixel());
505 image_ctrl
->renderImage(frame
.width
, frame
.height
, texture
);
506 XSetWindowBackgroundPixmap(display
, frame
.window
, frame
.base
);
508 if (tmp
) image_ctrl
->removeImage(tmp
);
511 texture
= &(screen
.getToolbarStyle()->window
);
512 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
514 XSetWindowBackground(display
, frame
.window_label
,
515 texture
->getColor()->getPixel());
518 image_ctrl
->renderImage(frame
.window_label_w
, frame
.label_h
, texture
);
519 XSetWindowBackgroundPixmap(display
, frame
.window_label
, frame
.label
);
521 if (tmp
) image_ctrl
->removeImage(tmp
);
524 texture
= &(screen
.getToolbarStyle()->label
);
525 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
527 XSetWindowBackground(display
, frame
.workspace_label
,
528 texture
->getColor()->getPixel());
531 image_ctrl
->renderImage(frame
.workspace_label_w
, frame
.label_h
, texture
);
532 XSetWindowBackgroundPixmap(display
, frame
.workspace_label
, frame
.wlabel
);
534 if (tmp
) image_ctrl
->removeImage(tmp
);
537 texture
= &(screen
.getToolbarStyle()->clock
);
538 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
540 XSetWindowBackground(display
, frame
.clock
,
541 texture
->getColor()->getPixel());
544 image_ctrl
->renderImage(frame
.clock_w
, frame
.label_h
, texture
);
545 XSetWindowBackgroundPixmap(display
, frame
.clock
, frame
.clk
);
547 if (tmp
) image_ctrl
->removeImage(tmp
);
550 texture
= &(screen
.getToolbarStyle()->button
);
551 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
554 frame
.button_pixel
= texture
->getColor()->getPixel();
555 XSetWindowBackground(display
, frame
.psbutton
, frame
.button_pixel
);
556 XSetWindowBackground(display
, frame
.nsbutton
, frame
.button_pixel
);
557 XSetWindowBackground(display
, frame
.pwbutton
, frame
.button_pixel
);
558 XSetWindowBackground(display
, frame
.nwbutton
, frame
.button_pixel
);
561 image_ctrl
->renderImage(frame
.button_w
, frame
.button_w
, texture
);
563 XSetWindowBackgroundPixmap(display
, frame
.psbutton
, frame
.button
);
564 XSetWindowBackgroundPixmap(display
, frame
.nsbutton
, frame
.button
);
565 XSetWindowBackgroundPixmap(display
, frame
.pwbutton
, frame
.button
);
566 XSetWindowBackgroundPixmap(display
, frame
.nwbutton
, frame
.button
);
568 if (tmp
) image_ctrl
->removeImage(tmp
);
571 texture
= &(screen
.getToolbarStyle()->pressed
);
572 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
573 frame
.pbutton
= None
;
574 frame
.pbutton_pixel
= texture
->getColor()->getPixel();
577 image_ctrl
->renderImage(frame
.button_w
, frame
.button_w
, texture
);
579 if (tmp
) image_ctrl
->removeImage(tmp
);
581 XSetWindowBorder(display
, frame
.window
,
582 screen
.getBorderColor()->getPixel());
583 XSetWindowBorderWidth(display
, frame
.window
, screen
.getBorderWidth());
585 XClearWindow(display
, frame
.window
);
586 XClearWindow(display
, frame
.workspace_label
);
587 XClearWindow(display
, frame
.window_label
);
588 XClearWindow(display
, frame
.clock
);
589 XClearWindow(display
, frame
.psbutton
);
590 XClearWindow(display
, frame
.nsbutton
);
591 XClearWindow(display
, frame
.pwbutton
);
592 XClearWindow(display
, frame
.nwbutton
);
595 redrawWorkspaceLabel();
596 redrawPrevWorkspaceButton();
597 redrawNextWorkspaceButton();
598 redrawPrevWindowButton();
599 redrawNextWindowButton();
602 toolbarmenu
->reconfigure();
607 void Toolbar::checkClock(Bool redraw
) {
608 #else // !HAVE_STRFTIME
609 void Toolbar::checkClock(Bool redraw
, Bool date
) {
610 #endif // HAVE_STRFTIME
614 if ((tmp
= time(NULL
)) != -1) {
615 if (! (tt
= localtime(&tmp
))) return;
616 if (tt
->tm_min
!= frame
.minute
|| tt
->tm_hour
!= frame
.hour
) {
617 frame
.hour
= tt
->tm_hour
;
618 frame
.minute
= tt
->tm_min
;
619 XClearWindow(display
, frame
.clock
);
627 if (! strftime(t
, 1024, screen
.strftimeFormat(), tt
))
629 #else // !HAVE_STRFTIME
632 // format the date... with special consideration for y2k ;)
633 if (screen
.getDateFormat() == Openbox::B_EuropeanDate
)
634 sprintf(t
, 18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeDateFormatEu
,
636 tt
->tm_mday
, tt
->tm_mon
+ 1,
637 (tt
->tm_year
>= 100) ? tt
->tm_year
- 100 : tt
->tm_year
);
639 sprintf(t
, i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeDateFormat
,
641 tt
->tm_mon
+ 1, tt
->tm_mday
,
642 (tt
->tm_year
>= 100) ? tt
->tm_year
- 100 : tt
->tm_year
);
644 if (screen
.isClock24Hour())
645 sprintf(t
, i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeTimeFormat24
,
647 frame
.hour
, frame
.minute
);
649 sprintf(t
, i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeTimeFormat12
,
651 ((frame
.hour
> 12) ? frame
.hour
- 12 :
652 ((frame
.hour
== 0) ? 12 : frame
.hour
)), frame
.minute
,
653 ((frame
.hour
>= 12) ?
654 i18n
->getMessage(ToolbarSet
,
655 ToolbarNoStrftimeTimeFormatP
, "p") :
656 i18n
->getMessage(ToolbarSet
,
657 ToolbarNoStrftimeTimeFormatA
, "a")));
659 #endif // HAVE_STRFTIME
661 int dx
= (frame
.bevel_w
* 2), dlen
= strlen(t
);
664 if (i18n
->multibyte()) {
665 XRectangle ink
, logical
;
666 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
667 t
, dlen
, &ink
, &logical
);
670 l
= XTextWidth(screen
.getToolbarStyle()->font
, t
, dlen
);
673 l
+= (frame
.bevel_w
* 4);
675 if (l
> frame
.clock_w
) {
676 for (; dlen
>= 0; dlen
--) {
677 if (i18n
->multibyte()) {
678 XRectangle ink
, logical
;
679 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
680 t
, dlen
, &ink
, &logical
);
683 l
= XTextWidth(screen
.getToolbarStyle()->font
, t
, dlen
);
685 l
+= (frame
.bevel_w
* 4);
687 if (l
< frame
.clock_w
)
691 switch (screen
.getToolbarStyle()->justify
) {
692 case BScreen::RightJustify
:
693 dx
+= frame
.clock_w
- l
;
696 case BScreen::CenterJustify
:
697 dx
+= (frame
.clock_w
- l
) / 2;
701 ToolbarStyle
*style
= screen
.getToolbarStyle();
702 if (i18n
->multibyte())
703 XmbDrawString(display
, frame
.clock
, style
->fontset
, style
->c_text_gc
,
704 dx
, (1 - style
->fontset_extents
->max_ink_extent
.y
),
707 XDrawString(display
, frame
.clock
, style
->c_text_gc
, dx
,
708 (style
->font
->ascent
+ 1), t
, dlen
);
713 void Toolbar::redrawWindowLabel(Bool redraw
) {
714 if (screen
.getOpenbox().getFocusedWindow()) {
716 XClearWindow(display
, frame
.window_label
);
718 OpenboxWindow
*foc
= screen
.getOpenbox().getFocusedWindow();
719 if (foc
->getScreen() != &screen
) return;
721 int dx
= (frame
.bevel_w
* 2), dlen
= strlen(*foc
->getTitle());
724 if (i18n
->multibyte()) {
725 XRectangle ink
, logical
;
726 XmbTextExtents(screen
.getToolbarStyle()->fontset
, *foc
->getTitle(),
727 dlen
, &ink
, &logical
);
730 l
= XTextWidth(screen
.getToolbarStyle()->font
, *foc
->getTitle(), dlen
);
732 l
+= (frame
.bevel_w
* 4);
734 if (l
> frame
.window_label_w
) {
735 for (; dlen
>= 0; dlen
--) {
736 if (i18n
->multibyte()) {
737 XRectangle ink
, logical
;
738 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
739 *foc
->getTitle(), dlen
, &ink
, &logical
);
742 l
= XTextWidth(screen
.getToolbarStyle()->font
,
743 *foc
->getTitle(), dlen
);
745 l
+= (frame
.bevel_w
* 4);
747 if (l
< frame
.window_label_w
)
751 switch (screen
.getToolbarStyle()->justify
) {
752 case BScreen::RightJustify
:
753 dx
+= frame
.window_label_w
- l
;
756 case BScreen::CenterJustify
:
757 dx
+= (frame
.window_label_w
- l
) / 2;
761 ToolbarStyle
*style
= screen
.getToolbarStyle();
762 if (i18n
->multibyte())
763 XmbDrawString(display
, frame
.window_label
, style
->fontset
,
764 style
->w_text_gc
, dx
,
765 (1 - style
->fontset_extents
->max_ink_extent
.y
),
766 *foc
->getTitle(), dlen
);
768 XDrawString(display
, frame
.window_label
, style
->w_text_gc
, dx
,
769 (style
->font
->ascent
+ 1), *foc
->getTitle(), dlen
);
771 XClearWindow(display
, frame
.window_label
);
776 void Toolbar::redrawWorkspaceLabel(Bool redraw
) {
777 if (screen
.getCurrentWorkspace()->getName()) {
779 XClearWindow(display
, frame
.workspace_label
);
781 int dx
= (frame
.bevel_w
* 2), dlen
=
782 strlen(screen
.getCurrentWorkspace()->getName());
785 if (i18n
->multibyte()) {
786 XRectangle ink
, logical
;
787 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
788 screen
.getCurrentWorkspace()->getName(), dlen
,
792 l
= XTextWidth(screen
.getToolbarStyle()->font
,
793 screen
.getCurrentWorkspace()->getName(), dlen
);
795 l
+= (frame
.bevel_w
* 4);
797 if (l
> frame
.workspace_label_w
) {
798 for (; dlen
>= 0; dlen
--) {
799 if (i18n
->multibyte()) {
800 XRectangle ink
, logical
;
801 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
802 screen
.getCurrentWorkspace()->getName(), dlen
,
806 l
= XTextWidth(screen
.getWindowStyle()->font
,
807 screen
.getCurrentWorkspace()->getName(), dlen
);
809 l
+= (frame
.bevel_w
* 4);
811 if (l
< frame
.workspace_label_w
)
815 switch (screen
.getToolbarStyle()->justify
) {
816 case BScreen::RightJustify
:
817 dx
+= frame
.workspace_label_w
- l
;
820 case BScreen::CenterJustify
:
821 dx
+= (frame
.workspace_label_w
- l
) / 2;
825 ToolbarStyle
*style
= screen
.getToolbarStyle();
826 if (i18n
->multibyte())
827 XmbDrawString(display
, frame
.workspace_label
, style
->fontset
,
828 style
->l_text_gc
, dx
,
829 (1 - style
->fontset_extents
->max_ink_extent
.y
),
830 (char *) screen
.getCurrentWorkspace()->getName(), dlen
);
832 XDrawString(display
, frame
.workspace_label
, style
->l_text_gc
, dx
,
833 (style
->font
->ascent
+ 1),
834 (char *) screen
.getCurrentWorkspace()->getName(), dlen
);
839 void Toolbar::redrawPrevWorkspaceButton(Bool pressed
, Bool redraw
) {
843 XSetWindowBackgroundPixmap(display
, frame
.psbutton
, frame
.pbutton
);
845 XSetWindowBackground(display
, frame
.psbutton
, frame
.pbutton_pixel
);
848 XSetWindowBackgroundPixmap(display
, frame
.psbutton
, frame
.button
);
850 XSetWindowBackground(display
, frame
.psbutton
, frame
.button_pixel
);
852 XClearWindow(display
, frame
.psbutton
);
855 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
858 pts
[0].x
= hw
- 2; pts
[0].y
= hh
;
859 pts
[1].x
= 4; pts
[1].y
= 2;
860 pts
[2].x
= 0; pts
[2].y
= -4;
862 XFillPolygon(display
, frame
.psbutton
, screen
.getToolbarStyle()->b_pic_gc
,
863 pts
, 3, Convex
, CoordModePrevious
);
867 void Toolbar::redrawNextWorkspaceButton(Bool pressed
, Bool redraw
) {
871 XSetWindowBackgroundPixmap(display
, frame
.nsbutton
, frame
.pbutton
);
873 XSetWindowBackground(display
, frame
.nsbutton
, frame
.pbutton_pixel
);
876 XSetWindowBackgroundPixmap(display
, frame
.nsbutton
, frame
.button
);
878 XSetWindowBackground(display
, frame
.nsbutton
, frame
.button_pixel
);
880 XClearWindow(display
, frame
.nsbutton
);
883 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
886 pts
[0].x
= hw
- 2; pts
[0].y
= hh
- 2;
887 pts
[1].x
= 4; pts
[1].y
= 2;
888 pts
[2].x
= -4; pts
[2].y
= 2;
890 XFillPolygon(display
, frame
.nsbutton
, screen
.getToolbarStyle()->b_pic_gc
,
891 pts
, 3, Convex
, CoordModePrevious
);
895 void Toolbar::redrawPrevWindowButton(Bool pressed
, Bool redraw
) {
899 XSetWindowBackgroundPixmap(display
, frame
.pwbutton
, frame
.pbutton
);
901 XSetWindowBackground(display
, frame
.pwbutton
, frame
.pbutton_pixel
);
904 XSetWindowBackgroundPixmap(display
, frame
.pwbutton
, frame
.button
);
906 XSetWindowBackground(display
, frame
.pwbutton
, frame
.button_pixel
);
908 XClearWindow(display
, frame
.pwbutton
);
911 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
914 pts
[0].x
= hw
- 2; pts
[0].y
= hh
;
915 pts
[1].x
= 4; pts
[1].y
= 2;
916 pts
[2].x
= 0; pts
[2].y
= -4;
918 XFillPolygon(display
, frame
.pwbutton
, screen
.getToolbarStyle()->b_pic_gc
,
919 pts
, 3, Convex
, CoordModePrevious
);
923 void Toolbar::redrawNextWindowButton(Bool pressed
, Bool redraw
) {
927 XSetWindowBackgroundPixmap(display
, frame
.nwbutton
, frame
.pbutton
);
929 XSetWindowBackground(display
, frame
.nwbutton
, frame
.pbutton_pixel
);
932 XSetWindowBackgroundPixmap(display
, frame
.nwbutton
, frame
.button
);
934 XSetWindowBackground(display
, frame
.nwbutton
, frame
.button_pixel
);
936 XClearWindow(display
, frame
.nwbutton
);
939 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
942 pts
[0].x
= hw
- 2; pts
[0].y
= hh
- 2;
943 pts
[1].x
= 4; pts
[1].y
= 2;
944 pts
[2].x
= -4; pts
[2].y
= 2;
946 XFillPolygon(display
, frame
.nwbutton
, screen
.getToolbarStyle()->b_pic_gc
,
947 pts
, 3, Convex
, CoordModePrevious
);
951 void Toolbar::edit() {
956 if (XGetInputFocus(display
, &window
, &foo
) &&
957 window
== frame
.workspace_label
)
960 XSetInputFocus(display
, frame
.workspace_label
,
961 ((screen
.sloppyFocus()) ? RevertToPointerRoot
:
964 XClearWindow(display
, frame
.workspace_label
);
966 openbox
.setNoFocus(True
);
967 if (openbox
.getFocusedWindow())
968 openbox
.getFocusedWindow()->setFocusFlag(False
);
970 XDrawRectangle(display
, frame
.workspace_label
,
971 screen
.getWindowStyle()->l_text_focus_gc
,
972 frame
.workspace_label_w
/ 2, 0, 1,
975 // change the background of the window to that of an active window label
976 Pixmap tmp
= frame
.wlabel
;
977 BTexture
*texture
= &(screen
.getWindowStyle()->l_focus
);
978 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
980 XSetWindowBackground(display
, frame
.workspace_label
,
981 texture
->getColor()->getPixel());
984 image_ctrl
->renderImage(frame
.workspace_label_w
, frame
.label_h
, texture
);
985 XSetWindowBackgroundPixmap(display
, frame
.workspace_label
, frame
.wlabel
);
987 if (tmp
) image_ctrl
->removeImage(tmp
);
991 void Toolbar::buttonPressEvent(XButtonEvent
*be
) {
992 if (be
->button
== 1) {
993 if (be
->window
== frame
.psbutton
)
994 redrawPrevWorkspaceButton(True
, True
);
995 else if (be
->window
== frame
.nsbutton
)
996 redrawNextWorkspaceButton(True
, True
);
997 else if (be
->window
== frame
.pwbutton
)
998 redrawPrevWindowButton(True
, True
);
999 else if (be
->window
== frame
.nwbutton
)
1000 redrawNextWindowButton(True
, True
);
1001 #ifndef HAVE_STRFTIME
1002 else if (be
->window
== frame
.clock
) {
1003 XClearWindow(display
, frame
.clock
);
1004 checkClock(True
, True
);
1006 #endif // HAVE_STRFTIME
1007 else if (! m_ontop
) {
1008 Window w
[1] = { frame
.window
};
1009 screen
.raiseWindows(w
, 1);
1011 } else if (be
->button
== 2 && (! m_ontop
)) {
1012 XLowerWindow(display
, frame
.window
);
1013 } else if (be
->button
== 3) {
1014 if (! toolbarmenu
->isVisible()) {
1017 x
= be
->x_root
- (toolbarmenu
->getWidth() / 2);
1018 y
= be
->y_root
- (toolbarmenu
->getHeight() / 2);
1022 else if (x
+ toolbarmenu
->getWidth() > screen
.size().w())
1023 x
= screen
.size().w() - toolbarmenu
->getWidth();
1027 else if (y
+ toolbarmenu
->getHeight() > screen
.size().h())
1028 y
= screen
.size().h() - toolbarmenu
->getHeight();
1030 toolbarmenu
->move(x
, y
);
1031 toolbarmenu
->show();
1033 toolbarmenu
->hide();
1039 void Toolbar::buttonReleaseEvent(XButtonEvent
*re
) {
1040 if (re
->button
== 1) {
1041 if (re
->window
== frame
.psbutton
) {
1042 redrawPrevWorkspaceButton(False
, True
);
1044 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1045 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1046 if (screen
.getCurrentWorkspace()->getWorkspaceID() > 0)
1047 screen
.changeWorkspaceID(screen
.getCurrentWorkspace()->
1048 getWorkspaceID() - 1);
1050 screen
.changeWorkspaceID(screen
.getWorkspaceCount() - 1);
1051 } else if (re
->window
== frame
.nsbutton
) {
1052 redrawNextWorkspaceButton(False
, True
);
1054 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1055 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1056 if (screen
.getCurrentWorkspace()->getWorkspaceID() <
1057 screen
.getWorkspaceCount() - 1)
1058 screen
.changeWorkspaceID(screen
.getCurrentWorkspace()->
1059 getWorkspaceID() + 1);
1061 screen
.changeWorkspaceID(0);
1062 } else if (re
->window
== frame
.pwbutton
) {
1063 redrawPrevWindowButton(False
, True
);
1065 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1066 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1068 } else if (re
->window
== frame
.nwbutton
) {
1069 redrawNextWindowButton(False
, True
);
1071 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1072 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1074 } else if (re
->window
== frame
.window_label
)
1075 screen
.raiseFocus();
1076 #ifndef HAVE_STRFTIME
1077 else if (re
->window
== frame
.clock
) {
1078 XClearWindow(display
, frame
.clock
);
1081 #endif // HAVE_STRFTIME
1086 void Toolbar::enterNotifyEvent(XCrossingEvent
*) {
1091 if (! hide_timer
->isTiming()) hide_timer
->start();
1093 if (hide_timer
->isTiming()) hide_timer
->stop();
1097 void Toolbar::leaveNotifyEvent(XCrossingEvent
*) {
1102 if (hide_timer
->isTiming()) hide_timer
->stop();
1103 } else if (! toolbarmenu
->isVisible()) {
1104 if (! hide_timer
->isTiming()) hide_timer
->start();
1109 void Toolbar::exposeEvent(XExposeEvent
*ee
) {
1110 if (ee
->window
== frame
.clock
) checkClock(True
);
1111 else if (ee
->window
== frame
.workspace_label
&& (! m_editing
))
1112 redrawWorkspaceLabel();
1113 else if (ee
->window
== frame
.window_label
) redrawWindowLabel();
1114 else if (ee
->window
== frame
.psbutton
) redrawPrevWorkspaceButton();
1115 else if (ee
->window
== frame
.nsbutton
) redrawNextWorkspaceButton();
1116 else if (ee
->window
== frame
.pwbutton
) redrawPrevWindowButton();
1117 else if (ee
->window
== frame
.nwbutton
) redrawNextWindowButton();
1121 void Toolbar::keyPressEvent(XKeyEvent
*ke
) {
1122 if (ke
->window
== frame
.workspace_label
&& m_editing
) {
1125 if (! new_workspace_name
) {
1126 new_workspace_name
= new char[128];
1129 if (! new_workspace_name
) return;
1134 XLookupString(ke
, keychar
, 1, &ks
, 0);
1136 // either we are told to end with a return or we hit the end of the buffer
1137 if (ks
== XK_Return
|| new_name_pos
== 127) {
1138 *(new_workspace_name
+ new_name_pos
) = 0;
1142 openbox
.setNoFocus(False
);
1143 if (openbox
.getFocusedWindow()) {
1144 openbox
.getFocusedWindow()->setInputFocus();
1145 openbox
.getFocusedWindow()->setFocusFlag(True
);
1147 XSetInputFocus(display
, PointerRoot
, None
, CurrentTime
);
1149 // check to make sure that new_name[0] != 0... otherwise we have a null
1150 // workspace name which causes serious problems, especially for the
1151 // Openbox::LoadRC() method.
1152 if (*new_workspace_name
) {
1153 screen
.getCurrentWorkspace()->setName(new_workspace_name
);
1154 screen
.getCurrentWorkspace()->getMenu()->hide();
1155 screen
.getWorkspacemenu()->
1156 remove(screen
.getCurrentWorkspace()->getWorkspaceID() + 2);
1157 screen
.getWorkspacemenu()->
1158 insert(screen
.getCurrentWorkspace()->getName(),
1159 screen
.getCurrentWorkspace()->getMenu(),
1160 screen
.getCurrentWorkspace()->getWorkspaceID() + 2);
1161 screen
.getWorkspacemenu()->update();
1164 delete [] new_workspace_name
;
1165 new_workspace_name
= (char *) 0;
1168 // reset the background to that of the workspace label (its normal
1170 Pixmap tmp
= frame
.wlabel
;
1171 BTexture
*texture
= &(screen
.getToolbarStyle()->label
);
1172 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
1173 frame
.wlabel
= None
;
1174 XSetWindowBackground(display
, frame
.workspace_label
,
1175 texture
->getColor()->getPixel());
1178 image_ctrl
->renderImage(frame
.workspace_label_w
, frame
.label_h
, texture
);
1179 XSetWindowBackgroundPixmap(display
, frame
.workspace_label
, frame
.wlabel
);
1181 if (tmp
) image_ctrl
->removeImage(tmp
);
1184 } else if (! (ks
== XK_Shift_L
|| ks
== XK_Shift_R
||
1185 ks
== XK_Control_L
|| ks
== XK_Control_R
||
1186 ks
== XK_Caps_Lock
|| ks
== XK_Shift_Lock
||
1187 ks
== XK_Meta_L
|| ks
== XK_Meta_R
||
1188 ks
== XK_Alt_L
|| ks
== XK_Alt_R
||
1189 ks
== XK_Super_L
|| ks
== XK_Super_R
||
1190 ks
== XK_Hyper_L
|| ks
== XK_Hyper_R
)) {
1191 if (ks
== XK_BackSpace
) {
1192 if (new_name_pos
> 0) {
1194 *(new_workspace_name
+ new_name_pos
) = '\0';
1196 *new_workspace_name
= '\0';
1199 *(new_workspace_name
+ new_name_pos
) = *keychar
;
1201 *(new_workspace_name
+ new_name_pos
) = '\0';
1204 XClearWindow(display
, frame
.workspace_label
);
1205 int l
= strlen(new_workspace_name
), tw
, x
;
1207 if (i18n
->multibyte()) {
1208 XRectangle ink
, logical
;
1209 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
1210 new_workspace_name
, l
, &ink
, &logical
);
1213 tw
= XTextWidth(screen
.getToolbarStyle()->font
,
1214 new_workspace_name
, l
);
1216 x
= (frame
.workspace_label_w
- tw
) / 2;
1218 if (x
< (signed) frame
.bevel_w
) x
= frame
.bevel_w
;
1220 WindowStyle
*style
= screen
.getWindowStyle();
1221 if (i18n
->multibyte())
1222 XmbDrawString(display
, frame
.workspace_label
, style
->fontset
,
1223 style
->l_text_focus_gc
, x
,
1224 (1 - style
->fontset_extents
->max_ink_extent
.y
),
1225 new_workspace_name
, l
);
1227 XDrawString(display
, frame
.workspace_label
, style
->l_text_focus_gc
, x
,
1228 (style
->font
->ascent
+ 1),
1229 new_workspace_name
, l
);
1231 XDrawRectangle(display
, frame
.workspace_label
,
1232 screen
.getWindowStyle()->l_text_focus_gc
, x
+ tw
, 0, 1,
1241 void Toolbar::timeout() {
1245 gettimeofday(&now
, 0);
1246 clock_timer
->setTimeout((60 - (now
.tv_sec
% 60)) * 1000);
1250 void Toolbar::HideHandler::timeout() {
1251 toolbar
->m_hidden
= !toolbar
->m_hidden
;
1252 if (toolbar
->m_hidden
)
1253 XMoveWindow(toolbar
->display
, toolbar
->frame
.window
,
1254 toolbar
->frame
.x_hidden
, toolbar
->frame
.y_hidden
);
1256 XMoveWindow(toolbar
->display
, toolbar
->frame
.window
,
1257 toolbar
->frame
.x
, toolbar
->frame
.y
);
1261 Toolbarmenu::Toolbarmenu(Toolbar
&tb
) : Basemenu(tb
.screen
), toolbar(tb
) {
1262 setLabel(i18n
->getMessage(ToolbarSet
, ToolbarToolbarTitle
, "Toolbar"));
1265 placementmenu
= new Placementmenu(*this);
1267 insert(i18n
->getMessage(CommonSet
, CommonPlacementTitle
, "Placement"),
1269 insert(i18n
->getMessage(CommonSet
, CommonAlwaysOnTop
, "Always on top"), 1);
1270 insert(i18n
->getMessage(CommonSet
, CommonAutoHide
, "Auto hide"), 2);
1271 insert(i18n
->getMessage(ToolbarSet
, ToolbarEditWkspcName
,
1272 "Edit current workspace name"), 3);
1279 void Toolbarmenu::setValues() {
1280 setItemSelected(1, toolbar
.onTop());
1281 setItemSelected(2, toolbar
.autoHide());
1285 Toolbarmenu::~Toolbarmenu() {
1286 delete placementmenu
;
1290 void Toolbarmenu::itemSelected(int button
, int index
) {
1294 BasemenuItem
*item
= find(index
);
1297 switch (item
->function()) {
1298 case 1: { // always on top
1299 Bool change
= ((toolbar
.onTop()) ? False
: True
);
1300 toolbar
.setOnTop(change
);
1301 setItemSelected(1, change
);
1303 if (toolbar
.onTop()) toolbar
.screen
.raiseWindows((Window
*) 0, 0);
1307 case 2: { // auto hide
1308 Bool change
= ((toolbar
.autoHide()) ? False
: True
);
1309 toolbar
.setAutoHide(change
);
1310 setItemSelected(2, change
);
1313 toolbar
.screen
.getSlit()->reposition();
1318 case 3: { // edit current workspace name
1328 void Toolbarmenu::internal_hide() {
1329 Basemenu::internal_hide();
1330 if (toolbar
.autoHide() && ! toolbar
.isEditing())
1331 toolbar
.hide_handler
.timeout();
1335 void Toolbarmenu::reconfigure() {
1337 placementmenu
->reconfigure();
1339 Basemenu::reconfigure();
1343 Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu
&tm
)
1344 : Basemenu(tm
.toolbar
.screen
), toolbarmenu(tm
) {
1345 setLabel(i18n
->getMessage(ToolbarSet
, ToolbarToolbarPlacement
,
1346 "Toolbar Placement"));
1348 setMinimumSublevels(3);
1350 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopLeft
,
1351 "Top Left"), Toolbar::TopLeft
);
1352 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomLeft
,
1353 "Bottom Left"), Toolbar::BottomLeft
);
1354 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopCenter
,
1355 "Top Center"), Toolbar::TopCenter
);
1356 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomCenter
,
1357 "Bottom Center"), Toolbar::BottomCenter
);
1358 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopRight
,
1359 "Top Right"), Toolbar::TopRight
);
1360 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomRight
,
1361 "Bottom Right"), Toolbar::BottomRight
);
1365 void Toolbarmenu::Placementmenu::itemSelected(int button
, int index
) {
1369 BasemenuItem
*item
= find(index
);
1372 toolbarmenu
.toolbar
.setPlacement(item
->function());
1374 toolbarmenu
.toolbar
.reconfigure();
1377 // reposition the slit as well to make sure it doesn't intersect the
1379 toolbarmenu
.toolbar
.screen
.getSlit()->reposition();