2002-03-19 14:30:43 +00:00
|
|
|
// Toolbar.cc for Fluxbox
|
|
|
|
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
|
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Toolbar.cc for Blackbox - an X11 Window manager
|
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2002-03-19 14:30:43 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2002-09-14 10:58:25 +00:00
|
|
|
// $Id: Toolbar.cc,v 1.32 2002/09/14 10:58:25 rathnor Exp $
|
2002-08-04 15:12:51 +00:00
|
|
|
|
|
|
|
#include "Toolbar.hh"
|
2002-02-07 15:12:23 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include "i18n.hh"
|
|
|
|
#include "fluxbox.hh"
|
|
|
|
#include "Clientmenu.hh"
|
|
|
|
#include "Icon.hh"
|
|
|
|
#include "Rootmenu.hh"
|
|
|
|
#include "Screen.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Workspace.hh"
|
|
|
|
#include "Workspacemenu.hh"
|
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
// use GNU extensions
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
#else // !TIME_WITH_SYS_TIME
|
2002-08-12 03:25:55 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#else // !HAVE_SYS_TIME_H
|
|
|
|
#include <time.h>
|
|
|
|
#endif // HAVE_SYS_TIME_H
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // TIME_WITH_SYS_TIME
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2002-01-21 00:53:02 +00:00
|
|
|
Toolbar::Toolbar(BScreen *scrn):
|
2002-08-04 15:12:51 +00:00
|
|
|
on_top(scrn->isToolbarOnTop()),
|
|
|
|
editing(false),
|
|
|
|
hidden(scrn->doToolbarAutoHide()),
|
|
|
|
do_auto_hide(scrn->doToolbarAutoHide()),
|
2002-01-21 00:53:02 +00:00
|
|
|
screen(scrn),
|
2002-08-04 15:12:51 +00:00
|
|
|
image_ctrl(scrn->getImageControl()),
|
2002-03-19 00:12:36 +00:00
|
|
|
clock_timer(this), // get the clock updating every minute
|
2002-08-04 15:12:51 +00:00
|
|
|
iconbar(0) {
|
2002-03-19 00:12:36 +00:00
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
fluxbox = Fluxbox::instance();
|
2002-03-19 00:12:36 +00:00
|
|
|
|
2002-08-24 19:31:24 +00:00
|
|
|
timeval delay;
|
|
|
|
delay.tv_sec = 1;
|
|
|
|
delay.tv_usec = 0;
|
|
|
|
clock_timer.setTimeout(delay);
|
2002-03-19 00:12:36 +00:00
|
|
|
clock_timer.start();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
hide_handler.toolbar = this;
|
2002-03-19 00:12:36 +00:00
|
|
|
hide_timer = new BTimer(&hide_handler);
|
2001-12-11 20:47:02 +00:00
|
|
|
hide_timer->setTimeout(fluxbox->getAutoRaiseDelay());
|
2002-08-04 15:12:51 +00:00
|
|
|
hide_timer->fireOnce(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
frame.grab_x = frame.grab_y = 0;
|
|
|
|
|
|
|
|
toolbarmenu = new Toolbarmenu(this);
|
|
|
|
|
|
|
|
display = fluxbox->getXDisplay();
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
2002-01-21 00:53:02 +00:00
|
|
|
CWColormap | CWOverrideRedirect | CWEventMask;
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
attrib.background_pixmap = None;
|
|
|
|
attrib.background_pixel = attrib.border_pixel =
|
2002-07-20 09:49:57 +00:00
|
|
|
screen->getBorderColor()->pixel();
|
|
|
|
attrib.colormap = screen->colormap();
|
2002-08-04 15:12:51 +00:00
|
|
|
attrib.override_redirect = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
|
2002-01-21 00:53:02 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
frame.window =
|
|
|
|
XCreateWindow(display, screen->getRootWindow(), 0, 0, 1, 1, 0,
|
|
|
|
screen->getDepth(), InputOutput, screen->getVisual(),
|
|
|
|
create_mask, &attrib);
|
|
|
|
fluxbox->saveToolbarSearch(frame.window, this);
|
|
|
|
|
|
|
|
attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask |
|
2002-01-21 00:53:02 +00:00
|
|
|
KeyPressMask | EnterWindowMask;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
frame.workspace_label =
|
|
|
|
XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
|
|
|
fluxbox->saveToolbarSearch(frame.workspace_label, this);
|
|
|
|
|
|
|
|
frame.window_label =
|
|
|
|
XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
|
|
|
fluxbox->saveToolbarSearch(frame.window_label, this);
|
|
|
|
|
|
|
|
frame.clock =
|
|
|
|
XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
|
|
|
fluxbox->saveToolbarSearch(frame.clock, this);
|
|
|
|
|
|
|
|
frame.psbutton =
|
|
|
|
XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
2002-01-21 00:53:02 +00:00
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox->saveToolbarSearch(frame.psbutton, this);
|
|
|
|
|
|
|
|
frame.nsbutton =
|
|
|
|
XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
2002-01-21 00:53:02 +00:00
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox->saveToolbarSearch(frame.nsbutton, this);
|
|
|
|
|
|
|
|
frame.pwbutton =
|
|
|
|
XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
2002-01-21 00:53:02 +00:00
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox->saveToolbarSearch(frame.pwbutton, this);
|
|
|
|
|
|
|
|
frame.nwbutton =
|
|
|
|
XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(),
|
2002-01-21 00:53:02 +00:00
|
|
|
InputOutput, screen->getVisual(), create_mask, &attrib);
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox->saveToolbarSearch(frame.nwbutton, this);
|
|
|
|
|
|
|
|
frame.base = frame.label = frame.wlabel = frame.clk = frame.button =
|
|
|
|
frame.pbutton = None;
|
|
|
|
|
2002-02-07 15:12:23 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
if (Fluxbox::instance()->useIconBar())
|
|
|
|
iconbar = new IconBar(screen, frame.window_label);
|
|
|
|
else
|
2002-02-07 15:12:23 +00:00
|
|
|
iconbar = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XMapSubwindows(display, frame.window);
|
2002-02-07 15:12:23 +00:00
|
|
|
XMapWindow(display, frame.window);
|
|
|
|
|
|
|
|
reconfigure();
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
Toolbar::~Toolbar() {
|
2001-12-11 20:47:02 +00:00
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
|
|
|
|
if (frame.base) image_ctrl->removeImage(frame.base);
|
|
|
|
if (frame.label) image_ctrl->removeImage(frame.label);
|
|
|
|
if (frame.wlabel) image_ctrl->removeImage(frame.wlabel);
|
|
|
|
if (frame.clk) image_ctrl->removeImage(frame.clk);
|
|
|
|
if (frame.button) image_ctrl->removeImage(frame.button);
|
|
|
|
if (frame.pbutton) image_ctrl->removeImage(frame.pbutton);
|
|
|
|
|
|
|
|
|
|
|
|
fluxbox->removeToolbarSearch(frame.window);
|
|
|
|
|
|
|
|
fluxbox->removeToolbarSearch(frame.workspace_label);
|
|
|
|
fluxbox->removeToolbarSearch(frame.window_label);
|
|
|
|
fluxbox->removeToolbarSearch(frame.clock);
|
|
|
|
fluxbox->removeToolbarSearch(frame.psbutton);
|
|
|
|
fluxbox->removeToolbarSearch(frame.nsbutton);
|
|
|
|
fluxbox->removeToolbarSearch(frame.pwbutton);
|
|
|
|
fluxbox->removeToolbarSearch(frame.nwbutton);
|
|
|
|
|
|
|
|
XDestroyWindow(display, frame.workspace_label);
|
|
|
|
XDestroyWindow(display, frame.window_label);
|
|
|
|
XDestroyWindow(display, frame.clock);
|
|
|
|
|
|
|
|
XDestroyWindow(display, frame.window);
|
|
|
|
|
|
|
|
delete hide_timer;
|
|
|
|
delete toolbarmenu;
|
|
|
|
if (iconbar)
|
|
|
|
delete iconbar;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::addIcon(FluxboxWindow *w) {
|
|
|
|
if (iconbar)
|
|
|
|
Fluxbox::instance()->saveToolbarSearch(iconbar->addIcon(w), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::delIcon(FluxboxWindow *w) {
|
|
|
|
if (iconbar)
|
|
|
|
Fluxbox::instance()->removeToolbarSearch(iconbar->delIcon(w));
|
|
|
|
}
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::reconfigure() {
|
2002-03-19 14:30:43 +00:00
|
|
|
int head_x = 0,
|
|
|
|
head_y = 0,
|
|
|
|
head_w,
|
|
|
|
head_h;
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.bevel_w = screen->getBevelWidth();
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
int head = (screen->hasXinerama())
|
|
|
|
? screen->getToolbarOnHead()
|
|
|
|
: -1;
|
|
|
|
|
|
|
|
if (head >= 0) { // toolbar on head nr, if -1 then over ALL heads
|
|
|
|
head_x = screen->getHeadX(head);
|
|
|
|
head_y = screen->getHeadY(head);
|
|
|
|
head_w = screen->getHeadWidth(head);
|
|
|
|
head_h = screen->getHeadHeight(head);
|
|
|
|
|
|
|
|
frame.width =
|
|
|
|
(screen->getHeadWidth(head) * screen->getToolbarWidthPercent() / 100);
|
|
|
|
} else {
|
2002-03-29 21:47:58 +00:00
|
|
|
head_w = screen->getWidth();
|
|
|
|
head_h = screen->getHeight();
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
|
|
frame.width = screen->getWidth() * screen->getToolbarWidthPercent() / 100;
|
|
|
|
}
|
|
|
|
#else // !XINERAMA
|
|
|
|
head_w = screen->getWidth();
|
|
|
|
head_h = screen->getHeight();
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.width = screen->getWidth() * screen->getToolbarWidthPercent() / 100;
|
2002-03-19 14:30:43 +00:00
|
|
|
#endif // XINERAMA
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
if (i18n->multibyte())
|
|
|
|
frame.height =
|
|
|
|
screen->getToolbarStyle()->font.set_extents->max_ink_extent.height;
|
|
|
|
else
|
|
|
|
frame.height = screen->getToolbarStyle()->font.fontstruct->ascent +
|
|
|
|
screen->getToolbarStyle()->font.fontstruct->descent;
|
|
|
|
frame.button_w = frame.height;
|
|
|
|
frame.height += 2;
|
|
|
|
frame.label_h = frame.height;
|
|
|
|
frame.height += (frame.bevel_w * 2);
|
|
|
|
|
|
|
|
switch (screen->getToolbarPlacement()) {
|
2002-01-06 09:37:50 +00:00
|
|
|
case TOPLEFT:
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y;
|
|
|
|
frame.x_hidden = head_x;
|
|
|
|
frame.y_hidden = head_y +
|
|
|
|
screen->getBevelWidth() - screen->getBorderWidth() - frame.height;
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-01-06 09:37:50 +00:00
|
|
|
case BOTTOMLEFT:
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
|
|
|
|
frame.x_hidden = head_x;
|
|
|
|
frame.y_hidden = head_y + head_h - screen->getBevelWidth() -
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getBorderWidth();
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-01-06 09:37:50 +00:00
|
|
|
case TOPCENTER:
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.x = head_x + ((head_w - frame.width) / 2);
|
|
|
|
frame.y = head_y;
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.y_hidden = head_y +
|
|
|
|
screen->getBevelWidth() - screen->getBorderWidth() - frame.height;
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-01-06 09:37:50 +00:00
|
|
|
case BOTTOMCENTER:
|
2001-12-11 20:47:02 +00:00
|
|
|
default:
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.x = head_x + ((head_w - frame.width) / 2);
|
|
|
|
frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.y_hidden = head_y + head_h - screen->getBevelWidth() -
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getBorderWidth();
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-01-06 09:37:50 +00:00
|
|
|
case TOPRIGHT:
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
|
|
|
|
frame.y = head_y;
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.y_hidden = head_y +
|
|
|
|
screen->getBevelWidth() - screen->getBorderWidth() - frame.height;
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
|
2002-01-06 09:37:50 +00:00
|
|
|
case BOTTOMRIGHT:
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - screen->getBorderWidth2x();
|
|
|
|
frame.y = head_y + head_h - frame.height - screen->getBorderWidth2x();
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2002-03-19 14:30:43 +00:00
|
|
|
frame.y_hidden = head_y + head_h - screen->getBevelWidth() -
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getBorderWidth();
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-21 00:53:02 +00:00
|
|
|
#ifdef HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
time_t ttmp = time(NULL);
|
|
|
|
struct tm *tt = 0;
|
|
|
|
|
|
|
|
if (ttmp != -1) {
|
|
|
|
tt = localtime(&ttmp);
|
|
|
|
if (tt) {
|
|
|
|
char t[1024], *time_string = (char *) 0;
|
|
|
|
int len = strftime(t, 1024, screen->getStrftimeFormat(), tt);
|
|
|
|
|
|
|
|
time_string = new char[len + 1];
|
|
|
|
|
|
|
|
memset(time_string, '0', len);
|
|
|
|
*(time_string + len) = '\0';
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
2002-01-21 00:53:02 +00:00
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set, time_string, len,
|
|
|
|
&ink, &logical);
|
|
|
|
frame.clock_w = logical.width;
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
2002-01-21 00:53:02 +00:00
|
|
|
frame.clock_w = XTextWidth(screen->getToolbarStyle()->font.fontstruct,
|
|
|
|
time_string, len);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
frame.clock_w += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
delete [] time_string;
|
|
|
|
} else
|
|
|
|
frame.clock_w = 0;
|
|
|
|
} else
|
|
|
|
frame.clock_w = 0;
|
2002-01-21 00:53:02 +00:00
|
|
|
#else // !HAVE_STRFTIME
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.clock_w =
|
|
|
|
XTextWidth(screen->getToolbarStyle()->font.fontstruct,
|
|
|
|
i18n->getMessage(
|
2002-01-21 00:53:02 +00:00
|
|
|
#ifdef NLS
|
|
|
|
ToolbarSet, ToolbarNoStrftimeLength,
|
|
|
|
#else // !NLS
|
|
|
|
0, 0,
|
|
|
|
#endif // NLS
|
|
|
|
"00:00000"),
|
|
|
|
strlen(i18n->getMessage(
|
|
|
|
#ifdef NLS
|
|
|
|
ToolbarSet, ToolbarNoStrftimeLength,
|
|
|
|
#else // !NLS
|
|
|
|
0, 0,
|
|
|
|
#endif // NLS
|
|
|
|
"00:00000"))) + (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
#endif // HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
unsigned int i;
|
2001-12-11 20:47:02 +00:00
|
|
|
unsigned int w = 0;
|
|
|
|
frame.workspace_label_w = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < screen->getCount(); i++) {
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getWorkspace(i)->name().c_str(),
|
|
|
|
screen->getWorkspace(i)->name().size(),
|
2001-12-11 20:47:02 +00:00
|
|
|
&ink, &logical);
|
|
|
|
w = logical.width;
|
|
|
|
} else
|
|
|
|
w = XTextWidth(screen->getToolbarStyle()->font.fontstruct,
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getWorkspace(i)->name().c_str(),
|
|
|
|
screen->getWorkspace(i)->name().size());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
w += (frame.bevel_w * 4);
|
|
|
|
|
2002-01-21 00:53:02 +00:00
|
|
|
if (w > frame.workspace_label_w)
|
|
|
|
frame.workspace_label_w = w;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frame.workspace_label_w < frame.clock_w)
|
|
|
|
frame.workspace_label_w = frame.clock_w;
|
|
|
|
else if (frame.workspace_label_w > frame.clock_w)
|
|
|
|
frame.clock_w = frame.workspace_label_w;
|
|
|
|
|
|
|
|
frame.window_label_w =
|
|
|
|
(frame.width - (frame.clock_w + (frame.button_w * 4) +
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.workspace_label_w + (frame.bevel_w * 8) + 6));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (hidden)
|
|
|
|
XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden,
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.width, frame.height);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
|
|
|
XMoveResizeWindow(display, frame.window, frame.x, frame.y,
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.width, frame.height);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XMoveResizeWindow(display, frame.workspace_label, frame.bevel_w,
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.bevel_w, frame.workspace_label_w,
|
|
|
|
frame.label_h);
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(display, frame.psbutton, (frame.bevel_w * 2) +
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.workspace_label_w + 1, frame.bevel_w + 1,
|
|
|
|
frame.button_w, frame.button_w);
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(display ,frame.nsbutton, (frame.bevel_w * 3) +
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.workspace_label_w + frame.button_w + 2,
|
|
|
|
frame.bevel_w + 1, frame.button_w, frame.button_w);
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(display, frame.window_label, (frame.bevel_w * 4) +
|
2002-01-08 00:43:52 +00:00
|
|
|
(frame.button_w * 2) + frame.workspace_label_w + 3,
|
|
|
|
frame.bevel_w, frame.window_label_w, frame.label_h);
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(display, frame.pwbutton, (frame.bevel_w * 5) +
|
2002-01-08 00:43:52 +00:00
|
|
|
(frame.button_w * 2) + frame.workspace_label_w +
|
|
|
|
frame.window_label_w + 4, frame.bevel_w + 1,
|
|
|
|
frame.button_w, frame.button_w);
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(display, frame.nwbutton, (frame.bevel_w * 6) +
|
2002-01-08 00:43:52 +00:00
|
|
|
(frame.button_w * 3) + frame.workspace_label_w +
|
|
|
|
frame.window_label_w + 5, frame.bevel_w + 1,
|
|
|
|
frame.button_w, frame.button_w);
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(display, frame.clock, frame.width - frame.clock_w -
|
2002-01-08 00:43:52 +00:00
|
|
|
frame.bevel_w, frame.bevel_w, frame.clock_w,
|
|
|
|
frame.label_h);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
Pixmap tmp = frame.base;
|
2002-07-23 17:11:59 +00:00
|
|
|
FbTk::Texture *texture = &(screen->getToolbarStyle()->toolbar);
|
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.base = None;
|
|
|
|
XSetWindowBackground(display, frame.window,
|
2002-07-20 09:49:57 +00:00
|
|
|
texture->color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
frame.base =
|
|
|
|
image_ctrl->renderImage(frame.width, frame.height, texture);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.window, frame.base);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.label;
|
|
|
|
texture = &(screen->getToolbarStyle()->window);
|
2002-07-23 17:11:59 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.label = None;
|
|
|
|
XSetWindowBackground(display, frame.window_label,
|
2002-07-20 09:49:57 +00:00
|
|
|
texture->color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
frame.label =
|
|
|
|
image_ctrl->renderImage(frame.window_label_w, frame.label_h, texture);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.window_label, frame.label);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.wlabel;
|
|
|
|
texture = &(screen->getToolbarStyle()->label);
|
2002-07-23 17:11:59 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.wlabel = None;
|
|
|
|
XSetWindowBackground(display, frame.workspace_label,
|
2002-07-20 09:49:57 +00:00
|
|
|
texture->color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
frame.wlabel =
|
|
|
|
image_ctrl->renderImage(frame.workspace_label_w, frame.label_h, texture);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.clk;
|
|
|
|
texture = &(screen->getToolbarStyle()->clock);
|
2002-07-23 17:11:59 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.clk = None;
|
|
|
|
XSetWindowBackground(display, frame.clock,
|
2002-07-20 09:49:57 +00:00
|
|
|
texture->color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
frame.clk =
|
|
|
|
image_ctrl->renderImage(frame.clock_w, frame.label_h, texture);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.clock, frame.clk);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.button;
|
|
|
|
texture = &(screen->getToolbarStyle()->button);
|
2002-07-23 17:11:59 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.button = None;
|
|
|
|
|
2002-07-20 09:49:57 +00:00
|
|
|
frame.button_pixel = texture->color().pixel();
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBackground(display, frame.psbutton, frame.button_pixel);
|
|
|
|
XSetWindowBackground(display, frame.nsbutton, frame.button_pixel);
|
|
|
|
XSetWindowBackground(display, frame.pwbutton, frame.button_pixel);
|
|
|
|
XSetWindowBackground(display, frame.nwbutton, frame.button_pixel);
|
|
|
|
} else {
|
|
|
|
frame.button =
|
|
|
|
image_ctrl->renderImage(frame.button_w, frame.button_w, texture);
|
|
|
|
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button);
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button);
|
|
|
|
}
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
tmp = frame.pbutton;
|
|
|
|
texture = &(screen->getToolbarStyle()->pressed);
|
2002-07-23 17:11:59 +00:00
|
|
|
if (texture->type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
frame.pbutton = None;
|
2002-07-20 09:49:57 +00:00
|
|
|
frame.pbutton_pixel = texture->color().pixel();
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
|
|
|
frame.pbutton =
|
|
|
|
image_ctrl->renderImage(frame.button_w, frame.button_w, texture);
|
|
|
|
if (tmp) image_ctrl->removeImage(tmp);
|
|
|
|
|
|
|
|
XSetWindowBorder(display, frame.window,
|
2002-07-20 09:49:57 +00:00
|
|
|
screen->getBorderColor()->pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBorderWidth(display, frame.window, screen->getBorderWidth());
|
|
|
|
|
|
|
|
XClearWindow(display, frame.window);
|
|
|
|
XClearWindow(display, frame.workspace_label);
|
|
|
|
XClearWindow(display, frame.window_label);
|
|
|
|
XClearWindow(display, frame.clock);
|
|
|
|
XClearWindow(display, frame.psbutton);
|
|
|
|
XClearWindow(display, frame.nsbutton);
|
|
|
|
XClearWindow(display, frame.pwbutton);
|
|
|
|
XClearWindow(display, frame.nwbutton);
|
|
|
|
|
|
|
|
redrawWindowLabel();
|
|
|
|
redrawWorkspaceLabel();
|
|
|
|
redrawPrevWorkspaceButton();
|
|
|
|
redrawNextWorkspaceButton();
|
|
|
|
redrawPrevWindowButton();
|
|
|
|
redrawNextWindowButton();
|
2002-08-04 15:12:51 +00:00
|
|
|
checkClock(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
toolbarmenu->reconfigure();
|
|
|
|
|
|
|
|
//iconbar, no iconbar?
|
|
|
|
if (Fluxbox::instance()->useIconBar()) {
|
|
|
|
if (!iconbar) {
|
|
|
|
iconbar = new IconBar(screen, frame.window_label);
|
|
|
|
if (screen->getIconCount()) {
|
2002-05-24 11:38:32 +00:00
|
|
|
BScreen::Icons & l = screen->getIconList();
|
2002-02-04 22:41:27 +00:00
|
|
|
BScreen::Icons::iterator it = l.begin();
|
|
|
|
BScreen::Icons::iterator it_end = l.end();
|
|
|
|
for(; it != it_end; ++it) {
|
|
|
|
addIcon(*it);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
iconbar->reconfigure();
|
|
|
|
} else {
|
|
|
|
if (iconbar) {
|
2002-02-04 22:41:27 +00:00
|
|
|
BScreen::Icons & l = screen->getIconList();
|
|
|
|
BScreen::Icons::iterator it = l.begin();
|
|
|
|
BScreen::Icons::iterator it_end = l.end();
|
|
|
|
for(; it != it_end; ++it) {
|
|
|
|
delIcon(*it);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
delete iconbar;
|
|
|
|
iconbar = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_STRFTIME
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::checkClock(bool redraw) {
|
2001-12-11 20:47:02 +00:00
|
|
|
#else // !HAVE_STRFTIME
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::checkClock(bool redraw, bool date) {
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
time_t tmp = 0;
|
|
|
|
struct tm *tt = 0;
|
|
|
|
|
|
|
|
if ((tmp = time(NULL)) != -1) {
|
|
|
|
if (! (tt = localtime(&tmp))) {
|
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): ! localtime(&tmp)"<<endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (tt->tm_min != frame.minute || tt->tm_hour != frame.hour) {
|
|
|
|
frame.hour = tt->tm_hour;
|
|
|
|
frame.minute = tt->tm_min;
|
|
|
|
XClearWindow(display, frame.clock);
|
2002-08-04 15:12:51 +00:00
|
|
|
redraw = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): time(null)<0"<<endl;
|
|
|
|
|
|
|
|
|
|
|
|
if (redraw) {
|
2002-08-24 19:31:24 +00:00
|
|
|
XClearWindow(display, frame.clock);
|
2002-01-21 00:53:02 +00:00
|
|
|
#ifdef HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
char t[1024];
|
|
|
|
if (! strftime(t, 1024, screen->getStrftimeFormat(), tt))
|
|
|
|
return;
|
2002-01-21 00:53:02 +00:00
|
|
|
#else // !HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
char t[9];
|
|
|
|
if (date) {
|
|
|
|
// format the date... with special consideration for y2k ;)
|
2002-01-21 00:53:02 +00:00
|
|
|
if (screen->getDateFormat() == Blackbox::B_EuropeanDate) {
|
2001-12-11 20:47:02 +00:00
|
|
|
sprintf(t,
|
2002-01-21 00:53:02 +00:00
|
|
|
i18n->getMessage(
|
|
|
|
#ifdef NLS
|
|
|
|
ToolbarSet, ToolbarNoStrftimeDateFormatEu,
|
|
|
|
#else // !NLS
|
|
|
|
0, 0,
|
|
|
|
#endif // NLS
|
|
|
|
"%02d.%02d.%02d"),
|
|
|
|
tt->tm_mday, tt->tm_mon + 1,
|
|
|
|
(tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
|
|
|
|
} else {
|
2001-12-11 20:47:02 +00:00
|
|
|
sprintf(t,
|
2002-01-21 00:53:02 +00:00
|
|
|
i18n->getMessage(
|
|
|
|
#ifdef NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
ToolbarSet, ToolbarNoStrftimeDateFormat,
|
2002-01-21 00:53:02 +00:00
|
|
|
#else // !NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
0, 0,
|
2002-01-21 00:53:02 +00:00
|
|
|
#endif // NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
"%02d/%02d/%02d"),
|
2002-01-21 00:53:02 +00:00
|
|
|
tt->tm_mon + 1, tt->tm_mday,
|
|
|
|
(tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
if (screen->isClock24Hour())
|
|
|
|
sprintf(t,
|
|
|
|
i18n->getMessage(
|
|
|
|
#ifdef NLS
|
|
|
|
ToolbarSet, ToolbarNoStrftimeTimeFormat24,
|
|
|
|
#else // !NLS
|
|
|
|
0, 0,
|
|
|
|
#endif // NLS
|
|
|
|
" %02d:%02d "),
|
|
|
|
frame.hour, frame.minute);
|
|
|
|
else
|
|
|
|
sprintf(t,
|
|
|
|
i18n->getMessage(
|
2002-01-21 00:53:02 +00:00
|
|
|
#ifdef NLS
|
|
|
|
ToolbarSet, ToolbarNoStrftimeTimeFormat12,
|
|
|
|
#else // !NLS
|
|
|
|
0, 0,
|
|
|
|
#endif // NLS
|
|
|
|
"%02d:%02d %sm"),
|
2001-12-11 20:47:02 +00:00
|
|
|
((frame.hour > 12) ? frame.hour - 12 :
|
|
|
|
((frame.hour == 0) ? 12 : frame.hour)), frame.minute,
|
|
|
|
((frame.hour >= 12) ?
|
|
|
|
i18n->getMessage(
|
2002-01-21 00:53:02 +00:00
|
|
|
#ifdef NLS
|
|
|
|
ToolbarSet, ToolbarNoStrftimeTimeFormatP,
|
|
|
|
#else // !NLS
|
|
|
|
0, 0,
|
|
|
|
#endif // NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
"p") :
|
|
|
|
i18n->getMessage(
|
2002-01-21 00:53:02 +00:00
|
|
|
#ifdef NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
ToolbarSet, ToolbarNoStrftimeTimeFormatA,
|
2002-01-21 00:53:02 +00:00
|
|
|
#else // !NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
0, 0,
|
2002-01-21 00:53:02 +00:00
|
|
|
#endif // NLS
|
2001-12-11 20:47:02 +00:00
|
|
|
"a")));
|
|
|
|
}
|
2002-01-21 00:53:02 +00:00
|
|
|
#endif // HAVE_STRFTIME
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
int dx = (frame.bevel_w * 2), dlen = strlen(t);
|
|
|
|
unsigned int l;
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
|
|
|
t, dlen, &ink, &logical);
|
|
|
|
l = logical.width;
|
|
|
|
} else
|
|
|
|
l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, t, dlen);
|
|
|
|
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l > frame.clock_w) {
|
|
|
|
for (; dlen >= 0; dlen--) {
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
|
|
|
t, dlen, &ink, &logical);
|
|
|
|
l = logical.width;
|
|
|
|
} else
|
|
|
|
l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, t, dlen);
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l < frame.clock_w)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (screen->getToolbarStyle()->font.justify) {
|
2002-08-04 15:12:51 +00:00
|
|
|
case DrawUtil::Font::RIGHT:
|
|
|
|
dx += frame.clock_w - l;
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2002-08-04 15:12:51 +00:00
|
|
|
case DrawUtil::Font::CENTER:
|
|
|
|
dx += (frame.clock_w - l) / 2;
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2002-08-04 15:12:51 +00:00
|
|
|
default: //LEFT, no justification
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XmbDrawString(display, frame.clock,
|
|
|
|
screen->getToolbarStyle()->font.set,
|
|
|
|
screen->getToolbarStyle()->c_text_gc, dx, 1 -
|
|
|
|
screen->getToolbarStyle()->font.set_extents->max_ink_extent.y,
|
|
|
|
t, dlen);
|
|
|
|
} else {
|
|
|
|
XDrawString(display, frame.clock,
|
|
|
|
screen->getToolbarStyle()->c_text_gc, dx,
|
|
|
|
screen->getToolbarStyle()->font.fontstruct->ascent + 1, t, dlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawWindowLabel(bool redraw) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (Fluxbox::instance()->getFocusedWindow()) {
|
|
|
|
if (redraw)
|
|
|
|
XClearWindow(display, frame.window_label);
|
|
|
|
|
|
|
|
FluxboxWindow *foc = Fluxbox::instance()->getFocusedWindow();
|
2002-05-03 13:14:06 +00:00
|
|
|
if (foc->getScreen() != screen || foc->getTitle().size() == 0)
|
2001-12-11 20:47:02 +00:00
|
|
|
return;
|
2002-05-03 13:14:06 +00:00
|
|
|
|
2002-04-03 23:04:01 +00:00
|
|
|
int dx = (frame.bevel_w * 2), dlen = foc->getTitle().size();
|
2001-12-11 20:47:02 +00:00
|
|
|
unsigned int l;
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
2002-04-03 23:04:01 +00:00
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set, foc->getTitle().c_str(), dlen,
|
2001-12-11 20:47:02 +00:00
|
|
|
&ink, &logical);
|
|
|
|
l = logical.width;
|
|
|
|
} else
|
2002-04-03 23:04:01 +00:00
|
|
|
l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l > frame.window_label_w) {
|
|
|
|
for (; dlen >= 0; dlen--) {
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
2002-04-03 23:04:01 +00:00
|
|
|
foc->getTitle().c_str(), dlen, &ink, &logical);
|
2001-12-11 20:47:02 +00:00
|
|
|
l = logical.width;
|
|
|
|
} else
|
2002-04-03 23:04:01 +00:00
|
|
|
l = XTextWidth(screen->getToolbarStyle()->font.fontstruct, foc->getTitle().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l < frame.window_label_w)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (screen->getToolbarStyle()->font.justify) {
|
2002-01-06 11:07:42 +00:00
|
|
|
case DrawUtil::Font::RIGHT:
|
2001-12-11 20:47:02 +00:00
|
|
|
dx += frame.window_label_w - l;
|
|
|
|
break;
|
|
|
|
|
2002-01-06 11:07:42 +00:00
|
|
|
case DrawUtil::Font::CENTER:
|
2001-12-11 20:47:02 +00:00
|
|
|
dx += (frame.window_label_w - l) / 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i18n->multibyte())
|
|
|
|
XmbDrawString(display, frame.window_label,
|
|
|
|
screen->getToolbarStyle()->font.set,
|
|
|
|
screen->getToolbarStyle()->w_text_gc, dx, 1 -
|
|
|
|
screen->getToolbarStyle()->font.set_extents->max_ink_extent.y,
|
2002-04-03 23:04:01 +00:00
|
|
|
foc->getTitle().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
|
|
|
XDrawString(display, frame.window_label,
|
2002-03-23 15:14:45 +00:00
|
|
|
screen->getToolbarStyle()->w_text_gc, dx,
|
|
|
|
screen->getToolbarStyle()->font.fontstruct->ascent + 1,
|
2002-04-03 23:04:01 +00:00
|
|
|
foc->getTitle().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
|
|
|
XClearWindow(display, frame.window_label);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawWorkspaceLabel(bool redraw) {
|
2002-04-09 23:16:28 +00:00
|
|
|
if (screen->getCurrentWorkspace()->name().size()>0) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (redraw)
|
|
|
|
XClearWindow(display, frame.workspace_label);
|
|
|
|
/* DrawString(
|
|
|
|
display, frame.label, screen->getToolbarStyle()->l_text_gc,
|
|
|
|
&screen->getToolbarStyle()->font,
|
|
|
|
frame.workspace_label_w, frame.width,
|
|
|
|
frame.bevel_w,
|
2002-04-09 23:16:28 +00:00
|
|
|
const_cast<char *>(screen->getCurrentWorkspace()->name().c_str()));*/
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
int dx = (frame.bevel_w * 2), dlen =
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->name().size();
|
2001-12-11 20:47:02 +00:00
|
|
|
unsigned int l;
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->name().c_str(), dlen,
|
2001-12-11 20:47:02 +00:00
|
|
|
&ink, &logical);
|
|
|
|
l = logical.width;
|
|
|
|
} else
|
|
|
|
l = XTextWidth(screen->getToolbarStyle()->font.fontstruct,
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->name().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l > frame.workspace_label_w) {
|
|
|
|
for (; dlen >= 0; dlen--) {
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->name().c_str(), dlen,
|
2001-12-11 20:47:02 +00:00
|
|
|
&ink, &logical);
|
|
|
|
l = logical.width;
|
|
|
|
} else {
|
|
|
|
l = XTextWidth(screen->getWindowStyle()->font.fontstruct,
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->name().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
l += (frame.bevel_w * 4);
|
|
|
|
|
|
|
|
if (l < frame.workspace_label_w)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (screen->getToolbarStyle()->font.justify) {
|
2002-01-06 11:07:42 +00:00
|
|
|
case DrawUtil::Font::RIGHT:
|
2001-12-11 20:47:02 +00:00
|
|
|
dx += frame.workspace_label_w - l;
|
|
|
|
break;
|
|
|
|
|
2002-01-06 11:07:42 +00:00
|
|
|
case DrawUtil::Font::CENTER:
|
2001-12-11 20:47:02 +00:00
|
|
|
dx += (frame.workspace_label_w - l) / 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XmbDrawString(display, frame.workspace_label,
|
|
|
|
screen->getToolbarStyle()->font.set,
|
|
|
|
screen->getToolbarStyle()->l_text_gc, dx, 1 -
|
|
|
|
screen->getToolbarStyle()->font.set_extents->max_ink_extent.y,
|
2002-04-09 23:16:28 +00:00
|
|
|
(char *) screen->getCurrentWorkspace()->name().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
XDrawString(display, frame.workspace_label,
|
|
|
|
screen->getToolbarStyle()->l_text_gc, dx,
|
|
|
|
screen->getToolbarStyle()->font.fontstruct->ascent + 1,
|
2002-04-09 23:16:28 +00:00
|
|
|
(char *) screen->getCurrentWorkspace()->name().c_str(), dlen);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (redraw) {
|
|
|
|
if (pressed) {
|
|
|
|
if (frame.pbutton)
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(display, frame.psbutton, frame.pbutton);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.psbutton, frame.pbutton_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
if (frame.button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button);
|
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.psbutton, frame.button_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
XClearWindow(display, frame.psbutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hh = frame.button_w / 2, hw = frame.button_w / 2;
|
|
|
|
|
|
|
|
XPoint pts[3];
|
|
|
|
pts[0].x = hw - 2; pts[0].y = hh;
|
|
|
|
pts[1].x = 4; pts[1].y = 2;
|
|
|
|
pts[2].x = 0; pts[2].y = -4;
|
|
|
|
|
|
|
|
XFillPolygon(display, frame.psbutton, screen->getToolbarStyle()->b_pic_gc,
|
2002-01-21 00:53:02 +00:00
|
|
|
pts, 3, Convex, CoordModePrevious);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawNextWorkspaceButton(bool pressed, bool redraw) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (redraw) {
|
|
|
|
if (pressed) {
|
|
|
|
if (frame.pbutton)
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.pbutton);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.nsbutton, frame.pbutton_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
if (frame.button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button);
|
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.nsbutton, frame.button_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
XClearWindow(display, frame.nsbutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hh = frame.button_w / 2, hw = frame.button_w / 2;
|
|
|
|
|
|
|
|
XPoint pts[3];
|
|
|
|
pts[0].x = hw - 2; pts[0].y = hh - 2;
|
|
|
|
pts[1].x = 4; pts[1].y = 2;
|
|
|
|
pts[2].x = -4; pts[2].y = 2;
|
|
|
|
|
|
|
|
XFillPolygon(display, frame.nsbutton, screen->getToolbarStyle()->b_pic_gc,
|
2002-01-21 00:53:02 +00:00
|
|
|
pts, 3, Convex, CoordModePrevious);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawPrevWindowButton(bool pressed, bool redraw) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (redraw) {
|
|
|
|
if (pressed) {
|
|
|
|
if (frame.pbutton)
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.pbutton);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.pwbutton, frame.pbutton_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
if (frame.button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button);
|
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.pwbutton, frame.button_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
XClearWindow(display, frame.pwbutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hh = frame.button_w / 2, hw = frame.button_w / 2;
|
|
|
|
|
|
|
|
XPoint pts[3];
|
|
|
|
pts[0].x = hw - 2; pts[0].y = hh;
|
|
|
|
pts[1].x = 4; pts[1].y = 2;
|
|
|
|
pts[2].x = 0; pts[2].y = -4;
|
|
|
|
|
|
|
|
XFillPolygon(display, frame.pwbutton, screen->getToolbarStyle()->b_pic_gc,
|
|
|
|
pts, 3, Convex, CoordModePrevious);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::redrawNextWindowButton(bool pressed, bool redraw) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (redraw) {
|
|
|
|
if (pressed) {
|
|
|
|
if (frame.pbutton)
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.pbutton);
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.nwbutton, frame.pbutton_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
if (frame.button)
|
|
|
|
XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button);
|
|
|
|
else
|
2002-01-21 00:53:02 +00:00
|
|
|
XSetWindowBackground(display, frame.nwbutton, frame.button_pixel);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
XClearWindow(display, frame.nwbutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
int hh = frame.button_w / 2, hw = frame.button_w / 2;
|
|
|
|
|
|
|
|
XPoint pts[3];
|
|
|
|
pts[0].x = hw - 2; pts[0].y = hh - 2;
|
|
|
|
pts[1].x = 4; pts[1].y = 2;
|
|
|
|
pts[2].x = -4; pts[2].y = 2;
|
|
|
|
|
|
|
|
XFillPolygon(display, frame.nwbutton, screen->getToolbarStyle()->b_pic_gc,
|
2002-01-21 00:53:02 +00:00
|
|
|
pts, 3, Convex, CoordModePrevious);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::edit() {
|
2001-12-11 20:47:02 +00:00
|
|
|
Window window;
|
|
|
|
int foo;
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
editing = true; //mark for editing
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
//workspace labe already got intput focus ?
|
|
|
|
if (XGetInputFocus(display, &window, &foo) &&
|
|
|
|
window == frame.workspace_label)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//set input focus to workspace label
|
|
|
|
XSetInputFocus(display, frame.workspace_label,
|
2002-01-21 00:53:02 +00:00
|
|
|
((screen->isSloppyFocus() || screen->isSemiSloppyFocus()) ?
|
|
|
|
RevertToPointerRoot : RevertToParent), CurrentTime);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XClearWindow(display, frame.workspace_label); //clear workspace text
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
fluxbox->setNoFocus(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
if (fluxbox->getFocusedWindow()) //disable focus on current focused window
|
2002-08-04 15:12:51 +00:00
|
|
|
fluxbox->getFocusedWindow()->setFocusFlag(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XDrawRectangle(display, frame.workspace_label,
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getWindowStyle()->l_text_focus_gc,
|
|
|
|
frame.workspace_label_w / 2, 0, 1,
|
|
|
|
frame.label_h - 1);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::buttonPressEvent(XButtonEvent *be) {
|
|
|
|
FluxboxWindow *fluxboxwin=0;
|
|
|
|
if (be->button == 1) {
|
|
|
|
if (be->window == frame.psbutton)
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawPrevWorkspaceButton(true, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
else if (be->window == frame.nsbutton)
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawNextWorkspaceButton(true, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
else if (be->window == frame.pwbutton)
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawPrevWindowButton(true, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
else if (be->window == frame.nwbutton)
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawNextWindowButton(true, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
else if ( iconbar ) {
|
|
|
|
if ( (fluxboxwin = iconbar->findWindow(be->window)) )
|
|
|
|
fluxboxwin->deiconify();
|
|
|
|
}
|
|
|
|
#ifndef HAVE_STRFTIME
|
|
|
|
else if (be->window == frame.clock) {
|
|
|
|
XClearWindow(display, frame.clock);
|
2002-08-04 15:12:51 +00:00
|
|
|
checkClock(true, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
else if (! on_top) {
|
2002-09-08 19:43:15 +00:00
|
|
|
Workspace::Stack st;
|
|
|
|
st.push_back(frame.window);
|
|
|
|
screen->raiseWindows(st);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
} else if (be->button == 2 && (! on_top)) {
|
|
|
|
XLowerWindow(display, frame.window);
|
|
|
|
} else if (be->button == 3) {
|
2002-08-12 03:25:55 +00:00
|
|
|
FluxboxWindow *fluxboxwin = 0;
|
|
|
|
if ( iconbar && (fluxboxwin = iconbar->findWindow(be->window)) ) {
|
|
|
|
Windowmenu *wm = fluxboxwin->getWindowmenu();
|
2002-09-14 10:58:25 +00:00
|
|
|
if (wm)
|
|
|
|
fluxboxwin->showMenu(be->x_root, be->y_root - wm->height());
|
2002-08-12 03:25:55 +00:00
|
|
|
} else if (! toolbarmenu->isVisible()) {
|
2001-12-11 20:47:02 +00:00
|
|
|
int x, y;
|
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
x = be->x_root - (toolbarmenu->width() / 2);
|
|
|
|
y = be->y_root - (toolbarmenu->height() / 2);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
2002-04-08 22:36:30 +00:00
|
|
|
else if (x + toolbarmenu->width() > screen->getWidth())
|
|
|
|
x = screen->getWidth() - toolbarmenu->width();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
2002-04-08 22:36:30 +00:00
|
|
|
else if (y + toolbarmenu->height() > screen->getHeight())
|
|
|
|
y = screen->getHeight() - toolbarmenu->height();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
toolbarmenu->move(x, y);
|
|
|
|
toolbarmenu->show();
|
|
|
|
} else
|
|
|
|
toolbarmenu->hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::buttonReleaseEvent(XButtonEvent *re) {
|
|
|
|
if (re->button == 1) {
|
|
|
|
if (re->window == frame.psbutton) {
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawPrevWorkspaceButton(false, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (re->x >= 0 && re->x < (signed) frame.button_w &&
|
|
|
|
re->y >= 0 && re->y < (signed) frame.button_w)
|
2002-02-20 23:13:32 +00:00
|
|
|
screen->prevWorkspace(1);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else if (re->window == frame.nsbutton) {
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawNextWorkspaceButton(false, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (re->x >= 0 && re->x < (signed) frame.button_w &&
|
|
|
|
re->y >= 0 && re->y < (signed) frame.button_w)
|
2002-02-20 23:13:32 +00:00
|
|
|
screen->nextWorkspace(1);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else if (re->window == frame.pwbutton) {
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawPrevWindowButton(false, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (re->x >= 0 && re->x < (signed) frame.button_w &&
|
|
|
|
re->y >= 0 && re->y < (signed) frame.button_w)
|
|
|
|
screen->prevFocus();
|
|
|
|
} else if (re->window == frame.nwbutton) {
|
2002-08-04 15:12:51 +00:00
|
|
|
redrawNextWindowButton(false, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (re->x >= 0 && re->x < (signed) frame.button_w &&
|
|
|
|
re->y >= 0 && re->y < (signed) frame.button_w)
|
|
|
|
screen->nextFocus();
|
|
|
|
} else if (re->window == frame.window_label)
|
|
|
|
screen->raiseFocus();
|
|
|
|
#ifndef HAVE_STRFTIME
|
|
|
|
else if (re->window == frame.clock) {
|
|
|
|
XClearWindow(display, frame.clock);
|
2002-08-04 15:12:51 +00:00
|
|
|
checkClock(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
} else if (re->button == 4) //mousewheel scroll up
|
2002-02-20 23:13:32 +00:00
|
|
|
screen->nextWorkspace(1);
|
2001-12-11 20:47:02 +00:00
|
|
|
else if (re->button == 5) //mousewheel scroll down
|
2002-02-20 23:13:32 +00:00
|
|
|
screen->prevWorkspace(1);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::enterNotifyEvent(XCrossingEvent *) {
|
|
|
|
if (! do_auto_hide)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (hidden) {
|
|
|
|
if (! hide_timer->isTiming()) hide_timer->start();
|
|
|
|
} else {
|
|
|
|
if (hide_timer->isTiming()) hide_timer->stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::leaveNotifyEvent(XCrossingEvent *) {
|
|
|
|
if (! do_auto_hide)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (hidden) {
|
|
|
|
if (hide_timer->isTiming()) hide_timer->stop();
|
|
|
|
} else if (! toolbarmenu->isVisible()) {
|
|
|
|
if (! hide_timer->isTiming()) hide_timer->start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::exposeEvent(XExposeEvent *ee) {
|
2002-08-04 15:12:51 +00:00
|
|
|
if (ee->window == frame.clock)
|
|
|
|
checkClock(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
else if (ee->window == frame.workspace_label && (! editing))
|
|
|
|
redrawWorkspaceLabel();
|
|
|
|
else if (ee->window == frame.window_label) redrawWindowLabel();
|
|
|
|
else if (ee->window == frame.psbutton) redrawPrevWorkspaceButton();
|
|
|
|
else if (ee->window == frame.nsbutton) redrawNextWorkspaceButton();
|
|
|
|
else if (ee->window == frame.pwbutton) redrawPrevWindowButton();
|
|
|
|
else if (ee->window == frame.nwbutton) redrawNextWindowButton();
|
|
|
|
else if (iconbar)//try iconbar
|
|
|
|
iconbar->exposeEvent(ee);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::keyPressEvent(XKeyEvent *ke) {
|
|
|
|
if (ke->window == frame.workspace_label && editing) {
|
2002-04-09 23:16:28 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
KeySym ks;
|
|
|
|
char keychar[1];
|
|
|
|
XLookupString(ke, keychar, 1, &ks, 0);
|
|
|
|
|
|
|
|
if (ks == XK_Return || ks == XK_Escape) {
|
2002-01-21 00:53:02 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-03 13:14:06 +00:00
|
|
|
editing = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
fluxbox->setNoFocus(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
if (fluxbox->getFocusedWindow()) {
|
|
|
|
fluxbox->getFocusedWindow()->setInputFocus();
|
2002-08-04 15:12:51 +00:00
|
|
|
fluxbox->getFocusedWindow()->setFocusFlag(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
|
|
|
XSetInputFocus(display, PointerRoot, None, CurrentTime);
|
2002-01-21 00:53:02 +00:00
|
|
|
|
|
|
|
if (ks == XK_Return) //change workspace name if keypress = Return
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->setName(new_workspace_name.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-22 07:37:54 +00:00
|
|
|
new_workspace_name.erase(); //erase temporary workspace name
|
2002-01-21 00:53:02 +00:00
|
|
|
|
2002-04-09 23:16:28 +00:00
|
|
|
screen->getCurrentWorkspace()->menu()->hide();
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getWorkspacemenu()->
|
2002-04-09 23:16:28 +00:00
|
|
|
remove(screen->getCurrentWorkspace()->workspaceID() + 2);
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getWorkspacemenu()->
|
2002-04-09 23:16:28 +00:00
|
|
|
insert(screen->getCurrentWorkspace()->name().c_str(),
|
|
|
|
screen->getCurrentWorkspace()->menu(),
|
2002-09-06 16:50:51 +00:00
|
|
|
screen->getCurrentWorkspace()->workspaceID() + 2);
|
2002-01-21 00:53:02 +00:00
|
|
|
screen->getWorkspacemenu()->update();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
reconfigure();
|
2002-05-03 13:14:06 +00:00
|
|
|
//save workspace names
|
|
|
|
Fluxbox::instance()->save_rc();
|
|
|
|
|
2002-08-17 22:22:57 +00:00
|
|
|
} else if (! IsModifierKey(ks) && !IsCursorKey(ks)) {
|
2002-01-21 00:53:02 +00:00
|
|
|
|
|
|
|
if (ks == XK_BackSpace && new_workspace_name.size())
|
|
|
|
new_workspace_name.erase(new_workspace_name.size()-1);
|
|
|
|
else
|
|
|
|
new_workspace_name += keychar[0];
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XClearWindow(display, frame.workspace_label);
|
2002-01-21 00:53:02 +00:00
|
|
|
int l = new_workspace_name.size(), tw, x;
|
2001-12-11 20:47:02 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
|
|
|
XmbTextExtents(screen->getToolbarStyle()->font.set,
|
2002-01-21 00:53:02 +00:00
|
|
|
new_workspace_name.c_str(), l, &ink, &logical);
|
2001-12-11 20:47:02 +00:00
|
|
|
tw = logical.width;
|
2002-08-12 03:25:55 +00:00
|
|
|
} else {
|
2001-12-11 20:47:02 +00:00
|
|
|
tw = XTextWidth(screen->getToolbarStyle()->font.fontstruct,
|
2002-01-21 00:53:02 +00:00
|
|
|
new_workspace_name.c_str(), l);
|
2002-08-12 03:25:55 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
x = (frame.workspace_label_w - tw) / 2;
|
|
|
|
|
|
|
|
if (x < (signed) frame.bevel_w) x = frame.bevel_w;
|
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
if (i18n->multibyte()) {
|
2001-12-11 20:47:02 +00:00
|
|
|
XmbDrawString(display, frame.workspace_label,
|
|
|
|
screen->getWindowStyle()->font.set,
|
|
|
|
screen->getWindowStyle()->l_text_focus_gc, x, 1 -
|
|
|
|
screen->getWindowStyle()->font.set_extents->max_ink_extent.y,
|
2002-01-21 00:53:02 +00:00
|
|
|
new_workspace_name.c_str(), l);
|
2002-08-12 03:25:55 +00:00
|
|
|
} else {
|
2001-12-11 20:47:02 +00:00
|
|
|
XDrawString(display, frame.workspace_label,
|
|
|
|
screen->getWindowStyle()->l_text_focus_gc, x,
|
|
|
|
screen->getToolbarStyle()->font.fontstruct->ascent + 1,
|
2002-01-21 00:53:02 +00:00
|
|
|
new_workspace_name.c_str(), l);
|
2002-08-12 03:25:55 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
XDrawRectangle(display, frame.workspace_label,
|
|
|
|
screen->getWindowStyle()->l_text_focus_gc, x + tw, 0, 1,
|
|
|
|
frame.label_h - 1);
|
2002-04-09 23:16:28 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::timeout() {
|
|
|
|
checkClock(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-24 19:31:24 +00:00
|
|
|
timeval delay;
|
|
|
|
delay.tv_sec = 1;
|
|
|
|
delay.tv_usec = 0;
|
|
|
|
clock_timer.setTimeout(delay);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbar::HideHandler::timeout() {
|
2001-12-11 20:47:02 +00:00
|
|
|
toolbar->hidden = ! toolbar->hidden;
|
|
|
|
if (toolbar->hidden)
|
|
|
|
XMoveWindow(toolbar->display, toolbar->frame.window,
|
|
|
|
toolbar->frame.x_hidden, toolbar->frame.y_hidden);
|
|
|
|
else
|
|
|
|
XMoveWindow(toolbar->display, toolbar->frame.window,
|
|
|
|
toolbar->frame.x, toolbar->frame.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Toolbarmenu::Toolbarmenu(Toolbar *tb) : Basemenu(tb->screen) {
|
|
|
|
toolbar = tb;
|
|
|
|
I18n *i18n = I18n::instance();
|
2002-04-04 11:28:19 +00:00
|
|
|
using namespace FBNLS;
|
2001-12-11 20:47:02 +00:00
|
|
|
setLabel(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
ToolbarSet, ToolbarToolbarTitle,
|
|
|
|
"Toolbar"));
|
2001-12-11 20:47:02 +00:00
|
|
|
setInternalMenu();
|
|
|
|
|
|
|
|
placementmenu = new Placementmenu(this);
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (toolbar->screen->hasXinerama()) { // only create if we need it
|
|
|
|
headmenu = new Headmenu(this);
|
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementTitle,
|
|
|
|
"Placement"),
|
|
|
|
placementmenu);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
|
|
#ifdef XINERAMA
|
|
|
|
if (toolbar->screen->hasXinerama()) { //TODO: NLS
|
|
|
|
insert(i18n->getMessage(0, 0, "Place on Head"), headmenu);
|
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonAlwaysOnTop,
|
|
|
|
"Always on top"),
|
|
|
|
1);
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonAutoHide,
|
|
|
|
"Auto hide"),
|
2001-12-11 20:47:02 +00:00
|
|
|
2);
|
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
ToolbarSet, ToolbarEditWkspcName,
|
|
|
|
"Edit current workspace name"),
|
|
|
|
3);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
update();
|
|
|
|
|
|
|
|
if (toolbar->isOnTop())
|
2002-04-03 12:08:54 +00:00
|
|
|
setItemSelected(1, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
if (toolbar->doAutoHide())
|
2002-04-03 12:08:54 +00:00
|
|
|
setItemSelected(2, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
Toolbarmenu::~Toolbarmenu() {
|
2001-12-11 20:47:02 +00:00
|
|
|
delete placementmenu;
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (toolbar->screen->hasXinerama()) {
|
|
|
|
delete headmenu;
|
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-03 12:08:54 +00:00
|
|
|
void Toolbarmenu::itemSelected(int button, unsigned int index) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (button == 1) {
|
|
|
|
BasemenuItem *item = find(index);
|
2002-08-12 03:25:55 +00:00
|
|
|
if (item == 0)
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
switch (item->function()) {
|
2002-05-03 13:14:06 +00:00
|
|
|
case 1: {// always on top
|
|
|
|
bool change = ((toolbar->isOnTop()) ? false : true);
|
2001-12-11 20:47:02 +00:00
|
|
|
toolbar->on_top = change;
|
2002-05-03 13:14:06 +00:00
|
|
|
screen()->saveToolbarOnTop(toolbar->on_top);
|
|
|
|
setItemSelected(1, change);
|
|
|
|
|
|
|
|
if (toolbar->isOnTop())
|
2002-09-08 19:43:15 +00:00
|
|
|
toolbar->screen->raiseWindows(Workspace::Stack());
|
2002-05-03 13:14:06 +00:00
|
|
|
|
|
|
|
Fluxbox::instance()->save_rc();
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2002-05-03 13:14:06 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-03 13:14:06 +00:00
|
|
|
case 2: { // auto hide
|
|
|
|
bool change = ((toolbar->doAutoHide()) ? false : true);
|
|
|
|
toolbar->do_auto_hide = change;
|
|
|
|
screen()->saveToolbarAutoHide(toolbar->do_auto_hide);
|
|
|
|
setItemSelected(2, change);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-12 03:25:55 +00:00
|
|
|
#ifdef SLIT
|
|
|
|
toolbar->screen->getSlit()->reposition();
|
|
|
|
#endif // SLIT
|
2002-05-03 13:14:06 +00:00
|
|
|
Fluxbox::instance()->save_rc();
|
|
|
|
break;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
case 3: // edit current workspace name
|
|
|
|
toolbar->edit(); //set edit mode
|
|
|
|
hide(); //dont show menu while editing name
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbarmenu::internal_hide() {
|
2001-12-11 20:47:02 +00:00
|
|
|
Basemenu::internal_hide();
|
|
|
|
if (toolbar->doAutoHide() && ! toolbar->isEditing())
|
|
|
|
toolbar->hide_handler.timeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-04 15:12:51 +00:00
|
|
|
void Toolbarmenu::reconfigure() {
|
2001-12-11 20:47:02 +00:00
|
|
|
placementmenu->reconfigure();
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (toolbar->screen->hasXinerama()) {
|
|
|
|
headmenu->reconfigure();
|
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
Basemenu::reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu *tm)
|
|
|
|
: Basemenu(tm->toolbar->screen) {
|
|
|
|
toolbarmenu = tm;
|
|
|
|
I18n *i18n = I18n::instance();
|
2002-04-04 11:28:19 +00:00
|
|
|
using namespace FBNLS;
|
2001-12-11 20:47:02 +00:00
|
|
|
setLabel(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
ToolbarSet, ToolbarToolbarPlacement,
|
|
|
|
"Toolbar Placement"));
|
2001-12-11 20:47:02 +00:00
|
|
|
setInternalMenu();
|
|
|
|
setMinimumSublevels(3);
|
|
|
|
|
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementTopLeft,
|
|
|
|
"Top Left"),
|
|
|
|
Toolbar::TOPLEFT);
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementBottomLeft,
|
|
|
|
"Bottom Left"),
|
|
|
|
Toolbar::BOTTOMLEFT);
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementTopCenter,
|
|
|
|
"Top Center"),
|
|
|
|
Toolbar::TOPCENTER);
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementBottomCenter,
|
|
|
|
"Bottom Center"),
|
|
|
|
Toolbar::BOTTOMCENTER);
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementTopRight,
|
|
|
|
"Top Right"),
|
|
|
|
Toolbar::TOPRIGHT);
|
2001-12-11 20:47:02 +00:00
|
|
|
insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
CommonSet, CommonPlacementBottomRight,
|
|
|
|
"Bottom Right"),
|
2002-01-06 09:37:50 +00:00
|
|
|
Toolbar::BOTTOMRIGHT);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-03 12:08:54 +00:00
|
|
|
void Toolbarmenu::Placementmenu::itemSelected(int button, unsigned int index) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (button == 1) {
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
if (! item)
|
|
|
|
return;
|
|
|
|
|
2002-01-20 02:20:18 +00:00
|
|
|
toolbarmenu->toolbar->screen->saveToolbarPlacement(
|
|
|
|
static_cast<Toolbar::Placement>(item->function()));
|
2001-12-11 20:47:02 +00:00
|
|
|
hide();
|
|
|
|
toolbarmenu->toolbar->reconfigure();
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
// reposition the slit as well to make sure it doesn't intersect the
|
|
|
|
// toolbar
|
|
|
|
toolbarmenu->toolbar->screen->getSlit()->reposition();
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
|
|
#ifdef XINERAMA
|
|
|
|
|
|
|
|
Toolbarmenu::Headmenu::Headmenu(Toolbarmenu *tm)
|
|
|
|
: Basemenu(tm->toolbar->screen) {
|
|
|
|
toolbarmenu = tm;
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
setLabel(i18n->getMessage(0, 0, "Place on Head")); //TODO: NLS
|
|
|
|
setInternalMenu();
|
|
|
|
|
|
|
|
int numHeads = toolbarmenu->toolbar->screen->getNumHeads();
|
|
|
|
// fill menu with head entries
|
|
|
|
for (int i = 0; i < numHeads; i++) {
|
|
|
|
char headName[32];
|
|
|
|
sprintf(headName, "Head %i", i+1); //TODO: NLS
|
|
|
|
insert(i18n->getMessage(0, 0, headName), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
insert(i18n->getMessage(0, 0, "All Heads"), -1); //TODO: NLS
|
|
|
|
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-03 12:08:54 +00:00
|
|
|
void Toolbarmenu::Headmenu::itemSelected(int button, unsigned int index) {
|
2002-03-19 14:30:43 +00:00
|
|
|
if (button == 1) {
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
if (! item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
toolbarmenu->toolbar->screen->saveToolbarOnHead(
|
|
|
|
static_cast<int>(item->function()));
|
|
|
|
hide();
|
|
|
|
toolbarmenu->toolbar->reconfigure();
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
// reposition the slit as well to make sure it doesn't intersect the
|
|
|
|
// toolbar
|
|
|
|
toolbarmenu->toolbar->screen->getSlit()->reposition();
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // XINERAMA
|