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;
77 // get the clock updating every minute
78 clock_timer
= new BTimer(openbox
, *this);
80 gettimeofday(&now
, 0);
81 clock_timer
->setTimeout((60 - (now
.tv_sec
% 60)) * 1000);
84 hide_handler
.toolbar
= this;
85 hide_timer
= new BTimer(openbox
, hide_handler
);
86 hide_timer
->setTimeout(openbox
.getAutoRaiseDelay());
87 hide_timer
->fireOnce(True
);
89 image_ctrl
= screen
.getImageControl();
92 new_workspace_name
= (char *) 0;
94 frame
.grab_x
= frame
.grab_y
= 0;
96 toolbarmenu
= new Toolbarmenu(*this);
98 display
= openbox
.getXDisplay();
99 XSetWindowAttributes attrib
;
100 unsigned long create_mask
= CWBackPixmap
| CWBackPixel
| CWBorderPixel
|
101 CWColormap
| CWOverrideRedirect
| CWEventMask
;
102 attrib
.background_pixmap
= None
;
103 attrib
.background_pixel
= attrib
.border_pixel
=
104 screen
.getBorderColor()->getPixel();
105 attrib
.colormap
= screen
.getColormap();
106 attrib
.override_redirect
= True
;
107 attrib
.event_mask
= ButtonPressMask
| ButtonReleaseMask
|
108 EnterWindowMask
| LeaveWindowMask
;
111 XCreateWindow(display
, screen
.getRootWindow(), 0, 0, 1, 1, 0,
112 screen
.getDepth(), InputOutput
, screen
.getVisual(),
113 create_mask
, &attrib
);
114 openbox
.saveToolbarSearch(frame
.window
, this);
116 attrib
.event_mask
= ButtonPressMask
| ButtonReleaseMask
| ExposureMask
|
117 KeyPressMask
| EnterWindowMask
;
119 frame
.workspace_label
=
120 XCreateWindow(display
, frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
121 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
122 openbox
.saveToolbarSearch(frame
.workspace_label
, this);
125 XCreateWindow(display
, frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
126 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
127 openbox
.saveToolbarSearch(frame
.window_label
, this);
130 XCreateWindow(display
, frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
131 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
132 openbox
.saveToolbarSearch(frame
.clock
, this);
135 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
136 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
137 openbox
.saveToolbarSearch(frame
.psbutton
, this);
140 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
141 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
142 openbox
.saveToolbarSearch(frame
.nsbutton
, this);
145 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
146 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
147 openbox
.saveToolbarSearch(frame
.pwbutton
, this);
150 XCreateWindow(display
,frame
.window
, 0, 0, 1, 1, 0, screen
.getDepth(),
151 InputOutput
, screen
.getVisual(), create_mask
, &attrib
);
152 openbox
.saveToolbarSearch(frame
.nwbutton
, this);
154 frame
.base
= frame
.label
= frame
.wlabel
= frame
.clk
= frame
.button
=
155 frame
.pbutton
= None
;
161 int Toolbar::getX() const {
162 return ((m_hidden
) ? frame
.x_hidden
: frame
.x
);
165 int Toolbar::getY() const {
166 if (screen
.hideToolbar()) return screen
.size().h();
167 else if (m_hidden
) return frame
.y_hidden
;
171 unsigned int Toolbar::getExposedHeight() const {
172 if (screen
.hideToolbar()) return 0;
173 else if (m_autohide
) return frame
.bevel_w
;
174 else return frame
.height
;
177 void Toolbar::mapToolbar(){
178 if (!screen
.hideToolbar()) {
179 //not hidden, so windows should not maximize over the toolbar
180 XMapSubwindows(display
, frame
.window
);
181 XMapWindow(display
, frame
.window
);
185 void Toolbar::unMapToolbar(){
186 //hidden so we can maximize over the toolbar
187 XUnmapWindow(display
, frame
.window
);
190 Toolbar::~Toolbar() {
192 if (frame
.base
) image_ctrl
->removeImage(frame
.base
);
193 if (frame
.label
) image_ctrl
->removeImage(frame
.label
);
194 if (frame
.wlabel
) image_ctrl
->removeImage(frame
.wlabel
);
195 if (frame
.clk
) image_ctrl
->removeImage(frame
.clk
);
196 if (frame
.button
) image_ctrl
->removeImage(frame
.button
);
197 if (frame
.pbutton
) image_ctrl
->removeImage(frame
.pbutton
);
199 openbox
.removeToolbarSearch(frame
.window
);
200 openbox
.removeToolbarSearch(frame
.workspace_label
);
201 openbox
.removeToolbarSearch(frame
.window_label
);
202 openbox
.removeToolbarSearch(frame
.clock
);
203 openbox
.removeToolbarSearch(frame
.psbutton
);
204 openbox
.removeToolbarSearch(frame
.nsbutton
);
205 openbox
.removeToolbarSearch(frame
.pwbutton
);
206 openbox
.removeToolbarSearch(frame
.nwbutton
);
208 XDestroyWindow(display
, frame
.workspace_label
);
209 XDestroyWindow(display
, frame
.window_label
);
210 XDestroyWindow(display
, frame
.clock
);
212 XDestroyWindow(display
, frame
.window
);
220 void Toolbar::setOnTop(bool b
) {
223 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.onTop" << ends
;
224 config
.setValue(s
.str(), m_ontop
? "True" : "False");
227 void Toolbar::setAutoHide(bool b
) {
230 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.autoHide" <<
232 config
.setValue(s
.str(), m_autohide
? "True" : "False");
235 void Toolbar::setWidthPercent(int w
) {
238 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.widthPercent"
240 config
.setValue(s
.str(), m_width_percent
);
243 void Toolbar::setPlacement(int p
) {
246 s
<< "session.screen" << screen
.getScreenNumber() << ".toolbar.placement" <<
248 const char *placement
;
249 switch (m_placement
) {
250 case TopLeft
: placement
= "TopLeft"; break;
251 case BottomLeft
: placement
= "BottomLeft"; break;
252 case TopCenter
: placement
= "TopCenter"; break;
253 case TopRight
: placement
= "TopRight"; break;
254 case BottomRight
: placement
= "BottomRight"; break;
255 case BottomCenter
: default: placement
= "BottomCenter"; break;
257 config
.setValue(s
.str(), placement
);
260 void Toolbar::load() {
261 std::ostrstream rscreen
, rname
, rclass
;
265 rscreen
<< "session.screen" << screen
.getScreenNumber() << '.' << ends
;
267 rname
<< rscreen
.str() << "toolbar.widthPercent" << ends
;
268 rclass
<< rscreen
.str() << "Toolbar.WidthPercent" << ends
;
269 if (config
.getValue(rname
.str(), rclass
.str(), l
) && (l
> 0 && l
<= 100))
272 rname
.seekp(0); rclass
.seekp(0);
273 rname
<< rscreen
.str() << "toolbar.placement" << ends
;
274 rclass
<< rscreen
.str() << "Toolbar.Placement" << ends
;
275 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
276 if (0 == strncasecmp(s
.c_str(), "TopLeft", s
.length()))
277 m_placement
= TopLeft
;
278 else if (0 == strncasecmp(s
.c_str(), "BottomLeft", s
.length()))
279 m_placement
= BottomLeft
;
280 else if (0 == strncasecmp(s
.c_str(), "TopCenter", s
.length()))
281 m_placement
= TopCenter
;
282 else if (0 == strncasecmp(s
.c_str(), "TopRight", s
.length()))
283 m_placement
= TopRight
;
284 else if ( 0 == strncasecmp(s
.c_str(), "BottomRight", s
.length()))
285 m_placement
= BottomRight
;
286 else if ( 0 == strncasecmp(s
.c_str(), "BottomCenter", s
.length()))
287 m_placement
= BottomCenter
;
290 rname
.seekp(0); rclass
.seekp(0);
291 rname
<< rscreen
.str() << "toolbar.onTop" << ends
;
292 rclass
<< rscreen
.str() << "Toolbar.OnTop" << ends
;
293 if (config
.getValue(rname
.str(), rclass
.str(), b
))
296 rname
.seekp(0); rclass
.seekp(0);
297 rname
<< rscreen
.str() << "toolbar.autoHide" << ends
;
298 rclass
<< rscreen
.str() << "Toolbar.AutoHide" << ends
;
299 if (config
.getValue(rname
.str(), rclass
.str(), b
))
300 m_hidden
= m_autohide
= b
;
303 void Toolbar::reconfigure() {
304 frame
.bevel_w
= screen
.getBevelWidth();
305 frame
.width
= screen
.size().w() * m_width_percent
/ 100;
307 if (i18n
->multibyte())
309 screen
.getToolbarStyle()->fontset_extents
->max_ink_extent
.height
;
311 frame
.height
= screen
.getToolbarStyle()->font
->ascent
+
312 screen
.getToolbarStyle()->font
->descent
;
313 frame
.button_w
= frame
.height
;
315 frame
.label_h
= frame
.height
;
316 frame
.height
+= (frame
.bevel_w
* 2);
318 switch (m_placement
) {
323 frame
.y_hidden
= screen
.getBevelWidth() - screen
.getBorderWidth()
329 frame
.y
= screen
.size().h() - frame
.height
330 - (screen
.getBorderWidth() * 2);
332 frame
.y_hidden
= screen
.size().h() - screen
.getBevelWidth()
333 - screen
.getBorderWidth();
337 frame
.x
= (screen
.size().w() - frame
.width
) / 2;
339 frame
.x_hidden
= frame
.x
;
340 frame
.y_hidden
= screen
.getBevelWidth() - screen
.getBorderWidth()
346 frame
.x
= (screen
.size().w() - frame
.width
) / 2;
347 frame
.y
= screen
.size().h() - frame
.height
348 - (screen
.getBorderWidth() * 2);
349 frame
.x_hidden
= frame
.x
;
350 frame
.y_hidden
= screen
.size().h() - screen
.getBevelWidth()
351 - screen
.getBorderWidth();
355 frame
.x
= screen
.size().w() - frame
.width
356 - (screen
.getBorderWidth() * 2);
358 frame
.x_hidden
= frame
.x
;
359 frame
.y_hidden
= screen
.getBevelWidth() - screen
.getBorderWidth()
364 frame
.x
= screen
.size().w() - frame
.width
365 - (screen
.getBorderWidth() * 2);
366 frame
.y
= screen
.size().h() - frame
.height
367 - (screen
.getBorderWidth() * 2);
368 frame
.x_hidden
= frame
.x
;
369 frame
.y_hidden
= screen
.size().h() - screen
.getBevelWidth()
370 - screen
.getBorderWidth();
375 time_t ttmp
= time(NULL
);
379 tt
= localtime(&ttmp
);
381 char t
[1025], *time_string
= (char *) 0;
382 int len
= strftime(t
, 1024, screen
.getStrftimeFormat(), tt
);
383 t
[len
++-1] = ' '; // add a space to the string for padding
386 if (i18n
->multibyte()) {
387 XRectangle ink
, logical
;
388 XmbTextExtents(screen
.getToolbarStyle()->fontset
, t
, len
, &ink
,
390 frame
.clock_w
= logical
.width
;
392 // ben's additional solution to pad some space beside the numbers
394 // screen.getToolbarStyle()->fontset_extents->max_logical_extent.width *
397 // brad's solution, which is currently buggy, too big
399 // screen.getToolbarStyle()->fontset_extents->max_logical_extent.width
402 frame
.clock_w
= XTextWidth(screen
.getToolbarStyle()->font
, t
, len
);
403 // ben's additional solution to pad some space beside the numbers
404 //frame.clock_w += screen.getToolbarStyle()->font->max_bounds.width * 4;
405 // brad's solution again, too big
406 //frame.clock_w = screen.getToolbarStyle()->font->max_bounds.width * len;
408 frame
.clock_w
+= (frame
.bevel_w
* 4);
410 delete [] time_string
;
417 #else // !HAVE_STRFTIME
419 XTextWidth(screen
.getToolbarStyle()->font
,
420 i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeLength
,
422 strlen(i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeLength
,
423 "00:00000"))) + (frame
.bevel_w
* 4);
424 #endif // HAVE_STRFTIME
428 frame
.workspace_label_w
= 0;
430 for (i
= 0; i
< screen
.getWorkspaceCount(); i
++) {
431 if (i18n
->multibyte()) {
432 XRectangle ink
, logical
;
433 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
434 screen
.getWorkspace(i
)->getName(),
435 strlen(screen
.getWorkspace(i
)->getName()),
439 w
= XTextWidth(screen
.getToolbarStyle()->font
,
440 screen
.getWorkspace(i
)->getName(),
441 strlen(screen
.getWorkspace(i
)->getName()));
443 w
+= (frame
.bevel_w
* 4);
445 if (w
> frame
.workspace_label_w
) frame
.workspace_label_w
= w
;
448 if (frame
.workspace_label_w
< frame
.clock_w
)
449 frame
.workspace_label_w
= frame
.clock_w
;
450 else if (frame
.workspace_label_w
> frame
.clock_w
)
451 frame
.clock_w
= frame
.workspace_label_w
;
453 frame
.window_label_w
=
454 (frame
.width
- (frame
.clock_w
+ (frame
.button_w
* 4) +
455 frame
.workspace_label_w
+ (frame
.bevel_w
* 8) + 6));
458 XMoveResizeWindow(display
, frame
.window
, frame
.x_hidden
, frame
.y_hidden
,
459 frame
.width
, frame
.height
);
461 XMoveResizeWindow(display
, frame
.window
, frame
.x
, frame
.y
,
462 frame
.width
, frame
.height
);
465 XMoveResizeWindow(display
, frame
.workspace_label
, frame
.bevel_w
,
466 frame
.bevel_w
, frame
.workspace_label_w
,
468 XMoveResizeWindow(display
, frame
.psbutton
, (frame
.bevel_w
* 2) +
469 frame
.workspace_label_w
+ 1, frame
.bevel_w
+ 1,
470 frame
.button_w
, frame
.button_w
);
471 XMoveResizeWindow(display
,frame
.nsbutton
, (frame
.bevel_w
* 3) +
472 frame
.workspace_label_w
+ frame
.button_w
+ 2,
473 frame
.bevel_w
+ 1, frame
.button_w
, frame
.button_w
);
474 XMoveResizeWindow(display
, frame
.window_label
, (frame
.bevel_w
* 4) +
475 (frame
.button_w
* 2) + frame
.workspace_label_w
+ 3,
476 frame
.bevel_w
, frame
.window_label_w
, frame
.label_h
);
477 XMoveResizeWindow(display
, frame
.pwbutton
, (frame
.bevel_w
* 5) +
478 (frame
.button_w
* 2) + frame
.workspace_label_w
+
479 frame
.window_label_w
+ 4, frame
.bevel_w
+ 1,
480 frame
.button_w
, frame
.button_w
);
481 XMoveResizeWindow(display
, frame
.nwbutton
, (frame
.bevel_w
* 6) +
482 (frame
.button_w
* 3) + frame
.workspace_label_w
+
483 frame
.window_label_w
+ 5, frame
.bevel_w
+ 1,
484 frame
.button_w
, frame
.button_w
);
485 XMoveResizeWindow(display
, frame
.clock
, frame
.width
- frame
.clock_w
-
486 frame
.bevel_w
, frame
.bevel_w
, frame
.clock_w
,
489 Pixmap tmp
= frame
.base
;
490 BTexture
*texture
= &(screen
.getToolbarStyle()->toolbar
);
491 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
493 XSetWindowBackground(display
, frame
.window
,
494 texture
->getColor()->getPixel());
497 image_ctrl
->renderImage(frame
.width
, frame
.height
, texture
);
498 XSetWindowBackgroundPixmap(display
, frame
.window
, frame
.base
);
500 if (tmp
) image_ctrl
->removeImage(tmp
);
503 texture
= &(screen
.getToolbarStyle()->window
);
504 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
506 XSetWindowBackground(display
, frame
.window_label
,
507 texture
->getColor()->getPixel());
510 image_ctrl
->renderImage(frame
.window_label_w
, frame
.label_h
, texture
);
511 XSetWindowBackgroundPixmap(display
, frame
.window_label
, frame
.label
);
513 if (tmp
) image_ctrl
->removeImage(tmp
);
516 texture
= &(screen
.getToolbarStyle()->label
);
517 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
519 XSetWindowBackground(display
, frame
.workspace_label
,
520 texture
->getColor()->getPixel());
523 image_ctrl
->renderImage(frame
.workspace_label_w
, frame
.label_h
, texture
);
524 XSetWindowBackgroundPixmap(display
, frame
.workspace_label
, frame
.wlabel
);
526 if (tmp
) image_ctrl
->removeImage(tmp
);
529 texture
= &(screen
.getToolbarStyle()->clock
);
530 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
532 XSetWindowBackground(display
, frame
.clock
,
533 texture
->getColor()->getPixel());
536 image_ctrl
->renderImage(frame
.clock_w
, frame
.label_h
, texture
);
537 XSetWindowBackgroundPixmap(display
, frame
.clock
, frame
.clk
);
539 if (tmp
) image_ctrl
->removeImage(tmp
);
542 texture
= &(screen
.getToolbarStyle()->button
);
543 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
546 frame
.button_pixel
= texture
->getColor()->getPixel();
547 XSetWindowBackground(display
, frame
.psbutton
, frame
.button_pixel
);
548 XSetWindowBackground(display
, frame
.nsbutton
, frame
.button_pixel
);
549 XSetWindowBackground(display
, frame
.pwbutton
, frame
.button_pixel
);
550 XSetWindowBackground(display
, frame
.nwbutton
, frame
.button_pixel
);
553 image_ctrl
->renderImage(frame
.button_w
, frame
.button_w
, texture
);
555 XSetWindowBackgroundPixmap(display
, frame
.psbutton
, frame
.button
);
556 XSetWindowBackgroundPixmap(display
, frame
.nsbutton
, frame
.button
);
557 XSetWindowBackgroundPixmap(display
, frame
.pwbutton
, frame
.button
);
558 XSetWindowBackgroundPixmap(display
, frame
.nwbutton
, frame
.button
);
560 if (tmp
) image_ctrl
->removeImage(tmp
);
563 texture
= &(screen
.getToolbarStyle()->pressed
);
564 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
565 frame
.pbutton
= None
;
566 frame
.pbutton_pixel
= texture
->getColor()->getPixel();
569 image_ctrl
->renderImage(frame
.button_w
, frame
.button_w
, texture
);
571 if (tmp
) image_ctrl
->removeImage(tmp
);
573 XSetWindowBorder(display
, frame
.window
,
574 screen
.getBorderColor()->getPixel());
575 XSetWindowBorderWidth(display
, frame
.window
, screen
.getBorderWidth());
577 XClearWindow(display
, frame
.window
);
578 XClearWindow(display
, frame
.workspace_label
);
579 XClearWindow(display
, frame
.window_label
);
580 XClearWindow(display
, frame
.clock
);
581 XClearWindow(display
, frame
.psbutton
);
582 XClearWindow(display
, frame
.nsbutton
);
583 XClearWindow(display
, frame
.pwbutton
);
584 XClearWindow(display
, frame
.nwbutton
);
587 redrawWorkspaceLabel();
588 redrawPrevWorkspaceButton();
589 redrawNextWorkspaceButton();
590 redrawPrevWindowButton();
591 redrawNextWindowButton();
594 toolbarmenu
->reconfigure();
599 void Toolbar::checkClock(Bool redraw
) {
600 #else // !HAVE_STRFTIME
601 void Toolbar::checkClock(Bool redraw
, Bool date
) {
602 #endif // HAVE_STRFTIME
606 if ((tmp
= time(NULL
)) != -1) {
607 if (! (tt
= localtime(&tmp
))) return;
608 if (tt
->tm_min
!= frame
.minute
|| tt
->tm_hour
!= frame
.hour
) {
609 frame
.hour
= tt
->tm_hour
;
610 frame
.minute
= tt
->tm_min
;
611 XClearWindow(display
, frame
.clock
);
619 if (! strftime(t
, 1024, screen
.getStrftimeFormat(), tt
))
621 #else // !HAVE_STRFTIME
624 // format the date... with special consideration for y2k ;)
625 if (screen
.getDateFormat() == Openbox::B_EuropeanDate
)
626 sprintf(t
, 18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeDateFormatEu
,
628 tt
->tm_mday
, tt
->tm_mon
+ 1,
629 (tt
->tm_year
>= 100) ? tt
->tm_year
- 100 : tt
->tm_year
);
631 sprintf(t
, i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeDateFormat
,
633 tt
->tm_mon
+ 1, tt
->tm_mday
,
634 (tt
->tm_year
>= 100) ? tt
->tm_year
- 100 : tt
->tm_year
);
636 if (screen
.isClock24Hour())
637 sprintf(t
, i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeTimeFormat24
,
639 frame
.hour
, frame
.minute
);
641 sprintf(t
, i18n
->getMessage(ToolbarSet
, ToolbarNoStrftimeTimeFormat12
,
643 ((frame
.hour
> 12) ? frame
.hour
- 12 :
644 ((frame
.hour
== 0) ? 12 : frame
.hour
)), frame
.minute
,
645 ((frame
.hour
>= 12) ?
646 i18n
->getMessage(ToolbarSet
,
647 ToolbarNoStrftimeTimeFormatP
, "p") :
648 i18n
->getMessage(ToolbarSet
,
649 ToolbarNoStrftimeTimeFormatA
, "a")));
651 #endif // HAVE_STRFTIME
653 int dx
= (frame
.bevel_w
* 2), dlen
= strlen(t
);
656 if (i18n
->multibyte()) {
657 XRectangle ink
, logical
;
658 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
659 t
, dlen
, &ink
, &logical
);
662 l
= XTextWidth(screen
.getToolbarStyle()->font
, t
, dlen
);
665 l
+= (frame
.bevel_w
* 4);
667 if (l
> frame
.clock_w
) {
668 for (; dlen
>= 0; dlen
--) {
669 if (i18n
->multibyte()) {
670 XRectangle ink
, logical
;
671 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
672 t
, dlen
, &ink
, &logical
);
675 l
= XTextWidth(screen
.getToolbarStyle()->font
, t
, dlen
);
677 l
+= (frame
.bevel_w
* 4);
679 if (l
< frame
.clock_w
)
683 switch (screen
.getToolbarStyle()->justify
) {
684 case BScreen::RightJustify
:
685 dx
+= frame
.clock_w
- l
;
688 case BScreen::CenterJustify
:
689 dx
+= (frame
.clock_w
- l
) / 2;
693 ToolbarStyle
*style
= screen
.getToolbarStyle();
694 if (i18n
->multibyte())
695 XmbDrawString(display
, frame
.clock
, style
->fontset
, style
->c_text_gc
,
696 dx
, (1 - style
->fontset_extents
->max_ink_extent
.y
),
699 XDrawString(display
, frame
.clock
, style
->c_text_gc
, dx
,
700 (style
->font
->ascent
+ 1), t
, dlen
);
705 void Toolbar::redrawWindowLabel(Bool redraw
) {
706 if (screen
.getOpenbox().getFocusedWindow()) {
708 XClearWindow(display
, frame
.window_label
);
710 OpenboxWindow
*foc
= screen
.getOpenbox().getFocusedWindow();
711 if (foc
->getScreen() != &screen
) return;
713 int dx
= (frame
.bevel_w
* 2), dlen
= strlen(*foc
->getTitle());
716 if (i18n
->multibyte()) {
717 XRectangle ink
, logical
;
718 XmbTextExtents(screen
.getToolbarStyle()->fontset
, *foc
->getTitle(),
719 dlen
, &ink
, &logical
);
722 l
= XTextWidth(screen
.getToolbarStyle()->font
, *foc
->getTitle(), dlen
);
724 l
+= (frame
.bevel_w
* 4);
726 if (l
> frame
.window_label_w
) {
727 for (; dlen
>= 0; dlen
--) {
728 if (i18n
->multibyte()) {
729 XRectangle ink
, logical
;
730 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
731 *foc
->getTitle(), dlen
, &ink
, &logical
);
734 l
= XTextWidth(screen
.getToolbarStyle()->font
,
735 *foc
->getTitle(), dlen
);
737 l
+= (frame
.bevel_w
* 4);
739 if (l
< frame
.window_label_w
)
743 switch (screen
.getToolbarStyle()->justify
) {
744 case BScreen::RightJustify
:
745 dx
+= frame
.window_label_w
- l
;
748 case BScreen::CenterJustify
:
749 dx
+= (frame
.window_label_w
- l
) / 2;
753 ToolbarStyle
*style
= screen
.getToolbarStyle();
754 if (i18n
->multibyte())
755 XmbDrawString(display
, frame
.window_label
, style
->fontset
,
756 style
->w_text_gc
, dx
,
757 (1 - style
->fontset_extents
->max_ink_extent
.y
),
758 *foc
->getTitle(), dlen
);
760 XDrawString(display
, frame
.window_label
, style
->w_text_gc
, dx
,
761 (style
->font
->ascent
+ 1), *foc
->getTitle(), dlen
);
763 XClearWindow(display
, frame
.window_label
);
768 void Toolbar::redrawWorkspaceLabel(Bool redraw
) {
769 if (screen
.getCurrentWorkspace()->getName()) {
771 XClearWindow(display
, frame
.workspace_label
);
773 int dx
= (frame
.bevel_w
* 2), dlen
=
774 strlen(screen
.getCurrentWorkspace()->getName());
777 if (i18n
->multibyte()) {
778 XRectangle ink
, logical
;
779 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
780 screen
.getCurrentWorkspace()->getName(), dlen
,
784 l
= XTextWidth(screen
.getToolbarStyle()->font
,
785 screen
.getCurrentWorkspace()->getName(), dlen
);
787 l
+= (frame
.bevel_w
* 4);
789 if (l
> frame
.workspace_label_w
) {
790 for (; dlen
>= 0; dlen
--) {
791 if (i18n
->multibyte()) {
792 XRectangle ink
, logical
;
793 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
794 screen
.getCurrentWorkspace()->getName(), dlen
,
798 l
= XTextWidth(screen
.getWindowStyle()->font
,
799 screen
.getCurrentWorkspace()->getName(), dlen
);
801 l
+= (frame
.bevel_w
* 4);
803 if (l
< frame
.workspace_label_w
)
807 switch (screen
.getToolbarStyle()->justify
) {
808 case BScreen::RightJustify
:
809 dx
+= frame
.workspace_label_w
- l
;
812 case BScreen::CenterJustify
:
813 dx
+= (frame
.workspace_label_w
- l
) / 2;
817 ToolbarStyle
*style
= screen
.getToolbarStyle();
818 if (i18n
->multibyte())
819 XmbDrawString(display
, frame
.workspace_label
, style
->fontset
,
820 style
->l_text_gc
, dx
,
821 (1 - style
->fontset_extents
->max_ink_extent
.y
),
822 (char *) screen
.getCurrentWorkspace()->getName(), dlen
);
824 XDrawString(display
, frame
.workspace_label
, style
->l_text_gc
, dx
,
825 (style
->font
->ascent
+ 1),
826 (char *) screen
.getCurrentWorkspace()->getName(), dlen
);
831 void Toolbar::redrawPrevWorkspaceButton(Bool pressed
, Bool redraw
) {
835 XSetWindowBackgroundPixmap(display
, frame
.psbutton
, frame
.pbutton
);
837 XSetWindowBackground(display
, frame
.psbutton
, frame
.pbutton_pixel
);
840 XSetWindowBackgroundPixmap(display
, frame
.psbutton
, frame
.button
);
842 XSetWindowBackground(display
, frame
.psbutton
, frame
.button_pixel
);
844 XClearWindow(display
, frame
.psbutton
);
847 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
850 pts
[0].x
= hw
- 2; pts
[0].y
= hh
;
851 pts
[1].x
= 4; pts
[1].y
= 2;
852 pts
[2].x
= 0; pts
[2].y
= -4;
854 XFillPolygon(display
, frame
.psbutton
, screen
.getToolbarStyle()->b_pic_gc
,
855 pts
, 3, Convex
, CoordModePrevious
);
859 void Toolbar::redrawNextWorkspaceButton(Bool pressed
, Bool redraw
) {
863 XSetWindowBackgroundPixmap(display
, frame
.nsbutton
, frame
.pbutton
);
865 XSetWindowBackground(display
, frame
.nsbutton
, frame
.pbutton_pixel
);
868 XSetWindowBackgroundPixmap(display
, frame
.nsbutton
, frame
.button
);
870 XSetWindowBackground(display
, frame
.nsbutton
, frame
.button_pixel
);
872 XClearWindow(display
, frame
.nsbutton
);
875 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
878 pts
[0].x
= hw
- 2; pts
[0].y
= hh
- 2;
879 pts
[1].x
= 4; pts
[1].y
= 2;
880 pts
[2].x
= -4; pts
[2].y
= 2;
882 XFillPolygon(display
, frame
.nsbutton
, screen
.getToolbarStyle()->b_pic_gc
,
883 pts
, 3, Convex
, CoordModePrevious
);
887 void Toolbar::redrawPrevWindowButton(Bool pressed
, Bool redraw
) {
891 XSetWindowBackgroundPixmap(display
, frame
.pwbutton
, frame
.pbutton
);
893 XSetWindowBackground(display
, frame
.pwbutton
, frame
.pbutton_pixel
);
896 XSetWindowBackgroundPixmap(display
, frame
.pwbutton
, frame
.button
);
898 XSetWindowBackground(display
, frame
.pwbutton
, frame
.button_pixel
);
900 XClearWindow(display
, frame
.pwbutton
);
903 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
906 pts
[0].x
= hw
- 2; pts
[0].y
= hh
;
907 pts
[1].x
= 4; pts
[1].y
= 2;
908 pts
[2].x
= 0; pts
[2].y
= -4;
910 XFillPolygon(display
, frame
.pwbutton
, screen
.getToolbarStyle()->b_pic_gc
,
911 pts
, 3, Convex
, CoordModePrevious
);
915 void Toolbar::redrawNextWindowButton(Bool pressed
, Bool redraw
) {
919 XSetWindowBackgroundPixmap(display
, frame
.nwbutton
, frame
.pbutton
);
921 XSetWindowBackground(display
, frame
.nwbutton
, frame
.pbutton_pixel
);
924 XSetWindowBackgroundPixmap(display
, frame
.nwbutton
, frame
.button
);
926 XSetWindowBackground(display
, frame
.nwbutton
, frame
.button_pixel
);
928 XClearWindow(display
, frame
.nwbutton
);
931 int hh
= frame
.button_w
/ 2, hw
= frame
.button_w
/ 2;
934 pts
[0].x
= hw
- 2; pts
[0].y
= hh
- 2;
935 pts
[1].x
= 4; pts
[1].y
= 2;
936 pts
[2].x
= -4; pts
[2].y
= 2;
938 XFillPolygon(display
, frame
.nwbutton
, screen
.getToolbarStyle()->b_pic_gc
,
939 pts
, 3, Convex
, CoordModePrevious
);
943 void Toolbar::edit() {
948 if (XGetInputFocus(display
, &window
, &foo
) &&
949 window
== frame
.workspace_label
)
952 XSetInputFocus(display
, frame
.workspace_label
,
953 ((screen
.isSloppyFocus()) ? RevertToPointerRoot
:
956 XClearWindow(display
, frame
.workspace_label
);
958 openbox
.setNoFocus(True
);
959 if (openbox
.getFocusedWindow())
960 openbox
.getFocusedWindow()->setFocusFlag(False
);
962 XDrawRectangle(display
, frame
.workspace_label
,
963 screen
.getWindowStyle()->l_text_focus_gc
,
964 frame
.workspace_label_w
/ 2, 0, 1,
967 // change the background of the window to that of an active window label
968 Pixmap tmp
= frame
.wlabel
;
969 BTexture
*texture
= &(screen
.getWindowStyle()->l_focus
);
970 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
972 XSetWindowBackground(display
, frame
.workspace_label
,
973 texture
->getColor()->getPixel());
976 image_ctrl
->renderImage(frame
.workspace_label_w
, frame
.label_h
, texture
);
977 XSetWindowBackgroundPixmap(display
, frame
.workspace_label
, frame
.wlabel
);
979 if (tmp
) image_ctrl
->removeImage(tmp
);
983 void Toolbar::buttonPressEvent(XButtonEvent
*be
) {
984 if (be
->button
== 1) {
985 if (be
->window
== frame
.psbutton
)
986 redrawPrevWorkspaceButton(True
, True
);
987 else if (be
->window
== frame
.nsbutton
)
988 redrawNextWorkspaceButton(True
, True
);
989 else if (be
->window
== frame
.pwbutton
)
990 redrawPrevWindowButton(True
, True
);
991 else if (be
->window
== frame
.nwbutton
)
992 redrawNextWindowButton(True
, True
);
993 #ifndef HAVE_STRFTIME
994 else if (be
->window
== frame
.clock
) {
995 XClearWindow(display
, frame
.clock
);
996 checkClock(True
, True
);
998 #endif // HAVE_STRFTIME
999 else if (! m_ontop
) {
1000 Window w
[1] = { frame
.window
};
1001 screen
.raiseWindows(w
, 1);
1003 } else if (be
->button
== 2 && (! m_ontop
)) {
1004 XLowerWindow(display
, frame
.window
);
1005 } else if (be
->button
== 3) {
1006 if (! toolbarmenu
->isVisible()) {
1009 x
= be
->x_root
- (toolbarmenu
->getWidth() / 2);
1010 y
= be
->y_root
- (toolbarmenu
->getHeight() / 2);
1014 else if (x
+ toolbarmenu
->getWidth() > screen
.size().w())
1015 x
= screen
.size().w() - toolbarmenu
->getWidth();
1019 else if (y
+ toolbarmenu
->getHeight() > screen
.size().h())
1020 y
= screen
.size().h() - toolbarmenu
->getHeight();
1022 toolbarmenu
->move(x
, y
);
1023 toolbarmenu
->show();
1025 toolbarmenu
->hide();
1031 void Toolbar::buttonReleaseEvent(XButtonEvent
*re
) {
1032 if (re
->button
== 1) {
1033 if (re
->window
== frame
.psbutton
) {
1034 redrawPrevWorkspaceButton(False
, True
);
1036 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1037 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1038 if (screen
.getCurrentWorkspace()->getWorkspaceID() > 0)
1039 screen
.changeWorkspaceID(screen
.getCurrentWorkspace()->
1040 getWorkspaceID() - 1);
1042 screen
.changeWorkspaceID(screen
.getWorkspaceCount() - 1);
1043 } else if (re
->window
== frame
.nsbutton
) {
1044 redrawNextWorkspaceButton(False
, True
);
1046 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1047 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1048 if (screen
.getCurrentWorkspace()->getWorkspaceID() <
1049 screen
.getWorkspaceCount() - 1)
1050 screen
.changeWorkspaceID(screen
.getCurrentWorkspace()->
1051 getWorkspaceID() + 1);
1053 screen
.changeWorkspaceID(0);
1054 } else if (re
->window
== frame
.pwbutton
) {
1055 redrawPrevWindowButton(False
, True
);
1057 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1058 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1060 } else if (re
->window
== frame
.nwbutton
) {
1061 redrawNextWindowButton(False
, True
);
1063 if (re
->x
>= 0 && re
->x
< (signed) frame
.button_w
&&
1064 re
->y
>= 0 && re
->y
< (signed) frame
.button_w
)
1066 } else if (re
->window
== frame
.window_label
)
1067 screen
.raiseFocus();
1068 #ifndef HAVE_STRFTIME
1069 else if (re
->window
== frame
.clock
) {
1070 XClearWindow(display
, frame
.clock
);
1073 #endif // HAVE_STRFTIME
1078 void Toolbar::enterNotifyEvent(XCrossingEvent
*) {
1083 if (! hide_timer
->isTiming()) hide_timer
->start();
1085 if (hide_timer
->isTiming()) hide_timer
->stop();
1089 void Toolbar::leaveNotifyEvent(XCrossingEvent
*) {
1094 if (hide_timer
->isTiming()) hide_timer
->stop();
1095 } else if (! toolbarmenu
->isVisible()) {
1096 if (! hide_timer
->isTiming()) hide_timer
->start();
1101 void Toolbar::exposeEvent(XExposeEvent
*ee
) {
1102 if (ee
->window
== frame
.clock
) checkClock(True
);
1103 else if (ee
->window
== frame
.workspace_label
&& (! m_editing
))
1104 redrawWorkspaceLabel();
1105 else if (ee
->window
== frame
.window_label
) redrawWindowLabel();
1106 else if (ee
->window
== frame
.psbutton
) redrawPrevWorkspaceButton();
1107 else if (ee
->window
== frame
.nsbutton
) redrawNextWorkspaceButton();
1108 else if (ee
->window
== frame
.pwbutton
) redrawPrevWindowButton();
1109 else if (ee
->window
== frame
.nwbutton
) redrawNextWindowButton();
1113 void Toolbar::keyPressEvent(XKeyEvent
*ke
) {
1114 if (ke
->window
== frame
.workspace_label
&& m_editing
) {
1117 if (! new_workspace_name
) {
1118 new_workspace_name
= new char[128];
1121 if (! new_workspace_name
) return;
1126 XLookupString(ke
, keychar
, 1, &ks
, 0);
1128 // either we are told to end with a return or we hit the end of the buffer
1129 if (ks
== XK_Return
|| new_name_pos
== 127) {
1130 *(new_workspace_name
+ new_name_pos
) = 0;
1134 openbox
.setNoFocus(False
);
1135 if (openbox
.getFocusedWindow()) {
1136 openbox
.getFocusedWindow()->setInputFocus();
1137 openbox
.getFocusedWindow()->setFocusFlag(True
);
1139 XSetInputFocus(display
, PointerRoot
, None
, CurrentTime
);
1141 // check to make sure that new_name[0] != 0... otherwise we have a null
1142 // workspace name which causes serious problems, especially for the
1143 // Openbox::LoadRC() method.
1144 if (*new_workspace_name
) {
1145 screen
.getCurrentWorkspace()->setName(new_workspace_name
);
1146 screen
.getCurrentWorkspace()->getMenu()->hide();
1147 screen
.getWorkspacemenu()->
1148 remove(screen
.getCurrentWorkspace()->getWorkspaceID() + 2);
1149 screen
.getWorkspacemenu()->
1150 insert(screen
.getCurrentWorkspace()->getName(),
1151 screen
.getCurrentWorkspace()->getMenu(),
1152 screen
.getCurrentWorkspace()->getWorkspaceID() + 2);
1153 screen
.getWorkspacemenu()->update();
1156 delete [] new_workspace_name
;
1157 new_workspace_name
= (char *) 0;
1160 // reset the background to that of the workspace label (its normal
1162 Pixmap tmp
= frame
.wlabel
;
1163 BTexture
*texture
= &(screen
.getToolbarStyle()->label
);
1164 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
1165 frame
.wlabel
= None
;
1166 XSetWindowBackground(display
, frame
.workspace_label
,
1167 texture
->getColor()->getPixel());
1170 image_ctrl
->renderImage(frame
.workspace_label_w
, frame
.label_h
, texture
);
1171 XSetWindowBackgroundPixmap(display
, frame
.workspace_label
, frame
.wlabel
);
1173 if (tmp
) image_ctrl
->removeImage(tmp
);
1176 } else if (! (ks
== XK_Shift_L
|| ks
== XK_Shift_R
||
1177 ks
== XK_Control_L
|| ks
== XK_Control_R
||
1178 ks
== XK_Caps_Lock
|| ks
== XK_Shift_Lock
||
1179 ks
== XK_Meta_L
|| ks
== XK_Meta_R
||
1180 ks
== XK_Alt_L
|| ks
== XK_Alt_R
||
1181 ks
== XK_Super_L
|| ks
== XK_Super_R
||
1182 ks
== XK_Hyper_L
|| ks
== XK_Hyper_R
)) {
1183 if (ks
== XK_BackSpace
) {
1184 if (new_name_pos
> 0) {
1186 *(new_workspace_name
+ new_name_pos
) = '\0';
1188 *new_workspace_name
= '\0';
1191 *(new_workspace_name
+ new_name_pos
) = *keychar
;
1193 *(new_workspace_name
+ new_name_pos
) = '\0';
1196 XClearWindow(display
, frame
.workspace_label
);
1197 int l
= strlen(new_workspace_name
), tw
, x
;
1199 if (i18n
->multibyte()) {
1200 XRectangle ink
, logical
;
1201 XmbTextExtents(screen
.getToolbarStyle()->fontset
,
1202 new_workspace_name
, l
, &ink
, &logical
);
1205 tw
= XTextWidth(screen
.getToolbarStyle()->font
,
1206 new_workspace_name
, l
);
1208 x
= (frame
.workspace_label_w
- tw
) / 2;
1210 if (x
< (signed) frame
.bevel_w
) x
= frame
.bevel_w
;
1212 WindowStyle
*style
= screen
.getWindowStyle();
1213 if (i18n
->multibyte())
1214 XmbDrawString(display
, frame
.workspace_label
, style
->fontset
,
1215 style
->l_text_focus_gc
, x
,
1216 (1 - style
->fontset_extents
->max_ink_extent
.y
),
1217 new_workspace_name
, l
);
1219 XDrawString(display
, frame
.workspace_label
, style
->l_text_focus_gc
, x
,
1220 (style
->font
->ascent
+ 1),
1221 new_workspace_name
, l
);
1223 XDrawRectangle(display
, frame
.workspace_label
,
1224 screen
.getWindowStyle()->l_text_focus_gc
, x
+ tw
, 0, 1,
1233 void Toolbar::timeout() {
1237 gettimeofday(&now
, 0);
1238 clock_timer
->setTimeout((60 - (now
.tv_sec
% 60)) * 1000);
1242 void Toolbar::HideHandler::timeout() {
1243 toolbar
->m_hidden
= !toolbar
->m_hidden
;
1244 if (toolbar
->m_hidden
)
1245 XMoveWindow(toolbar
->display
, toolbar
->frame
.window
,
1246 toolbar
->frame
.x_hidden
, toolbar
->frame
.y_hidden
);
1248 XMoveWindow(toolbar
->display
, toolbar
->frame
.window
,
1249 toolbar
->frame
.x
, toolbar
->frame
.y
);
1253 Toolbarmenu::Toolbarmenu(Toolbar
&tb
) : Basemenu(tb
.screen
), toolbar(tb
) {
1254 setLabel(i18n
->getMessage(ToolbarSet
, ToolbarToolbarTitle
, "Toolbar"));
1257 placementmenu
= new Placementmenu(*this);
1259 insert(i18n
->getMessage(CommonSet
, CommonPlacementTitle
, "Placement"),
1261 insert(i18n
->getMessage(CommonSet
, CommonAlwaysOnTop
, "Always on top"), 1);
1262 insert(i18n
->getMessage(CommonSet
, CommonAutoHide
, "Auto hide"), 2);
1263 insert(i18n
->getMessage(ToolbarSet
, ToolbarEditWkspcName
,
1264 "Edit current workspace name"), 3);
1268 if (toolbar
.onTop()) setItemSelected(1, True
);
1269 if (toolbar
.autoHide()) setItemSelected(2, True
);
1273 Toolbarmenu::~Toolbarmenu() {
1274 delete placementmenu
;
1278 void Toolbarmenu::itemSelected(int button
, int index
) {
1282 BasemenuItem
*item
= find(index
);
1285 switch (item
->function()) {
1286 case 1: { // always on top
1287 Bool change
= ((toolbar
.onTop()) ? False
: True
);
1288 toolbar
.setOnTop(change
);
1289 setItemSelected(1, change
);
1291 if (toolbar
.onTop()) toolbar
.screen
.raiseWindows((Window
*) 0, 0);
1295 case 2: { // auto hide
1296 Bool change
= ((toolbar
.autoHide()) ? False
: True
);
1297 toolbar
.setAutoHide(change
);
1298 setItemSelected(2, change
);
1301 toolbar
.screen
.getSlit()->reposition();
1306 case 3: { // edit current workspace name
1316 void Toolbarmenu::internal_hide() {
1317 Basemenu::internal_hide();
1318 if (toolbar
.autoHide() && ! toolbar
.isEditing())
1319 toolbar
.hide_handler
.timeout();
1323 void Toolbarmenu::reconfigure() {
1324 placementmenu
->reconfigure();
1326 Basemenu::reconfigure();
1330 Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu
&tm
)
1331 : Basemenu(tm
.toolbar
.screen
), toolbarmenu(tm
) {
1332 setLabel(i18n
->getMessage(ToolbarSet
, ToolbarToolbarPlacement
,
1333 "Toolbar Placement"));
1335 setMinimumSublevels(3);
1337 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopLeft
,
1338 "Top Left"), Toolbar::TopLeft
);
1339 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomLeft
,
1340 "Bottom Left"), Toolbar::BottomLeft
);
1341 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopCenter
,
1342 "Top Center"), Toolbar::TopCenter
);
1343 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomCenter
,
1344 "Bottom Center"), Toolbar::BottomCenter
);
1345 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopRight
,
1346 "Top Right"), Toolbar::TopRight
);
1347 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomRight
,
1348 "Bottom Right"), Toolbar::BottomRight
);
1353 void Toolbarmenu::Placementmenu::itemSelected(int button
, int index
) {
1357 BasemenuItem
*item
= find(index
);
1360 toolbarmenu
.toolbar
.setPlacement(item
->function());
1362 toolbarmenu
.toolbar
.reconfigure();
1365 // reposition the slit as well to make sure it doesn't intersect the
1367 toolbarmenu
.toolbar
.screen
.getSlit()->reposition();