2002-01-09 14:11:20 +00:00
|
|
|
|
// Screen.cc for Fluxbox Window Manager
|
2002-12-13 20:19:05 +00:00
|
|
|
|
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen at users.sourceforge.net)
|
2002-01-09 14:11:20 +00:00
|
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
|
// Screen.cc for Blackbox - an X11 Window manager
|
2002-12-13 20:19:05 +00:00
|
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
|
2001-12-11 20:47:02 +00:00
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2002-05-08 10:14:51 +00:00
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
2003-02-16 15:12:08 +00:00
|
|
|
|
// $Id: Screen.cc,v 1.107 2003/02/16 15:12:08 rathnor Exp $
|
2002-10-25 20:58:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "Screen.hh"
|
|
|
|
|
|
|
|
|
|
#include "i18n.hh"
|
|
|
|
|
#include "fluxbox.hh"
|
2002-11-30 20:18:35 +00:00
|
|
|
|
#include "ImageControl.hh"
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include "Toolbar.hh"
|
|
|
|
|
#include "Window.hh"
|
|
|
|
|
#include "Workspace.hh"
|
|
|
|
|
#include "StringUtil.hh"
|
2002-11-17 11:29:06 +00:00
|
|
|
|
#include "Netizen.hh"
|
2002-12-02 23:19:16 +00:00
|
|
|
|
#include "DirHelper.hh"
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#include "WinButton.hh"
|
|
|
|
|
#include "SimpleCommand.hh"
|
2003-01-07 02:06:06 +00:00
|
|
|
|
#include "MenuTheme.hh"
|
2003-01-09 17:41:02 +00:00
|
|
|
|
#include "FbCommands.hh"
|
2003-01-12 17:59:20 +00:00
|
|
|
|
#include "BoolMenuItem.hh"
|
2003-01-12 18:21:27 +00:00
|
|
|
|
//#include "IntResMenuItem.hh"
|
2003-01-12 17:59:20 +00:00
|
|
|
|
#include "MacroCommand.hh"
|
2003-02-02 16:32:41 +00:00
|
|
|
|
#include "XLayerItem.hh"
|
|
|
|
|
#include "MultLayers.hh"
|
2003-02-03 13:56:12 +00:00
|
|
|
|
#include "LayeredMenu.hh"
|
2002-01-09 14:11:20 +00:00
|
|
|
|
|
2002-03-18 20:20:09 +00:00
|
|
|
|
//use GNU extensions
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#ifndef _GNU_SOURCE
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
#endif // _GNU_SOURCE
|
|
|
|
|
|
2002-10-13 22:30:18 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
2002-10-13 22:30:18 +00:00
|
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#include "Slit.hh"
|
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef STDC_HEADERS
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <sys/types.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // STDC_HEADERS
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef HAVE_CTYPE_H
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <ctype.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_CTYPE_H
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef HAVE_DIRENT_H
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <dirent.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_DIRENT_H
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef HAVE_LOCALE_H
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <locale.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_LOCALE_H
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <unistd.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <sys/stat.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_SYS_STAT_H
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifdef HAVE_STDARG_H
|
2002-10-25 20:58:14 +00:00
|
|
|
|
#include <stdarg.h>
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#endif // HAVE_STDARG_H
|
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#else // !TIME_WITH_SYS_TIME
|
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#else // !HAVE_SYS_TIME_H
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#endif // HAVE_SYS_TIME_H
|
|
|
|
|
#endif // TIME_WITH_SYS_TIME
|
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
|
#ifndef MAXPATHLEN
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#define MAXPATHLEN 255
|
|
|
|
|
#endif // MAXPATHLEN
|
|
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
|
#include <X11/keysym.h>
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
#include <iostream>
|
2002-01-20 02:17:23 +00:00
|
|
|
|
#include <memory>
|
2002-02-08 13:35:20 +00:00
|
|
|
|
#include <algorithm>
|
2002-01-20 02:17:23 +00:00
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
using namespace std;
|
|
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
|
static bool running = true;
|
2002-10-25 20:58:14 +00:00
|
|
|
|
namespace {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-10-25 20:58:14 +00:00
|
|
|
|
int anotherWMRunning(Display *display, XErrorEvent *) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
fprintf(stderr,
|
|
|
|
|
I18n::instance()->
|
|
|
|
|
getMessage(
|
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenAnotherWMRunning,
|
|
|
|
|
"BScreen::BScreen: an error occured while querying the X server.\n"
|
|
|
|
|
" another window manager already running on display %s.\n"),
|
|
|
|
|
DisplayString(display));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
running = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return(-1);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FbTk::Menu *createMenuFromScreen(BScreen &screen) {
|
2003-02-03 13:56:12 +00:00
|
|
|
|
FbTk::Menu *menu = new LayeredMenu(*screen.menuTheme(),
|
|
|
|
|
screen.getScreenNumber(),
|
|
|
|
|
*screen.getImageControl(),
|
|
|
|
|
*screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer()));
|
2003-02-02 16:32:41 +00:00
|
|
|
|
return menu;
|
2003-01-09 17:41:02 +00:00
|
|
|
|
}
|
2003-02-16 15:12:08 +00:00
|
|
|
|
|
|
|
|
|
class WindowLayerMenuItem : public FbTk::MenuItem {
|
|
|
|
|
public:
|
|
|
|
|
WindowLayerMenuItem(const char *label, FluxboxWindow &win, int layernum):
|
|
|
|
|
FbTk::MenuItem(label), m_window(win), m_layernum(layernum) {
|
|
|
|
|
}
|
|
|
|
|
bool isEnabled() const { return m_window.getLayerNum() != m_layernum; }
|
|
|
|
|
void click(int button, int time) {
|
|
|
|
|
m_window.moveToLayer(m_layernum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
FluxboxWindow &m_window;
|
|
|
|
|
int m_layernum;
|
2002-10-25 20:58:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-16 15:12:08 +00:00
|
|
|
|
}; // End anonymous namespace
|
|
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
|
//---------- resource manipulators ---------
|
|
|
|
|
template<>
|
|
|
|
|
void Resource<Tab::Alignment>::
|
|
|
|
|
setFromString(const char *strval) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_value = Tab::getTabAlignmentNum(strval);
|
2002-01-20 02:17:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
void Resource<Tab::Placement>::
|
|
|
|
|
setFromString(const char *strval) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_value = Tab::getTabPlacementNum(strval);
|
2002-01-20 02:17:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
void Resource<Toolbar::Placement>::
|
|
|
|
|
setFromString(const char *strval) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (strcasecmp(strval, "TopLeft")==0)
|
|
|
|
|
m_value = Toolbar::TOPLEFT;
|
|
|
|
|
else if (strcasecmp(strval, "BottomLeft")==0)
|
|
|
|
|
m_value = Toolbar::BOTTOMLEFT;
|
|
|
|
|
else if (strcasecmp(strval, "TopCenter")==0)
|
|
|
|
|
m_value = Toolbar::TOPCENTER;
|
|
|
|
|
else if (strcasecmp(strval, "BottomCenter")==0)
|
|
|
|
|
m_value = Toolbar::BOTTOMCENTER;
|
|
|
|
|
else if (strcasecmp(strval, "TopRight")==0)
|
|
|
|
|
m_value = Toolbar::TOPRIGHT;
|
|
|
|
|
else if (strcasecmp(strval, "BottomRight")==0)
|
|
|
|
|
m_value = Toolbar::BOTTOMRIGHT;
|
2002-12-04 22:43:18 +00:00
|
|
|
|
else if (strcasecmp(strval, "LeftTop") == 0)
|
|
|
|
|
m_value = Toolbar::LEFTTOP;
|
|
|
|
|
else if (strcasecmp(strval, "LeftCenter") == 0)
|
|
|
|
|
m_value = Toolbar::LEFTCENTER;
|
|
|
|
|
else if (strcasecmp(strval, "LeftBottom") == 0)
|
|
|
|
|
m_value = Toolbar::LEFTBOTTOM;
|
|
|
|
|
else if (strcasecmp(strval, "RightTop") == 0)
|
|
|
|
|
m_value = Toolbar::RIGHTTOP;
|
|
|
|
|
else if (strcasecmp(strval, "RightCenter") == 0)
|
|
|
|
|
m_value = Toolbar::RIGHTCENTER;
|
|
|
|
|
else if (strcasecmp(strval, "RightBottom") == 0)
|
|
|
|
|
m_value = Toolbar::RIGHTBOTTOM;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
else
|
|
|
|
|
setDefaultValue();
|
2002-01-20 02:17:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------- resource accessors --------------
|
|
|
|
|
template<>
|
|
|
|
|
string Resource<Tab::Alignment>::
|
|
|
|
|
getString() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return Tab::getTabAlignmentString(m_value);
|
2002-01-20 02:17:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
string Resource<Tab::Placement>::
|
|
|
|
|
getString() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return Tab::getTabPlacementString(m_value);
|
2002-01-20 02:17:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
string Resource<Toolbar::Placement>::
|
|
|
|
|
getString() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
switch (m_value) {
|
|
|
|
|
case Toolbar::TOPLEFT:
|
|
|
|
|
return string("TopLeft");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::BOTTOMLEFT:
|
|
|
|
|
return string("BottomLeft");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::TOPCENTER:
|
|
|
|
|
return string("TopCenter");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::BOTTOMCENTER:
|
|
|
|
|
return string("BottomCenter");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::TOPRIGHT:
|
|
|
|
|
return string("TopRight");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::BOTTOMRIGHT:
|
|
|
|
|
return string("BottomRight");
|
|
|
|
|
break;
|
2002-12-04 22:43:18 +00:00
|
|
|
|
case Toolbar::LEFTTOP:
|
|
|
|
|
return string("LeftTop");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::LEFTCENTER:
|
|
|
|
|
return string("LeftCenter");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::LEFTBOTTOM:
|
|
|
|
|
return string("LeftBottom");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::RIGHTTOP:
|
|
|
|
|
return string("RightTop");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::RIGHTCENTER:
|
|
|
|
|
return string("RightCenter");
|
|
|
|
|
break;
|
|
|
|
|
case Toolbar::RIGHTBOTTOM:
|
|
|
|
|
return string("RightBottom");
|
|
|
|
|
break;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
//default string
|
|
|
|
|
return string("BottomCenter");
|
2002-01-20 02:17:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-09 17:41:02 +00:00
|
|
|
|
namespace {
|
2003-01-12 23:56:49 +00:00
|
|
|
|
|
2003-01-09 17:41:02 +00:00
|
|
|
|
class AddWorkspaceCmd:public FbTk::Command {
|
|
|
|
|
public:
|
|
|
|
|
explicit AddWorkspaceCmd(BScreen &scrn):m_screen(scrn) { }
|
|
|
|
|
void execute() {
|
|
|
|
|
m_screen.addWorkspace();
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
BScreen &m_screen;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RemoveLastWorkspaceCmd:public FbTk::Command {
|
|
|
|
|
public:
|
|
|
|
|
explicit RemoveLastWorkspaceCmd(BScreen &scrn):m_screen(scrn) { }
|
|
|
|
|
void execute() {
|
|
|
|
|
m_screen.removeLastWorkspace();
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
BScreen &m_screen;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void setupWorkspacemenu(BScreen &scr, FbTk::Menu &menu) {
|
|
|
|
|
menu.removeAll(); // clear all items
|
|
|
|
|
using namespace FbTk;
|
2003-01-12 23:56:49 +00:00
|
|
|
|
menu.setLabel("Workspace");
|
2003-01-09 17:41:02 +00:00
|
|
|
|
RefCount<Command> new_workspace(new AddWorkspaceCmd(scr));
|
|
|
|
|
RefCount<Command> remove_last(new RemoveLastWorkspaceCmd(scr));
|
|
|
|
|
menu.insert("New Workspace", new_workspace);
|
|
|
|
|
menu.insert("Remove Last", remove_last);
|
2003-01-12 23:56:49 +00:00
|
|
|
|
menu.update();
|
2003-01-09 17:41:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
2002-01-20 02:17:23 +00:00
|
|
|
|
|
2003-01-12 23:56:49 +00:00
|
|
|
|
/// for root command
|
|
|
|
|
class RootTheme: public FbTk::Theme {
|
|
|
|
|
public:
|
|
|
|
|
explicit RootTheme(BScreen &scr):FbTk::Theme(scr.getScreenNumber()),
|
|
|
|
|
m_root_command(*this, "rootCommand", "RootCommand"),
|
|
|
|
|
m_scr(scr) { }
|
|
|
|
|
void reconfigTheme() {
|
|
|
|
|
// override resource root command?
|
|
|
|
|
if (m_scr.getRootCommand() == "") {
|
|
|
|
|
// do root command
|
|
|
|
|
FbCommands::ExecuteCmd cmd(*m_root_command);
|
|
|
|
|
cmd.execute();
|
|
|
|
|
} else {
|
|
|
|
|
FbCommands::ExecuteCmd cmd(m_scr.getRootCommand());
|
|
|
|
|
cmd.execute();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
FbTk::ThemeItem<std::string> m_root_command;
|
|
|
|
|
BScreen &m_scr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
void FbTk::ThemeItem<std::string>::load() { }
|
|
|
|
|
|
|
|
|
|
template <>
|
2003-02-15 02:03:09 +00:00
|
|
|
|
void FbTk::ThemeItem<std::string>::setDefaultValue() {
|
|
|
|
|
*(*this) = "";
|
|
|
|
|
}
|
2003-01-12 23:56:49 +00:00
|
|
|
|
|
|
|
|
|
template <>
|
2003-02-15 02:03:09 +00:00
|
|
|
|
void FbTk::ThemeItem<std::string>::setFromString(const char *str) {
|
|
|
|
|
*(*this) = (str ? str : "");
|
|
|
|
|
}
|
2003-01-12 23:56:49 +00:00
|
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
|
BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
|
2003-02-15 02:03:09 +00:00
|
|
|
|
const std::string &scrname,
|
|
|
|
|
const std::string &altscrname):
|
2002-12-01 13:42:15 +00:00
|
|
|
|
toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"),
|
|
|
|
|
toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"),
|
|
|
|
|
image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"),
|
|
|
|
|
opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"),
|
|
|
|
|
full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"),
|
|
|
|
|
max_over_slit(rm, true, scrname+".maxOverSlit",altscrname+".MaxOverSlit"),
|
|
|
|
|
tab_rotate_vertical(rm, true, scrname+".tab.rotatevertical", altscrname+".Tab.RotateVertical"),
|
|
|
|
|
sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"),
|
|
|
|
|
workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"),
|
|
|
|
|
desktop_wheeling(rm, true, scrname+".desktopwheeling", altscrname+".DesktopWheeling"),
|
|
|
|
|
show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"),
|
|
|
|
|
focus_last(rm, true, scrname+".focusLastWindow", altscrname+".FocusLastWindow"),
|
|
|
|
|
focus_new(rm, true, scrname+".focusNewWindows", altscrname+".FocusNewWindows"),
|
|
|
|
|
antialias(rm, false, scrname+".antialias", altscrname+".Antialias"),
|
|
|
|
|
rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
|
|
|
|
|
workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"),
|
|
|
|
|
toolbar_width_percent(rm, 65, scrname+".toolbar.widthPercent", altscrname+".Toolbar.WidthPercent"),
|
|
|
|
|
edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"),
|
|
|
|
|
tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"),
|
|
|
|
|
tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"),
|
|
|
|
|
tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"),
|
|
|
|
|
tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"),
|
2003-01-12 17:59:20 +00:00
|
|
|
|
toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead")
|
2002-01-20 02:17:23 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2002-10-25 20:58:14 +00:00
|
|
|
|
BScreen::BScreen(ResourceManager &rm,
|
2002-12-01 13:42:15 +00:00
|
|
|
|
const string &screenname, const string &altscreenname,
|
2003-02-03 13:56:12 +00:00
|
|
|
|
int scrn, int num_layers) : ScreenInfo(scrn),
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_clientlist_sig(*this), // client signal
|
|
|
|
|
m_workspacecount_sig(*this), // workspace count signal
|
|
|
|
|
m_workspacenames_sig(*this), // workspace names signal
|
|
|
|
|
m_currentworkspace_sig(*this), // current workspace signal
|
2003-02-03 13:56:12 +00:00
|
|
|
|
m_layermanager(num_layers),
|
2003-02-02 16:32:41 +00:00
|
|
|
|
theme(0), m_windowtheme(scrn),
|
2003-01-07 02:06:06 +00:00
|
|
|
|
m_menutheme(new FbTk::MenuTheme(scrn)),
|
2003-01-12 23:56:49 +00:00
|
|
|
|
resource(rm, screenname, altscreenname),
|
|
|
|
|
m_root_theme(new RootTheme(*this))
|
2002-01-10 12:49:15 +00:00
|
|
|
|
{
|
2003-01-12 23:56:49 +00:00
|
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
|
|
|
|
|
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
|
|
|
|
|
ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
|
|
|
|
|
XSelectInput(disp, getRootWindow(), event_mask);
|
|
|
|
|
XSync(disp, False);
|
|
|
|
|
XSetErrorHandler((XErrorHandler) old);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
managed = running;
|
|
|
|
|
if (! managed)
|
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
I18n *i18n = I18n::instance();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenManagingScreen,
|
|
|
|
|
"BScreen::BScreen: managing screen %d "
|
|
|
|
|
"using visual 0x%lx, depth %d\n"),
|
2002-12-01 13:42:15 +00:00
|
|
|
|
getScreenNumber(), XVisualIDFromVisual(getVisual()),
|
|
|
|
|
getDepth());
|
|
|
|
|
|
|
|
|
|
Fluxbox * const fluxbox = Fluxbox::instance();
|
2002-10-15 10:54:40 +00:00
|
|
|
|
#ifdef HAVE_GETPID
|
2002-12-01 13:42:15 +00:00
|
|
|
|
pid_t bpid = getpid();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
XChangeProperty(disp, getRootWindow(),
|
|
|
|
|
Fluxbox::instance()->getFluxboxPidAtom(), XA_CARDINAL,
|
|
|
|
|
sizeof(pid_t) * 8, PropModeReplace,
|
|
|
|
|
(unsigned char *) &bpid, 1);
|
2002-10-15 10:54:40 +00:00
|
|
|
|
#endif // HAVE_GETPID
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
XDefineCursor(disp, getRootWindow(), fluxbox->getSessionCursor());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
image_control =
|
2003-01-10 00:35:19 +00:00
|
|
|
|
new FbTk::ImageControl(scrn, true, fluxbox->colorsPerChannel(),
|
2003-02-15 02:03:09 +00:00
|
|
|
|
fluxbox->getCacheLife(), fluxbox->getCacheMax());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
image_control->installRootColormap();
|
|
|
|
|
root_colormap_installed = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
fluxbox->load_rc(this);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
image_control->setDither(*resource.image_dither);
|
|
|
|
|
theme = new Theme(disp, getRootWindow(), colormap(), getScreenNumber(),
|
|
|
|
|
fluxbox->getStyleFilename(), getRootCommand().c_str());
|
2002-01-11 10:21:44 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
theme->reconfigure(*resource.antialias);
|
2002-12-02 23:19:16 +00:00
|
|
|
|
// set database for new Theme Engine
|
|
|
|
|
FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename());
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
// special case for tab rotated
|
|
|
|
|
if (*resource.tab_rotate_vertical &&
|
|
|
|
|
( *resource.tab_placement == Tab::PLEFT || *resource.tab_placement == Tab::PRIGHT)) {
|
|
|
|
|
theme->getWindowStyle().tab.font.rotate(90);
|
|
|
|
|
} else {
|
|
|
|
|
theme->getWindowStyle().tab.font.rotate(0);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
const char *s = i18n->getMessage(
|
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenPositionLength,
|
|
|
|
|
"W: 0000 x H: 0000");
|
2002-01-20 02:17:23 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
int l = strlen(s);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_h = m_windowtheme.font().height();
|
|
|
|
|
geom_w = m_windowtheme.font().textWidth(s, l);
|
2002-10-15 17:17:00 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
geom_w += getBevelWidth()*2;
|
|
|
|
|
geom_h += getBevelWidth()*2;
|
|
|
|
|
|
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
|
unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder;
|
|
|
|
|
attrib.border_pixel = getBorderColor()->pixel();
|
|
|
|
|
attrib.colormap = colormap();
|
|
|
|
|
attrib.save_under = true;
|
|
|
|
|
|
|
|
|
|
geom_window =
|
|
|
|
|
XCreateWindow(disp, getRootWindow(),
|
|
|
|
|
0, 0, geom_w, geom_h, theme->getBorderWidth(), getDepth(),
|
|
|
|
|
InputOutput, getVisual(), mask, &attrib);
|
|
|
|
|
geom_visible = false;
|
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
if (m_windowtheme.labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) {
|
|
|
|
|
if (m_windowtheme.titleFocusTexture().type() ==
|
2002-12-01 13:42:15 +00:00
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
|
geom_pixmap = None;
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.setBackgroundColor(m_windowtheme.titleFocusTexture().color());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else {
|
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2003-02-16 01:14:54 +00:00
|
|
|
|
m_windowtheme.titleFocusTexture());
|
|
|
|
|
geom_window.setBackgroundPixmap(geom_pixmap);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2003-02-16 01:14:54 +00:00
|
|
|
|
if (m_windowtheme.labelFocusTexture().type() ==
|
2002-12-01 13:42:15 +00:00
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
|
geom_pixmap = None;
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.setBackgroundColor(m_windowtheme.labelFocusTexture().color());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else {
|
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2003-02-16 01:14:54 +00:00
|
|
|
|
m_windowtheme.labelFocusTexture());
|
|
|
|
|
geom_window.setBackgroundPixmap(geom_pixmap);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
|
workspacemenu.reset(createMenuFromScreen(*this));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
Workspace *wkspc = (Workspace *) 0;
|
|
|
|
|
if (*resource.workspaces != 0) {
|
|
|
|
|
for (int i = 0; i < *resource.workspaces; ++i) {
|
2003-02-03 13:56:12 +00:00
|
|
|
|
wkspc = new Workspace(this, m_layermanager, workspacesList.size());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacesList.push_back(wkspc);
|
|
|
|
|
workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2003-02-03 13:56:12 +00:00
|
|
|
|
wkspc = new Workspace(this, m_layermanager, workspacesList.size());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacesList.push_back(wkspc);
|
|
|
|
|
workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
current_workspace = workspacesList.front();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-10-15 10:54:40 +00:00
|
|
|
|
#ifdef SLIT
|
2003-01-12 17:59:20 +00:00
|
|
|
|
m_slit.reset(new Slit(*this));
|
2002-10-15 10:54:40 +00:00
|
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
m_toolbar.reset(new Toolbar(*this));
|
2003-01-12 17:59:20 +00:00
|
|
|
|
|
|
|
|
|
setupWorkspacemenu(*this, *workspacemenu);
|
|
|
|
|
|
|
|
|
|
m_configmenu.reset(createMenuFromScreen(*this));
|
|
|
|
|
setupConfigmenu(*m_configmenu.get());
|
|
|
|
|
|
|
|
|
|
workspacemenu->setItemSelected(2, true);
|
|
|
|
|
|
|
|
|
|
m_toolbar->reconfigure();
|
|
|
|
|
|
2002-12-13 20:19:05 +00:00
|
|
|
|
initMenu(); // create and initiate rootmenu
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
raiseWindows(Workspace::Stack());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
//update menus
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->update();
|
2003-01-12 17:59:20 +00:00
|
|
|
|
m_configmenu->update();
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#ifdef SLIT
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (m_slit.get())
|
|
|
|
|
m_slit->reconfigure();
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#endif // SLIT
|
2002-10-15 10:54:40 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
// start with workspace 0
|
|
|
|
|
changeWorkspaceID(0);
|
|
|
|
|
updateNetizenWorkspaceCount();
|
2002-02-04 07:01:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
int i;
|
|
|
|
|
unsigned int nchild;
|
|
|
|
|
Window r, p, *children;
|
|
|
|
|
XQueryTree(disp, getRootWindow(), &r, &p, &children, &nchild);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
// preen the window list of all icon windows... for better dockapp support
|
|
|
|
|
for (i = 0; i < (int) nchild; i++) {
|
2002-02-04 07:01:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (children[i] == None) continue;
|
|
|
|
|
|
|
|
|
|
XWMHints *wmhints = XGetWMHints(getBaseDisplay()->getXDisplay(),
|
|
|
|
|
children[i]);
|
|
|
|
|
|
|
|
|
|
if (wmhints) {
|
|
|
|
|
if ((wmhints->flags & IconWindowHint) &&
|
|
|
|
|
(wmhints->icon_window != children[i]))
|
|
|
|
|
for (int j = 0; j < (int) nchild; j++) {
|
|
|
|
|
if (children[j] == wmhints->icon_window) {
|
|
|
|
|
children[j] = None;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
XFree(wmhints);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// manage shown windows
|
|
|
|
|
for (i = 0; i < (int) nchild; ++i) {
|
|
|
|
|
if (children[i] == None || (! fluxbox->validateWindow(children[i])))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
XWindowAttributes attrib;
|
|
|
|
|
if (XGetWindowAttributes(disp, children[i],
|
|
|
|
|
&attrib)) {
|
|
|
|
|
if (attrib.override_redirect)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (attrib.map_state != IsUnmapped) {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FluxboxWindow *win = createWindow(children[i]);
|
2003-01-05 22:26:56 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (win) {
|
|
|
|
|
XMapRequestEvent mre;
|
|
|
|
|
mre.window = children[i];
|
2003-01-05 22:26:56 +00:00
|
|
|
|
win->mapRequestEvent(mre);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! resource.sloppy_focus) {
|
|
|
|
|
XSetInputFocus(disp, m_toolbar->getWindowID(),
|
|
|
|
|
RevertToParent, CurrentTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XFree(children);
|
|
|
|
|
XFlush(disp);
|
2002-02-08 13:35:20 +00:00
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
BScreen::~BScreen() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! managed)
|
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (geom_pixmap != None)
|
|
|
|
|
image_control->removeImage(geom_pixmap);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
removeWorkspaceNames();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Workspaces::iterator w_it = workspacesList.begin();
|
|
|
|
|
Workspaces::iterator w_it_end = workspacesList.end();
|
|
|
|
|
for(; w_it != w_it_end; ++w_it) {
|
|
|
|
|
delete (*w_it);
|
|
|
|
|
}
|
|
|
|
|
workspacesList.clear();
|
2002-05-17 16:30:24 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Icons::iterator i_it = iconList.begin();
|
|
|
|
|
Icons::iterator i_it_end = iconList.end();
|
|
|
|
|
for(; i_it != i_it_end; ++i_it) {
|
|
|
|
|
delete (*i_it);
|
|
|
|
|
}
|
|
|
|
|
iconList.clear();
|
2002-05-17 16:30:24 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator n_it = netizenList.begin();
|
|
|
|
|
Netizens::iterator n_it_end = netizenList.end();
|
|
|
|
|
for(; n_it != n_it_end; ++n_it) {
|
|
|
|
|
delete (*n_it);
|
|
|
|
|
}
|
|
|
|
|
netizenList.clear();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
delete image_control;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
delete theme;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-05 22:26:56 +00:00
|
|
|
|
/// TODO
|
|
|
|
|
unsigned int BScreen::getMaxLeft() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TODO
|
|
|
|
|
unsigned int BScreen::getMaxRight() const {
|
|
|
|
|
return getWidth();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TODO
|
|
|
|
|
unsigned int BScreen::getMaxTop() const {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/// TODO
|
|
|
|
|
unsigned int BScreen::getMaxBottom() const {
|
|
|
|
|
return getHeight();
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-25 20:58:14 +00:00
|
|
|
|
void BScreen::iconUpdate() {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
|
2002-10-25 20:58:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::reconfigure() {
|
2002-10-15 10:54:40 +00:00
|
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl;
|
2002-10-15 10:54:40 +00:00
|
|
|
|
#endif // DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Fluxbox::instance()->loadRootCommand(this);
|
|
|
|
|
theme->setRootCommand(getRootCommand());
|
2002-12-02 23:19:16 +00:00
|
|
|
|
const string &filename = Fluxbox::instance()->getStyleFilename();
|
|
|
|
|
theme->load(filename.c_str()); // old theme engine
|
|
|
|
|
FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine
|
2002-12-01 13:42:15 +00:00
|
|
|
|
theme->reconfigure(*resource.antialias);
|
2002-12-02 23:19:16 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
|
|
const char *s = i18n->getMessage(
|
2002-12-02 23:19:16 +00:00
|
|
|
|
FBNLS::ScreenSet,
|
|
|
|
|
FBNLS::ScreenPositionLength,
|
|
|
|
|
"W: 0000 x H: 0000");
|
2002-12-01 13:42:15 +00:00
|
|
|
|
int l = strlen(s);
|
|
|
|
|
|
2002-12-02 23:19:16 +00:00
|
|
|
|
//TODO: repeated from somewhere else?
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_h = m_windowtheme.font().height();
|
|
|
|
|
geom_w = m_windowtheme.font().textWidth(s, l);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
geom_w += getBevelWidth()*2;
|
|
|
|
|
geom_h += getBevelWidth()*2;
|
|
|
|
|
|
|
|
|
|
Pixmap tmp = geom_pixmap;
|
2003-02-16 01:14:54 +00:00
|
|
|
|
if (m_windowtheme.labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) {
|
|
|
|
|
if (m_windowtheme.titleFocusTexture().type() ==
|
2002-12-01 13:42:15 +00:00
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
|
geom_pixmap = None;
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.setBackgroundColor(m_windowtheme.titleFocusTexture().color());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else {
|
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2003-02-16 01:14:54 +00:00
|
|
|
|
m_windowtheme.titleFocusTexture());
|
|
|
|
|
geom_window.setBackgroundPixmap(geom_pixmap);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2003-02-16 01:14:54 +00:00
|
|
|
|
if (m_windowtheme.labelFocusTexture().type() ==
|
2002-12-01 13:42:15 +00:00
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
|
|
|
|
geom_pixmap = None;
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.setBackgroundColor(m_windowtheme.labelFocusTexture().color());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else {
|
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2003-02-16 01:14:54 +00:00
|
|
|
|
m_windowtheme.labelFocusTexture());
|
|
|
|
|
geom_window.setBackgroundPixmap(geom_pixmap);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-15 02:03:09 +00:00
|
|
|
|
if (tmp)
|
|
|
|
|
image_control->removeImage(tmp);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.setBorderWidth(theme->getBorderWidth());
|
|
|
|
|
geom_window.setBorderColor(theme->getBorderColor());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
//reconfigure menus
|
|
|
|
|
workspacemenu->reconfigure();
|
2003-01-12 17:59:20 +00:00
|
|
|
|
m_configmenu->reconfigure();
|
2002-04-28 19:54:10 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
{
|
2003-02-15 02:03:09 +00:00
|
|
|
|
//int remember_sub = m_rootmenu->currentSubmenu();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
initMenu();
|
|
|
|
|
raiseWindows(Workspace::Stack());
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->reconfigure();
|
2003-02-15 02:03:09 +00:00
|
|
|
|
//m_rootmenu->drawSubmenu(remember_sub);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
|
// m_toolbar->setPlacement(*resource.toolbar_placement);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_toolbar->reconfigure();
|
2002-12-02 23:19:16 +00:00
|
|
|
|
if (m_toolbar->theme().font().isAntialias() != *resource.antialias)
|
|
|
|
|
m_toolbar->theme().font().setAntialias(*resource.antialias);
|
2002-12-04 22:43:18 +00:00
|
|
|
|
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#ifdef SLIT
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (m_slit.get())
|
|
|
|
|
m_slit->reconfigure();
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
//reconfigure workspaces
|
|
|
|
|
Workspaces::iterator wit = workspacesList.begin();
|
|
|
|
|
Workspaces::iterator wit_end = workspacesList.end();
|
|
|
|
|
for (; wit != wit_end; ++wit) {
|
|
|
|
|
(*wit)->reconfigure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//reconfigure Icons
|
|
|
|
|
Icons::iterator iit = iconList.begin();
|
|
|
|
|
Icons::iterator iit_end = iconList.end();
|
|
|
|
|
for (; iit != iit_end; ++iit) {
|
|
|
|
|
if ((*iit)->validateClient())
|
|
|
|
|
(*iit)->reconfigure();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
image_control->timeout();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::rereadMenu() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
initMenu();
|
|
|
|
|
raiseWindows(Workspace::Stack());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::removeWorkspaceNames() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspaceNames.erase(workspaceNames.begin(), workspaceNames.end());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::updateWorkspaceNamesAtom() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_workspacenames_sig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BScreen::addIcon(FluxboxWindow *w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! w) return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
w->setWorkspace(-1);
|
|
|
|
|
w->setWindowNumber(iconList.size());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
iconList.push_back(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_toolbar->addIcon(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::removeIcon(FluxboxWindow *w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! w)
|
|
|
|
|
return;
|
2002-02-20 22:41:13 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
{
|
2002-04-04 14:28:54 +00:00
|
|
|
|
Icons::iterator it = iconList.begin();
|
2002-02-17 19:19:05 +00:00
|
|
|
|
Icons::iterator it_end = iconList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (*it == w) {
|
|
|
|
|
iconList.erase(it);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-17 19:19:05 +00:00
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
2002-02-20 22:41:13 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_toolbar->delIcon(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Icons::iterator it = iconList.begin();
|
|
|
|
|
Icons::iterator it_end = iconList.end();
|
|
|
|
|
for (int i = 0; it != it_end; ++it, ++i) {
|
|
|
|
|
(*it)->setWindowNumber(i);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
|
void BScreen::removeWindow(FluxboxWindow *win) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Workspaces::iterator it = workspacesList.begin();
|
|
|
|
|
Workspaces::iterator it_end = workspacesList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->removeWindow(win);
|
|
|
|
|
}
|
2002-09-08 19:45:59 +00:00
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
|
FluxboxWindow *BScreen::getIcon(unsigned int index) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (index < iconList.size())
|
|
|
|
|
return iconList[index];
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-15 10:54:40 +00:00
|
|
|
|
void BScreen::setAntialias(bool value) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (*resource.antialias == value)
|
|
|
|
|
return;
|
|
|
|
|
resource.antialias = value;
|
|
|
|
|
reconfigure();
|
2002-10-15 10:54:40 +00:00
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
int BScreen::addWorkspace() {
|
2003-02-03 13:56:12 +00:00
|
|
|
|
Workspace *wkspc = new Workspace(this, m_layermanager, workspacesList.size());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacesList.push_back(wkspc);
|
|
|
|
|
addWorkspaceName(wkspc->name().c_str()); // update names
|
|
|
|
|
//add workspace to workspacemenu
|
|
|
|
|
workspacemenu->insert(wkspc->name().c_str(), &wkspc->menu(),
|
|
|
|
|
wkspc->workspaceID() + 2); //+2 so we add it after "remove last"
|
2002-02-28 15:46:01 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacemenu->update();
|
|
|
|
|
saveWorkspaces(workspacesList.size());
|
|
|
|
|
m_toolbar->reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
updateNetizenWorkspaceCount();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return workspacesList.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-23 17:32:30 +00:00
|
|
|
|
/// removes last workspace
|
|
|
|
|
/// @return number of desktops left
|
2002-08-02 12:58:37 +00:00
|
|
|
|
int BScreen::removeLastWorkspace() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (workspacesList.size() <= 1)
|
|
|
|
|
return 0;
|
|
|
|
|
Workspace *wkspc = workspacesList.back();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (current_workspace->workspaceID() == wkspc->workspaceID())
|
|
|
|
|
changeWorkspaceID(current_workspace->workspaceID() - 1);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
wkspc->removeAll();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts
|
|
|
|
|
workspacemenu->update();
|
2002-10-25 20:58:14 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
//remove last workspace
|
|
|
|
|
workspacesList.pop_back();
|
|
|
|
|
delete wkspc;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_toolbar->reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
updateNetizenWorkspaceCount();
|
|
|
|
|
saveWorkspaces(workspacesList.size());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return workspacesList.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
|
void BScreen::changeWorkspaceID(unsigned int id) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! current_workspace || id >= workspacesList.size())
|
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (id != current_workspace->workspaceID()) {
|
|
|
|
|
XSync(BaseDisplay::getXDisplay(), true);
|
|
|
|
|
FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow();
|
2002-10-11 10:22:06 +00:00
|
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<__FILE__<<"("<<__FUNCTION__<<"): focused = "<<focused<<endl;
|
2002-10-11 10:22:06 +00:00
|
|
|
|
#endif // DEBUG
|
2002-08-30 14:03:31 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (focused && focused->isMoving()) {
|
|
|
|
|
reassociateGroup(focused, id, true);
|
|
|
|
|
focused->pauseMoving();
|
|
|
|
|
}
|
2002-08-30 14:03:31 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Workspace *wksp = getCurrentWorkspace();
|
|
|
|
|
Workspace::Windows wins = wksp->getWindowList();
|
|
|
|
|
Workspace::Windows::iterator it = wins.begin();
|
|
|
|
|
for (; it != wins.end(); ++it) {
|
|
|
|
|
if ((*it)->isStuck()) {
|
|
|
|
|
reassociateGroup(*it,id,true);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-12 14:55:11 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
current_workspace->hideAll();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (focused && focused->getScreen() == this &&
|
|
|
|
|
(! focused->isStuck()) && (!focused->isMoving())) {
|
|
|
|
|
current_workspace->setLastFocusedWindow(focused);
|
|
|
|
|
Fluxbox::instance()->setFocusedWindow(0); // set focused window to none
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
// set new workspace
|
|
|
|
|
current_workspace = getWorkspace(id);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true);
|
|
|
|
|
m_toolbar->redrawWorkspaceLabel(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
current_workspace->showAll();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (*resource.focus_last && current_workspace->getLastFocusedWindow() &&
|
|
|
|
|
!(focused && focused->isMoving())) {
|
|
|
|
|
current_workspace->getLastFocusedWindow()->setInputFocus();
|
2002-10-11 10:22:06 +00:00
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
|
} else if (focused && (focused->isStuck() || focused->isMoving())) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
focused->setInputFocus();
|
|
|
|
|
}
|
2002-08-30 14:03:31 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (focused && focused->isMoving()) {
|
|
|
|
|
focused->resumeMoving();
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
updateNetizenCurrentWorkspace();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-26 22:25:53 +00:00
|
|
|
|
|
2002-07-23 13:47:05 +00:00
|
|
|
|
void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! current_workspace || id >= workspacesList.size())
|
|
|
|
|
return;
|
2002-02-26 22:25:53 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (!win)
|
|
|
|
|
win = Fluxbox::instance()->getFocusedWindow();
|
2002-07-23 13:47:05 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (id != current_workspace->workspaceID()) {
|
|
|
|
|
XSync(BaseDisplay::getXDisplay(), True);
|
2002-02-26 22:25:53 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (win && win->getScreen() == this &&
|
|
|
|
|
(! win->isStuck())) {
|
2002-02-26 22:25:53 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if ( win->getTab() ) {
|
|
|
|
|
Tab *tab = win->getTab();
|
|
|
|
|
tab->disconnect();
|
|
|
|
|
tab->setPosition();
|
|
|
|
|
}
|
2002-02-26 22:25:53 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (win->isIconic()) {
|
|
|
|
|
win->deiconify();
|
|
|
|
|
}
|
2002-09-10 10:59:57 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
win->withdraw();
|
|
|
|
|
reassociateWindow(win, id, true);
|
2002-10-11 10:22:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
// change workspace ?
|
|
|
|
|
if (changeWS) {
|
|
|
|
|
changeWorkspaceID(id);
|
|
|
|
|
win->setInputFocus();
|
|
|
|
|
}
|
2002-10-11 10:22:06 +00:00
|
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Sending to id = "<<id<<endl;
|
|
|
|
|
cerr<<"win->workspaceId="<<win->getWorkspaceNumber()<<endl;
|
2002-10-11 10:22:06 +00:00
|
|
|
|
#endif //DEBUG
|
2002-02-26 22:25:53 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
2002-10-11 10:22:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
2002-02-26 22:25:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
void BScreen::addNetizen(Netizen *n) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
netizenList.push_back(n);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
n->sendWorkspaceCount();
|
|
|
|
|
n->sendCurrentWorkspace();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Workspaces::iterator it = workspacesList.begin();
|
|
|
|
|
Workspaces::iterator it_end = workspacesList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
for (int i = 0; i < (*it)->getCount(); ++i) {
|
|
|
|
|
n->sendWindowAdd((*it)->getWindow(i)->getClientWindow(),
|
|
|
|
|
(*it)->workspaceID());
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Window f = ((Fluxbox::instance()->getFocusedWindow()) ?
|
2002-10-25 20:58:14 +00:00
|
|
|
|
Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
n->sendWindowFocus(f);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BScreen::removeNetizen(Window w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
if ((*it)->getWindowID() == w) {
|
|
|
|
|
Netizen *n = *it;
|
|
|
|
|
delete n;
|
|
|
|
|
netizenList.erase(it);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::updateNetizenCurrentWorkspace() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_currentworkspace_sig.notify();
|
2002-02-04 07:01:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendCurrentWorkspace();
|
|
|
|
|
}
|
2002-02-04 07:01:06 +00:00
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::updateNetizenWorkspaceCount() {
|
2002-02-04 07:01:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendWorkspaceCount();
|
|
|
|
|
}
|
2002-09-07 20:22:08 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_workspacecount_sig.notify();
|
2002-02-04 07:01:06 +00:00
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::updateNetizenWindowFocus() {
|
2002-02-08 13:35:20 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
Window f = ((Fluxbox::instance()->getFocusedWindow()) ?
|
|
|
|
|
Fluxbox::instance()->getFocusedWindow()->getClientWindow() : None);
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendWindowFocus(f);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendWindowAdd(w, p);
|
|
|
|
|
}
|
2002-09-07 20:22:08 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_clientlist_sig.notify();
|
2002-02-20 22:41:13 +00:00
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowDel(Window w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendWindowDel(w);
|
|
|
|
|
}
|
2002-09-07 20:22:08 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
m_clientlist_sig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowRaise(Window w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendWindowRaise(w);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowLower(Window w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendWindowLower(w);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenConfigNotify(XEvent *e) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->sendConfigNotify(e);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-05 22:26:56 +00:00
|
|
|
|
FluxboxWindow *BScreen::createWindow(Window client) {
|
2003-01-07 02:06:06 +00:00
|
|
|
|
FluxboxWindow *win = new FluxboxWindow(client, this, getScreenNumber(), *getImageControl(),
|
2003-02-03 13:56:12 +00:00
|
|
|
|
winFrameTheme(), *menuTheme(),
|
2003-02-09 14:11:14 +00:00
|
|
|
|
*layerManager().getLayer(Fluxbox::instance()->getNormalLayer()));
|
2003-01-05 22:26:56 +00:00
|
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
|
if (win->initialState() == WithdrawnState)
|
|
|
|
|
getSlit()->addClient(win->getClientWindow());
|
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
|
|
if (!win->isManaged()) {
|
|
|
|
|
delete win;
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
Fluxbox::instance()->saveWindowSearch(client, win);
|
|
|
|
|
Fluxbox::instance()->attachSignals(*win);
|
|
|
|
|
setupWindowActions(*win);
|
|
|
|
|
}
|
|
|
|
|
return win;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BScreen::setupWindowActions(FluxboxWindow &win) {
|
|
|
|
|
|
|
|
|
|
FbWinFrame &frame = win.frame();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef FbTk::RefCount<FbTk::Command> CommandRef;
|
|
|
|
|
|
|
|
|
|
using namespace FbTk;
|
2003-01-07 02:06:06 +00:00
|
|
|
|
typedef RefCount<Command> CommandRef;
|
|
|
|
|
typedef SimpleCommand<FluxboxWindow> WindowCmd;
|
|
|
|
|
|
|
|
|
|
CommandRef iconify_cmd(new WindowCmd(win, &FluxboxWindow::iconify));
|
|
|
|
|
CommandRef maximize_cmd(new WindowCmd(win, &FluxboxWindow::maximize));
|
|
|
|
|
CommandRef maximize_vert_cmd(new WindowCmd(win, &FluxboxWindow::maximizeVertical));
|
|
|
|
|
CommandRef maximize_horiz_cmd(new WindowCmd(win, &FluxboxWindow::maximizeHorizontal));
|
|
|
|
|
CommandRef close_cmd(new WindowCmd(win, &FluxboxWindow::close));
|
|
|
|
|
CommandRef shade_cmd(new WindowCmd(win, &FluxboxWindow::shade));
|
|
|
|
|
CommandRef raise_cmd(new WindowCmd(win, &FluxboxWindow::raise));
|
2003-02-16 15:12:08 +00:00
|
|
|
|
CommandRef lower_cmd(new WindowCmd(win, &FluxboxWindow::lower));
|
2003-01-07 02:06:06 +00:00
|
|
|
|
CommandRef stick_cmd(new WindowCmd(win, &FluxboxWindow::stick));
|
|
|
|
|
CommandRef show_menu_cmd(new WindowCmd(win, &FluxboxWindow::popupMenu));
|
|
|
|
|
|
|
|
|
|
// clear old buttons from frame
|
|
|
|
|
frame.removeAllButtons();
|
2003-02-16 13:55:49 +00:00
|
|
|
|
//!! TODO: fix this ugly hack
|
|
|
|
|
// get titlebar configuration
|
|
|
|
|
const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft();
|
|
|
|
|
for (char c=0; c<2; c++) {
|
2003-02-16 15:12:08 +00:00
|
|
|
|
for (unsigned int i=0; i< dir->size(); ++i) {
|
2003-02-16 13:55:49 +00:00
|
|
|
|
//create new buttons
|
|
|
|
|
FbTk::Button *newbutton = 0;
|
|
|
|
|
if (win.isIconifiable() && (*dir)[i] == Fluxbox::MINIMIZE) {
|
|
|
|
|
newbutton = new WinButton(WinButton::MINIMIZE,
|
|
|
|
|
frame.titlebar(),
|
|
|
|
|
0, 0, 10, 10);
|
|
|
|
|
newbutton->setOnClick(iconify_cmd);
|
2003-01-05 22:26:56 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2003-02-16 13:55:49 +00:00
|
|
|
|
cerr<<__FILE__<<": Creating iconify button"<<endl;
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#endif //DEBUG
|
2003-02-16 13:55:49 +00:00
|
|
|
|
} else if (win.isMaximizable() && (*dir)[i] == Fluxbox::MAXIMIZE) {
|
|
|
|
|
newbutton = new WinButton(WinButton::MAXIMIZE,
|
|
|
|
|
frame.titlebar(),
|
|
|
|
|
0, 0, 10, 10);
|
2003-01-05 22:26:56 +00:00
|
|
|
|
|
2003-02-16 13:55:49 +00:00
|
|
|
|
newbutton->setOnClick(maximize_cmd, 1);
|
|
|
|
|
newbutton->setOnClick(maximize_horiz_cmd, 3);
|
|
|
|
|
newbutton->setOnClick(maximize_vert_cmd, 2);
|
2003-01-05 22:26:56 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2003-02-16 13:55:49 +00:00
|
|
|
|
cerr<<__FILE__<<":Creating maximize button"<<endl;
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#endif // DEBUG
|
2003-02-16 13:55:49 +00:00
|
|
|
|
} else if (win.isClosable() && (*dir)[i] == Fluxbox::CLOSE) {
|
|
|
|
|
newbutton = new WinButton(WinButton::CLOSE,
|
|
|
|
|
frame.titlebar(),
|
|
|
|
|
0, 0, 10, 10);
|
2003-01-07 02:06:06 +00:00
|
|
|
|
|
2003-02-16 13:55:49 +00:00
|
|
|
|
newbutton->setOnClick(close_cmd);
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#ifdef DEBUG
|
2003-02-16 13:55:49 +00:00
|
|
|
|
cerr<<__FILE__<<": Creating close button"<<endl;
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#endif // DEBUG
|
2003-02-16 13:55:49 +00:00
|
|
|
|
} else if ((*dir)[i] == Fluxbox::STICK) {
|
|
|
|
|
newbutton = new WinButton(WinButton::STICK,
|
|
|
|
|
frame.titlebar(),
|
|
|
|
|
0, 0, 10, 10);
|
|
|
|
|
newbutton->setOnClick(stick_cmd);
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
cerr<<__FILE__<<": Creating stick button"<<endl;
|
|
|
|
|
#endif // DEBUG
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newbutton != 0) {
|
|
|
|
|
newbutton->show();
|
|
|
|
|
if (c == 0)
|
|
|
|
|
frame.addLeftButton(newbutton);
|
|
|
|
|
else
|
|
|
|
|
frame.addRightButton(newbutton);
|
|
|
|
|
}
|
|
|
|
|
} //end for i
|
|
|
|
|
dir = &Fluxbox::instance()->getTitlebarRight();
|
|
|
|
|
} // end for c
|
|
|
|
|
|
2003-01-07 02:06:06 +00:00
|
|
|
|
// setup titlebar
|
|
|
|
|
frame.setOnClickTitlebar(raise_cmd, 1, false, true); // on press with button 1
|
|
|
|
|
frame.setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1
|
|
|
|
|
frame.setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3
|
2003-02-16 15:12:08 +00:00
|
|
|
|
frame.setOnClickTitlebar(lower_cmd, 2, false, true); // on press with button 2
|
2003-01-07 02:06:06 +00:00
|
|
|
|
frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
|
|
|
|
|
// setup menu
|
|
|
|
|
FbTk::Menu &menu = win.getWindowmenu();
|
|
|
|
|
menu.removeAll(); // clear old items
|
2003-02-15 02:03:09 +00:00
|
|
|
|
menu.disableTitle(); // not titlebar
|
2003-01-07 02:06:06 +00:00
|
|
|
|
|
2003-02-16 15:12:08 +00:00
|
|
|
|
// check and setup layer menu
|
|
|
|
|
FbTk::Menu &layer_menu = win.getLayermenu();
|
|
|
|
|
// if it hasn't already been setup (no need to reset it)
|
|
|
|
|
if (layer_menu.numberOfItems() == 0) {
|
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
struct {
|
|
|
|
|
int set;
|
|
|
|
|
int base;
|
|
|
|
|
const char *default_str;
|
|
|
|
|
int layernum;
|
|
|
|
|
} layer_menuitems[] = {
|
|
|
|
|
//TODO: nls
|
|
|
|
|
{0, 0, "Above Slit", fluxbox->getAboveSlitLayer()},
|
|
|
|
|
{0, 0, "Slit", fluxbox->getSlitLayer()},
|
|
|
|
|
{0, 0, "Top", fluxbox->getTopLayer()},
|
|
|
|
|
{0, 0, "Normal", fluxbox->getNormalLayer()},
|
|
|
|
|
{0, 0, "Bottom", fluxbox->getBottomLayer()},
|
|
|
|
|
{0, 0, "Desktop", fluxbox->getDesktopLayer()},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (size_t i=0; i < 6; ++i) {
|
|
|
|
|
// TODO: fetch nls string
|
|
|
|
|
layer_menu.insert(new WindowLayerMenuItem(layer_menuitems[i].default_str,
|
|
|
|
|
win, layer_menuitems[i].layernum));
|
|
|
|
|
};
|
|
|
|
|
layer_menu.update();
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-07 02:06:06 +00:00
|
|
|
|
// set new menu items
|
|
|
|
|
menu.insert("Shade", shade_cmd);
|
|
|
|
|
menu.insert("Stick", stick_cmd);
|
|
|
|
|
menu.insert("Maximize", maximize_cmd);
|
|
|
|
|
menu.insert("Maximize Vertical", maximize_vert_cmd);
|
|
|
|
|
menu.insert("Maximize Horizontal", maximize_horiz_cmd);
|
|
|
|
|
menu.insert("Iconify", iconify_cmd);
|
|
|
|
|
menu.insert("Raise", raise_cmd);
|
|
|
|
|
menu.insert("Lower", lower_cmd);
|
2003-02-16 15:12:08 +00:00
|
|
|
|
menu.insert("Layer...", &layer_menu);
|
2003-01-07 02:06:06 +00:00
|
|
|
|
menu.insert("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
menu.insert("Close", close_cmd);
|
|
|
|
|
|
|
|
|
|
menu.reconfigure(); // update graphics
|
|
|
|
|
|
2003-01-05 22:26:56 +00:00
|
|
|
|
}
|
2002-09-08 19:45:59 +00:00
|
|
|
|
void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
|
// TODO: I don't think we need this...
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
cerr<<"BScreen::raiseWindows() called"<<endl;
|
|
|
|
|
#endif //DEBUG
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)];
|
|
|
|
|
int i = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Workspaces::iterator wit = workspacesList.begin();
|
|
|
|
|
Workspaces::iterator wit_end = workspacesList.end();
|
|
|
|
|
for (; wit != wit_end; ++wit) {
|
|
|
|
|
session_stack[i++] = (*wit)->menu().windowID();
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
session_stack[i++] = workspacemenu->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Rootmenus::iterator rit = rootmenuList.begin();
|
|
|
|
|
Rootmenus::iterator rit_end = rootmenuList.end();
|
|
|
|
|
for (; rit != rit_end; ++rit) {
|
|
|
|
|
session_stack[i++] = (*rit)->windowID();
|
|
|
|
|
}
|
2002-12-13 20:19:05 +00:00
|
|
|
|
session_stack[i++] = m_rootmenu->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (m_toolbar->isOnTop())
|
|
|
|
|
session_stack[i++] = m_toolbar->getWindowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-11-24 20:56:06 +00:00
|
|
|
|
#ifdef SLIT
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (m_slit->isOnTop())
|
|
|
|
|
session_stack[i++] = m_slit->getWindowID();
|
2002-11-12 22:58:40 +00:00
|
|
|
|
#endif // SLIT
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (!workspace_stack.empty()) {
|
|
|
|
|
Workspace::Stack::const_reverse_iterator it = workspace_stack.rbegin();
|
|
|
|
|
Workspace::Stack::const_reverse_iterator it_end = workspace_stack.rend();
|
|
|
|
|
for (; it != it_end; ++it)
|
|
|
|
|
session_stack[i++] = (*it);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i);
|
2003-02-02 16:32:41 +00:00
|
|
|
|
*/
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-17 11:02:30 +00:00
|
|
|
|
void BScreen::saveStrftimeFormat(const char *format) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
//make sure std::string don't get 0 string
|
|
|
|
|
resource.strftime_format = (format ? format : "");
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-23 17:11:59 +00:00
|
|
|
|
void BScreen::addWorkspaceName(const char *name) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
workspaceNames.push_back(name);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-11 22:28:18 +00:00
|
|
|
|
string BScreen::getNameOfWorkspace(unsigned int workspace) const {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (workspace < workspaceNames.size()) {
|
|
|
|
|
return workspaceNames[workspace];
|
|
|
|
|
} else {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-30 14:03:31 +00:00
|
|
|
|
void BScreen::reassociateGroup(FluxboxWindow *w, unsigned int wkspc_id, bool ignore_sticky) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (w->hasTab() && (w->getTab()->next() || w->getTab()->prev())) {
|
|
|
|
|
Tab *tab_it = w->getTab()->first();
|
|
|
|
|
for (; tab_it; tab_it = tab_it->next()) {
|
|
|
|
|
reassociateWindow(tab_it->getWindow(), wkspc_id, ignore_sticky);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// no tab, juts move this one
|
|
|
|
|
reassociateWindow(w, wkspc_id, ignore_sticky);
|
|
|
|
|
}
|
2002-08-30 14:03:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
|
void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ignore_sticky) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! w) return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (wkspc_id >= getCount()) {
|
|
|
|
|
wkspc_id = current_workspace->workspaceID();
|
2002-10-11 10:22:06 +00:00
|
|
|
|
#ifdef DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): wkspc_id >= getCount()"<<endl;
|
2002-10-11 10:22:06 +00:00
|
|
|
|
#endif // DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (w->getWorkspaceNumber() == wkspc_id)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (w->isIconic()) {
|
|
|
|
|
removeIcon(w);
|
|
|
|
|
getWorkspace(wkspc_id)->addWindow(w);
|
|
|
|
|
} else if (ignore_sticky || ! w->isStuck()) {
|
|
|
|
|
getWorkspace(w->getWorkspaceNumber())->removeWindow(w);
|
|
|
|
|
getWorkspace(wkspc_id)->addWindow(w);
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-18 20:20:09 +00:00
|
|
|
|
void BScreen::nextFocus(int opts) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
bool have_focused = false;
|
|
|
|
|
int focused_window_number = -1;
|
|
|
|
|
FluxboxWindow *focused = Fluxbox::instance()->getFocusedWindow();
|
|
|
|
|
const int num_windows = getCurrentWorkspace()->getCount();
|
|
|
|
|
|
|
|
|
|
if (focused != 0) {
|
|
|
|
|
if (focused->getScreen()->getScreenNumber() ==
|
|
|
|
|
getScreenNumber()) {
|
|
|
|
|
have_focused = true;
|
|
|
|
|
focused_window_number = focused->getWindowNumber();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_windows >= 1) {
|
|
|
|
|
Workspace *wksp = getCurrentWorkspace();
|
|
|
|
|
Workspace::Windows &wins = wksp->getWindowList();
|
|
|
|
|
Workspace::Windows::iterator it = wins.begin();
|
|
|
|
|
|
|
|
|
|
if (!have_focused) {
|
|
|
|
|
focused = *it;
|
|
|
|
|
} else {
|
|
|
|
|
for (; *it != focused; ++it) //get focused window iterator
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
do {
|
|
|
|
|
++it;
|
|
|
|
|
if (it == wins.end())
|
|
|
|
|
it = wins.begin();
|
|
|
|
|
// see if the window should be skipped
|
|
|
|
|
if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) )
|
|
|
|
|
break;
|
|
|
|
|
} while (*it != focused);
|
|
|
|
|
|
|
|
|
|
if (*it != focused && it != wins.end())
|
2003-02-09 14:11:14 +00:00
|
|
|
|
(*it)->raise();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
}
|
2002-04-02 23:14:54 +00:00
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-18 20:20:09 +00:00
|
|
|
|
void BScreen::prevFocus(int opts) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
bool have_focused = false;
|
|
|
|
|
int focused_window_number = -1;
|
|
|
|
|
FluxboxWindow *focused;
|
|
|
|
|
int num_windows = getCurrentWorkspace()->getCount();
|
2002-04-02 23:14:54 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if ((focused = Fluxbox::instance()->getFocusedWindow())) {
|
|
|
|
|
if (focused->getScreen()->getScreenNumber() ==
|
|
|
|
|
getScreenNumber()) {
|
|
|
|
|
have_focused = true;
|
|
|
|
|
focused_window_number = focused->getWindowNumber();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_windows >= 1) {
|
|
|
|
|
Workspace *wksp = getCurrentWorkspace();
|
|
|
|
|
Workspace::Windows &wins = wksp->getWindowList();
|
|
|
|
|
Workspace::Windows::iterator it = wins.begin();
|
|
|
|
|
|
|
|
|
|
if (!have_focused) {
|
|
|
|
|
focused = *it;
|
|
|
|
|
} else {
|
|
|
|
|
for (; *it != focused; ++it) //get focused window iterator
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2002-09-12 14:55:11 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
do {
|
|
|
|
|
if (it == wins.begin())
|
|
|
|
|
it = wins.end();
|
|
|
|
|
--it;
|
|
|
|
|
// see if the window should be skipped
|
|
|
|
|
if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) )
|
|
|
|
|
break;
|
|
|
|
|
} while (*it != focused);
|
|
|
|
|
|
|
|
|
|
if (*it != focused && it != wins.end())
|
2003-02-09 14:11:14 +00:00
|
|
|
|
(*it)->raise();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::raiseFocus() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
bool have_focused = false;
|
|
|
|
|
int focused_window_number = -1;
|
|
|
|
|
Fluxbox * const fb = Fluxbox::instance();
|
2002-10-25 20:58:14 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (fb->getFocusedWindow())
|
|
|
|
|
if (fb->getFocusedWindow()->getScreen()->getScreenNumber() ==
|
|
|
|
|
getScreenNumber()) {
|
|
|
|
|
have_focused = true;
|
|
|
|
|
focused_window_number = fb->getFocusedWindow()->getWindowNumber();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((getCurrentWorkspace()->getCount() > 1) && have_focused)
|
2003-02-09 14:11:14 +00:00
|
|
|
|
fb->getFocusedWindow()->raise();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::initMenu() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
I18n *i18n = I18n::instance();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-13 20:19:05 +00:00
|
|
|
|
if (m_rootmenu.get()) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
rootmenuList.erase(rootmenuList.begin(), rootmenuList.end());
|
|
|
|
|
|
2002-12-13 20:19:05 +00:00
|
|
|
|
while (m_rootmenu->numberOfItems())
|
|
|
|
|
m_rootmenu->remove(0);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else
|
2003-01-12 17:59:20 +00:00
|
|
|
|
m_rootmenu.reset(createMenuFromScreen(*this));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
bool defaultMenu = true;
|
|
|
|
|
Fluxbox * const fb = Fluxbox::instance();
|
|
|
|
|
if (fb->getMenuFilename()) {
|
|
|
|
|
ifstream menu_file(fb->getMenuFilename());
|
|
|
|
|
|
|
|
|
|
if (!menu_file.fail()) {
|
|
|
|
|
if (! menu_file.eof()) {
|
|
|
|
|
string line;
|
|
|
|
|
int row = 0;
|
|
|
|
|
while (getline(menu_file, line) && ! menu_file.eof()) {
|
|
|
|
|
row++;
|
|
|
|
|
if (line[0] != '#') {
|
|
|
|
|
string key;
|
|
|
|
|
int pos=0;
|
|
|
|
|
int err = StringUtil::getStringBetween(key, line.c_str(), '[', ']');
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (key == "begin") {
|
|
|
|
|
pos += err;
|
|
|
|
|
string label;
|
|
|
|
|
err = StringUtil::getStringBetween(label, line.c_str()+pos, '(', ')');
|
|
|
|
|
if (err>0) {
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->setLabel(label.c_str());
|
2003-01-09 17:41:02 +00:00
|
|
|
|
defaultMenu = parseMenuFile(menu_file, *m_rootmenu.get(), row);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else
|
|
|
|
|
cerr<<"Error in menufile. Line("<<row<<")"<<endl;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile,
|
|
|
|
|
"%s: Empty menu file"),
|
2002-12-01 13:42:15 +00:00
|
|
|
|
fb->getMenuFilename());
|
|
|
|
|
}
|
|
|
|
|
menu_file.close();
|
|
|
|
|
} else
|
|
|
|
|
perror(fb->getMenuFilename());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (defaultMenu) {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FbTk::RefCount<FbTk::Command> restart_fb(new FbCommands::RestartFluxboxCmd());
|
|
|
|
|
FbTk::RefCount<FbTk::Command> exit_fb(new FbCommands::ExitFluxboxCmd());
|
|
|
|
|
FbTk::RefCount<FbTk::Command> execute_xterm(new FbCommands::ExecuteCmd("xterm"));
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->setInternalMenu();
|
|
|
|
|
m_rootmenu->insert(i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::Screenxterm,
|
|
|
|
|
"xterm"),
|
|
|
|
|
execute_xterm);
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->insert(i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenRestart,
|
|
|
|
|
"Restart"),
|
|
|
|
|
restart_fb);
|
2002-12-13 20:19:05 +00:00
|
|
|
|
m_rootmenu->insert(i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenExit,
|
|
|
|
|
"Exit"),
|
|
|
|
|
exit_fb);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else
|
|
|
|
|
fb->saveMenuFilename(fb->getMenuFilename());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
/// looks through a menufile and adds correct items to the root-menu.
|
2003-01-09 17:41:02 +00:00
|
|
|
|
bool BScreen::parseMenuFile(ifstream &file, FbTk::Menu &menu, int &row) {
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
string line;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
while (! file.eof()) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (getline(file, line)) {
|
|
|
|
|
row++;
|
|
|
|
|
if (line[0] != '#') { //the line is commented
|
|
|
|
|
int parse_pos = 0, err = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
std::string str_key, str_label, str_cmd;
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
err = StringUtil::getStringBetween(str_key, line.c_str(), '[', ']');
|
|
|
|
|
if (err > 0 ) {
|
|
|
|
|
parse_pos += err;
|
|
|
|
|
err = StringUtil::getStringBetween(str_label, line.c_str() + parse_pos, '(', ')');
|
|
|
|
|
if (err>0) {
|
|
|
|
|
parse_pos += err;
|
|
|
|
|
StringUtil::getStringBetween(str_cmd, line.c_str() + parse_pos, '{', '}');
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
continue; //read next line
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (!str_key.size())
|
|
|
|
|
continue; //read next line
|
|
|
|
|
|
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
if (str_key == "end") {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
return ((menu.numberOfItems() == 0) ? true : false);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else if (str_key == "nop") {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
menu.insert(str_label.c_str());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else if (str_key == "exec") { // exec
|
|
|
|
|
if (!(str_label.size() && str_cmd.size())) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenEXECError,
|
|
|
|
|
"BScreen::parseMenuFile: [exec] error, "
|
|
|
|
|
"no menu label and/or command defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
2003-01-09 17:41:02 +00:00
|
|
|
|
} else {
|
|
|
|
|
FbTk::RefCount<FbTk::Command> exec_cmd(new FbCommands::ExecuteCmd(str_cmd));
|
|
|
|
|
menu.insert(str_label.c_str(), exec_cmd);
|
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} else if (str_key == "exit") { // exit
|
|
|
|
|
if (!str_label.size()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenEXITError,
|
|
|
|
|
"BScreen::parseMenuFile: [exit] error, "
|
|
|
|
|
"no menu label defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FbTk::RefCount<FbTk::Command> exit_fb_cmd(new FbCommands::ExitFluxboxCmd());
|
|
|
|
|
menu.insert(str_label.c_str(), exit_fb_cmd);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
2003-02-15 02:03:09 +00:00
|
|
|
|
} else if (str_key == "style") { // style
|
|
|
|
|
if (!( str_label.size() && str_cmd.size())) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLEError,
|
|
|
|
|
"BScreen::parseMenuFile: [style] error, "
|
|
|
|
|
"no menu label and/or filename defined\n"));
|
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else {
|
|
|
|
|
// perform shell style ~ home directory expansion
|
|
|
|
|
// and insert style
|
|
|
|
|
FbTk::RefCount<FbTk::Command>
|
|
|
|
|
setstyle_cmd(new FbCommands::
|
|
|
|
|
SetStyleCmd(StringUtil::
|
|
|
|
|
expandFilename(str_cmd)));
|
|
|
|
|
menu.insert(str_label.c_str(), setstyle_cmd);
|
2003-01-09 17:41:02 +00:00
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (str_key == "config") {
|
2003-01-12 17:59:20 +00:00
|
|
|
|
if (! str_label.size()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenCONFIGError,
|
|
|
|
|
"BScreen::parseMenufile: [config] error, "
|
|
|
|
|
"no label defined"));
|
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else {
|
|
|
|
|
cerr<<"inserts configmenu: "<<m_configmenu.get()<<endl;
|
|
|
|
|
menu.insert(str_label.c_str(), m_configmenu.get());
|
|
|
|
|
}
|
|
|
|
|
} // end of config
|
2002-12-01 13:42:15 +00:00
|
|
|
|
else if ( str_key == "include") { // include
|
|
|
|
|
if (!str_label.size()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenINCLUDEError,
|
|
|
|
|
"BScreen::parseMenuFile: [include] error, "
|
|
|
|
|
"no filename defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else { // start of else 'x'
|
|
|
|
|
// perform shell style ~ home directory expansion
|
|
|
|
|
string newfile(StringUtil::expandFilename(str_label));
|
|
|
|
|
|
|
|
|
|
if (newfile.size() != 0) {
|
|
|
|
|
FILE *submenufile = fopen(newfile.c_str(), "r");
|
|
|
|
|
|
|
|
|
|
if (submenufile) {
|
|
|
|
|
struct stat buf;
|
|
|
|
|
if (fstat(fileno(submenufile), &buf) ||
|
|
|
|
|
(! S_ISREG(buf.st_mode))) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2003-02-15 02:03:09 +00:00
|
|
|
|
FBNLS::ScreenSet,
|
|
|
|
|
FBNLS::ScreenINCLUDEErrorReg,
|
2003-01-09 17:41:02 +00:00
|
|
|
|
"BScreen::parseMenuFile: [include] error: "
|
2003-02-15 02:03:09 +00:00
|
|
|
|
"'%s' is not a regular file\n"),
|
|
|
|
|
newfile.c_str());
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
}
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! feof(submenufile)) {
|
|
|
|
|
fclose(submenufile);
|
|
|
|
|
ifstream subfile(newfile.c_str());
|
|
|
|
|
if (! parseMenuFile(subfile, menu, row))
|
|
|
|
|
Fluxbox::instance()->saveMenuFilename(newfile.c_str());
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
perror(newfile.c_str());
|
|
|
|
|
}
|
|
|
|
|
} // end of else 'x'
|
|
|
|
|
} // end of include
|
|
|
|
|
else if (str_key == "submenu") { // sub
|
|
|
|
|
if (!str_label.size()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSUBMENUError,
|
|
|
|
|
"BScreen::parseMenuFile: [submenu] error, "
|
|
|
|
|
"no menu label defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FbTk::Menu *submenu = createMenuFromScreen(*this);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
if (str_cmd.size())
|
|
|
|
|
submenu->setLabel(str_cmd.c_str());
|
|
|
|
|
else
|
|
|
|
|
submenu->setLabel(str_label.c_str());
|
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
|
parseMenuFile(file, *submenu, row);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
submenu->update();
|
2003-01-09 17:41:02 +00:00
|
|
|
|
menu.insert(str_label.c_str(), submenu);
|
2003-01-12 17:59:20 +00:00
|
|
|
|
// save to list so we can delete it later
|
2002-12-01 13:42:15 +00:00
|
|
|
|
rootmenuList.push_back(submenu);
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
} // end of sub
|
|
|
|
|
else if (str_key == "restart") {
|
|
|
|
|
if (!str_label.size()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenRESTARTError,
|
|
|
|
|
"BScreen::parseMenuFile: [restart] error, "
|
|
|
|
|
"no menu label defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else {
|
2003-01-09 17:41:02 +00:00
|
|
|
|
/* if (str_cmd.size())
|
|
|
|
|
menu.insert(str_label.c_str(), BScreen::RESTARTOTHER, str_cmd.c_str());
|
|
|
|
|
else
|
|
|
|
|
*/
|
|
|
|
|
FbTk::RefCount<FbTk::Command> restart_fb(new FbCommands::RestartFluxboxCmd());
|
|
|
|
|
menu.insert(str_label.c_str(), restart_fb);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
} // end of restart
|
|
|
|
|
else if (str_key == "reconfig") { // reconf
|
|
|
|
|
if (!str_label.c_str()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenRECONFIGError,
|
|
|
|
|
"BScreen::parseMenuFile: [reconfig] error, "
|
|
|
|
|
"no menu label defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
2003-01-09 17:41:02 +00:00
|
|
|
|
} else {
|
|
|
|
|
FbTk::RefCount<FbTk::Command> reconfig_fb_cmd(new FbCommands::ReconfigureFluxboxCmd());
|
|
|
|
|
menu.insert(str_label.c_str(), reconfig_fb_cmd);
|
|
|
|
|
}
|
2003-02-15 02:03:09 +00:00
|
|
|
|
} else if (str_key == "stylesdir" || str_key == "stylesmenu") {
|
|
|
|
|
|
|
|
|
|
bool newmenu = (str_key == "stylesmenu");
|
|
|
|
|
|
|
|
|
|
if (!( str_label.size() && str_cmd.size()) && newmenu) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRError,
|
|
|
|
|
"BScreen::parseMenuFile: [stylesdir/stylesmenu]"
|
|
|
|
|
" error, no directory defined\n"));
|
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else {
|
|
|
|
|
createStyleMenu(menu, newmenu, str_label.c_str(),
|
|
|
|
|
(newmenu) ? str_cmd.c_str() : str_label.c_str());
|
|
|
|
|
}
|
|
|
|
|
} // end of stylesdir
|
2002-12-01 13:42:15 +00:00
|
|
|
|
else if (str_key == "workspaces") {
|
|
|
|
|
if (!str_label.size()) {
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->getMessage(
|
2003-01-09 17:41:02 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenWORKSPACESError,
|
|
|
|
|
"BScreen:parseMenuFile: [workspaces] error, "
|
|
|
|
|
"no menu label defined\n"));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
|
} else
|
2003-01-09 17:41:02 +00:00
|
|
|
|
menu.insert(str_label.c_str(), workspacemenu.get());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
} // end of work
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-09 17:41:02 +00:00
|
|
|
|
return ((menu.numberOfItems() == 0) ? true : false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
|
void BScreen::setupConfigmenu(FbTk::Menu &menu) {
|
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
using namespace FBNLS;
|
|
|
|
|
|
|
|
|
|
FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
|
2003-02-15 02:03:09 +00:00
|
|
|
|
FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(),
|
|
|
|
|
&Fluxbox::save_rc));
|
2003-01-12 17:59:20 +00:00
|
|
|
|
FbTk::RefCount<FbTk::Command> reconf_cmd(new FbCommands::ReconfigureFluxboxCmd());
|
|
|
|
|
s_a_reconf_macro->add(saverc_cmd);
|
|
|
|
|
s_a_reconf_macro->add(reconf_cmd);
|
|
|
|
|
FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro);
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
|
#ifdef SLIT
|
|
|
|
|
if (getSlit() != 0)
|
|
|
|
|
menu.insert("Slit", &getSlit()->menu());
|
|
|
|
|
#endif // SLIT
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
|
menu.insert(i18n->getMessage(
|
|
|
|
|
ToolbarSet, ToolbarToolbarTitle,
|
|
|
|
|
"Toolbar"), &m_toolbar->menu());
|
|
|
|
|
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuImageDithering,
|
|
|
|
|
"Image Dithering"),
|
|
|
|
|
*resource.image_dither, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(
|
|
|
|
|
i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuOpaqueMove,
|
|
|
|
|
"Opaque Window Moving"),
|
|
|
|
|
*resource.opaque_move, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuFullMax,
|
|
|
|
|
"Full Maximization"),
|
|
|
|
|
*resource.full_max, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuFocusNew,
|
|
|
|
|
"Focus New Windows"),
|
|
|
|
|
*resource.focus_new, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuFocusLast,
|
|
|
|
|
"Focus Last Window on Workspace"),
|
|
|
|
|
*resource.focus_last, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuMaxOverSlit,
|
|
|
|
|
"Maximize Over Slit"),
|
|
|
|
|
*resource.max_over_slit, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuWorkspaceWarping,
|
|
|
|
|
"Workspace Warping"),
|
|
|
|
|
*resource.workspace_warping, save_and_reconfigure));
|
|
|
|
|
menu.insert(new
|
|
|
|
|
BoolMenuItem(i18n->getMessage(
|
|
|
|
|
ConfigmenuSet, ConfigmenuDesktopWheeling,
|
|
|
|
|
"Desktop MouseWheel Switching"),
|
|
|
|
|
*resource.desktop_wheeling, save_and_reconfigure));
|
|
|
|
|
menu.insert(new BoolMenuItem("antialias", *resource.antialias, save_and_reconfigure));
|
|
|
|
|
// finaly update menu
|
|
|
|
|
menu.update();
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
void BScreen::createStyleMenu(FbTk::Menu &menu, bool newmenu,
|
|
|
|
|
const char *label, const char *directory) {
|
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
// perform shell style ~ home directory expansion
|
|
|
|
|
string stylesdir(StringUtil::expandFilename(directory ? directory : ""));
|
2002-08-14 22:21:06 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
struct stat statbuf;
|
2002-02-17 18:56:14 +00:00
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
if (! stat(stylesdir.c_str(), &statbuf)) {
|
|
|
|
|
if (S_ISDIR(statbuf.st_mode)) { // is a directory?
|
2002-02-17 18:56:14 +00:00
|
|
|
|
|
2002-12-02 23:19:16 +00:00
|
|
|
|
DirHelper d(stylesdir.c_str());
|
2003-02-15 02:03:09 +00:00
|
|
|
|
std::vector<std::string> filelist(d.entries());
|
|
|
|
|
for (size_t file_index = 0; file_index < d.entries(); ++file_index)
|
|
|
|
|
filelist[file_index] = d.readFilename();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
std::sort(filelist.begin(), filelist.end(), greater<string>());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
int slen = stylesdir.size();
|
|
|
|
|
for (size_t file_index = 0; file_index < d.entries(); file_index++) {
|
|
|
|
|
int nlen = filelist[file_index].size();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
char style[MAXPATHLEN + 1];
|
|
|
|
|
strncpy(style, stylesdir.c_str(), slen);
|
|
|
|
|
*(style + slen) = '/';
|
2003-02-15 02:03:09 +00:00
|
|
|
|
strncpy(style + slen + 1, filelist[file_index].c_str(), nlen + 1);
|
|
|
|
|
if ( !stat(style, &statbuf) && S_ISREG(statbuf.st_mode)) {
|
|
|
|
|
FbTk::RefCount<FbTk::Command> setstyle_cmd(new FbCommands::
|
|
|
|
|
SetStyleCmd(style));
|
|
|
|
|
menu.insert(filelist[file_index].c_str(), setstyle_cmd);
|
|
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
menu.update();
|
|
|
|
|
// ??
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Fluxbox::instance()->saveMenuFilename(stylesdir.c_str());
|
|
|
|
|
} else { // dir
|
|
|
|
|
fprintf(stderr,
|
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNotDir,
|
|
|
|
|
"BScreen::parseMenuFile:"
|
|
|
|
|
" [stylesdir/stylesmenu] error, %s is not a"
|
|
|
|
|
" directory\n"), stylesdir.c_str());
|
|
|
|
|
} // end of 'dir'
|
|
|
|
|
} else { // stat
|
|
|
|
|
fprintf(stderr,
|
2002-02-17 18:56:14 +00:00
|
|
|
|
i18n->
|
|
|
|
|
getMessage(
|
2002-12-01 13:42:15 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNoExist,
|
|
|
|
|
"BScreen::parseMenuFile: [stylesdir/stylesmenu]"
|
|
|
|
|
" error, %s does not exist\n"), stylesdir.c_str());
|
2003-02-15 02:03:09 +00:00
|
|
|
|
} // end of stat
|
|
|
|
|
|
2002-02-17 18:56:14 +00:00
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::shutdown() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask);
|
|
|
|
|
XSync(getBaseDisplay()->getXDisplay(), False);
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
|
|
|
|
Workspaces::iterator it = workspacesList.begin();
|
|
|
|
|
Workspaces::iterator it_end = workspacesList.end();
|
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
|
(*it)->shutdown();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!iconList.empty()) {
|
|
|
|
|
iconList.back()->restore(true); // restore with remap
|
|
|
|
|
delete iconList.back(); // the window removes it self from iconlist
|
2002-12-01 13:42:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 02:03:09 +00:00
|
|
|
|
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#ifdef SLIT
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (m_slit.get())
|
|
|
|
|
m_slit->shutdown();
|
2003-01-05 22:26:56 +00:00
|
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::showPosition(int x, int y) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! geom_visible) {
|
2002-03-19 14:30:43 +00:00
|
|
|
|
#ifdef XINERAMA
|
2002-12-01 13:42:15 +00:00
|
|
|
|
unsigned int head = hasXinerama() ? getCurrHead() : 0;
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.moveResize(getHeadX(head) + (getHeadWidth(head) - geom_w) / 2,
|
|
|
|
|
getHeadY(head) + (getHeadHeight(head) - geom_h) / 2,
|
|
|
|
|
geom_w, geom_h);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
#else // !XINERMA
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.moveResize((getWidth() - geom_w) / 2,
|
|
|
|
|
(getHeight() - geom_h) / 2, geom_w, geom_h);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.show();
|
|
|
|
|
geom_window.raise();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
geom_visible = true;
|
|
|
|
|
}
|
|
|
|
|
const int label_size = 1024;
|
|
|
|
|
char label[label_size];
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
snprintf(label, label_size,
|
|
|
|
|
I18n::instance()->getMessage(
|
2003-02-16 01:14:54 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenPositionFormat,
|
|
|
|
|
"X: %4d x Y: %4d"), x, y);
|
|
|
|
|
|
|
|
|
|
geom_window.clear();
|
|
|
|
|
|
|
|
|
|
m_windowtheme.font().drawText(
|
|
|
|
|
geom_window.window(),
|
|
|
|
|
getScreenNumber(),
|
|
|
|
|
m_windowtheme.labelTextFocusGC(),
|
|
|
|
|
label, strlen(label),
|
|
|
|
|
theme->getBevelWidth(), theme->getBevelWidth() +
|
|
|
|
|
m_windowtheme.font().ascent());
|
2002-10-15 17:17:00 +00:00
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (! geom_visible) {
|
2002-03-19 14:30:43 +00:00
|
|
|
|
#ifdef XINERAMA
|
2002-12-01 13:42:15 +00:00
|
|
|
|
unsigned int head = hasXinerama() ? getCurrHead() : 0;
|
2002-03-19 14:30:43 +00:00
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.moveResize(getHeadX(head) + (getHeadWidth(head) - geom_w) / 2,
|
|
|
|
|
getHeadY(head) + (getHeadHeight(head) - geom_h) / 2,
|
|
|
|
|
geom_w, geom_h);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
#else // !XINERMA
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.moveResize((getWidth() - geom_w) / 2,
|
|
|
|
|
(getHeight() - geom_h) / 2, geom_w, geom_h);
|
2002-03-19 14:30:43 +00:00
|
|
|
|
#endif // XINERAMA
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.show();
|
|
|
|
|
geom_window.raise();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
geom_visible = true;
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
|
char label[1024];
|
|
|
|
|
|
|
|
|
|
sprintf(label,
|
|
|
|
|
I18n::instance()->getMessage(
|
2003-02-16 01:14:54 +00:00
|
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat,
|
|
|
|
|
"W: %4d x H: %4d"), gx, gy);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.clear();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
|
//TODO: geom window again?! repeated
|
2003-02-16 01:14:54 +00:00
|
|
|
|
m_windowtheme.font().drawText(
|
|
|
|
|
geom_window.window(),
|
|
|
|
|
getScreenNumber(),
|
|
|
|
|
m_windowtheme.labelTextFocusGC(),
|
|
|
|
|
label, strlen(label),
|
|
|
|
|
theme->getBevelWidth(), theme->getBevelWidth() +
|
|
|
|
|
m_windowtheme.font().ascent());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
|
void BScreen::hideGeometry() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (geom_visible) {
|
2003-02-16 01:14:54 +00:00
|
|
|
|
geom_window.hide();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
geom_visible = false;
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-02 16:32:41 +00:00
|
|
|
|
void BScreen::setLayer(FbTk::XLayerItem &item, int layernum) {
|
2003-02-03 13:56:12 +00:00
|
|
|
|
m_layermanager.moveToLayer(item, layernum);
|
2003-02-02 16:32:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
/**
|
|
|
|
|
Goes to the workspace "right" of the current
|
|
|
|
|
*/
|
2002-02-20 23:04:51 +00:00
|
|
|
|
void BScreen::nextWorkspace(const int delta) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
changeWorkspaceID( (getCurrentWorkspaceID()+delta) % getCount());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
/**
|
|
|
|
|
Goes to the workspace "left" of the current
|
|
|
|
|
*/
|
2002-02-20 23:04:51 +00:00
|
|
|
|
void BScreen::prevWorkspace(const int delta) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
changeWorkspaceID( (getCurrentWorkspaceID()-delta+getCount()) % getCount());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
}
|
2002-02-02 19:51:15 +00:00
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
/**
|
|
|
|
|
Goes to the workspace "right" of the current
|
|
|
|
|
*/
|
2002-02-20 23:04:51 +00:00
|
|
|
|
void BScreen::rightWorkspace(const int delta) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (getCurrentWorkspaceID()+delta < getCount())
|
|
|
|
|
changeWorkspaceID(getCurrentWorkspaceID()+delta);
|
2002-02-02 19:51:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
/**
|
|
|
|
|
Goes to the workspace "left" of the current
|
|
|
|
|
*/
|
2002-02-20 23:04:51 +00:00
|
|
|
|
void BScreen::leftWorkspace(const int delta) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
if (getCurrentWorkspaceID() >= static_cast<unsigned int>(delta))
|
|
|
|
|
changeWorkspaceID(getCurrentWorkspaceID()-delta);
|
2002-02-02 19:51:15 +00:00
|
|
|
|
}
|
2002-02-07 14:46:23 +00:00
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
/**
|
|
|
|
|
@return true if the windows should be skiped else false
|
|
|
|
|
*/
|
2002-04-02 23:14:54 +00:00
|
|
|
|
bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
return ((opts & CYCLESKIPSTUCK) != 0 && w->isStuck() || // skip if stuck
|
|
|
|
|
(opts & CYCLESKIPLOWERTABS) != 0 && w->isLowerTab() || // skip if lower tab
|
|
|
|
|
(opts & CYCLESKIPSHADED) != 0 && w->isShaded()); // skip if shaded
|
2002-04-02 23:14:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-27 21:55:36 +00:00
|
|
|
|
/**
|
|
|
|
|
Access and clear the auto-group window
|
|
|
|
|
*/
|
2002-08-02 12:58:37 +00:00
|
|
|
|
FluxboxWindow* BScreen::useAutoGroupWindow() {
|
2002-12-01 13:42:15 +00:00
|
|
|
|
Window w = auto_group_window;
|
|
|
|
|
auto_group_window = 0;
|
|
|
|
|
return w ? Fluxbox::instance()->searchWindow(w) : 0;
|
2002-08-02 12:58:37 +00:00
|
|
|
|
}
|
|
|
|
|
|