From db451d95bf97b8a8e995f031ac98da50606fd3a0 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Thu, 31 Oct 2002 06:54:56 +0000 Subject: [PATCH] rename, remove bullshit. ya --- src/Netizen.cc | 117 -- src/Netizen.hh | 63 - src/Slit.cc | 915 --------------- src/Slit.hh | 205 ---- src/Toolbar.cc | 1236 -------------------- src/Toolbar.hh | 197 ---- src/{BaseDisplay.cc => basedisplay.cc} | 9 +- src/{BaseDisplay.hh => basedisplay.hh} | 4 +- src/blackbox.cc | 27 +- src/blackbox.hh | 9 +- src/{Color.cc => color.cc} | 4 +- src/{Color.hh => color.hh} | 0 src/{Configuration.cc => configuration.cc} | 4 +- src/{Configuration.hh => configuration.hh} | 0 src/{Font.cc => font.cc} | 31 +- src/{Font.hh => font.hh} | 6 +- src/{GCCache.cc => gccache.cc} | 8 +- src/{GCCache.hh => gccache.hh} | 4 +- src/i18n.cc | 119 -- src/i18n.hh | 63 - src/{Image.cc => image.cc} | 9 +- src/{Image.hh => image.hh} | 6 +- src/{ImageControl.cc => imagecontrol.cc} | 9 +- src/main.cc | 1 - src/{Screen.cc => screen.cc} | 37 +- src/{Screen.hh => screen.hh} | 20 +- src/{Texture.cc => texture.cc} | 8 +- src/{Texture.hh => texture.hh} | 4 +- src/{Timer.cc => timer.cc} | 6 +- src/{Timer.hh => timer.hh} | 0 src/{Util.cc => util.cc} | 2 +- src/{Util.hh => util.hh} | 0 src/{Window.cc => window.cc} | 25 +- src/{Window.hh => window.hh} | 8 +- src/{Workspace.cc => workspace.cc} | 21 +- src/{Workspace.hh => workspace.hh} | 0 src/{XAtom.cc => xatom.cc} | 6 +- src/{XAtom.hh => xatom.hh} | 0 38 files changed, 124 insertions(+), 3059 deletions(-) delete mode 100644 src/Netizen.cc delete mode 100644 src/Netizen.hh delete mode 100644 src/Slit.cc delete mode 100644 src/Slit.hh delete mode 100644 src/Toolbar.cc delete mode 100644 src/Toolbar.hh rename src/{BaseDisplay.cc => basedisplay.cc} (99%) rename src/{BaseDisplay.hh => basedisplay.hh} (99%) rename src/{Color.cc => color.cc} (99%) rename src/{Color.hh => color.hh} (100%) rename src/{Configuration.cc => configuration.cc} (99%) rename src/{Configuration.hh => configuration.hh} (100%) rename src/{Font.cc => font.cc} (94%) rename src/{Font.hh => font.hh} (97%) rename src/{GCCache.cc => gccache.cc} (98%) rename src/{GCCache.hh => gccache.hh} (98%) delete mode 100644 src/i18n.cc delete mode 100644 src/i18n.hh rename src/{Image.cc => image.cc} (99%) rename src/{Image.hh => image.hh} (98%) rename src/{ImageControl.cc => imagecontrol.cc} (99%) rename src/{Screen.cc => screen.cc} (99%) rename src/{Screen.hh => screen.hh} (98%) rename src/{Texture.cc => texture.cc} (98%) rename src/{Texture.hh => texture.hh} (99%) rename src/{Timer.cc => timer.cc} (97%) rename src/{Timer.hh => timer.hh} (100%) rename src/{Util.cc => util.cc} (99%) rename src/{Util.hh => util.hh} (100%) rename src/{Window.cc => window.cc} (99%) rename src/{Window.hh => window.hh} (99%) rename src/{Workspace.cc => workspace.cc} (99%) rename src/{Workspace.hh => workspace.hh} (100%) rename src/{XAtom.cc => xatom.cc} (99%) rename src/{XAtom.hh => xatom.hh} (100%) diff --git a/src/Netizen.cc b/src/Netizen.cc deleted file mode 100644 index a50f5e0b..00000000 --- a/src/Netizen.cc +++ /dev/null @@ -1,117 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Netizen.cc for Blackbox - An X11 Window Manager -// Copyright (c) 2001 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif // HAVE_CONFIG_H - -#include "Netizen.hh" -#include "Screen.hh" -#include "XAtom.hh" - -Netizen::Netizen(BScreen *scr, Window win) { - screen = scr; - blackbox = scr->getBlackbox(); - xatom = blackbox->getXAtom(); - window = win; - - event.type = ClientMessage; - event.xclient.message_type = - xatom->getAtom(XAtom::blackbox_structure_messages); - event.xclient.display = blackbox->getXDisplay(); - event.xclient.window = window; - event.xclient.format = 32; - event.xclient.data.l[0] = xatom->getAtom(XAtom::blackbox_notify_startup); - event.xclient.data.l[1] = event.xclient.data.l[2] = - event.xclient.data.l[3] = event.xclient.data.l[4] = 0l; - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendWorkspaceCount(void) { - event.xclient.data.l[0] = - xatom->getAtom(XAtom::blackbox_notify_workspace_count); - event.xclient.data.l[1] = screen->getWorkspaceCount(); - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendCurrentWorkspace(void) { - event.xclient.data.l[0] = - xatom->getAtom(XAtom::blackbox_notify_current_workspace); - event.xclient.data.l[1] = screen->getCurrentWorkspaceID(); - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendWindowFocus(Window w) { - event.xclient.data.l[0] = xatom->getAtom(XAtom::blackbox_notify_window_focus); - event.xclient.data.l[1] = w; - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendWindowAdd(Window w, unsigned long p) { - event.xclient.data.l[0] = xatom->getAtom(XAtom::blackbox_notify_window_add); - event.xclient.data.l[1] = w; - event.xclient.data.l[2] = p; - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); - - event.xclient.data.l[2] = 0l; -} - - -void Netizen::sendWindowDel(Window w) { - event.xclient.data.l[0] = xatom->getAtom(XAtom::blackbox_notify_window_del); - event.xclient.data.l[1] = w; - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendWindowRaise(Window w) { - event.xclient.data.l[0] = xatom->getAtom(XAtom::blackbox_notify_window_raise); - event.xclient.data.l[1] = w; - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendWindowLower(Window w) { - event.xclient.data.l[0] = - xatom->getAtom(XAtom::blackbox_notify_window_lower); - event.xclient.data.l[1] = w; - - XSendEvent(blackbox->getXDisplay(), window, False, NoEventMask, &event); -} - - -void Netizen::sendConfigNotify(XEvent *e) { - XSendEvent(blackbox->getXDisplay(), window, False, - StructureNotifyMask, e); -} diff --git a/src/Netizen.hh b/src/Netizen.hh deleted file mode 100644 index aebd20e1..00000000 --- a/src/Netizen.hh +++ /dev/null @@ -1,63 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Netizen.hh for Blackbox - An X11 Window Manager -// Copyright (c) 2001 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifndef __Netizen_hh -#define __Netizen_hh - -extern "C" { -#include -} - -// forward declaration -class Blackbox; -class BScreen; -class Netizen; -class XAtom; - -class Netizen { -private: - Blackbox *blackbox; - BScreen *screen; - XAtom *xatom; - Window window; - XEvent event; - -public: - Netizen(BScreen *, Window); - - inline Window getWindowID(void) const { return window; } - - void sendWorkspaceCount(void); - void sendCurrentWorkspace(void); - - void sendWindowFocus(Window); - void sendWindowAdd(Window, unsigned long); - void sendWindowDel(Window); - void sendWindowRaise(Window); - void sendWindowLower(Window); - - void sendConfigNotify(XEvent *); -}; - - -#endif // __Netizen_hh diff --git a/src/Slit.cc b/src/Slit.cc deleted file mode 100644 index c15f66c4..00000000 --- a/src/Slit.cc +++ /dev/null @@ -1,915 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -// Slit.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H - -extern "C" { -#include -} - -#include "i18n.hh" -#include "blackbox.hh" -#include "Image.hh" -#include "Screen.hh" -#include "Slit.hh" -#include "Toolbar.hh" - - -Slit::Slit(BScreen *scr) { - screen = scr; - blackbox = screen->getBlackbox(); - slitstr = "session.screen" + itostring(screen->getScreenNumber()) + ".slit."; - config = blackbox->getConfig(); - - load_rc(); - - display = screen->getBaseDisplay()->getXDisplay(); - frame.window = frame.pixmap = None; - - timer = new BTimer(blackbox, this); - timer->setTimeout(blackbox->getAutoRaiseDelay()); - - slitmenu = new Slitmenu(this); - - XSetWindowAttributes attrib; - unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - screen->getBorderColor()->pixel(); - attrib.colormap = screen->getColormap(); - attrib.override_redirect = True; - attrib.event_mask = SubstructureRedirectMask | ButtonPressMask | - EnterWindowMask | LeaveWindowMask; - - frame.rect.setSize(1, 1); - - frame.window = - XCreateWindow(display, screen->getRootWindow(), - frame.rect.x(), frame.rect.y(), - frame.rect.width(), frame.rect.height(), - screen->getBorderWidth(), screen->getDepth(), InputOutput, - screen->getVisual(), create_mask, &attrib); - blackbox->saveSlitSearch(frame.window, this); - - screen->addStrut(&strut); - - reconfigure(); -} - - -Slit::~Slit(void) { - delete timer; - - delete slitmenu; - - screen->removeStrut(&strut); - screen->updateAvailableArea(); - - screen->getImageControl()->removeImage(frame.pixmap); - - blackbox->removeSlitSearch(frame.window); - - XDestroyWindow(display, frame.window); -} - - -void Slit::addClient(Window w) { - if (! blackbox->validateWindow(w)) - return; - - SlitClient *client = new SlitClient; - client->client_window = w; - - XWMHints *wmhints = XGetWMHints(display, w); - - if (wmhints) { - if ((wmhints->flags & IconWindowHint) && - (wmhints->icon_window != None)) { - // some dock apps use separate windows, we need to hide these - XMoveWindow(display, client->client_window, screen->getWidth() + 10, - screen->getHeight() + 10); - XMapWindow(display, client->client_window); - - client->icon_window = wmhints->icon_window; - client->window = client->icon_window; - } else { - client->icon_window = None; - client->window = client->client_window; - } - - XFree(wmhints); - } else { - client->icon_window = None; - client->window = client->client_window; - } - - XWindowAttributes attrib; - if (XGetWindowAttributes(display, client->window, &attrib)) { - client->rect.setSize(attrib.width, attrib.height); - } else { - client->rect.setSize(64, 64); - } - - Atom *proto; - int num_return = 0; - if (XGetWMProtocols(display, client->window, &proto, &num_return)) { - for (int i = 0; i < num_return; ++i) { - if (proto[i] == - blackbox->getXAtom()->getAtom(XAtom::blackbox_structure_messages)) { - screen->addNetizen(new Netizen(screen, client->window)); - } - } - } - - XSetWindowBorderWidth(display, client->window, 0); - - XGrabServer(display); - XSelectInput(display, frame.window, NoEventMask); - XSelectInput(display, client->window, NoEventMask); - XReparentWindow(display, client->window, frame.window, 0, 0); - XMapRaised(display, client->window); - XChangeSaveSet(display, client->window, SetModeInsert); - XSelectInput(display, frame.window, SubstructureRedirectMask | - ButtonPressMask | EnterWindowMask | LeaveWindowMask); - XSelectInput(display, client->window, StructureNotifyMask | - SubstructureNotifyMask | EnterWindowMask); - - XUngrabServer(display); - - clientList.push_back(client); - - blackbox->saveSlitSearch(client->client_window, this); - blackbox->saveSlitSearch(client->icon_window, this); - reconfigure(); -} - - -void Slit::removeClient(SlitClient *client, bool remap) { - blackbox->removeSlitSearch(client->client_window); - blackbox->removeSlitSearch(client->icon_window); - clientList.remove(client); - - screen->removeNetizen(client->window); - - if (remap && blackbox->validateWindow(client->window)) { - XGrabServer(display); - XSelectInput(display, frame.window, NoEventMask); - XSelectInput(display, client->window, NoEventMask); - XReparentWindow(display, client->window, screen->getRootWindow(), - client->rect.x(), client->rect.y()); - XChangeSaveSet(display, client->window, SetModeDelete); - XSelectInput(display, frame.window, SubstructureRedirectMask | - ButtonPressMask | EnterWindowMask | LeaveWindowMask); - XUngrabServer(display); - } - - delete client; - client = (SlitClient *) 0; -} - - -struct SlitClientMatch { - Window window; - SlitClientMatch(Window w): window(w) {} - inline bool operator()(const Slit::SlitClient* client) const { - return (client->window == window); - } -}; - - -void Slit::removeClient(Window w, bool remap) { - SlitClientList::iterator it = clientList.begin(); - const SlitClientList::iterator end = clientList.end(); - - it = std::find_if(it, end, SlitClientMatch(w)); - if (it != end) { - removeClient(*it, remap); - reconfigure(); - } -} - - -void Slit::saveOnTop(bool b) { - on_top = b; - config->setValue(slitstr + "onTop", on_top); -} - -void Slit::saveAutoHide(bool b) { - do_auto_hide = b; - config->setValue(slitstr + "autoHide", do_auto_hide); -} - -void Slit::savePlacement(int p) { - placement = p; - const char *pname; - switch (placement) { - case TopLeft: pname = "TopLeft"; break; - case CenterLeft: pname = "CenterLeft"; break; - case BottomLeft: pname = "BottomLeft"; break; - case TopCenter: pname = "TopCenter"; break; - case BottomCenter: pname = "BottomCenter"; break; - case TopRight: pname = "TopRight"; break; - case BottomRight: pname = "BottomRight"; break; - case CenterRight: default: pname = "CenterRight"; break; - } - config->setValue(slitstr + "placement", pname); -} - -void Slit::saveDirection(int d) { - direction = d; - config->setValue(slitstr + "direction", (direction == Horizontal ? - "Horizontal" : "Vertical")); -} - -void Slit::save_rc(void) { - saveOnTop(on_top); - saveAutoHide(do_auto_hide); - savePlacement(placement); - saveDirection(direction); -} - -void Slit::load_rc(void) { - std::string s; - - if (! config->getValue(slitstr + "onTop", on_top)) - on_top = false; - - if (! config->getValue(slitstr + "autoHide", do_auto_hide)) - do_auto_hide = false; - hidden = do_auto_hide; - - if (config->getValue(slitstr + "direction", s) && s == "Horizontal") - direction = Horizontal; - else - direction = Vertical; - - if (config->getValue(slitstr + "placement", s)) { - if (s == "TopLeft") - placement = TopLeft; - else if (s == "CenterLeft") - placement = CenterLeft; - else if (s == "BottomLeft") - placement = BottomLeft; - else if (s == "TopCenter") - placement = TopCenter; - else if (s == "BottomCenter") - placement = BottomCenter; - else if (s == "TopRight") - placement = TopRight; - else if (s == "BottomRight") - placement = BottomRight; - else //if (s == "CenterRight") - placement = CenterRight; - } else - placement = CenterRight; -} - - -void Slit::reconfigure(void) { - SlitClientList::iterator it = clientList.begin(); - const SlitClientList::iterator end = clientList.end(); - SlitClient *client; - - unsigned int width = 0, height = 0; - - switch (direction) { - case Vertical: - for (; it != end; ++it) { - client = *it; - height += client->rect.height() + screen->getBevelWidth(); - - if (width < client->rect.width()) - width = client->rect.width(); - } - - if (width < 1) - width = 1; - else - width += (screen->getBevelWidth() * 2); - - if (height < 1) - height = 1; - else - height += screen->getBevelWidth(); - - break; - - case Horizontal: - for (; it != end; ++it) { - client = *it; - width += client->rect.width() + screen->getBevelWidth(); - - if (height < client->rect.height()) - height = client->rect.height(); - } - - if (width < 1) - width = 1; - else - width += screen->getBevelWidth(); - - if (height < 1) - height = 1; - else - height += (screen->getBevelWidth() * 2); - - break; - } - frame.rect.setSize(width, height); - - reposition(); - - XSetWindowBorderWidth(display ,frame.window, screen->getBorderWidth()); - XSetWindowBorder(display, frame.window, - screen->getBorderColor()->pixel()); - - if (clientList.empty()) - XUnmapWindow(display, frame.window); - else - XMapWindow(display, frame.window); - - BTexture *texture = &(screen->getToolbarStyle()->toolbar); - frame.pixmap = texture->render(frame.rect.width(), frame.rect.height(), - frame.pixmap); - if (! frame.pixmap) - XSetWindowBackground(display, frame.window, texture->color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.window, frame.pixmap); - - XClearWindow(display, frame.window); - - it = clientList.begin(); - - int x, y; - - switch (direction) { - case Vertical: - x = 0; - y = screen->getBevelWidth(); - - for (; it != end; ++it) { - client = *it; - x = (frame.rect.width() - client->rect.width()) / 2; - - XMoveResizeWindow(display, client->window, x, y, - client->rect.width(), client->rect.height()); - XMapWindow(display, client->window); - - // for ICCCM compliance - client->rect.setPos(x, y); - - XEvent event; - event.type = ConfigureNotify; - - event.xconfigure.display = display; - event.xconfigure.event = client->window; - event.xconfigure.window = client->window; - event.xconfigure.x = x; - event.xconfigure.y = y; - event.xconfigure.width = client->rect.width(); - event.xconfigure.height = client->rect.height(); - event.xconfigure.border_width = 0; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = False; - - XSendEvent(display, client->window, False, StructureNotifyMask, &event); - - y += client->rect.height() + screen->getBevelWidth(); - } - - break; - - case Horizontal: - x = screen->getBevelWidth(); - y = 0; - - for (; it != end; ++it) { - client = *it; - y = (frame.rect.height() - client->rect.height()) / 2; - - XMoveResizeWindow(display, client->window, x, y, - client->rect.width(), client->rect.height()); - XMapWindow(display, client->window); - - // for ICCCM compliance - client->rect.setPos(x, y); - - XEvent event; - event.type = ConfigureNotify; - - event.xconfigure.display = display; - event.xconfigure.event = client->window; - event.xconfigure.window = client->window; - event.xconfigure.x = x; - event.xconfigure.y = y; - event.xconfigure.width = client->rect.width(); - event.xconfigure.height = client->rect.height(); - event.xconfigure.border_width = 0; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = False; - - XSendEvent(display, client->window, False, StructureNotifyMask, &event); - - x += client->rect.width() + screen->getBevelWidth(); - } - break; - } - - slitmenu->reconfigure(); -} - - -void Slit::updateStrut(void) { - strut.top = strut.bottom = strut.left = strut.right = 0; - - if (! clientList.empty()) { - // when not hidden both borders are in use, when hidden only one is - unsigned int border_width = screen->getBorderWidth(); - if (! do_auto_hide) - border_width *= 2; - - switch (direction) { - case Vertical: - switch (placement) { - case TopCenter: - strut.top = getExposedHeight() + border_width; - break; - case BottomCenter: - strut.bottom = getExposedHeight() + border_width; - break; - case TopLeft: - case CenterLeft: - case BottomLeft: - strut.left = getExposedWidth() + border_width; - break; - case TopRight: - case CenterRight: - case BottomRight: - strut.right = getExposedWidth() + border_width; - break; - } - break; - case Horizontal: - switch (placement) { - case TopCenter: - case TopLeft: - case TopRight: - strut.top = frame.rect.top() + getExposedHeight() + border_width; - break; - case BottomCenter: - case BottomLeft: - case BottomRight: - int pos; - if (do_auto_hide) - pos = frame.y_hidden; - else - pos = frame.rect.y(); - strut.bottom = (screen->getRect().bottom() - pos); - break; - case CenterLeft: - strut.left = getExposedWidth() + border_width; - break; - case CenterRight: - strut.right = getExposedWidth() + border_width; - break; - } - break; - } - } - - // update area with new Strut info - screen->updateAvailableArea(); -} - - -void Slit::reposition(void) { - int x = 0, y = 0; - - switch (placement) { - case TopLeft: - case CenterLeft: - case BottomLeft: - x = 0; - frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.rect.width(); - - if (placement == TopLeft) - y = 0; - else if (placement == CenterLeft) - y = (screen->getHeight() - frame.rect.height()) / 2; - else - y = screen->getHeight() - frame.rect.height() - - (screen->getBorderWidth() * 2); - - break; - - case TopCenter: - case BottomCenter: - x = (screen->getWidth() - frame.rect.width()) / 2; - frame.x_hidden = x; - - if (placement == TopCenter) - y = 0; - else - y = screen->getHeight() - frame.rect.height() - - (screen->getBorderWidth() * 2); - - break; - - case TopRight: - case CenterRight: - case BottomRight: - x = screen->getWidth() - frame.rect.width() - - (screen->getBorderWidth() * 2); - frame.x_hidden = screen->getWidth() - screen->getBevelWidth() - - screen->getBorderWidth(); - - if (placement == TopRight) - y = 0; - else if (placement == CenterRight) - y = (screen->getHeight() - frame.rect.height()) / 2; - else - y = screen->getHeight() - frame.rect.height() - - (screen->getBorderWidth() * 2); - break; - } - - frame.rect.setPos(x, y); - - // we have to add the border to the rect as it is not accounted for - Rect tbar_rect = screen->getToolbar()->getRect(); - tbar_rect.setSize(tbar_rect.width() + (screen->getBorderWidth() * 2), - tbar_rect.height() + (screen->getBorderWidth() * 2)); - Rect slit_rect = frame.rect; - slit_rect.setSize(slit_rect.width() + (screen->getBorderWidth() * 2), - slit_rect.height() + (screen->getBorderWidth() * 2)); - - if (! screen->doHideToolbar() && slit_rect.intersects(tbar_rect)) { - int delta = screen->getToolbar()->getExposedHeight() + - screen->getBorderWidth(); - if (frame.rect.bottom() <= tbar_rect.bottom()) - delta = -delta; - - frame.rect.setY(frame.rect.y() + delta); - } - - if (placement == TopCenter) - frame.y_hidden = 0 - frame.rect.height() + screen->getBorderWidth() - + screen->getBevelWidth(); - else if (placement == BottomCenter) - frame.y_hidden = screen->getHeight() - screen->getBorderWidth() - - screen->getBevelWidth(); - else - frame.y_hidden = frame.rect.y(); - - updateStrut(); - - if (hidden) - XMoveResizeWindow(display, frame.window, - frame.x_hidden, frame.y_hidden, - frame.rect.width(), frame.rect.height()); - else - XMoveResizeWindow(display, frame.window, - frame.rect.x(), frame.rect.y(), - frame.rect.width(), frame.rect.height()); -} - - -void Slit::shutdown(void) { - while (! clientList.empty()) - removeClient(clientList.front()); -} - - -void Slit::buttonPressEvent(const XButtonEvent *e) { - if (e->window != frame.window) return; - - if (e->button == Button1 && (! on_top)) { - Window w[1] = { frame.window }; - screen->raiseWindows(w, 1); - } else if (e->button == Button2 && (! on_top)) { - XLowerWindow(display, frame.window); - } else if (e->button == Button3) { - if (! slitmenu->isVisible()) { - int x, y; - - x = e->x_root - (slitmenu->getWidth() / 2); - y = e->y_root - (slitmenu->getHeight() / 2); - - if (x < 0) - x = 0; - else if (x + slitmenu->getWidth() > screen->getWidth()) - x = screen->getWidth() - slitmenu->getWidth(); - - if (y < 0) - y = 0; - else if (y + slitmenu->getHeight() > screen->getHeight()) - y = screen->getHeight() - slitmenu->getHeight(); - - slitmenu->move(x, y); - slitmenu->show(); - } else { - slitmenu->hide(); - } - } -} - - -void Slit::enterNotifyEvent(const XCrossingEvent *) { - if (! do_auto_hide) - return; - - if (hidden) { - if (! timer->isTiming()) timer->start(); - } else { - if (timer->isTiming()) timer->stop(); - } -} - - -void Slit::leaveNotifyEvent(const XCrossingEvent *) { - if (! do_auto_hide) - return; - - if (hidden) { - if (timer->isTiming()) timer->stop(); - } else if (! slitmenu->isVisible()) { - if (! timer->isTiming()) timer->start(); - } -} - - -void Slit::configureRequestEvent(const XConfigureRequestEvent *e) { - if (! blackbox->validateWindow(e->window)) - return; - - XWindowChanges xwc; - - xwc.x = e->x; - xwc.y = e->y; - xwc.width = e->width; - xwc.height = e->height; - xwc.border_width = 0; - xwc.sibling = e->above; - xwc.stack_mode = e->detail; - - XConfigureWindow(display, e->window, e->value_mask, &xwc); - - SlitClientList::iterator it = clientList.begin(); - const SlitClientList::iterator end = clientList.end(); - for (; it != end; ++it) { - SlitClient *client = *it; - if (client->window == e->window && - (static_cast(client->rect.width()) != e->width || - static_cast(client->rect.height()) != e->height)) { - client->rect.setSize(e->width, e->height); - - reconfigure(); - return; - } - } -} - - -void Slit::timeout(void) { - hidden = ! hidden; - if (hidden) - XMoveWindow(display, frame.window, frame.x_hidden, frame.y_hidden); - else - XMoveWindow(display, frame.window, frame.rect.x(), frame.rect.y()); -} - - -void Slit::toggleAutoHide(void) { - saveAutoHide(do_auto_hide ? False : True); - - updateStrut(); - - if (do_auto_hide == False && hidden) { - // force the slit to be visible - if (timer->isTiming()) timer->stop(); - timeout(); - } -} - - -void Slit::unmapNotifyEvent(const XUnmapEvent *e) { - removeClient(e->window); -} - - -Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) { - slit = sl; - - setLabel(i18n(SlitSet, SlitSlitTitle, "Slit")); - setInternalMenu(); - - directionmenu = new Directionmenu(this); - placementmenu = new Placementmenu(this); - - insert(i18n(CommonSet, CommonDirectionTitle, "Direction"), - directionmenu); - insert(i18n(CommonSet, CommonPlacementTitle, "Placement"), - placementmenu); - insert(i18n(CommonSet, CommonAlwaysOnTop, "Always on top"), 1); - insert(i18n(CommonSet, CommonAutoHide, "Auto hide"), 2); - - update(); - - if (slit->isOnTop()) setItemSelected(2, True); - if (slit->doAutoHide()) setItemSelected(3, True); -} - - -Slitmenu::~Slitmenu(void) { - delete directionmenu; - delete placementmenu; -} - - -void Slitmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - if (! item) return; - - switch (item->function()) { - case 1: { // always on top - slit->saveOnTop(! slit->isOnTop()); - setItemSelected(2, slit->isOnTop()); - - if (slit->isOnTop()) slit->screen->raiseWindows((Window *) 0, 0); - break; - } - - case 2: { // auto hide - slit->toggleAutoHide(); - setItemSelected(3, slit->doAutoHide()); - - break; - } - } // switch -} - - -void Slitmenu::internal_hide(void) { - Basemenu::internal_hide(); - if (slit->doAutoHide()) - slit->timeout(); -} - - -void Slitmenu::reconfigure(void) { - directionmenu->reconfigure(); - placementmenu->reconfigure(); - - Basemenu::reconfigure(); -} - - -Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm) - : Basemenu(sm->slit->screen), slit(sm->slit) { - - setLabel(i18n(SlitSet, SlitSlitDirection, "Slit Direction")); - setInternalMenu(); - - insert(i18n(CommonSet, CommonDirectionHoriz, "Horizontal"), - Slit::Horizontal); - insert(i18n(CommonSet, CommonDirectionVert, "Vertical"), - Slit::Vertical); - - update(); - setValues(); -} - - -void Slitmenu::Directionmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Slitmenu::Directionmenu::setValues(void) { - const bool horiz = slit->getDirection() == Slit::Horizontal; - setItemSelected(0, horiz); - setItemSelected(1, ! horiz); -} - - -void Slitmenu::Directionmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - if (! item) return; - - slit->saveDirection(item->function()); - hide(); - slit->reconfigure(); -} - - -Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm) - : Basemenu(sm->slit->screen), slit(sm->slit) { - - setLabel(i18n(SlitSet, SlitSlitPlacement, "Slit Placement")); - setMinimumSublevels(3); - setInternalMenu(); - - insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"), - Slit::TopLeft); - insert(i18n(CommonSet, CommonPlacementCenterLeft, "Center Left"), - Slit::CenterLeft); - insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"), - Slit::BottomLeft); - insert(i18n(CommonSet, CommonPlacementTopCenter, "Top Center"), - Slit::TopCenter); - insert(""); - insert(i18n(CommonSet, CommonPlacementBottomCenter, "Bottom Center"), - Slit::BottomCenter); - insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"), - Slit::TopRight); - insert(i18n(CommonSet, CommonPlacementCenterRight, "Center Right"), - Slit::CenterRight); - insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"), - Slit::BottomRight); - - update(); - - setValues(); -} - - -void Slitmenu::Placementmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Slitmenu::Placementmenu::setValues(void) { - int place = 0; - switch (slit->getPlacement()) { - case Slit::BottomRight: - place++; - case Slit::CenterRight: - place++; - case Slit::TopRight: - place++; - case Slit::BottomCenter: - place++; - case Slit::TopCenter: - place++; - case Slit::BottomLeft: - place++; - case Slit::CenterLeft: - place++; - case Slit::TopLeft: - break; - } - setItemSelected(0, 0 == place); - setItemSelected(1, 1 == place); - setItemSelected(2, 2 == place); - setItemSelected(3, 3 == place); - setItemSelected(5, 4 == place); - setItemSelected(6, 5 == place); - setItemSelected(7, 6 == place); - setItemSelected(8, 7 == place); -} - - -void Slitmenu::Placementmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - if (! (item && item->function())) return; - - slit->savePlacement(item->function()); - hide(); - slit->reconfigure(); -} - diff --git a/src/Slit.hh b/src/Slit.hh deleted file mode 100644 index 798ccb24..00000000 --- a/src/Slit.hh +++ /dev/null @@ -1,205 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Slit.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifndef __Slit_hh -#define __Slit_hh - -extern "C" { -#include -#include -} - -#include -#include - -#include "Screen.hh" -#include "Basemenu.hh" - -// forward declaration -class Slit; -class Slitmenu; - -class Slitmenu : public Basemenu { -private: - class Directionmenu : public Basemenu { - private: - Directionmenu(const Directionmenu&); - Directionmenu& operator=(const Directionmenu&); - Slit *slit; - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - Directionmenu(Slitmenu *sm); - virtual void reconfigure(void); - }; - - class Placementmenu : public Basemenu { - private: - Placementmenu(const Placementmenu&); - Placementmenu& operator=(const Placementmenu&); - Slit *slit; - - protected: - virtual void itemSelected(int buton, unsigned int index); - virtual void setValues(void); - - public: - Placementmenu(Slitmenu *sm); - virtual void reconfigure(void); - }; - - Directionmenu *directionmenu; - Placementmenu *placementmenu; - - Slit *slit; - - friend class Directionmenu; - friend class Placementmenu; - friend class Slit; - - Slitmenu(const Slitmenu&); - Slitmenu& operator=(const Slitmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - virtual void internal_hide(void); - -public: - Slitmenu(Slit *sl); - virtual ~Slitmenu(void); - - inline Basemenu *getDirectionmenu(void) { return directionmenu; } - inline Basemenu *getPlacementmenu(void) { return placementmenu; } - - void reconfigure(void); -}; - - -class Slit : public TimeoutHandler { -public: - struct SlitClient { - Window window, client_window, icon_window; - - Rect rect; - }; - -private: - typedef std::list SlitClientList; - - bool on_top, hidden, do_auto_hide; - int direction, placement; - std::string slitstr; - Display *display; - - Blackbox *blackbox; - BScreen *screen; - Configuration *config; - BTimer *timer; - Strut strut; - - SlitClientList clientList; - Slitmenu *slitmenu; - - struct SlitFrame { - Pixmap pixmap; - Window window; - - int x_hidden, y_hidden; - Rect rect; - } frame; - - void updateStrut(void); - - friend class Slitmenu; - friend class Slitmenu::Directionmenu; - friend class Slitmenu::Placementmenu; - - Slit(const Slit&); - Slit& operator=(const Slit&); - -public: - Slit(BScreen *scr); - virtual ~Slit(void); - - inline bool isOnTop(void) const { return on_top; } - inline bool isHidden(void) const { return hidden; } - inline bool doAutoHide(void) const { return do_auto_hide; } - inline int getPlacement(void) const { return placement; } - inline int getDirection(void) const { return direction; } - - void saveOnTop(bool); - void saveAutoHide(bool); - void savePlacement(int); - void saveDirection(int); - - inline Slitmenu *getMenu(void) { return slitmenu; } - - inline Window getWindowID(void) const { return frame.window; } - - inline int getX(void) const - { return ((hidden) ? frame.x_hidden : frame.rect.x()); } - inline int getY(void) const - { return ((hidden) ? frame.y_hidden : frame.rect.y()); } - - inline unsigned int getWidth(void) const { return frame.rect.width(); } - inline unsigned int getExposedWidth(void) const { - if (direction == Vertical && do_auto_hide) - return screen->getBevelWidth(); - return frame.rect.width(); - } - inline unsigned int getHeight(void) const { return frame.rect.height(); } - inline unsigned int getExposedHeight(void) const { - if (direction == Horizontal && do_auto_hide) - return screen->getBevelWidth(); - return frame.rect.height(); - } - - void addClient(Window w); - void removeClient(SlitClient *client, bool remap = True); - void removeClient(Window w, bool remap = True); - void load_rc(void); - void save_rc(void); - void reconfigure(void); - void updateSlit(void); - void reposition(void); - void shutdown(void); - void toggleAutoHide(void); - - void buttonPressEvent(const XButtonEvent *e); - void enterNotifyEvent(const XCrossingEvent * /*unused*/); - void leaveNotifyEvent(const XCrossingEvent * /*unused*/); - void configureRequestEvent(const XConfigureRequestEvent *e); - void unmapNotifyEvent(const XUnmapEvent *e); - - virtual void timeout(void); - - enum { Vertical = 1, Horizontal }; - enum { TopLeft = 1, CenterLeft, BottomLeft, TopCenter, BottomCenter, - TopRight, CenterRight, BottomRight }; -}; - - -#endif // __Slit_hh diff --git a/src/Toolbar.cc b/src/Toolbar.cc deleted file mode 100644 index 587d3fd4..00000000 --- a/src/Toolbar.cc +++ /dev/null @@ -1,1236 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Toolbar.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H - -extern "C" { -#include - -#ifdef HAVE_STRING_H -# include -#endif // HAVE_STRING_H - -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H - -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else // !TIME_WITH_SYS_TIME -# ifdef HAVE_SYS_TIME_H -# include -# else // !HAVE_SYS_TIME_H -# include -# endif // HAVE_SYS_TIME_H -#endif // TIME_WITH_SYS_TIME -} - -#include -using std::string; - -#include "i18n.hh" -#include "blackbox.hh" -#include "Font.hh" -#include "GCCache.hh" -#include "Image.hh" -#include "Screen.hh" -#include "Toolbar.hh" -#include "Window.hh" -#include "Workspace.hh" -#include "Clientmenu.hh" -#include "Workspacemenu.hh" -#include "Slit.hh" - - -static long aMinuteFromNow(void) { - timeval now; - gettimeofday(&now, 0); - return ((60 - (now.tv_sec % 60)) * 1000); -} - - -Toolbar::Toolbar(BScreen *scrn) { - screen = scrn; - blackbox = screen->getBlackbox(); - toolbarstr = "session.screen" + itostring(screen->getScreenNumber()) + - ".toolbar."; - config = blackbox->getConfig(); - - load_rc(); - - // get the clock updating every minute - clock_timer = new BTimer(blackbox, this); - clock_timer->setTimeout(aMinuteFromNow()); - clock_timer->recurring(True); - clock_timer->start(); - frame.minute = frame.hour = -1; - - hide_handler.toolbar = this; - hide_timer = new BTimer(blackbox, &hide_handler); - hide_timer->setTimeout(blackbox->getAutoRaiseDelay()); - - editing = False; - new_name_pos = 0; - - toolbarmenu = new Toolbarmenu(this); - - display = blackbox->getXDisplay(); - XSetWindowAttributes attrib; - unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - screen->getBorderColor()->pixel(); - attrib.colormap = screen->getColormap(); - attrib.override_redirect = True; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - EnterWindowMask | LeaveWindowMask; - - frame.window = - XCreateWindow(display, screen->getRootWindow(), 0, 0, 1, 1, 0, - screen->getDepth(), InputOutput, screen->getVisual(), - create_mask, &attrib); - blackbox->saveToolbarSearch(frame.window, this); - - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask | - KeyPressMask | EnterWindowMask; - - frame.workspace_label = - XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen->getDepth(), - InputOutput, screen->getVisual(), create_mask, &attrib); - blackbox->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); - blackbox->saveToolbarSearch(frame.window_label, this); - - frame.clock = - XCreateWindow(display, frame.window, 0, 0, 1, 1, 0, screen->getDepth(), - InputOutput, screen->getVisual(), create_mask, &attrib); - blackbox->saveToolbarSearch(frame.clock, this); - - frame.psbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(), - InputOutput, screen->getVisual(), create_mask, &attrib); - blackbox->saveToolbarSearch(frame.psbutton, this); - - frame.nsbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(), - InputOutput, screen->getVisual(), create_mask, &attrib); - blackbox->saveToolbarSearch(frame.nsbutton, this); - - frame.pwbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(), - InputOutput, screen->getVisual(), create_mask, &attrib); - blackbox->saveToolbarSearch(frame.pwbutton, this); - - frame.nwbutton = - XCreateWindow(display ,frame.window, 0, 0, 1, 1, 0, screen->getDepth(), - InputOutput, screen->getVisual(), create_mask, &attrib); - blackbox->saveToolbarSearch(frame.nwbutton, this); - - frame.base = frame.label = frame.wlabel = frame.clk = frame.button = - frame.pbutton = None; - - reconfigure(); - mapToolbar(); -} - - -Toolbar::~Toolbar(void) { - unmapToolbar(); - - if (frame.base) screen->getImageControl()->removeImage(frame.base); - if (frame.label) screen->getImageControl()->removeImage(frame.label); - if (frame.wlabel) screen->getImageControl()->removeImage(frame.wlabel); - if (frame.clk) screen->getImageControl()->removeImage(frame.clk); - if (frame.button) screen->getImageControl()->removeImage(frame.button); - if (frame.pbutton) screen->getImageControl()->removeImage(frame.pbutton); - - blackbox->removeToolbarSearch(frame.window); - blackbox->removeToolbarSearch(frame.workspace_label); - blackbox->removeToolbarSearch(frame.window_label); - blackbox->removeToolbarSearch(frame.clock); - blackbox->removeToolbarSearch(frame.psbutton); - blackbox->removeToolbarSearch(frame.nsbutton); - blackbox->removeToolbarSearch(frame.pwbutton); - blackbox->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 clock_timer; - delete toolbarmenu; -} - - -void Toolbar::mapToolbar() { - if (!screen->doHideToolbar()) { - //not hidden, so windows should not maximize over the toolbar - XMapSubwindows(display, frame.window); - XMapWindow(display, frame.window); - } - screen->addStrut(&strut); - updateStrut(); -} - - -void Toolbar::unmapToolbar() { - if (toolbarmenu->isVisible()) - toolbarmenu->hide(); - //hidden so we can maximize over the toolbar - screen->removeStrut(&strut); - screen->updateAvailableArea(); - - XUnmapWindow(display, frame.window); - updateStrut(); -} - - -void Toolbar::saveOnTop(bool b) { - on_top = b; - config->setValue(toolbarstr + "onTop", on_top); -} - - -void Toolbar::saveAutoHide(bool b) { - do_auto_hide = b; - config->setValue(toolbarstr + "autoHide", do_auto_hide); -} - - -void Toolbar::saveWidthPercent(unsigned int w) { - width_percent = w; - config->setValue(toolbarstr + "widthPercent", width_percent); -} - - -void Toolbar::savePlacement(int p) { - placement = p; - const char *pname; - switch (placement) { - case TopLeft: pname = "TopLeft"; break; - case BottomLeft: pname = "BottomLeft"; break; - case TopCenter: pname = "TopCenter"; break; - case TopRight: pname = "TopRight"; break; - case BottomRight: pname = "BottomRight"; break; - case BottomCenter: default: pname = "BottomCenter"; break; - } - config->setValue(toolbarstr + "placement", pname); -} - - -void Toolbar::save_rc(void) { - saveOnTop(on_top); - saveAutoHide(do_auto_hide); - saveWidthPercent(width_percent); - savePlacement(placement); -} - - -void Toolbar::load_rc(void) { - string s; - - if (! config->getValue(toolbarstr + "onTop", on_top)) - on_top = false; - - if (! config->getValue(toolbarstr + "autoHide", do_auto_hide)) - do_auto_hide = false; - hidden = do_auto_hide; - - if (! config->getValue(toolbarstr + "widthPercent", width_percent) || - width_percent == 0 || width_percent > 100) - width_percent = 66; - - if (config->getValue(toolbarstr + "placement", s)) { - if (s == "TopLeft") - placement = TopLeft; - else if (s == "BottomLeft") - placement = BottomLeft; - else if (s == "TopCenter") - placement = TopCenter; - else if (s == "TopRight") - placement = TopRight; - else if (s == "BottomRight") - placement = BottomRight; - else //if (s == "BottomCenter") - placement = BottomCenter; - } else - placement = BottomCenter; -} - - -void Toolbar::reconfigure(void) { - unsigned int width, height; - - width = (screen->getWidth() * width_percent) / 100; - height = screen->getToolbarStyle()->font->height(); - - frame.bevel_w = screen->getBevelWidth(); - frame.button_w = height; - height += 2; - frame.label_h = height; - height += (frame.bevel_w * 2); - - frame.rect.setSize(width, height); - - int x, y; - switch (placement) { - case TopLeft: - case TopRight: - case TopCenter: - if (placement == TopLeft) - x = 0; - else if (placement == TopRight) - x = screen->getWidth() - frame.rect.width() - - (screen->getBorderWidth() * 2); - else - x = (screen->getWidth() - frame.rect.width()) / 2; - - y = 0; - - frame.x_hidden = x; - frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.rect.height(); - break; - - case BottomLeft: - case BottomRight: - case BottomCenter: - default: - if (placement == BottomLeft) - x = 0; - else if (placement == BottomRight) - x = screen->getWidth() - frame.rect.width() - - (screen->getBorderWidth() * 2); - else - x = (screen->getWidth() - frame.rect.width()) / 2; - - y = screen->getHeight() - frame.rect.height() - - (screen->getBorderWidth() * 2); - - frame.x_hidden = x; - frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - - screen->getBorderWidth(); - break; - } - - frame.rect.setPos(x, y); - - updateStrut(); - -#ifdef HAVE_STRFTIME - time_t ttmp = time(NULL); - - frame.clock_w = 0; - if (ttmp != -1) { - struct tm *tt = localtime(&ttmp); - if (tt) { - char t[1024]; - int len = strftime(t, 1024, screen->getStrftimeFormat(), tt); - if (len == 0) { // invalid time format found - screen->saveStrftimeFormat("%I:%M %p"); // so use the default - strftime(t, 1024, screen->getStrftimeFormat(), tt); - } - // find the length of the rendered string and add room for two extra - // characters to it. This allows for variable width output of the fonts - BFont *font = screen->getToolbarStyle()->font; - frame.clock_w = font->measureString(t) + font->maxCharWidth() * 2; - } - } -#else // !HAVE_STRFTIME - { - string s = i18n(ToolbarSet, ToolbarNoStrftimeLength, "00:00000"); - frame.clock_w = screen->getToolbarStyle()->font->measureString(s); - } -#endif // HAVE_STRFTIME - - frame.workspace_label_w = 0; - - for (unsigned int i = 0; i < screen->getWorkspaceCount(); i++) { - const string& workspace_name = screen->getWorkspace(i)->getName(); - width = screen->getToolbarStyle()->font->measureString(workspace_name); - if (width > frame.workspace_label_w) frame.workspace_label_w = width; - } - - frame.workspace_label_w = frame.clock_w = - std::max(frame.workspace_label_w, frame.clock_w) + (frame.bevel_w * 4); - - // XXX: where'd the +6 come from? - frame.window_label_w = - (frame.rect.width() - (frame.clock_w + (frame.button_w * 4) + - frame.workspace_label_w + (frame.bevel_w * 8) + 6)); - - if (hidden) { - XMoveResizeWindow(display, frame.window, frame.x_hidden, frame.y_hidden, - frame.rect.width(), frame.rect.height()); - } else { - XMoveResizeWindow(display, frame.window, frame.rect.x(), frame.rect.y(), - frame.rect.width(), frame.rect.height()); - } - - XMoveResizeWindow(display, frame.workspace_label, frame.bevel_w, - frame.bevel_w, frame.workspace_label_w, - frame.label_h); - XMoveResizeWindow(display, frame.psbutton, - ((frame.bevel_w * 2) + frame.workspace_label_w + 1), - frame.bevel_w + 1, frame.button_w, frame.button_w); - XMoveResizeWindow(display, frame.nsbutton, - ((frame.bevel_w * 3) + frame.workspace_label_w + - frame.button_w + 2), frame.bevel_w + 1, frame.button_w, - frame.button_w); - XMoveResizeWindow(display, frame.window_label, - ((frame.bevel_w * 4) + (frame.button_w * 2) + - frame.workspace_label_w + 3), frame.bevel_w, - frame.window_label_w, frame.label_h); - XMoveResizeWindow(display, frame.pwbutton, - ((frame.bevel_w * 5) + (frame.button_w * 2) + - frame.workspace_label_w + frame.window_label_w + 4), - frame.bevel_w + 1, frame.button_w, frame.button_w); - XMoveResizeWindow(display, frame.nwbutton, - ((frame.bevel_w * 6) + (frame.button_w * 3) + - frame.workspace_label_w + frame.window_label_w + 5), - frame.bevel_w + 1, frame.button_w, frame.button_w); - XMoveResizeWindow(display, frame.clock, - frame.rect.width() - frame.clock_w - (frame.bevel_w * 2), - frame.bevel_w, frame.clock_w, frame.label_h); - - ToolbarStyle *style = screen->getToolbarStyle(); - frame.base = style->toolbar.render(frame.rect.width(), frame.rect.height(), - frame.base); - if (! frame.base) - XSetWindowBackground(display, frame.window, - style->toolbar.color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.window, frame.base); - - frame.label = style->window.render(frame.window_label_w, frame.label_h, - frame.label); - if (! frame.label) - XSetWindowBackground(display, frame.window_label, - style->window.color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.window_label, frame.label); - - frame.wlabel = style->label.render(frame.workspace_label_w, frame.label_h, - frame.wlabel); - if (! frame.wlabel) - XSetWindowBackground(display, frame.workspace_label, - style->label.color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel); - - frame.clk = style->clock.render(frame.clock_w, frame.label_h, frame.clk); - if (! frame.clk) - XSetWindowBackground(display, frame.clock, style->clock.color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.clock, frame.clk); - - frame.button = style->button.render(frame.button_w, frame.button_w, - frame.button); - if (! frame.button) { - frame.button_pixel = style->button.color().pixel(); - 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 { - XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button); - XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button); - XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button); - XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button); - } - - frame.pbutton = style->pressed.render(frame.button_w, frame.button_w, - frame.pbutton); - if (! frame.pbutton) - frame.pbutton_pixel = style->pressed.color().pixel(); - - XSetWindowBorder(display, frame.window, - screen->getBorderColor()->pixel()); - 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(); - checkClock(True); - - toolbarmenu->reconfigure(); -} - - -void Toolbar::updateStrut(void) { - // left and right are always 0 - strut.top = strut.bottom = 0; - - // when hidden only one border is visible - unsigned int border_width = screen->getBorderWidth(); - if (! do_auto_hide) - border_width *= 2; - - if (! screen->doHideToolbar()) { - switch(placement) { - case TopLeft: - case TopCenter: - case TopRight: - strut.top = getExposedHeight() + border_width; - break; - default: - strut.bottom = getExposedHeight() + border_width; - } - } - - screen->updateAvailableArea(); -} - - -#ifdef HAVE_STRFTIME -void Toolbar::checkClock(bool redraw) { -#else // !HAVE_STRFTIME -void Toolbar::checkClock(bool redraw, bool date) { -#endif // HAVE_STRFTIME - time_t tmp = 0; - struct tm *tt = 0; - - if ((tmp = time(NULL)) != -1) { - if (! (tt = localtime(&tmp))) 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); - redraw = True; - } - } - - if (redraw) { -#ifdef HAVE_STRFTIME - char t[1024]; - if (! strftime(t, 1024, screen->getStrftimeFormat(), tt)) - return; -#else // !HAVE_STRFTIME - char t[9]; - if (date) { - // format the date... with special consideration for y2k ;) - if (screen->getDateFormat() == Blackbox::B_EuropeanDate) - sprintf(t, 18n(ToolbarSet, ToolbarNoStrftimeDateFormatEu, - "%02d.%02d.%02d"), - tt->tm_mday, tt->tm_mon + 1, - (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); - else - sprintf(t, i18n(ToolbarSet, ToolbarNoStrftimeDateFormat, - "%02d/%02d/%02d"), - tt->tm_mon + 1, tt->tm_mday, - (tt->tm_year >= 100) ? tt->tm_year - 100 : tt->tm_year); - } else { - if (screen->isClock24Hour()) - sprintf(t, i18n(ToolbarSet, ToolbarNoStrftimeTimeFormat24, - " %02d:%02d "), - frame.hour, frame.minute); - else - sprintf(t, i18n(ToolbarSet, ToolbarNoStrftimeTimeFormat12, - "%02d:%02d %sm"), - ((frame.hour > 12) ? frame.hour - 12 : - ((frame.hour == 0) ? 12 : frame.hour)), frame.minute, - ((frame.hour >= 12) ? - i18n(ToolbarSet, ToolbarNoStrftimeTimeFormatP, "p") : - i18n(ToolbarSet, ToolbarNoStrftimeTimeFormatA, "a"))); - } -#endif // HAVE_STRFTIME - - ToolbarStyle *style = screen->getToolbarStyle(); - - int pos = frame.bevel_w * 2; // this is modified by doJustify() - style->doJustify(t, pos, frame.clock_w, frame.bevel_w * 4); - -#ifdef XFT - XClearWindow(display, frame.clock); -#endif // XFT - - style->font->drawString(frame.clock, pos, 1, style->c_text, t); - } -} - - -void Toolbar::redrawWindowLabel(bool redraw) { - BlackboxWindow *foc = screen->getBlackbox()->getFocusedWindow(); - if (! foc) { - XClearWindow(display, frame.window_label); - return; - } - -#ifdef XFT - redraw = true; -#endif // XFT - - if (redraw) - XClearWindow(display, frame.window_label); - - if (foc->getScreen() != screen) return; - - const char *title = foc->getTitle(); - ToolbarStyle *style = screen->getToolbarStyle(); - - int pos = frame.bevel_w * 2; // modified by doJustify() - style->doJustify(title, pos, frame.window_label_w, frame.bevel_w * 4); - style->font->drawString(frame.window_label, pos, 1, style->w_text, title); -} - - -void Toolbar::redrawWorkspaceLabel(bool redraw) { - const string& name = screen->getCurrentWorkspace()->getName(); - -#ifdef XFT - redraw = true; -#endif // XFT - - if (redraw) - XClearWindow(display, frame.workspace_label); - - ToolbarStyle *style = screen->getToolbarStyle(); - - int pos = frame.bevel_w * 2; - style->doJustify(name.c_str(), pos, frame.workspace_label_w, - frame.bevel_w * 4); - style->font->drawString(frame.workspace_label, pos, 1, style->l_text, name); -} - - -void Toolbar::drawArrow(Drawable surface, bool left) const { - ToolbarStyle *style = screen->getToolbarStyle(); - - BPen pen(style->b_pic); - - int hh = frame.button_w / 2, hw = frame.button_w / 2; - XPoint pts[3]; - const int bullet_size = 3; - - - if (left) { -#ifdef BITMAPBUTTONS - if (style->left_button.mask != None) { - XSetClipMask(blackbox->getXDisplay(), pen.gc(), style->left_button.mask); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), - (frame.button_w - style->left_button.w)/2, - (frame.button_w - style->left_button.h)/2); - - XFillRectangle(blackbox->getXDisplay(), surface, pen.gc(), - (frame.button_w - style->left_button.w)/2, - (frame.button_w - style->left_button.h)/2, - style->left_button.w, style->left_button.h); - - XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); - } else { -#endif // BITMAPBUTTONS - pts[0].x = hw - bullet_size; - pts[0].y = hh; - pts[1].x = 2 * bullet_size; - pts[1].y = bullet_size; - pts[2].x = 0; - pts[2].y = -(2 * bullet_size); - XFillPolygon(display, surface, pen.gc(), pts, 3, Convex, - CoordModePrevious); -#ifdef BITMAPBUTTONS - } -#endif // BITMAPBUTTONS - } else { -#ifdef BITMAPBUTTONS - if (style->right_button.mask != None) { - XSetClipMask(blackbox->getXDisplay(), pen.gc(), - style->right_button.mask); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), - (frame.button_w - style->right_button.w)/2, - (frame.button_w - style->right_button.h)/2); - - XFillRectangle(blackbox->getXDisplay(), surface, pen.gc(), - (frame.button_w - style->right_button.w)/2, - (frame.button_w - style->right_button.h)/2, - (frame.button_w + style->right_button.w)/2, - (frame.button_w + style->right_button.h)/2); - - XSetClipMask(blackbox->getXDisplay(), pen.gc(), None); - XSetClipOrigin(blackbox->getXDisplay(), pen.gc(), 0, 0); - } else { -#endif // BITMAPBUTTONS - pts[0].x = hw - bullet_size; - pts[0].y = hh - bullet_size; - pts[1].x = (2 * bullet_size); - pts[1].y = bullet_size; - pts[2].x = -(2 * bullet_size); - pts[2].y = bullet_size; - XFillPolygon(display, surface, pen.gc(), pts, 3, Convex, - CoordModePrevious); -#ifdef BITMAPBUTTONS - } -#endif - } -} - - -void Toolbar::redrawPrevWorkspaceButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.psbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.psbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.psbutton, frame.button); - else - XSetWindowBackground(display, frame.psbutton, frame.button_pixel); - } - XClearWindow(display, frame.psbutton); - } - - drawArrow(frame.psbutton, True); -} - - -void Toolbar::redrawNextWorkspaceButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.nsbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.nsbutton, frame.button); - else - XSetWindowBackground(display, frame.nsbutton, frame.button_pixel); - } - XClearWindow(display, frame.nsbutton); - } - - drawArrow(frame.nsbutton, False); -} - - -void Toolbar::redrawPrevWindowButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.pwbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.pwbutton, frame.button); - else - XSetWindowBackground(display, frame.pwbutton, frame.button_pixel); - } - XClearWindow(display, frame.pwbutton); - } - - drawArrow(frame.pwbutton, True); -} - - -void Toolbar::redrawNextWindowButton(bool pressed, bool redraw) { - if (redraw) { - if (pressed) { - if (frame.pbutton) - XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.pbutton); - else - XSetWindowBackground(display, frame.nwbutton, frame.pbutton_pixel); - } else { - if (frame.button) - XSetWindowBackgroundPixmap(display, frame.nwbutton, frame.button); - else - XSetWindowBackground(display, frame.nwbutton, frame.button_pixel); - } - XClearWindow(display, frame.nwbutton); - } - - drawArrow(frame.nwbutton, False); -} - - -void Toolbar::edit(void) { - Window window; - int foo; - - editing = True; - XGetInputFocus(display, &window, &foo); - if (window == frame.workspace_label) - return; - - XSetInputFocus(display, frame.workspace_label, - RevertToPointerRoot, CurrentTime); - XClearWindow(display, frame.workspace_label); - - blackbox->setNoFocus(True); - if (blackbox->getFocusedWindow()) - blackbox->getFocusedWindow()->setFocusFlag(False); - - ToolbarStyle *style = screen->getToolbarStyle(); - BPen pen(style->l_text); - XDrawRectangle(display, frame.workspace_label, pen.gc(), - frame.workspace_label_w / 2, 0, 1, - frame.label_h - 1); - // change the background of the window to that of an active window label - BTexture *texture = &(screen->getWindowStyle()->l_focus); - frame.wlabel = texture->render(frame.workspace_label_w, frame.label_h, - frame.wlabel); - if (! frame.wlabel) - XSetWindowBackground(display, frame.workspace_label, - texture->color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.workspace_label, frame.wlabel); -} - - -void Toolbar::buttonPressEvent(const XButtonEvent *be) { - if (be->button == 1) { - if (be->window == frame.psbutton) - redrawPrevWorkspaceButton(True, True); - else if (be->window == frame.nsbutton) - redrawNextWorkspaceButton(True, True); - else if (be->window == frame.pwbutton) - redrawPrevWindowButton(True, True); - else if (be->window == frame.nwbutton) - redrawNextWindowButton(True, True); -#ifndef HAVE_STRFTIME - else if (be->window == frame.clock) { - XClearWindow(display, frame.clock); - checkClock(True, True); - } -#endif // HAVE_STRFTIME - else if (! on_top) { - Window w[1] = { frame.window }; - screen->raiseWindows(w, 1); - } - } else if (be->button == 2 && (! on_top)) { - XLowerWindow(display, frame.window); - } else if (be->button == 3) { - if (toolbarmenu->isVisible()) { - toolbarmenu->hide(); - } else { - int x, y; - - x = be->x_root - (toolbarmenu->getWidth() / 2); - y = be->y_root - (toolbarmenu->getHeight() / 2); - - if (x < 0) - x = 0; - else if (x + toolbarmenu->getWidth() > screen->getWidth()) - x = screen->getWidth() - toolbarmenu->getWidth(); - - if (y < 0) - y = 0; - else if (y + toolbarmenu->getHeight() > screen->getHeight()) - y = screen->getHeight() - toolbarmenu->getHeight(); - - toolbarmenu->move(x, y); - toolbarmenu->show(); - } - } -} - - - -void Toolbar::buttonReleaseEvent(const XButtonEvent *re) { - if (re->button == 1) { - if (re->window == frame.psbutton) { - redrawPrevWorkspaceButton(False, True); - - if (re->x >= 0 && re->x < static_cast(frame.button_w) && - re->y >= 0 && re->y < static_cast(frame.button_w)) - if (screen->getCurrentWorkspace()->getID() > 0) - screen->changeWorkspaceID(screen->getCurrentWorkspace()-> - getID() - 1); - else - screen->changeWorkspaceID(screen->getWorkspaceCount() - 1); - } else if (re->window == frame.nsbutton) { - redrawNextWorkspaceButton(False, True); - - if (re->x >= 0 && re->x < static_cast(frame.button_w) && - re->y >= 0 && re->y < static_cast(frame.button_w)) - if (screen->getCurrentWorkspace()->getID() < - (screen->getWorkspaceCount() - 1)) - screen->changeWorkspaceID(screen->getCurrentWorkspace()-> - getID() + 1); - else - screen->changeWorkspaceID(0); - } else if (re->window == frame.pwbutton) { - redrawPrevWindowButton(False, True); - - if (re->x >= 0 && re->x < static_cast(frame.button_w) && - re->y >= 0 && re->y < static_cast(frame.button_w)) - screen->prevFocus(); - } else if (re->window == frame.nwbutton) { - redrawNextWindowButton(False, True); - - if (re->x >= 0 && re->x < static_cast(frame.button_w) && - re->y >= 0 && re->y < static_cast(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); - checkClock(True); - } -#endif // HAVE_STRFTIME - } -} - - -void Toolbar::enterNotifyEvent(const 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(const 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(const XExposeEvent *ee) { - if (ee->window == frame.clock) checkClock(True); - 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(); -} - - -void Toolbar::keyPressEvent(const XKeyEvent *ke) { - if (ke->window == frame.workspace_label && editing) { - if (new_workspace_name.empty()) { - new_name_pos = 0; - } - - KeySym ks; - char keychar[1]; - XLookupString(const_cast(ke), keychar, 1, &ks, 0); - - // either we are told to end with a return or we hit 127 chars - if (ks == XK_Return || new_name_pos == 127) { - editing = False; - - blackbox->setNoFocus(False); - if (blackbox->getFocusedWindow()) - blackbox->getFocusedWindow()->setInputFocus(); - else - blackbox->setFocusedWindow(0); - - // the toolbar will be reconfigured when the change to the workspace name - // gets caught in the PropertyNotify event handler - screen->getCurrentWorkspace()->setName(new_workspace_name); - - new_workspace_name.erase(); - new_name_pos = 0; - - // reset the background to that of the workspace label (its normal - // setting) - BTexture *texture = &(screen->getToolbarStyle()->label); - frame.wlabel = texture->render(frame.workspace_label_w, frame.label_h, - frame.wlabel); - if (! frame.wlabel) - XSetWindowBackground(display, frame.workspace_label, - texture->color().pixel()); - else - XSetWindowBackgroundPixmap(display, frame.workspace_label, - frame.wlabel); - } else if (! (ks == XK_Shift_L || ks == XK_Shift_R || - ks == XK_Control_L || ks == XK_Control_R || - ks == XK_Caps_Lock || ks == XK_Shift_Lock || - ks == XK_Meta_L || ks == XK_Meta_R || - ks == XK_Alt_L || ks == XK_Alt_R || - ks == XK_Super_L || ks == XK_Super_R || - ks == XK_Hyper_L || ks == XK_Hyper_R)) { - if (ks == XK_BackSpace) { - if (new_name_pos > 0) { - --new_name_pos; - new_workspace_name.erase(new_name_pos); - } else { - new_workspace_name.resize(0); - } - } else { - new_workspace_name += (*keychar); - ++new_name_pos; - } - - XClearWindow(display, frame.workspace_label); - unsigned int tw, x; - - tw = screen->getToolbarStyle()->font->measureString(new_workspace_name); - x = (frame.workspace_label_w - tw) / 2; - - if (x < frame.bevel_w) x = frame.bevel_w; - - ToolbarStyle *style = screen->getToolbarStyle(); - style->font->drawString(frame.workspace_label, x, 1, style->l_text, - new_workspace_name); - BPen pen(style->l_text); - XDrawRectangle(display, frame.workspace_label, pen.gc(), x + tw, 0, 1, - frame.label_h - 1); - } - } -} - - -void Toolbar::timeout(void) { - checkClock(True); - - clock_timer->setTimeout(aMinuteFromNow()); -} - - -void Toolbar::HideHandler::timeout(void) { - 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.rect.x(), toolbar->frame.rect.y()); -} - - -void Toolbar::toggleAutoHide(void) { - saveAutoHide(! doAutoHide()); - - updateStrut(); - screen->getSlit()->reposition(); - - if (do_auto_hide == False && hidden) { - // force the slit to be visible - if (hide_timer->isTiming()) hide_timer->stop(); - hide_handler.timeout(); - } -} - - -Toolbarmenu::Toolbarmenu(Toolbar *tb) : Basemenu(tb->screen) { - toolbar = tb; - - setLabel(i18n(ToolbarSet, ToolbarToolbarTitle, "Toolbar")); - setInternalMenu(); - - placementmenu = new Placementmenu(this); - - insert(i18n(CommonSet, CommonPlacementTitle, "Placement"), - placementmenu); - insert(i18n(CommonSet, CommonAlwaysOnTop, "Always on top"), 1); - insert(i18n(CommonSet, CommonAutoHide, "Auto hide"), 2); - insert(i18n(ToolbarSet, ToolbarEditWkspcName, - "Edit current workspace name"), 3); - - update(); - setValues(); -} - - -void Toolbarmenu::setValues() { - setItemSelected(1, toolbar->isOnTop()); - setItemSelected(2, toolbar->doAutoHide()); -} - - -Toolbarmenu::~Toolbarmenu(void) { - delete placementmenu; -} - - -void Toolbarmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - if (! item) return; - - switch (item->function()) { - case 1: { // always on top - toolbar->saveOnTop(! toolbar->isOnTop()); - setItemSelected(1, toolbar->isOnTop()); - - if (toolbar->isOnTop()) getScreen()->raiseWindows((Window *) 0, 0); - break; - } - - case 2: { // auto hide - toolbar->toggleAutoHide(); - setItemSelected(2, toolbar->doAutoHide()); - - break; - } - - case 3: { // edit current workspace name - toolbar->edit(); - hide(); - - break; - } - } // switch -} - - -void Toolbarmenu::internal_hide(void) { - Basemenu::internal_hide(); - if (toolbar->doAutoHide() && ! toolbar->isEditing()) - toolbar->hide_handler.timeout(); -} - - -void Toolbarmenu::reconfigure(void) { - setValues(); - placementmenu->reconfigure(); - - Basemenu::reconfigure(); -} - - -Toolbarmenu::Placementmenu::Placementmenu(Toolbarmenu *tm) - : Basemenu(tm->toolbar->screen), toolbar(tm->toolbar) { - setLabel(i18n(ToolbarSet, ToolbarToolbarPlacement, "Toolbar Placement")); - setInternalMenu(); - setMinimumSublevels(3); - - insert(i18n(CommonSet, CommonPlacementTopLeft, "Top Left"), - Toolbar::TopLeft); - insert(i18n(CommonSet, CommonPlacementBottomLeft, "Bottom Left"), - Toolbar::BottomLeft); - insert(i18n(CommonSet, CommonPlacementTopCenter, "Top Center"), - Toolbar::TopCenter); - insert(i18n(CommonSet, CommonPlacementBottomCenter, "Bottom Center"), - Toolbar::BottomCenter); - insert(i18n(CommonSet, CommonPlacementTopRight, "Top Right"), - Toolbar::TopRight); - insert(i18n(CommonSet, CommonPlacementBottomRight, "Bottom Right"), - Toolbar::BottomRight); - update(); - setValues(); -} - - -void Toolbarmenu::Placementmenu::setValues(void) { - int place = 0; - switch (toolbar->getPlacement()) { - case Toolbar::BottomRight: - place++; - case Toolbar::TopRight: - place++; - case Toolbar::BottomCenter: - place++; - case Toolbar::TopCenter: - place++; - case Toolbar::BottomLeft: - place++; - case Toolbar::TopLeft: - break; - } - setItemSelected(0, 0 == place); - setItemSelected(1, 1 == place); - setItemSelected(2, 2 == place); - setItemSelected(3, 3 == place); - setItemSelected(4, 4 == place); - setItemSelected(5, 5 == place); -} - - -void Toolbarmenu::Placementmenu::reconfigure(void) { - setValues(); - Basemenu::reconfigure(); -} - - -void Toolbarmenu::Placementmenu::itemSelected(int button, unsigned int index) { - if (button != 1) - return; - - BasemenuItem *item = find(index); - if (! item) return; - - toolbar->savePlacement(item->function()); - hide(); - toolbar->reconfigure(); - - // reposition the slit as well to make sure it doesn't intersect the - // toolbar - getScreen()->getSlit()->reposition(); -} - - -void ToolbarStyle::doJustify(const std::string &text, int &start_pos, - unsigned int max_length, - unsigned int modifier) const { - size_t text_len = text.size(); - unsigned int length; - - do { - length = font->measureString(string(text, 0, text_len)) + modifier; - } while (length > max_length && text_len-- > 0); - - switch (justify) { - case RightJustify: - start_pos += max_length - length; - break; - - case CenterJustify: - start_pos += (max_length - length) / 2; - break; - - case LeftJustify: - default: - break; - } -} diff --git a/src/Toolbar.hh b/src/Toolbar.hh deleted file mode 100644 index 45464e77..00000000 --- a/src/Toolbar.hh +++ /dev/null @@ -1,197 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// Toolbar.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifndef __Toolbar_hh -#define __Toolbar_hh - -extern "C" { -#include -} - -#include "Screen.hh" -#include "Basemenu.hh" -#include "Timer.hh" - -// forward declaration -class Toolbar; - -class Toolbarmenu : public Basemenu { -private: - class Placementmenu : public Basemenu { - private: - Placementmenu(const Placementmenu&); - Placementmenu& operator=(const Placementmenu&); - Toolbar *toolbar; - - protected: - virtual void itemSelected(int button, unsigned int index); - virtual void setValues(void); - - public: - Placementmenu(Toolbarmenu *tm); - virtual void reconfigure(void); - }; - - Toolbar *toolbar; - Placementmenu *placementmenu; - - friend class Placementmenu; - friend class Toolbar; - - Toolbarmenu(const Toolbarmenu&); - Toolbarmenu& operator=(const Toolbarmenu&); - -protected: - virtual void itemSelected(int button, unsigned int index); - virtual void internal_hide(void); - virtual void setValues(void); - -public: - Toolbarmenu(Toolbar *tb); - ~Toolbarmenu(void); - - inline Basemenu *getPlacementmenu(void) { return placementmenu; } - - virtual void reconfigure(void); -}; - - -class Toolbar : public TimeoutHandler { -private: - bool on_top, editing, hidden, do_auto_hide; - unsigned int width_percent; - int placement; - std::string toolbarstr; - Display *display; - - struct ToolbarFrame { - unsigned long button_pixel, pbutton_pixel; - Pixmap base, label, wlabel, clk, button, pbutton; - Window window, workspace_label, window_label, clock, psbutton, nsbutton, - pwbutton, nwbutton; - - int x_hidden, y_hidden, hour, minute; - unsigned int window_label_w, workspace_label_w, clock_w, - button_w, bevel_w, label_h; - - Rect rect; - } frame; - - class HideHandler : public TimeoutHandler { - public: - Toolbar *toolbar; - - virtual void timeout(void); - } hide_handler; - - Blackbox *blackbox; - BScreen *screen; - Configuration *config; - BTimer *clock_timer, *hide_timer; - Toolbarmenu *toolbarmenu; - Strut strut; - - std::string new_workspace_name; - size_t new_name_pos; - - friend class HideHandler; - friend class Toolbarmenu; - friend class Toolbarmenu::Placementmenu; - - void drawArrow(Drawable surface, bool left) const; - void redrawPrevWorkspaceButton(bool pressed = False, bool redraw = False); - void redrawNextWorkspaceButton(bool pressed = False, bool redraw = False); - void redrawPrevWindowButton(bool preseed = False, bool redraw = False); - void redrawNextWindowButton(bool preseed = False, bool redraw = False); - - void updateStrut(void); - -#ifdef HAVE_STRFTIME - void checkClock(bool redraw = False); -#else // HAVE_STRFTIME - void checkClock(bool redraw = False, bool date = False); -#endif // HAVE_STRFTIME - - Toolbar(const Toolbar&); - Toolbar& operator=(const Toolbar&); - -public: - Toolbar(BScreen *scrn); - virtual ~Toolbar(void); - - inline Toolbarmenu *getMenu(void) { return toolbarmenu; } - - inline bool isEditing(void) const { return editing; } - inline bool isOnTop(void) const { return on_top; } - inline bool isHidden(void) const { return hidden; } - inline bool doAutoHide(void) const { return do_auto_hide; } - inline unsigned int getWidthPercent(void) const { return width_percent; } - inline int getPlacement(void) const { return placement; } - - void saveOnTop(bool); - void saveAutoHide(bool); - void saveWidthPercent(unsigned int); - void savePlacement(int); - - void save_rc(void); - void load_rc(void); - - void mapToolbar(void); - void unmapToolbar(void); - - inline Window getWindowID(void) const { return frame.window; } - - inline const Rect& getRect(void) const { return frame.rect; } - inline unsigned int getWidth(void) const { return frame.rect.width(); } - inline unsigned int getHeight(void) const { return frame.rect.height(); } - inline unsigned int getExposedHeight(void) const - { return (screen->doHideToolbar() ? 0 : - ((do_auto_hide) ? frame.bevel_w : - frame.rect.height())); } - inline int getX(void) const - { return ((hidden) ? frame.x_hidden : frame.rect.x()); } - inline int getY(void) const - { return ((hidden) ? frame.y_hidden : frame.rect.y()); } - - void buttonPressEvent(const XButtonEvent *be); - void buttonReleaseEvent(const XButtonEvent *re); - void enterNotifyEvent(const XCrossingEvent * /*unused*/); - void leaveNotifyEvent(const XCrossingEvent * /*unused*/); - void exposeEvent(const XExposeEvent *ee); - void keyPressEvent(const XKeyEvent *ke); - - void edit(void); - void reconfigure(void); - void toggleAutoHide(void); - - void redrawWindowLabel(bool redraw = False); - void redrawWorkspaceLabel(bool redraw = False); - - virtual void timeout(void); - - enum { TopLeft = 1, BottomLeft, TopCenter, - BottomCenter, TopRight, BottomRight }; -}; - - -#endif // __Toolbar_hh diff --git a/src/BaseDisplay.cc b/src/basedisplay.cc similarity index 99% rename from src/BaseDisplay.cc rename to src/basedisplay.cc index 51d79399..65574d65 100644 --- a/src/BaseDisplay.cc +++ b/src/basedisplay.cc @@ -85,11 +85,10 @@ extern "C" { #include using std::string; -#include "i18n.hh" -#include "BaseDisplay.hh" -#include "GCCache.hh" -#include "Timer.hh" -#include "Util.hh" +#include "basedisplay.hh" +#include "gccache.hh" +#include "timer.hh" +#include "util.hh" // X error handler to handle any and all X errors while the application is diff --git a/src/BaseDisplay.hh b/src/basedisplay.hh similarity index 99% rename from src/BaseDisplay.hh rename to src/basedisplay.hh index e4ef2387..c4286955 100644 --- a/src/BaseDisplay.hh +++ b/src/basedisplay.hh @@ -36,8 +36,8 @@ extern "C" { class BaseDisplay; class BGCCache; -#include "Timer.hh" -#include "Util.hh" +#include "timer.hh" +#include "util.hh" class ScreenInfo { private: diff --git a/src/blackbox.cc b/src/blackbox.cc index 82c8b1d1..63e0ef05 100644 --- a/src/blackbox.cc +++ b/src/blackbox.cc @@ -96,21 +96,20 @@ extern "C" { #include using std::string; -#include "i18n.hh" #include "blackbox.hh" -#include "Basemenu.hh" -#include "Clientmenu.hh" -#include "GCCache.hh" -#include "Image.hh" -#include "Rootmenu.hh" -#include "Screen.hh" -#include "Slit.hh" -#include "Toolbar.hh" -#include "Util.hh" -#include "Window.hh" -#include "Workspace.hh" -#include "Workspacemenu.hh" -#include "XAtom.hh" +#include "basemenu.hh" +#include "clientmenu.hh" +#include "gccache.hh" +#include "image.hh" +#include "rootmenu.hh" +#include "screen.hh" +#include "slit.hh" +#include "toolbar.hh" +#include "util.hh" +#include "window.hh" +#include "workspace.hh" +#include "workspacemenu.hh" +#include "xatom.hh" Blackbox *blackbox; diff --git a/src/blackbox.hh b/src/blackbox.hh index 1efec772..52e0e653 100644 --- a/src/blackbox.hh +++ b/src/blackbox.hh @@ -47,11 +47,10 @@ extern "C" { #include #include -#include "i18n.hh" -#include "BaseDisplay.hh" -#include "Configuration.hh" -#include "Timer.hh" -#include "XAtom.hh" +#include "basedisplay.hh" +#include "configuration.hh" +#include "timer.hh" +#include "xatom.hh" #define AttribShaded (1l << 0) #define AttribMaxHoriz (1l << 1) diff --git a/src/Color.cc b/src/color.cc similarity index 99% rename from src/Color.cc rename to src/color.cc index 85f3ec19..0aca132d 100644 --- a/src/Color.cc +++ b/src/color.cc @@ -31,8 +31,8 @@ extern "C" { #include -#include "Color.hh" -#include "BaseDisplay.hh" +#include "color.hh" +#include "basedisplay.hh" BColor::ColorCache BColor::colorcache; diff --git a/src/Color.hh b/src/color.hh similarity index 100% rename from src/Color.hh rename to src/color.hh diff --git a/src/Configuration.cc b/src/configuration.cc similarity index 99% rename from src/Configuration.cc rename to src/configuration.cc index 52e1b272..b7a7097e 100644 --- a/src/Configuration.cc +++ b/src/configuration.cc @@ -30,8 +30,8 @@ extern "C" { #endif // HAVE_STDLIB_H } -#include "Configuration.hh" -#include "Util.hh" +#include "configuration.hh" +#include "util.hh" #include diff --git a/src/Configuration.hh b/src/configuration.hh similarity index 100% rename from src/Configuration.hh rename to src/configuration.hh diff --git a/src/Font.cc b/src/font.cc similarity index 94% rename from src/Font.cc rename to src/font.cc index 4699350c..ba1ae1c1 100644 --- a/src/Font.cc +++ b/src/font.cc @@ -38,18 +38,17 @@ using std::string; using std::cerr; using std::endl; -#include "i18n.hh" -#include "Font.hh" -#include "Util.hh" -#include "GCCache.hh" -#include "Color.hh" +#include "font.hh" +#include "util.hh" +#include "gccache.hh" +#include "color.hh" string BFont::_fallback_font = "fixed"; #ifdef XFT BFont::BFont(Display *d, BScreen *screen, const string &family, int size, bool bold, bool italic, bool shadow, unsigned char offset, - int tint, bool antialias) : + unsigned char tint, bool antialias) : _display(d), _screen(screen), _family(family), @@ -265,22 +264,14 @@ void BFont::drawString(Drawable d, int x, int y, const BColor &color, _screen->getColormap()); assert(draw); - if (_shadow) { XftColor c; - if (_tint >= 0) { - c.color.red = 0; - c.color.green = 0; - c.color.blue = 0; - c.color.alpha = 0xffff * _tint/100; // transparent shadow - c.pixel = BlackPixel(_display, _screen->getScreenNumber()); - } else { - c.color.red = 0xffff * -_tint/100; - c.color.green = 0xffff * -_tint/100; - c.color.blue = 0xffff * -_tint/100; - c.color.alpha = 0xffff * -_tint/100; - c.pixel = WhitePixel(_display, _screen->getScreenNumber()); - } + c.color.red = 0; + c.color.green = 0; + c.color.blue = 0; + c.color.alpha = _tint | _tint << 8; // transparent shadow + c.pixel = BlackPixel(_display, _screen->getScreenNumber()); + #ifdef XFT_UTF8 XftDrawStringUtf8( #else diff --git a/src/Font.hh b/src/font.hh similarity index 97% rename from src/Font.hh rename to src/font.hh index 6f6431ef..f28a0ac5 100644 --- a/src/Font.hh +++ b/src/font.hh @@ -40,7 +40,7 @@ class BGCCache; class BGCCacheItem; class BColor; -#include "Screen.hh" +#include "screen.hh" class BFont { /* @@ -73,7 +73,7 @@ private: bool _antialias; bool _shadow; unsigned char _offset; - int _tint; + unsigned char _tint; XftFont *_xftfont; @@ -99,7 +99,7 @@ public: // loads an Xft font BFont(Display *d, BScreen *screen, const std::string &family, int size, bool bold, bool italic, bool shadow, unsigned char offset, - int tint, bool antialias = True); + unsigned char tint, bool antialias = True); #endif // loads a standard X font BFont(Display *d, BScreen *screen, const std::string &xlfd); diff --git a/src/GCCache.cc b/src/gccache.cc similarity index 98% rename from src/GCCache.cc rename to src/gccache.cc index 829d130f..76bdfc37 100644 --- a/src/GCCache.cc +++ b/src/gccache.cc @@ -29,10 +29,10 @@ extern "C" { #include } -#include "GCCache.hh" -#include "BaseDisplay.hh" -#include "Color.hh" -#include "Util.hh" +#include "gccache.hh" +#include "basedisplay.hh" +#include "color.hh" +#include "util.hh" BGCCacheContext::~BGCCacheContext(void) { diff --git a/src/GCCache.hh b/src/gccache.hh similarity index 98% rename from src/GCCache.hh rename to src/gccache.hh index 614eac1d..b81cdfd9 100644 --- a/src/GCCache.hh +++ b/src/gccache.hh @@ -28,8 +28,8 @@ extern "C" { #include } -#include "BaseDisplay.hh" -#include "Color.hh" +#include "basedisplay.hh" +#include "color.hh" class BGCCacheItem; diff --git a/src/i18n.cc b/src/i18n.cc deleted file mode 100644 index 0eb0a911..00000000 --- a/src/i18n.cc +++ /dev/null @@ -1,119 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- -// i18n.cc for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifdef HAVE_CONFIG_H -# include "../config.h" -#endif // HAVE_CONFIG_H - -extern "C" { -#include - -#ifdef HAVE_STDLIB_H -# include -#endif // HAVE_STDLIB_H - -#ifdef HAVE_STRING_H -# include -#endif // HAVE_STRING_H - -#ifdef HAVE_STDIO_H -# include -#endif // HAVE_STDIO_H - -#ifdef HAVE_LOCALE_H -# include -#endif // HAVE_LOCALE_H -} - -#include -using std::string; - -#include "i18n.hh" - - -// the rest of bb source uses True and False from X, so we continue that -#define True true -#define False false - -I18n::I18n(void) { - mb = False; -#ifdef HAVE_SETLOCALE - locale = setlocale(LC_ALL, ""); - if (! locale) { - fprintf(stderr, "failed to set locale, reverting to \"C\"\n"); -#endif // HAVE_SETLOCALE - locale = "C"; -#ifdef HAVE_SETLOCALE - } else { - // MB_CUR_MAX returns the size of a char in the current locale - if (MB_CUR_MAX > 1) - mb = True; - // truncate any encoding off the end of the locale - char *l = strchr(locale, '@'); - if (l) *l = '\0'; - l = strchr(locale, '.'); - if (l) *l = '\0'; - } - -#ifdef HAVE_CATOPEN - catalog_fd = (nl_catd) -1; -#endif -#endif // HAVE_SETLOCALE -} - - -I18n::~I18n(void) { -#if defined(NLS) && defined(HAVE_CATCLOSE) - if (catalog_fd != (nl_catd) -1) - catclose(catalog_fd); -#endif // HAVE_CATCLOSE -} - - -void I18n::openCatalog(const char *catalog) { -#if defined(NLS) && defined(HAVE_CATOPEN) - string catalog_filename = LOCALEPATH; - catalog_filename += '/'; - catalog_filename += locale; - catalog_filename += '/'; - catalog_filename += catalog; - -# ifdef MCLoadBySet - catalog_fd = catopen(catalog_filename.c_str(), MCLoadBySet); -# else // !MCLoadBySet - catalog_fd = catopen(catalog_filename.c_str(), NL_CAT_LOCALE); -# endif // MCLoadBySet - - if (catalog_fd == (nl_catd) -1) - fprintf(stderr, "failed to open catalog, using default messages\n"); -#endif // HAVE_CATOPEN -} - -const char* I18n::operator()(int set, int msg, const char *msgString) const { -#if defined(NLS) && defined(HAVE_CATGETS) - if (catalog_fd != (nl_catd) -1) - return catgets(catalog_fd, set, msg, msgString); - else -#endif - return msgString; -} diff --git a/src/i18n.hh b/src/i18n.hh deleted file mode 100644 index b86d9d80..00000000 --- a/src/i18n.hh +++ /dev/null @@ -1,63 +0,0 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- -// i18n.hh for Blackbox - an X11 Window manager -// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry -// 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, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// 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. - -#ifndef __i18n_h -#define __i18n_h - -// always include this just for the #defines -// this keeps the calls to i18n->getMessage clean, otherwise we have to -// add ifdefs to every call to getMessage -#include "../nls/blackbox-nls.hh" - -extern "C" { -#ifdef HAVE_LOCALE_H -# include -#endif // HAVE_LOCALE_H - -#ifdef HAVE_NL_TYPES_H -# include -#endif // HAVE_NL_TYPES_H -} - - -class I18n { -private: - char *locale; - bool mb; -#ifdef HAVE_NL_TYPES_H - nl_catd catalog_fd; -#endif - -public: - I18n(void); - ~I18n(void); - - inline bool multibyte(void) const { return mb; } - - const char* operator()(int set, int msg, const char *msgString) const; - void openCatalog(const char *catalog); -}; - -extern I18n i18n; - -#endif // __i18n_h diff --git a/src/Image.cc b/src/image.cc similarity index 99% rename from src/Image.cc rename to src/image.cc index 2094c003..11fcd1d7 100644 --- a/src/Image.cc +++ b/src/image.cc @@ -34,11 +34,10 @@ using std::max; using std::min; #include "blackbox.hh" -#include "i18n.hh" -#include "BaseDisplay.hh" -#include "GCCache.hh" -#include "Image.hh" -#include "Texture.hh" +#include "basedisplay.hh" +#include "gccache.hh" +#include "image.hh" +#include "texture.hh" BImage::BImage(BImageControl *c, int w, int h) { diff --git a/src/Image.hh b/src/image.hh similarity index 98% rename from src/Image.hh rename to src/image.hh index 94cb3c60..3482b065 100644 --- a/src/Image.hh +++ b/src/image.hh @@ -31,9 +31,9 @@ extern "C" { #include -#include "Timer.hh" -#include "BaseDisplay.hh" -#include "Color.hh" +#include "timer.hh" +#include "basedisplay.hh" +#include "color.hh" class BImageControl; class BTexture; diff --git a/src/ImageControl.cc b/src/imagecontrol.cc similarity index 99% rename from src/ImageControl.cc rename to src/imagecontrol.cc index c93a40f9..159e02fd 100644 --- a/src/ImageControl.cc +++ b/src/imagecontrol.cc @@ -40,11 +40,10 @@ extern "C" { #include #include "blackbox.hh" -#include "i18n.hh" -#include "BaseDisplay.hh" -#include "Color.hh" -#include "Image.hh" -#include "Texture.hh" +#include "basedisplay.hh" +#include "color.hh" +#include "image.hh" +#include "texture.hh" static unsigned long bsqrt(unsigned long x) { if (x <= 0) return 0; diff --git a/src/main.cc b/src/main.cc index c16fba2d..f672eb23 100644 --- a/src/main.cc +++ b/src/main.cc @@ -52,7 +52,6 @@ extern "C" { #include using std::string; -#include "i18n.hh" #include "blackbox.hh" diff --git a/src/Screen.cc b/src/screen.cc similarity index 99% rename from src/Screen.cc rename to src/screen.cc index eb933206..6fbfbdcc 100644 --- a/src/Screen.cc +++ b/src/screen.cc @@ -77,21 +77,21 @@ using std::string; #include "i18n.hh" #include "blackbox.hh" -#include "Clientmenu.hh" -#include "Font.hh" -#include "GCCache.hh" -#include "Iconmenu.hh" -#include "Image.hh" -#include "Screen.hh" -#include "Slit.hh" -#include "Rootmenu.hh" -#include "Toolbar.hh" -#include "Util.hh" -#include "Window.hh" -#include "Workspace.hh" -#include "Workspacemenu.hh" -#include "Util.hh" -#include "XAtom.hh" +#include "clientmenu.hh" +#include "font.hh" +#include "gccache.hh" +#include "iconmenu.hh" +#include "image.hh" +#include "screen.hh" +#include "slit.hh" +#include "rootmenu.hh" +#include "toolbar.hh" +#include "util.hh" +#include "window.hh" +#include "workspace.hh" +#include "workspacemenu.hh" +#include "util.hh" +#include "xatom.hh" #ifndef FONT_ELEMENT_SIZE #define FONT_ELEMENT_SIZE 50 @@ -2314,8 +2314,7 @@ bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { for (; it != end; ++it) { const string& fname = *it; - //ignore backups and dot files - if (fname[fname.size()-1] == '~' || fname[0] == '.') + if (fname[fname.size()-1] == '~') continue; string style = stylesdir; @@ -2751,13 +2750,11 @@ BFont *BScreen::readDatabaseFont(const string &rbasename, offset = 1; } - int tint = 25; + unsigned char tint = 0x40; if (style.getValue(rbasename + "xft.shadow.tint", s)) { tint = atoi(s.c_str()); } - if (tint > 100) tint = 100; - if (tint < -100) tint = -100; BFont *b = new BFont(blackbox->getXDisplay(), this, family, i, bold, italic, dropShadow && resource.shadow_fonts, offset, diff --git a/src/Screen.hh b/src/screen.hh similarity index 98% rename from src/Screen.hh rename to src/screen.hh index c6044812..53fdffdd 100644 --- a/src/Screen.hh +++ b/src/screen.hh @@ -42,16 +42,16 @@ extern "C" { #include #include -#include "Color.hh" -#include "Texture.hh" -#include "Image.hh" -#include "Configmenu.hh" -#include "Iconmenu.hh" -#include "Netizen.hh" -#include "Rootmenu.hh" -#include "Timer.hh" -#include "Workspace.hh" -#include "Workspacemenu.hh" +#include "color.hh" +#include "texture.hh" +#include "image.hh" +#include "configmenu.hh" +#include "iconmenu.hh" +#include "netizen.hh" +#include "rootmenu.hh" +#include "timer.hh" +#include "workspace.hh" +#include "workspacemenu.hh" #include "blackbox.hh" class Slit; // forward reference diff --git a/src/Texture.cc b/src/texture.cc similarity index 98% rename from src/Texture.cc rename to src/texture.cc index 75283a91..3185b2c9 100644 --- a/src/Texture.cc +++ b/src/texture.cc @@ -34,10 +34,10 @@ extern "C" { #include -#include "Texture.hh" -#include "BaseDisplay.hh" -#include "Image.hh" -#include "Screen.hh" +#include "texture.hh" +#include "basedisplay.hh" +#include "image.hh" +#include "screen.hh" #include "blackbox.hh" using std::string; diff --git a/src/Texture.hh b/src/texture.hh similarity index 99% rename from src/Texture.hh rename to src/texture.hh index fa6c6390..4133e485 100644 --- a/src/Texture.hh +++ b/src/texture.hh @@ -24,8 +24,8 @@ #ifndef TEXTURE_HH #define TEXTURE_HH -#include "Color.hh" -#include "Util.hh" +#include "color.hh" +#include "util.hh" class BImageControl; #include diff --git a/src/Timer.cc b/src/timer.cc similarity index 97% rename from src/Timer.cc rename to src/timer.cc index 99f05ba9..8bf91250 100644 --- a/src/Timer.cc +++ b/src/timer.cc @@ -25,9 +25,9 @@ # include "../config.h" #endif // HAVE_CONFIG_H -#include "BaseDisplay.hh" -#include "Timer.hh" -#include "Util.hh" +#include "basedisplay.hh" +#include "timer.hh" +#include "util.hh" BTimer::BTimer(TimerQueueManager *m, TimeoutHandler *h) { manager = m; diff --git a/src/Timer.hh b/src/timer.hh similarity index 100% rename from src/Timer.hh rename to src/timer.hh diff --git a/src/Util.cc b/src/util.cc similarity index 99% rename from src/Util.cc rename to src/util.cc index 90135447..bd5703bc 100644 --- a/src/Util.cc +++ b/src/util.cc @@ -56,7 +56,7 @@ extern "C" { #include -#include "Util.hh" +#include "util.hh" using std::string; diff --git a/src/Util.hh b/src/util.hh similarity index 100% rename from src/Util.hh rename to src/util.hh diff --git a/src/Window.cc b/src/window.cc similarity index 99% rename from src/Window.cc rename to src/window.cc index 680943e2..206e66c6 100644 --- a/src/Window.cc +++ b/src/window.cc @@ -44,20 +44,19 @@ extern "C" { #endif // HAVE_STDLIB_H } -#include "i18n.hh" #include "blackbox.hh" -#include "Clientmenu.hh" -#include "Font.hh" -#include "GCCache.hh" -#include "Iconmenu.hh" -#include "Image.hh" -#include "Screen.hh" -#include "Toolbar.hh" -#include "Util.hh" -#include "Window.hh" -#include "Windowmenu.hh" -#include "Workspace.hh" -#include "Slit.hh" +#include "clientmenu.hh" +#include "font.hh" +#include "gccache.hh" +#include "iconmenu.hh" +#include "image.hh" +#include "screen.hh" +#include "toolbar.hh" +#include "util.hh" +#include "window.hh" +#include "windowmenu.hh" +#include "workspace.hh" +#include "slit.hh" using std::string; using std::abs; diff --git a/src/Window.hh b/src/window.hh similarity index 99% rename from src/Window.hh rename to src/window.hh index b923c4bf..e8249b08 100644 --- a/src/Window.hh +++ b/src/window.hh @@ -34,10 +34,10 @@ extern "C" { #include -#include "BaseDisplay.hh" -#include "Timer.hh" -#include "Util.hh" -#include "Windowmenu.hh" +#include "basedisplay.hh" +#include "timer.hh" +#include "util.hh" +#include "windowmenu.hh" #define MwmHintsFunctions (1l << 0) #define MwmHintsDecorations (1l << 1) diff --git a/src/Workspace.cc b/src/workspace.cc similarity index 99% rename from src/Workspace.cc rename to src/workspace.cc index 67e19110..8c44adab 100644 --- a/src/Workspace.cc +++ b/src/workspace.cc @@ -45,18 +45,17 @@ extern "C" { using std::string; -#include "i18n.hh" #include "blackbox.hh" -#include "Clientmenu.hh" -#include "Font.hh" -#include "Netizen.hh" -#include "Screen.hh" -#include "Toolbar.hh" -#include "Util.hh" -#include "Window.hh" -#include "Workspace.hh" -#include "Windowmenu.hh" -#include "XAtom.hh" +#include "clientmenu.hh" +#include "font.hh" +#include "netizen.hh" +#include "screen.hh" +#include "toolbar.hh" +#include "util.hh" +#include "window.hh" +#include "workspace.hh" +#include "windowmenu.hh" +#include "xatom.hh" Workspace::Workspace(BScreen *scrn, unsigned int i) { diff --git a/src/Workspace.hh b/src/workspace.hh similarity index 100% rename from src/Workspace.hh rename to src/workspace.hh diff --git a/src/XAtom.cc b/src/xatom.cc similarity index 99% rename from src/XAtom.cc rename to src/xatom.cc index bfd58483..59e8b164 100644 --- a/src/XAtom.cc +++ b/src/xatom.cc @@ -23,9 +23,9 @@ #include -#include "XAtom.hh" -#include "Screen.hh" -#include "Util.hh" +#include "xatom.hh" +#include "screen.hh" +#include "util.hh" XAtom::XAtom(Display *d) { _display = d; diff --git a/src/XAtom.hh b/src/xatom.hh similarity index 100% rename from src/XAtom.hh rename to src/xatom.hh -- 2.39.2