2002-02-09 16:41:53 +00:00
|
|
|
// Workspace.cc for Fluxbox
|
|
|
|
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
|
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Workspace.cc for Blackbox - an X11 Window manager
|
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// 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.
|
|
|
|
|
2002-02-26 22:34:49 +00:00
|
|
|
// $Id: Workspace.cc,v 1.12 2002/02/26 22:34:49 fluxgen Exp $
|
2002-01-20 02:08:12 +00:00
|
|
|
|
|
|
|
// use GNU extensions
|
2001-12-11 20:47:02 +00:00
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
|
|
#include "i18n.hh"
|
|
|
|
#include "fluxbox.hh"
|
|
|
|
#include "Clientmenu.hh"
|
|
|
|
#include "Screen.hh"
|
|
|
|
#include "Toolbar.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Workspace.hh"
|
|
|
|
#include "Windowmenu.hh"
|
2002-01-06 11:07:42 +00:00
|
|
|
#include "StringUtil.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_STDIO_H
|
|
|
|
# include <stdio.h>
|
|
|
|
#endif // HAVE_STDIO_H
|
|
|
|
|
|
|
|
#ifdef STDC_HEADERS
|
|
|
|
# include <string.h>
|
|
|
|
#endif // STDC_HEADERS
|
|
|
|
|
2002-01-20 02:08:12 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
#include <algorithm>
|
2002-02-10 19:05:12 +00:00
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
2002-02-08 14:06:35 +00:00
|
|
|
|
2002-02-16 11:28:16 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
#endif
|
|
|
|
|
2002-01-20 02:08:12 +00:00
|
|
|
Workspace::Workspace(BScreen *scrn, int i):
|
|
|
|
screen(scrn),
|
|
|
|
lastfocus(0),
|
|
|
|
name(""),
|
2002-02-09 16:41:53 +00:00
|
|
|
id(i),
|
2002-01-20 02:08:12 +00:00
|
|
|
cascade_x(32), cascade_y(32)
|
|
|
|
{
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
clientmenu = new Clientmenu(this);
|
|
|
|
|
|
|
|
char *tmp;
|
|
|
|
screen->getNameOfWorkspace(id, &tmp);
|
|
|
|
setName(tmp);
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
delete [] tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-01-20 02:08:12 +00:00
|
|
|
Workspace::~Workspace() {
|
2001-12-11 20:47:02 +00:00
|
|
|
delete clientmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const int Workspace::addWindow(FluxboxWindow *w, Bool place) {
|
2002-01-20 02:08:12 +00:00
|
|
|
if (! w)
|
|
|
|
return -1;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-20 02:08:12 +00:00
|
|
|
if (place)
|
|
|
|
placeWindow(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
w->setWorkspace(id);
|
2002-02-08 14:06:35 +00:00
|
|
|
w->setWindowNumber(windowList.size());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
stackingList.push_front(w);
|
|
|
|
windowList.push_back(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
clientmenu->insert((const char **) w->getTitle());
|
|
|
|
clientmenu->update();
|
|
|
|
|
|
|
|
screen->updateNetizenWindowAdd(w->getClientWindow(), id);
|
|
|
|
|
|
|
|
raiseWindow(w);
|
|
|
|
|
|
|
|
return w->getWindowNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const int Workspace::removeWindow(FluxboxWindow *w) {
|
|
|
|
if (! w) return -1;
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
stackingList.remove(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (w->isFocused()) {
|
|
|
|
if (screen->isSloppyFocus())
|
|
|
|
Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0);
|
|
|
|
else if (w->isTransient() && w->getTransientFor() &&
|
|
|
|
w->getTransientFor()->isVisible())
|
|
|
|
w->getTransientFor()->setInputFocus();
|
|
|
|
else {
|
2002-02-09 16:41:53 +00:00
|
|
|
FluxboxWindow *top = 0;
|
|
|
|
if (stackingList.size()!=0)
|
|
|
|
top = stackingList.front();
|
|
|
|
|
|
|
|
if (!top || !top->setInputFocus()) {
|
2001-12-11 20:47:02 +00:00
|
|
|
Fluxbox::instance()->setFocusedWindow((FluxboxWindow *) 0);
|
|
|
|
XSetInputFocus(Fluxbox::instance()->getXDisplay(),
|
2002-01-20 02:08:12 +00:00
|
|
|
screen->getToolbar()->getWindowID(),
|
|
|
|
RevertToParent, CurrentTime);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastfocus == w)
|
|
|
|
lastfocus = (FluxboxWindow *) 0;
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
windowList.erase(windowList.begin() + w->getWindowNumber());
|
2001-12-11 20:47:02 +00:00
|
|
|
clientmenu->remove(w->getWindowNumber());
|
|
|
|
clientmenu->update();
|
|
|
|
|
|
|
|
screen->updateNetizenWindowDel(w->getClientWindow());
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
{
|
|
|
|
Windows::iterator it = windowList.begin();
|
|
|
|
Windows::const_iterator it_end = windowList.end();
|
|
|
|
for (int i = 0; it != it_end; ++it, ++i) {
|
|
|
|
(*it)->setWindowNumber(i);
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
return windowList.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::showAll(void) {
|
2002-02-08 14:06:35 +00:00
|
|
|
WindowStack::iterator it = stackingList.begin();
|
|
|
|
WindowStack::iterator it_end = stackingList.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->deiconify(False, False);
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::hideAll(void) {
|
2002-02-08 14:06:35 +00:00
|
|
|
WindowStack::reverse_iterator it = stackingList.rbegin();
|
|
|
|
WindowStack::reverse_iterator it_end = stackingList.rend();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if (! (*it)->isStuck())
|
|
|
|
(*it)->withdraw();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::removeAll(void) {
|
2002-02-08 14:06:35 +00:00
|
|
|
Windows::iterator it = windowList.begin();
|
|
|
|
Windows::const_iterator it_end = windowList.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->iconify();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::raiseWindow(FluxboxWindow *w) {
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w;
|
|
|
|
|
2002-02-26 22:34:49 +00:00
|
|
|
while (bottom->isTransient() && bottom->getTransientFor() &&
|
|
|
|
bottom->getTransientFor() != bottom) //prevent infinite loop
|
2001-12-11 20:47:02 +00:00
|
|
|
bottom = bottom->getTransientFor();
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
win = bottom;
|
2002-02-26 22:34:49 +00:00
|
|
|
while (win->hasTransient() && win->getTransient() &&
|
|
|
|
win->getTransient() != win) {//prevent infinite loop
|
2001-12-11 20:47:02 +00:00
|
|
|
win = win->getTransient();
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window *nstack = new Window[i], *curr = nstack;
|
|
|
|
Workspace *wkspc;
|
|
|
|
|
|
|
|
win = bottom;
|
|
|
|
while (True) {
|
|
|
|
*(curr++) = win->getFrameWindow();
|
|
|
|
screen->updateNetizenWindowRaise(win->getClientWindow());
|
|
|
|
|
|
|
|
if (! win->isIconic()) {
|
|
|
|
wkspc = screen->getWorkspace(win->getWorkspaceNumber());
|
2002-02-08 14:06:35 +00:00
|
|
|
wkspc->stackingList.remove(win);
|
|
|
|
wkspc->stackingList.push_front(win);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-02-26 22:34:49 +00:00
|
|
|
if (! win->hasTransient() || ! win->getTransient() ||
|
|
|
|
win->getTransient() == win) //prevent infinite loop
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
2002-02-26 22:34:49 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
win = win->getTransient();
|
|
|
|
}
|
|
|
|
|
|
|
|
screen->raiseWindows(nstack, i);
|
|
|
|
|
|
|
|
delete [] nstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::lowerWindow(FluxboxWindow *w) {
|
|
|
|
FluxboxWindow *win = (FluxboxWindow *) 0, *bottom = w;
|
|
|
|
|
2002-02-26 22:34:49 +00:00
|
|
|
while (bottom->isTransient() && bottom->getTransientFor()
|
|
|
|
&& bottom->getTransientFor() != bottom) //prevent infinite loop
|
2001-12-11 20:47:02 +00:00
|
|
|
bottom = bottom->getTransientFor();
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
win = bottom;
|
2002-02-26 22:34:49 +00:00
|
|
|
while (win->hasTransient() && win->getTransient() &&
|
|
|
|
win->getTransient() != win) { //prevent infinite loop
|
2001-12-11 20:47:02 +00:00
|
|
|
win = win->getTransient();
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window *nstack = new Window[i], *curr = nstack;
|
|
|
|
Workspace *wkspc;
|
|
|
|
|
|
|
|
while (True) {
|
|
|
|
*(curr++) = win->getFrameWindow();
|
|
|
|
screen->updateNetizenWindowLower(win->getClientWindow());
|
|
|
|
|
|
|
|
if (! win->isIconic()) {
|
|
|
|
wkspc = screen->getWorkspace(win->getWorkspaceNumber());
|
2002-02-08 14:06:35 +00:00
|
|
|
wkspc->stackingList.remove(win);
|
|
|
|
wkspc->stackingList.push_back(win);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-02-26 22:34:49 +00:00
|
|
|
if (! win->getTransientFor() ||
|
|
|
|
win->getTransientFor() == win)//prevent infinite loop
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
win = win->getTransientFor();
|
|
|
|
}
|
|
|
|
|
|
|
|
Fluxbox::instance()->grab();
|
|
|
|
|
|
|
|
XLowerWindow(screen->getBaseDisplay()->getXDisplay(), *nstack);
|
|
|
|
XRestackWindows(screen->getBaseDisplay()->getXDisplay(), nstack, i);
|
|
|
|
|
|
|
|
Fluxbox::instance()->ungrab();
|
|
|
|
|
|
|
|
delete [] nstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::reconfigure(void) {
|
|
|
|
clientmenu->reconfigure();
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
Windows::iterator it = windowList.begin();
|
|
|
|
Windows::iterator it_end = windowList.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if ((*it)->validateClient())
|
|
|
|
(*it)->reconfigure();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FluxboxWindow *Workspace::getWindow(int index) {
|
2002-02-08 14:06:35 +00:00
|
|
|
if ((index >= 0) && (index < windowList.size()))
|
|
|
|
return windowList[index];
|
2001-12-11 20:47:02 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const int Workspace::getCount(void) {
|
2002-02-08 14:06:35 +00:00
|
|
|
return windowList.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::update(void) {
|
|
|
|
clientmenu->update();
|
|
|
|
screen->getToolbar()->redrawWindowLabel(True);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 11:28:16 +00:00
|
|
|
bool Workspace::isCurrent(void) {
|
2001-12-11 20:47:02 +00:00
|
|
|
return (id == screen->getCurrentWorkspaceID());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-16 11:28:16 +00:00
|
|
|
bool Workspace::isLastWindow(FluxboxWindow *w) {
|
2002-02-08 14:06:35 +00:00
|
|
|
return (w == windowList.back());
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::setCurrent(void) {
|
|
|
|
screen->changeWorkspaceID(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::setName(char *new_name) {
|
|
|
|
|
|
|
|
if (new_name) {
|
2002-01-20 02:08:12 +00:00
|
|
|
name = new_name;
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
2002-01-20 02:08:12 +00:00
|
|
|
char tname[128];
|
|
|
|
sprintf(tname, I18n::instance()->
|
2002-01-18 01:35:27 +00:00
|
|
|
getMessage(
|
2001-12-11 20:47:02 +00:00
|
|
|
#ifdef NLS
|
2002-01-18 01:35:27 +00:00
|
|
|
WorkspaceSet, WorkspaceDefaultNameFormat,
|
2001-12-11 20:47:02 +00:00
|
|
|
#else // !NLS
|
2002-01-18 01:35:27 +00:00
|
|
|
0, 0,
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // NLS
|
2002-01-18 01:35:27 +00:00
|
|
|
"Workspace %d"), id + 1);
|
2002-01-20 02:08:12 +00:00
|
|
|
name = tname;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
screen->updateWorkspaceNamesAtom();
|
|
|
|
|
2002-01-20 02:08:12 +00:00
|
|
|
clientmenu->setLabel(name.c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
clientmenu->update();
|
|
|
|
}
|
|
|
|
|
2002-02-16 11:28:16 +00:00
|
|
|
//------------ shutdown ---------
|
|
|
|
// Calles restore on all windows
|
|
|
|
// in the workspace and then
|
|
|
|
// clears the windowList
|
|
|
|
//-------------------------------
|
2001-12-11 20:47:02 +00:00
|
|
|
void Workspace::shutdown(void) {
|
2002-02-10 19:05:12 +00:00
|
|
|
|
|
|
|
while (!windowList.empty()) {
|
|
|
|
windowList.back()->restore();
|
|
|
|
delete windowList.back(); //delete window (the window removes it self from windowList)
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Workspace::placeWindow(FluxboxWindow *win) {
|
|
|
|
Bool placed = False;
|
|
|
|
int win_w = win->getWidth() + (screen->getBorderWidth2x() * 2),
|
|
|
|
win_h = win->getHeight() + (screen->getBorderWidth2x() * 2),
|
|
|
|
#ifdef SLIT
|
|
|
|
slit_x = screen->getSlit()->getX() - screen->getBorderWidth(),
|
|
|
|
slit_y = screen->getSlit()->getY() - screen->getBorderWidth(),
|
|
|
|
slit_w = screen->getSlit()->getWidth() +
|
|
|
|
(screen->getBorderWidth2x() * 2),
|
|
|
|
slit_h = screen->getSlit()->getHeight() +
|
|
|
|
(screen->getBorderWidth2x() * 2),
|
|
|
|
#endif // SLIT
|
|
|
|
toolbar_x = screen->getToolbar()->getX() - screen->getBorderWidth(),
|
|
|
|
toolbar_y = screen->getToolbar()->getY() - screen->getBorderWidth(),
|
|
|
|
toolbar_w = screen->getToolbar()->getWidth() +
|
|
|
|
(screen->getBorderWidth2x() * 2),
|
|
|
|
toolbar_h = screen->getToolbar()->getHeight() +
|
|
|
|
(screen->getBorderWidth2x() * 2),
|
|
|
|
place_x = 0, place_y = 0, change_x = 1, change_y = 1;
|
|
|
|
|
2002-01-11 10:43:55 +00:00
|
|
|
if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP)
|
2001-12-11 20:47:02 +00:00
|
|
|
change_y = -1;
|
2002-01-11 10:43:55 +00:00
|
|
|
if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT)
|
2001-12-11 20:47:02 +00:00
|
|
|
change_x = -1;
|
|
|
|
|
|
|
|
register int test_x, test_y, curr_w, curr_h;
|
|
|
|
|
|
|
|
switch (screen->getPlacementPolicy()) {
|
2002-01-11 10:43:55 +00:00
|
|
|
case BScreen::ROWSMARTPLACEMENT: {
|
2001-12-11 20:47:02 +00:00
|
|
|
test_y = screen->getBorderWidth() + screen->getEdgeSnapThreshold();
|
2002-01-11 10:43:55 +00:00
|
|
|
if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP)
|
2001-12-11 20:47:02 +00:00
|
|
|
test_y = screen->getHeight() - win_h - test_y;
|
|
|
|
|
2002-01-11 10:43:55 +00:00
|
|
|
while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ?
|
2001-12-11 20:47:02 +00:00
|
|
|
test_y > 0 : test_y + win_h < (signed) screen->getHeight()) &&
|
|
|
|
! placed) {
|
|
|
|
test_x = screen->getBorderWidth() + screen->getEdgeSnapThreshold();
|
2002-01-11 10:43:55 +00:00
|
|
|
if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT)
|
2002-02-08 14:06:35 +00:00
|
|
|
test_x = screen->getWidth() - win_w - test_x;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-11 10:43:55 +00:00
|
|
|
while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ?
|
2001-12-11 20:47:02 +00:00
|
|
|
test_x > 0 : test_x + win_w < (signed) screen->getWidth()) &&
|
|
|
|
! placed) {
|
|
|
|
placed = True;
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
Windows::iterator it = windowList.begin();
|
|
|
|
Windows::iterator it_end = windowList.end();
|
|
|
|
for (; it != it_end && placed; ++it) {
|
|
|
|
curr_w = (*it)->getWidth() + screen->getBorderWidth2x() +
|
2001-12-11 20:47:02 +00:00
|
|
|
screen->getBorderWidth2x();
|
|
|
|
curr_h =
|
2002-02-08 14:06:35 +00:00
|
|
|
(((*it)->isShaded())
|
|
|
|
? (*it)->getTitleHeight()
|
|
|
|
: (*it)->getHeight()) +
|
|
|
|
screen->getBorderWidth2x() +
|
|
|
|
screen->getBorderWidth2x();
|
|
|
|
|
|
|
|
if ((*it)->getXFrame() < test_x + win_w &&
|
|
|
|
(*it)->getXFrame() + curr_w > test_x &&
|
|
|
|
(*it)->getYFrame() < test_y + win_h &&
|
|
|
|
(*it)->getYFrame() + curr_h > test_y)
|
2001-12-11 20:47:02 +00:00
|
|
|
placed = False;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((toolbar_x < test_x + win_w &&
|
|
|
|
toolbar_x + toolbar_w > test_x &&
|
|
|
|
toolbar_y < test_y + win_h &&
|
|
|
|
toolbar_y + toolbar_h > test_y)
|
|
|
|
#ifdef SLIT
|
|
|
|
||
|
|
|
|
(slit_x < test_x + win_w &&
|
|
|
|
slit_x + slit_w > test_x &&
|
|
|
|
slit_y < test_y + win_h &&
|
|
|
|
slit_y + slit_h > test_y)
|
|
|
|
#endif // SLIT
|
|
|
|
)
|
|
|
|
placed = False;
|
|
|
|
|
|
|
|
if (placed) {
|
|
|
|
place_x = test_x;
|
|
|
|
place_y = test_y;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_x += change_x;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_y += change_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
break; }
|
|
|
|
|
2002-01-11 10:43:55 +00:00
|
|
|
case BScreen::COLSMARTPLACEMENT: {
|
2001-12-11 20:47:02 +00:00
|
|
|
test_x = screen->getBorderWidth() + screen->getEdgeSnapThreshold();
|
2002-01-11 10:43:55 +00:00
|
|
|
if (screen->getRowPlacementDirection() == BScreen::RIGHTLEFT)
|
2001-12-11 20:47:02 +00:00
|
|
|
test_x = screen->getWidth() - win_w - test_x;
|
|
|
|
|
2002-01-11 10:43:55 +00:00
|
|
|
while (((screen->getRowPlacementDirection() == BScreen::RIGHTLEFT) ?
|
2001-12-11 20:47:02 +00:00
|
|
|
test_x > 0 : test_x + win_w < (signed) screen->getWidth()) &&
|
|
|
|
! placed) {
|
|
|
|
test_y = screen->getBorderWidth() + screen->getEdgeSnapThreshold();
|
2002-01-11 10:43:55 +00:00
|
|
|
if (screen->getColPlacementDirection() == BScreen::BOTTOMTOP)
|
2002-02-08 14:06:35 +00:00
|
|
|
test_y = screen->getHeight() - win_h - test_y;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-11 10:43:55 +00:00
|
|
|
while (((screen->getColPlacementDirection() == BScreen::BOTTOMTOP) ?
|
2001-12-11 20:47:02 +00:00
|
|
|
test_y > 0 : test_y + win_h < (signed) screen->getHeight()) &&
|
|
|
|
! placed) {
|
|
|
|
placed = True;
|
|
|
|
|
2002-02-08 14:06:35 +00:00
|
|
|
Windows::iterator it = windowList.begin();
|
|
|
|
Windows::iterator it_end = windowList.end();
|
|
|
|
for (; it != it_end && placed; ++it) {
|
|
|
|
curr_w = (*it)->getWidth() + screen->getBorderWidth2x() +
|
2001-12-11 20:47:02 +00:00
|
|
|
screen->getBorderWidth2x();
|
|
|
|
curr_h =
|
2002-02-08 14:06:35 +00:00
|
|
|
(((*it)->isShaded())
|
|
|
|
? (*it)->getTitleHeight()
|
|
|
|
: (*it)->getHeight()) +
|
|
|
|
screen->getBorderWidth2x() +
|
|
|
|
screen->getBorderWidth2x();
|
|
|
|
|
|
|
|
if ((*it)->getXFrame() < test_x + win_w &&
|
|
|
|
(*it)->getXFrame() + curr_w > test_x &&
|
|
|
|
(*it)->getYFrame() < test_y + win_h &&
|
|
|
|
(*it)->getYFrame() + curr_h > test_y)
|
2001-12-11 20:47:02 +00:00
|
|
|
placed = False;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((toolbar_x < test_x + win_w &&
|
2002-01-18 01:35:27 +00:00
|
|
|
toolbar_x + toolbar_w > test_x &&
|
|
|
|
toolbar_y < test_y + win_h &&
|
|
|
|
toolbar_y + toolbar_h > test_y)
|
2001-12-11 20:47:02 +00:00
|
|
|
#ifdef SLIT
|
2002-01-18 01:35:27 +00:00
|
|
|
||
|
2001-12-11 20:47:02 +00:00
|
|
|
(slit_x < test_x + win_w &&
|
2002-01-18 01:35:27 +00:00
|
|
|
slit_x + slit_w > test_x &&
|
|
|
|
slit_y < test_y + win_h &&
|
|
|
|
slit_y + slit_h > test_y)
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // SLIT
|
2002-01-18 01:35:27 +00:00
|
|
|
)
|
|
|
|
placed = False;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:35:27 +00:00
|
|
|
if (placed) {
|
|
|
|
place_x = test_x;
|
|
|
|
place_y = test_y;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:35:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:35:27 +00:00
|
|
|
test_y += change_y;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-18 01:35:27 +00:00
|
|
|
test_x += change_x;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break; }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! placed) {
|
|
|
|
if (((unsigned) cascade_x > (screen->getWidth() / 2)) ||
|
2002-01-18 01:35:27 +00:00
|
|
|
((unsigned) cascade_y > (screen->getHeight() / 2)))
|
2001-12-11 20:47:02 +00:00
|
|
|
cascade_x = cascade_y = 32;
|
|
|
|
|
|
|
|
place_x = cascade_x;
|
|
|
|
place_y = cascade_y;
|
|
|
|
|
|
|
|
cascade_x += win->getTitleHeight();
|
|
|
|
cascade_y += win->getTitleHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (place_x + win_w > (signed) screen->getWidth())
|
|
|
|
place_x = (((signed) screen->getWidth()) - win_w) / 2;
|
|
|
|
if (place_y + win_h > (signed) screen->getHeight())
|
|
|
|
place_y = (((signed) screen->getHeight()) - win_h) / 2;
|
|
|
|
|
|
|
|
win->configure(place_x, place_y, win->getWidth(), win->getHeight());
|
|
|
|
}
|