2002-05-25 00:29:44 +00:00
|
|
|
// -*- 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 <shaleh@debian.org>
|
2002-04-11 03:20:38 +00:00
|
|
|
// 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
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
extern "C" {
|
2002-04-11 03:20:38 +00:00
|
|
|
#include <X11/keysym.h>
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "i18n.hh"
|
|
|
|
#include "blackbox.hh"
|
|
|
|
#include "Image.hh"
|
|
|
|
#include "Screen.hh"
|
|
|
|
#include "Slit.hh"
|
|
|
|
#include "Toolbar.hh"
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Slit::Slit(BScreen *scr) {
|
|
|
|
screen = scr;
|
|
|
|
blackbox = screen->getBlackbox();
|
2002-05-26 20:25:38 +00:00
|
|
|
slitstr = (std::string)"session.screen" + itostring(screen->getScreenNumber())
|
|
|
|
+ ".slit.";
|
|
|
|
config = blackbox->getConfig();
|
2002-04-16 23:50:53 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
load_rc();
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
display = screen->getBaseDisplay()->getXDisplay();
|
2002-04-11 03:20:38 +00:00
|
|
|
frame.window = frame.pixmap = None;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
timer = new BTimer(blackbox, this);
|
|
|
|
timer->setTimeout(blackbox->getAutoRaiseDelay());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
slitmenu = new Slitmenu(this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
2002-05-25 00:29:44 +00:00
|
|
|
CWColormap | CWOverrideRedirect | CWEventMask;
|
2002-04-11 03:20:38 +00:00
|
|
|
attrib.background_pixmap = None;
|
|
|
|
attrib.background_pixel = attrib.border_pixel =
|
2002-05-25 00:29:44 +00:00
|
|
|
screen->getBorderColor()->pixel();
|
|
|
|
attrib.colormap = screen->getColormap();
|
2002-04-11 03:20:38 +00:00
|
|
|
attrib.override_redirect = True;
|
|
|
|
attrib.event_mask = SubstructureRedirectMask | ButtonPressMask |
|
2002-05-25 00:29:44 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setSize(1, 1);
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
frame.window =
|
2002-05-25 00:29:44 +00:00
|
|
|
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);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Slit::~Slit(void) {
|
2002-04-11 03:20:38 +00:00
|
|
|
delete timer;
|
|
|
|
|
|
|
|
delete slitmenu;
|
|
|
|
|
2002-07-07 10:27:06 +00:00
|
|
|
screen->removeStrut(&strut);
|
|
|
|
screen->updateAvailableArea();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
screen->getImageControl()->removeImage(frame.pixmap);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
blackbox->removeSlitSearch(frame.window);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XDestroyWindow(display, frame.window);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Slit::addClient(Window w) {
|
2002-05-25 00:29:44 +00:00
|
|
|
if (! blackbox->validateWindow(w))
|
|
|
|
return;
|
|
|
|
|
|
|
|
SlitClient *client = new SlitClient;
|
|
|
|
client->client_window = w;
|
|
|
|
|
|
|
|
XWMHints *wmhints = XGetWMHints(display, w);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
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;
|
2002-04-11 03:20:38 +00:00
|
|
|
} else {
|
|
|
|
client->icon_window = None;
|
|
|
|
client->window = client->client_window;
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XFree(wmhints);
|
|
|
|
} else {
|
|
|
|
client->icon_window = None;
|
|
|
|
client->window = client->client_window;
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XWindowAttributes attrib;
|
|
|
|
if (XGetWindowAttributes(display, client->window, &attrib)) {
|
|
|
|
client->rect.setSize(attrib.width, attrib.height);
|
|
|
|
} else {
|
|
|
|
client->rect.setSize(64, 64);
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XSetWindowBorderWidth(display, client->window, 0);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
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);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XUngrabServer(display);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
clientList.push_back(client);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
blackbox->saveSlitSearch(client->client_window, this);
|
|
|
|
blackbox->saveSlitSearch(client->icon_window, this);
|
|
|
|
reconfigure();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slit::removeClient(SlitClient *client, bool remap) {
|
|
|
|
blackbox->removeSlitSearch(client->client_window);
|
|
|
|
blackbox->removeSlitSearch(client->icon_window);
|
2002-04-27 18:53:59 +00:00
|
|
|
clientList.remove(client);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
screen->removeNetizen(client->window);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (remap && blackbox->validateWindow(client->window)) {
|
|
|
|
XGrabServer(display);
|
2002-04-11 03:20:38 +00:00
|
|
|
XSelectInput(display, frame.window, NoEventMask);
|
|
|
|
XSelectInput(display, client->window, NoEventMask);
|
2002-05-25 00:29:44 +00:00
|
|
|
XReparentWindow(display, client->window, screen->getRootWindow(),
|
|
|
|
client->rect.x(), client->rect.y());
|
2002-04-11 03:20:38 +00:00
|
|
|
XChangeSaveSet(display, client->window, SetModeDelete);
|
|
|
|
XSelectInput(display, frame.window, SubstructureRedirectMask |
|
2002-05-16 22:35:59 +00:00
|
|
|
ButtonPressMask | EnterWindowMask | LeaveWindowMask);
|
2002-05-25 00:29:44 +00:00
|
|
|
XUngrabServer(display);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
delete client;
|
|
|
|
client = (SlitClient *) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
struct SlitClientMatch {
|
|
|
|
Window window;
|
|
|
|
SlitClientMatch(Window w): window(w) {}
|
|
|
|
inline bool operator()(const Slit::SlitClient* client) const {
|
|
|
|
return (client->window == window);
|
|
|
|
}
|
|
|
|
};
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slit::removeClient(Window w, bool remap) {
|
|
|
|
SlitClientList::iterator it = clientList.begin();
|
|
|
|
const SlitClientList::iterator end = clientList.end();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
it = std::find_if(it, end, SlitClientMatch(w));
|
|
|
|
if (it != end) {
|
|
|
|
removeClient(*it, remap);
|
2002-04-27 18:53:59 +00:00
|
|
|
reconfigure();
|
2002-04-16 23:50:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
void Slit::reconfigure(void) {
|
2002-05-25 00:29:44 +00:00
|
|
|
SlitClientList::iterator it = clientList.begin();
|
|
|
|
const SlitClientList::iterator end = clientList.end();
|
|
|
|
SlitClient *client;
|
2002-05-16 09:24:40 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
unsigned int width = 0, height = 0;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
switch (direction) {
|
2002-04-11 03:20:38 +00:00
|
|
|
case Vertical:
|
2002-05-25 00:29:44 +00:00
|
|
|
for (; it != end; ++it) {
|
|
|
|
client = *it;
|
|
|
|
height += client->rect.height() + screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (width < client->rect.width())
|
|
|
|
width = client->rect.width();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (width < 1)
|
|
|
|
width = 1;
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-05-25 00:29:44 +00:00
|
|
|
width += (screen->getBevelWidth() * 2);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (height < 1)
|
|
|
|
height = 1;
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-05-25 00:29:44 +00:00
|
|
|
height += screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Horizontal:
|
2002-05-25 00:29:44 +00:00
|
|
|
for (; it != end; ++it) {
|
|
|
|
client = *it;
|
|
|
|
width += client->rect.width() + screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (height < client->rect.height())
|
|
|
|
height = client->rect.height();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (width < 1)
|
|
|
|
width = 1;
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-05-25 00:29:44 +00:00
|
|
|
width += screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (height < 1)
|
|
|
|
height = 1;
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-05-25 00:29:44 +00:00
|
|
|
height += (screen->getBevelWidth() * 2);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setSize(width, height);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
reposition();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XSetWindowBorderWidth(display ,frame.window, screen->getBorderWidth());
|
2002-04-11 03:20:38 +00:00
|
|
|
XSetWindowBorder(display, frame.window,
|
2002-05-25 00:29:44 +00:00
|
|
|
screen->getBorderColor()->pixel());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (clientList.empty())
|
2002-04-11 03:20:38 +00:00
|
|
|
XUnmapWindow(display, frame.window);
|
|
|
|
else
|
|
|
|
XMapWindow(display, frame.window);
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
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
|
2002-04-11 03:20:38 +00:00
|
|
|
XSetWindowBackgroundPixmap(display, frame.window, frame.pixmap);
|
2002-05-25 00:29:44 +00:00
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
XClearWindow(display, frame.window);
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
it = clientList.begin();
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
int x, y;
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
switch (direction) {
|
2002-04-11 03:20:38 +00:00
|
|
|
case Vertical:
|
|
|
|
x = 0;
|
2002-05-25 00:29:44 +00:00
|
|
|
y = screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
for (; it != end; ++it) {
|
|
|
|
client = *it;
|
|
|
|
x = (frame.rect.width() - client->rect.width()) / 2;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XMoveResizeWindow(display, client->window, x, y,
|
|
|
|
client->rect.width(), client->rect.height());
|
|
|
|
XMapWindow(display, client->window);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
// for ICCCM compliance
|
2002-05-25 00:29:44 +00:00
|
|
|
client->rect.setPos(x, y);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XEvent event;
|
|
|
|
event.type = ConfigureNotify;
|
|
|
|
|
|
|
|
event.xconfigure.display = display;
|
2002-05-25 00:29:44 +00:00
|
|
|
event.xconfigure.event = client->window;
|
|
|
|
event.xconfigure.window = client->window;
|
2002-04-11 03:20:38 +00:00
|
|
|
event.xconfigure.x = x;
|
|
|
|
event.xconfigure.y = y;
|
2002-05-25 00:29:44 +00:00
|
|
|
event.xconfigure.width = client->rect.width();
|
|
|
|
event.xconfigure.height = client->rect.height();
|
2002-04-11 03:20:38 +00:00
|
|
|
event.xconfigure.border_width = 0;
|
|
|
|
event.xconfigure.above = frame.window;
|
|
|
|
event.xconfigure.override_redirect = False;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XSendEvent(display, client->window, False, StructureNotifyMask, &event);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
y += client->rect.height() + screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Horizontal:
|
2002-05-25 00:29:44 +00:00
|
|
|
x = screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
y = 0;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
for (; it != end; ++it) {
|
|
|
|
client = *it;
|
|
|
|
y = (frame.rect.height() - client->rect.height()) / 2;
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XMoveResizeWindow(display, client->window, x, y,
|
|
|
|
client->rect.width(), client->rect.height());
|
|
|
|
XMapWindow(display, client->window);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
// for ICCCM compliance
|
2002-05-25 00:29:44 +00:00
|
|
|
client->rect.setPos(x, y);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
XEvent event;
|
|
|
|
event.type = ConfigureNotify;
|
|
|
|
|
|
|
|
event.xconfigure.display = display;
|
2002-05-25 00:29:44 +00:00
|
|
|
event.xconfigure.event = client->window;
|
|
|
|
event.xconfigure.window = client->window;
|
2002-04-11 03:20:38 +00:00
|
|
|
event.xconfigure.x = x;
|
|
|
|
event.xconfigure.y = y;
|
2002-05-25 00:29:44 +00:00
|
|
|
event.xconfigure.width = client->rect.width();
|
|
|
|
event.xconfigure.height = client->rect.height();
|
2002-04-11 03:20:38 +00:00
|
|
|
event.xconfigure.border_width = 0;
|
|
|
|
event.xconfigure.above = frame.window;
|
|
|
|
event.xconfigure.override_redirect = False;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
XSendEvent(display, client->window, False, StructureNotifyMask, &event);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
x += client->rect.width() + screen->getBevelWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
slitmenu->reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slit::updateStrut(void) {
|
|
|
|
strut.top = strut.bottom = strut.left = strut.right = 0;
|
|
|
|
|
|
|
|
if (! clientList.empty()) {
|
2002-06-21 01:06:29 +00:00
|
|
|
// 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;
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
switch (direction) {
|
2002-05-25 00:29:44 +00:00
|
|
|
case Vertical:
|
2002-05-26 20:25:38 +00:00
|
|
|
switch (placement) {
|
2002-05-25 00:29:44 +00:00
|
|
|
case TopCenter:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.top = getExposedHeight() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
case BottomCenter:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.bottom = getExposedHeight() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
case TopLeft:
|
|
|
|
case CenterLeft:
|
|
|
|
case BottomLeft:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.left = getExposedWidth() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
case TopRight:
|
|
|
|
case CenterRight:
|
|
|
|
case BottomRight:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.right = getExposedWidth() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Horizontal:
|
2002-05-26 20:25:38 +00:00
|
|
|
switch (placement) {
|
2002-05-25 00:29:44 +00:00
|
|
|
case TopCenter:
|
|
|
|
case TopLeft:
|
|
|
|
case TopRight:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.top = getExposedHeight() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
case BottomCenter:
|
|
|
|
case BottomLeft:
|
|
|
|
case BottomRight:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.bottom = getExposedHeight() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
case CenterLeft:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.left = getExposedWidth() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
case CenterRight:
|
2002-06-21 01:06:29 +00:00
|
|
|
strut.right = getExposedWidth() + border_width;
|
2002-05-25 00:29:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update area with new Strut info
|
|
|
|
screen->updateAvailableArea();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
void Slit::reposition(void) {
|
|
|
|
// place the slit in the appropriate place
|
2002-05-26 20:25:38 +00:00
|
|
|
switch (placement) {
|
2002-04-11 03:20:38 +00:00
|
|
|
case TopLeft:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos(0, 0);
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
if (direction == Vertical) {
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth()
|
|
|
|
- frame.rect.width();
|
|
|
|
frame.y_hidden = 0;
|
2002-04-11 03:20:38 +00:00
|
|
|
} else {
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.x_hidden = 0;
|
|
|
|
frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth()
|
|
|
|
- frame.rect.height();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CenterLeft:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos(0, (screen->getHeight() - frame.rect.height()) / 2);
|
|
|
|
|
|
|
|
frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth()
|
|
|
|
- frame.rect.width();
|
|
|
|
frame.y_hidden = frame.rect.y();
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BottomLeft:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos(0, (screen->getHeight() - frame.rect.height()
|
|
|
|
- (screen->getBorderWidth() * 2)));
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
if (direction == Vertical) {
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth()
|
|
|
|
- frame.rect.width();
|
|
|
|
frame.y_hidden = frame.rect.y();
|
|
|
|
} else {
|
|
|
|
frame.x_hidden = 0;
|
|
|
|
frame.y_hidden = screen->getHeight() - screen->getBevelWidth()
|
|
|
|
- screen->getBorderWidth();
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TopCenter:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos((screen->getWidth() - frame.rect.width()) / 2, 0);
|
|
|
|
|
|
|
|
frame.x_hidden = frame.rect.x();
|
|
|
|
frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth()
|
|
|
|
- frame.rect.height();
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BottomCenter:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos((screen->getWidth() - frame.rect.width()) / 2,
|
|
|
|
(screen->getHeight() - frame.rect.height()
|
|
|
|
- (screen->getBorderWidth() * 2)));
|
|
|
|
frame.x_hidden = frame.rect.x();
|
|
|
|
frame.y_hidden = screen->getHeight() - screen->getBevelWidth()
|
|
|
|
- screen->getBorderWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TopRight:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos((screen->getWidth() - frame.rect.width()
|
|
|
|
- (screen->getBorderWidth() * 2)), 0);
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
if (direction == Vertical) {
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.x_hidden = screen->getWidth() - screen->getBevelWidth()
|
|
|
|
- screen->getBorderWidth();
|
|
|
|
frame.y_hidden = 0;
|
|
|
|
} else {
|
|
|
|
frame.x_hidden = frame.rect.x();
|
|
|
|
frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth()
|
|
|
|
- frame.rect.height();
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CenterRight:
|
|
|
|
default:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos((screen->getWidth() - frame.rect.width()
|
|
|
|
- (screen->getBorderWidth() * 2)),
|
|
|
|
(screen->getHeight() - frame.rect.height()) / 2);
|
|
|
|
|
|
|
|
frame.x_hidden = screen->getWidth() - screen->getBevelWidth()
|
|
|
|
- screen->getBorderWidth();
|
|
|
|
frame.y_hidden = frame.rect.y();
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BottomRight:
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setPos((screen->getWidth() - frame.rect.width()
|
|
|
|
- (screen->getBorderWidth() * 2)),
|
|
|
|
(screen->getHeight() - frame.rect.height()
|
|
|
|
- (screen->getBorderWidth() * 2)));
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
if (direction == Vertical) {
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.x_hidden = screen->getWidth() - screen->getBevelWidth()
|
|
|
|
- screen->getBorderWidth();
|
|
|
|
frame.y_hidden = frame.rect.y();
|
|
|
|
} else {
|
|
|
|
frame.x_hidden = frame.rect.x();
|
|
|
|
frame.y_hidden = screen->getHeight() - screen->getBevelWidth()
|
|
|
|
- screen->getBorderWidth();
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
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 (slit_rect.intersects(tbar_rect)) {
|
|
|
|
Toolbar *tbar = screen->getToolbar();
|
|
|
|
frame.y_hidden = frame.rect.y();
|
|
|
|
|
|
|
|
int delta = tbar->getExposedHeight() + (screen->getBorderWidth() * 2);
|
|
|
|
if (frame.rect.bottom() <= tbar_rect.bottom()) {
|
|
|
|
delta = -delta;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.rect.setY(frame.rect.y() + delta);
|
2002-05-26 20:25:38 +00:00
|
|
|
if (direction == Vertical)
|
2002-05-25 00:29:44 +00:00
|
|
|
frame.y_hidden += delta;
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
updateStrut();
|
|
|
|
|
|
|
|
if (hidden)
|
|
|
|
XMoveResizeWindow(display, frame.window, frame.x_hidden,
|
|
|
|
frame.y_hidden, frame.rect.width(), frame.rect.height());
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-05-25 00:29:44 +00:00
|
|
|
XMoveResizeWindow(display, frame.window, frame.rect.x(), frame.rect.y(),
|
|
|
|
frame.rect.width(), frame.rect.height());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Slit::shutdown(void) {
|
2002-05-25 00:29:44 +00:00
|
|
|
while (! clientList.empty())
|
2002-04-27 18:53:59 +00:00
|
|
|
removeClient(clientList.front());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
void Slit::buttonPressEvent(const XButtonEvent *e) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (e->window != frame.window) return;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (e->button == Button1 && (! on_top)) {
|
2002-04-11 03:20:38 +00:00
|
|
|
Window w[1] = { frame.window };
|
2002-05-25 00:29:44 +00:00
|
|
|
screen->raiseWindows(w, 1);
|
|
|
|
} else if (e->button == Button2 && (! on_top)) {
|
2002-04-11 03:20:38 +00:00
|
|
|
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;
|
2002-05-25 00:29:44 +00:00
|
|
|
else if (x + slitmenu->getWidth() > screen->getWidth())
|
|
|
|
x = screen->getWidth() - slitmenu->getWidth();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
2002-05-25 00:29:44 +00:00
|
|
|
else if (y + slitmenu->getHeight() > screen->getHeight())
|
|
|
|
y = screen->getHeight() - slitmenu->getHeight();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
slitmenu->move(x, y);
|
|
|
|
slitmenu->show();
|
|
|
|
} else {
|
|
|
|
slitmenu->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
void Slit::enterNotifyEvent(const XCrossingEvent *) {
|
2002-05-25 00:29:44 +00:00
|
|
|
if (! do_auto_hide)
|
2002-04-11 03:20:38 +00:00
|
|
|
return;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (hidden) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (! timer->isTiming()) timer->start();
|
|
|
|
} else {
|
|
|
|
if (timer->isTiming()) timer->stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
void Slit::leaveNotifyEvent(const XCrossingEvent *) {
|
2002-05-25 00:29:44 +00:00
|
|
|
if (! do_auto_hide)
|
2002-04-11 03:20:38 +00:00
|
|
|
return;
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (hidden) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (timer->isTiming()) timer->stop();
|
|
|
|
} else if (! slitmenu->isVisible()) {
|
2002-05-25 00:29:44 +00:00
|
|
|
if (! timer->isTiming()) timer->start();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
void Slit::configureRequestEvent(const XConfigureRequestEvent *e) {
|
2002-05-25 00:29:44 +00:00
|
|
|
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<signed>(client->rect.width()) != e->width ||
|
|
|
|
static_cast<signed>(client->rect.height()) != e->height)) {
|
|
|
|
client->rect.setSize(e->width, e->height);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-27 18:53:59 +00:00
|
|
|
reconfigure();
|
2002-05-25 00:29:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Slit::timeout(void) {
|
2002-05-25 00:29:44 +00:00
|
|
|
hidden = ! hidden;
|
|
|
|
if (hidden)
|
|
|
|
XMoveWindow(display, frame.window, frame.x_hidden, frame.y_hidden);
|
2002-04-11 03:20:38 +00:00
|
|
|
else
|
2002-05-25 00:29:44 +00:00
|
|
|
XMoveWindow(display, frame.window, frame.rect.x(), frame.rect.y());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slit::toggleAutoHide(void) {
|
2002-05-26 20:25:38 +00:00
|
|
|
saveAutoHide(do_auto_hide ? False : True);
|
2002-05-25 00:29:44 +00:00
|
|
|
|
|
|
|
updateStrut();
|
|
|
|
|
|
|
|
if (do_auto_hide == False && hidden) {
|
|
|
|
// force the slit to be visible
|
|
|
|
if (timer->isTiming()) timer->stop();
|
|
|
|
timeout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-05 01:24:32 +00:00
|
|
|
void Slit::unmapNotifyEvent(const XUnmapEvent *e) {
|
2002-05-25 00:29:44 +00:00
|
|
|
removeClient(e->window);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Slitmenu::Slitmenu(Slit *sl) : Basemenu(sl->screen) {
|
|
|
|
slit = sl;
|
|
|
|
|
2002-05-16 22:35:59 +00:00
|
|
|
setLabel(i18n(SlitSet, SlitSlitTitle, "Slit"));
|
2002-04-11 03:20:38 +00:00
|
|
|
setInternalMenu();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
directionmenu = new Directionmenu(this);
|
|
|
|
placementmenu = new Placementmenu(this);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-16 22:35:59 +00:00
|
|
|
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);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
update();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (slit->isOnTop()) setItemSelected(2, True);
|
|
|
|
if (slit->doAutoHide()) setItemSelected(3, True);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Slitmenu::~Slitmenu(void) {
|
|
|
|
delete directionmenu;
|
|
|
|
delete placementmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slitmenu::itemSelected(int button, unsigned int index) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
if (! item) return;
|
|
|
|
|
|
|
|
switch (item->function()) {
|
|
|
|
case 1: { // always on top
|
2002-05-26 20:25:38 +00:00
|
|
|
slit->saveOnTop(! slit->isOnTop());
|
|
|
|
setItemSelected(2, slit->isOnTop());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
if (slit->isOnTop()) slit->screen->raiseWindows((Window *) 0, 0);
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2: { // auto hide
|
2002-05-25 00:29:44 +00:00
|
|
|
slit->toggleAutoHide();
|
2002-05-26 20:25:38 +00:00
|
|
|
setItemSelected(3, slit->doAutoHide());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} // switch
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Slitmenu::internal_hide(void) {
|
|
|
|
Basemenu::internal_hide();
|
2002-05-25 00:29:44 +00:00
|
|
|
if (slit->doAutoHide())
|
|
|
|
slit->timeout();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Slitmenu::reconfigure(void) {
|
|
|
|
directionmenu->reconfigure();
|
|
|
|
placementmenu->reconfigure();
|
|
|
|
|
|
|
|
Basemenu::reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Slitmenu::Directionmenu::Directionmenu(Slitmenu *sm)
|
2002-05-26 20:25:38 +00:00
|
|
|
: Basemenu(sm->slit->screen), slit(sm->slit) {
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setLabel(i18n(SlitSet, SlitSlitDirection, "Slit Direction"));
|
|
|
|
setInternalMenu();
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
insert(i18n(CommonSet, CommonDirectionHoriz, "Horizontal"),
|
|
|
|
Slit::Horizontal);
|
|
|
|
insert(i18n(CommonSet, CommonDirectionVert, "Vertical"),
|
|
|
|
Slit::Vertical);
|
2002-04-17 23:07:11 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
update();
|
2002-05-26 20:25:38 +00:00
|
|
|
setValues();
|
|
|
|
}
|
2002-04-17 23:07:11 +00:00
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
|
|
|
|
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);
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slitmenu::Directionmenu::itemSelected(int button, unsigned int index) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
if (! item) return;
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
slit->saveDirection(item->function());
|
2002-04-11 03:20:38 +00:00
|
|
|
hide();
|
2002-05-26 20:25:38 +00:00
|
|
|
slit->reconfigure();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Slitmenu::Placementmenu::Placementmenu(Slitmenu *sm)
|
2002-05-26 20:25:38 +00:00
|
|
|
: Basemenu(sm->slit->screen), slit(sm->slit) {
|
2002-05-25 00:29:44 +00:00
|
|
|
|
|
|
|
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();
|
2002-05-26 20:25:38 +00:00
|
|
|
|
|
|
|
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);
|
2002-05-25 00:29:44 +00:00
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Slitmenu::Placementmenu::itemSelected(int button, unsigned int index) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
if (! (item && item->function())) return;
|
|
|
|
|
2002-05-26 20:25:38 +00:00
|
|
|
slit->savePlacement(item->function());
|
2002-04-11 03:20:38 +00:00
|
|
|
hide();
|
2002-05-26 20:25:38 +00:00
|
|
|
slit->reconfigure();
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|