2002-01-09 14:11:20 +00:00
|
|
|
// Screen.cc for Fluxbox Window Manager
|
|
|
|
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
|
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Screen.cc for Blackbox - an X11 Window manager
|
|
|
|
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2002-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.
|
|
|
|
|
2002-09-12 14:55:11 +00:00
|
|
|
// $Id: Screen.cc,v 1.69 2002/09/12 14:55:11 rathnor Exp $
|
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
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
#include "Screen.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
#include "i18n.hh"
|
|
|
|
#include "fluxbox.hh"
|
|
|
|
#include "Icon.hh"
|
|
|
|
#include "Image.hh"
|
2002-01-06 11:07:42 +00:00
|
|
|
#include "StringUtil.hh"
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
#include "Slit.hh"
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
#include "Rootmenu.hh"
|
|
|
|
#include "Toolbar.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Workspace.hh"
|
|
|
|
#include "Workspacemenu.hh"
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef STDC_HEADERS
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <sys/types.h>
|
|
|
|
#endif // STDC_HEADERS
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef HAVE_CTYPE_H
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <ctype.h>
|
|
|
|
#endif // HAVE_CTYPE_H
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef HAVE_DIRENT_H
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <dirent.h>
|
|
|
|
#endif // HAVE_DIRENT_H
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef HAVE_LOCALE_H
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <locale.h>
|
|
|
|
#endif // HAVE_LOCALE_H
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <sys/types.h>
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif // HAVE_UNISTD_H
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif // HAVE_SYS_STAT_H
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef HAVE_STDARG_H
|
2001-12-11 20:47:02 +00:00
|
|
|
# include <stdarg.h>
|
|
|
|
#endif // HAVE_STDARG_H
|
|
|
|
|
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;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
static int anotherWMRunning(Display *display, XErrorEvent *) {
|
|
|
|
fprintf(stderr,
|
|
|
|
I18n::instance()->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenAnotherWMRunning,
|
2001-12-11 20:47:02 +00:00
|
|
|
"BScreen::BScreen: an error occured while querying the X server.\n"
|
|
|
|
" another window manager already running on display %s.\n"),
|
|
|
|
DisplayString(display));
|
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
running = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dcmp(const void *one, const void *two) {
|
|
|
|
return (strcmp((*(char **) one), (*(char **) two)));
|
|
|
|
}
|
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
//---------- resource manipulators ---------
|
|
|
|
template<>
|
|
|
|
void Resource<Tab::Alignment>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
m_value = Tab::getTabAlignmentNum(strval);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Resource<Tab::Placement>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
m_value = Tab::getTabPlacementNum(strval);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void Resource<Toolbar::Placement>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
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;
|
|
|
|
else
|
|
|
|
setDefaultValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------- resource accessors --------------
|
|
|
|
template<>
|
|
|
|
string Resource<Tab::Alignment>::
|
|
|
|
getString() {
|
|
|
|
return Tab::getTabAlignmentString(m_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
string Resource<Tab::Placement>::
|
|
|
|
getString() {
|
|
|
|
return Tab::getTabPlacementString(m_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
string Resource<Toolbar::Placement>::
|
|
|
|
getString() {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
//default string
|
|
|
|
return string("BottomCenter");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
|
|
|
|
const std::string &scrname, const std::string &altscrname):
|
|
|
|
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"),
|
2002-04-12 14:56:15 +00:00
|
|
|
workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"),
|
2002-05-08 10:14:51 +00:00
|
|
|
desktop_wheeling(rm, true, scrname+".desktopwheeling", altscrname+".DesktopWheeling"),
|
2002-05-19 17:56:55 +00:00
|
|
|
show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"),
|
2002-01-21 02:10:25 +00:00
|
|
|
focus_last(rm, true, scrname+".focusLastWindow", altscrname+".FocusLastWindow"),
|
|
|
|
focus_new(rm, true, scrname+".focusNewWindows", altscrname+".FocusNewWindows"),
|
2002-01-20 02:17:23 +00:00
|
|
|
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"),
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"),
|
|
|
|
#endif // XINERAMA
|
2002-01-20 02:17:23 +00:00
|
|
|
toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement")
|
|
|
|
{
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
BScreen::BScreen(ResourceManager &rm, Fluxbox *b,
|
|
|
|
const string &screenname, const string &altscreenname,
|
|
|
|
int scrn) : ScreenInfo(b, scrn),
|
2002-09-07 20:22:08 +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
|
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
theme(0),
|
|
|
|
resource(rm, screenname, altscreenname)
|
2002-01-10 12:49:15 +00:00
|
|
|
{
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox = b;
|
|
|
|
|
|
|
|
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
|
2002-01-20 02:17:23 +00:00
|
|
|
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
|
2002-02-17 18:56:14 +00:00
|
|
|
ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
|
|
|
|
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), event_mask);
|
|
|
|
XSync(getBaseDisplay()->getXDisplay(), False);
|
|
|
|
XSetErrorHandler((XErrorHandler) old);
|
|
|
|
|
|
|
|
managed = running;
|
|
|
|
if (! managed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenManagingScreen,
|
|
|
|
"BScreen::BScreen: managing screen %d "
|
|
|
|
"using visual 0x%lx, depth %d\n"),
|
|
|
|
getScreenNumber(), XVisualIDFromVisual(getVisual()),
|
|
|
|
getDepth());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
rootmenu = 0;
|
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
#ifdef HAVE_GETPID
|
2001-12-11 20:47:02 +00:00
|
|
|
pid_t bpid = getpid();
|
|
|
|
|
|
|
|
XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(),
|
2002-01-21 02:10:25 +00:00
|
|
|
fluxbox->getFluxboxPidAtom(), XA_CARDINAL,
|
|
|
|
sizeof(pid_t) * 8, PropModeReplace,
|
|
|
|
(unsigned char *) &bpid, 1);
|
2002-01-20 02:17:23 +00:00
|
|
|
#endif // HAVE_GETPID
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
XDefineCursor(getBaseDisplay()->getXDisplay(), getRootWindow(),
|
2002-01-20 02:17:23 +00:00
|
|
|
fluxbox->getSessionCursor());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
image_control =
|
2002-07-20 09:35:01 +00:00
|
|
|
new BImageControl(fluxbox, this, true, fluxbox->colorsPerChannel(),
|
2002-01-21 02:10:25 +00:00
|
|
|
fluxbox->getCacheLife(), fluxbox->getCacheMax());
|
2001-12-11 20:47:02 +00:00
|
|
|
image_control->installRootColormap();
|
2002-04-04 14:28:54 +00:00
|
|
|
root_colormap_installed = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
fluxbox->load_rc(this);
|
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
image_control->setDither(*resource.image_dither);
|
2002-07-20 09:35:01 +00:00
|
|
|
theme = new Theme(getBaseDisplay()->getXDisplay(), getRootWindow(), colormap(), getScreenNumber(),
|
2002-01-10 12:49:15 +00:00
|
|
|
image_control, fluxbox->getStyleFilename(), getRootCommand().c_str());
|
2002-01-11 10:21:44 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef NEWWMSPEC
|
|
|
|
Atom netwmsupported[] = {
|
|
|
|
// getBaseDisplay()->getNETWMStateAtom(),
|
|
|
|
getBaseDisplay()->getNETNumberOfDesktopsAtom(),
|
|
|
|
getBaseDisplay()->getNETCurrentDesktopAtom(),
|
|
|
|
getBaseDisplay()->getNETSupportingWMCheckAtom(),
|
|
|
|
};
|
|
|
|
|
|
|
|
XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(),
|
|
|
|
getBaseDisplay()->getNETSupportedAtom(), XA_ATOM, 32, PropModeReplace,
|
|
|
|
(unsigned char *)netwmsupported, (sizeof netwmsupported)/sizeof netwmsupported[0]);
|
|
|
|
#endif //!NEWWMSPEC
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
const char *s = i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenPositionLength,
|
2002-01-20 02:17:23 +00:00
|
|
|
"0: 0000 x 0: 0000");
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
int l = strlen(s);
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
2001-12-13 20:44:57 +00:00
|
|
|
XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical);
|
2001-12-11 20:47:02 +00:00
|
|
|
geom_w = logical.width;
|
|
|
|
|
2001-12-13 20:44:57 +00:00
|
|
|
geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height;
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
2001-12-13 20:44:57 +00:00
|
|
|
geom_h = theme->getWindowStyle().font.fontstruct->ascent +
|
2002-01-20 02:17:23 +00:00
|
|
|
theme->getWindowStyle().font.fontstruct->descent;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2001-12-13 20:44:57 +00:00
|
|
|
geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
geom_w += getBevelWidth()*2;
|
|
|
|
geom_h += getBevelWidth()*2;
|
|
|
|
|
|
|
|
XSetWindowAttributes attrib;
|
|
|
|
unsigned long mask = CWBorderPixel | CWColormap | CWSaveUnder;
|
2002-07-20 09:35:01 +00:00
|
|
|
attrib.border_pixel = getBorderColor()->pixel();
|
|
|
|
attrib.colormap = colormap();
|
2002-04-04 14:28:54 +00:00
|
|
|
attrib.save_under = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
geom_window =
|
|
|
|
XCreateWindow(getBaseDisplay()->getXDisplay(), getRootWindow(),
|
2002-02-04 07:01:06 +00:00
|
|
|
0, 0, geom_w, geom_h, theme->getBorderWidth(), getDepth(),
|
|
|
|
InputOutput, getVisual(), mask, &attrib);
|
2002-04-04 14:28:54 +00:00
|
|
|
geom_visible = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-07-23 17:11:59 +00:00
|
|
|
if (theme->getWindowStyle().l_focus.type() & FbTk::Texture::PARENTRELATIVE) {
|
|
|
|
if (theme->getWindowStyle().t_focus.type() ==
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-07-20 09:35:01 +00:00
|
|
|
theme->getWindowStyle().t_focus.color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2002-02-04 07:01:06 +00:00
|
|
|
&theme->getWindowStyle().t_focus);
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(),
|
|
|
|
geom_window, geom_pixmap);
|
|
|
|
}
|
|
|
|
} else {
|
2002-07-23 17:11:59 +00:00
|
|
|
if (theme->getWindowStyle().l_focus.type() ==
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-07-20 09:35:01 +00:00
|
|
|
theme->getWindowStyle().l_focus.color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2002-02-04 07:01:06 +00:00
|
|
|
&theme->getWindowStyle().l_focus);
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(),
|
|
|
|
geom_window, geom_pixmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
workspacemenu = new Workspacemenu(this);
|
|
|
|
iconmenu = new Iconmenu(this);
|
|
|
|
configmenu = new Configmenu(this);
|
|
|
|
|
|
|
|
Workspace *wkspc = (Workspace *) 0;
|
2002-01-20 02:17:23 +00:00
|
|
|
if (*resource.workspaces != 0) {
|
|
|
|
for (int i = 0; i < *resource.workspaces; ++i) {
|
2002-02-08 13:35:20 +00:00
|
|
|
wkspc = new Workspace(this, workspacesList.size());
|
|
|
|
workspacesList.push_back(wkspc);
|
2002-04-09 23:20:40 +00:00
|
|
|
workspacemenu->insert(wkspc->name().c_str(), wkspc->menu());
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-02-08 13:35:20 +00:00
|
|
|
wkspc = new Workspace(this, workspacesList.size());
|
|
|
|
workspacesList.push_back(wkspc);
|
2002-04-09 23:20:40 +00:00
|
|
|
workspacemenu->insert(wkspc->name().c_str(), wkspc->menu());
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
workspacemenu->insert(i18n->
|
2002-02-04 07:01:06 +00:00
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::IconSet, FBNLS::IconIcons,
|
2002-02-04 07:01:06 +00:00
|
|
|
"Icons"),
|
2001-12-11 20:47:02 +00:00
|
|
|
iconmenu);
|
|
|
|
workspacemenu->update();
|
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
current_workspace = workspacesList.front();
|
2002-04-04 14:28:54 +00:00
|
|
|
workspacemenu->setItemSelected(2, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
toolbar = new Toolbar(this);
|
|
|
|
|
2002-02-04 07:01:06 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
slit = new Slit(this);
|
2002-02-04 07:01:06 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-03-08 12:18:22 +00:00
|
|
|
initMenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
raiseWindows(Workspace::Stack());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-08 14:24:57 +00:00
|
|
|
//update menus
|
|
|
|
rootmenu->update();
|
|
|
|
#ifdef SLIT
|
|
|
|
slit->reconfigure();
|
|
|
|
#endif
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
changeWorkspaceID(0);
|
2002-02-04 07:01:06 +00:00
|
|
|
updateNetizenWorkspaceCount();
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
int i;
|
|
|
|
unsigned int nchild;
|
|
|
|
Window r, p, *children;
|
|
|
|
XQueryTree(getBaseDisplay()->getXDisplay(), getRootWindow(), &r, &p,
|
|
|
|
&children, &nchild);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
if (children[i] == None) continue;
|
|
|
|
|
|
|
|
XWMHints *wmhints = XGetWMHints(getBaseDisplay()->getXDisplay(),
|
2002-02-04 07:01:06 +00:00
|
|
|
children[i]);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (wmhints) {
|
|
|
|
if ((wmhints->flags & IconWindowHint) &&
|
2002-02-04 07:01:06 +00:00
|
|
|
(wmhints->icon_window != children[i]))
|
|
|
|
for (int j = 0; j < (int) nchild; j++) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (children[j] == wmhints->icon_window) {
|
|
|
|
children[j] = None;
|
|
|
|
break;
|
|
|
|
}
|
2002-02-04 07:01:06 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
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(getBaseDisplay()->getXDisplay(), children[i],
|
|
|
|
&attrib)) {
|
|
|
|
if (attrib.override_redirect)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (attrib.map_state != IsUnmapped) {
|
2002-02-11 11:52:07 +00:00
|
|
|
|
|
|
|
FluxboxWindow *win = new FluxboxWindow(children[i], this);
|
|
|
|
if (!win->isManaged()) {
|
|
|
|
delete win;
|
|
|
|
win = 0;
|
2002-09-07 20:22:08 +00:00
|
|
|
} else {
|
|
|
|
Fluxbox::instance()->attachSignals(*win);
|
2002-01-18 01:27:46 +00:00
|
|
|
}
|
2002-02-11 11:52:07 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
if (win) {
|
|
|
|
XMapRequestEvent mre;
|
|
|
|
mre.window = children[i];
|
|
|
|
win->restoreAttributes();
|
|
|
|
win->mapRequestEvent(&mre);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! resource.sloppy_focus)
|
|
|
|
XSetInputFocus(getBaseDisplay()->getXDisplay(), toolbar->getWindowID(),
|
|
|
|
RevertToParent, CurrentTime);
|
|
|
|
|
|
|
|
XFree(children);
|
|
|
|
XFlush(getBaseDisplay()->getXDisplay());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
namespace {
|
2002-04-04 14:28:54 +00:00
|
|
|
template<typename T>
|
|
|
|
void delete_obj(T * obj) {
|
|
|
|
delete obj;
|
|
|
|
}
|
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() {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (! managed) return;
|
|
|
|
|
|
|
|
if (geom_pixmap != None)
|
|
|
|
image_control->removeImage(geom_pixmap);
|
|
|
|
|
|
|
|
if (geom_window != None)
|
|
|
|
XDestroyWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
|
|
|
|
removeWorkspaceNames();
|
|
|
|
|
2002-05-17 16:30:24 +00:00
|
|
|
#ifdef __INTEL_COMPILER
|
|
|
|
//Didn't got icc to work with std::for_each
|
|
|
|
//so we do this by hand.
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
#else //__INTEL_COMPILER
|
2002-04-04 14:28:54 +00:00
|
|
|
std::for_each(
|
|
|
|
workspacesList.begin(),
|
|
|
|
workspacesList.end(),
|
|
|
|
delete_obj<Workspace>);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
// don't delete items in the rootmenuList?
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
std::for_each(
|
|
|
|
iconList.begin(),
|
|
|
|
iconList.end(),
|
|
|
|
delete_obj<FluxboxWindow>);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
std::for_each(
|
|
|
|
netizenList.begin(),
|
|
|
|
netizenList.end(),
|
|
|
|
delete_obj<Netizen>);
|
2002-05-17 16:30:24 +00:00
|
|
|
#endif //!__INTEL_COMPILER
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
delete rootmenu;
|
|
|
|
delete workspacemenu;
|
|
|
|
delete iconmenu;
|
|
|
|
delete configmenu;
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
delete slit;
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
delete toolbar;
|
|
|
|
delete image_control;
|
|
|
|
|
|
|
|
delete theme;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::reconfigure() {
|
2002-01-10 12:49:15 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<<endl;
|
|
|
|
#endif
|
|
|
|
Fluxbox::instance()->loadRootCommand(this);
|
|
|
|
theme->setRootCommand(getRootCommand());
|
2002-01-09 14:11:20 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->load(fluxbox->getStyleFilename());
|
|
|
|
theme->reconfigure();
|
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
const char *s = i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenPositionLength,
|
|
|
|
"0: 0000 x 0: 0000");
|
2001-12-11 20:47:02 +00:00
|
|
|
int l = strlen(s);
|
|
|
|
|
|
|
|
if (i18n->multibyte()) {
|
|
|
|
XRectangle ink, logical;
|
2001-12-13 20:44:57 +00:00
|
|
|
XmbTextExtents(theme->getWindowStyle().font.set, s, l, &ink, &logical);
|
2001-12-11 20:47:02 +00:00
|
|
|
geom_w = logical.width;
|
|
|
|
|
2001-12-13 20:44:57 +00:00
|
|
|
geom_h = theme->getWindowStyle().font.set_extents->max_ink_extent.height;
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
2001-12-13 20:44:57 +00:00
|
|
|
geom_w = XTextWidth(theme->getWindowStyle().font.fontstruct, s, l);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2001-12-13 20:44:57 +00:00
|
|
|
geom_h = theme->getWindowStyle().font.fontstruct->ascent +
|
|
|
|
theme->getWindowStyle().font.fontstruct->descent;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
geom_w += getBevelWidth()*2;
|
|
|
|
geom_h += getBevelWidth()*2;
|
|
|
|
|
|
|
|
Pixmap tmp = geom_pixmap;
|
2002-07-23 17:11:59 +00:00
|
|
|
if (theme->getWindowStyle().l_focus.type() & FbTk::Texture::PARENTRELATIVE) {
|
|
|
|
if (theme->getWindowStyle().t_focus.type() ==
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-07-20 09:35:01 +00:00
|
|
|
theme->getWindowStyle().t_focus.color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2001-12-13 20:44:57 +00:00
|
|
|
&theme->getWindowStyle().t_focus);
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(),
|
|
|
|
geom_window, geom_pixmap);
|
|
|
|
}
|
|
|
|
} else {
|
2002-07-23 17:11:59 +00:00
|
|
|
if (theme->getWindowStyle().l_focus.type() ==
|
|
|
|
(FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
|
2001-12-11 20:47:02 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
XSetWindowBackground(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-07-20 09:35:01 +00:00
|
|
|
theme->getWindowStyle().l_focus.color().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
} else {
|
|
|
|
geom_pixmap = image_control->renderImage(geom_w, geom_h,
|
2001-12-13 20:44:57 +00:00
|
|
|
&theme->getWindowStyle().l_focus);
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBackgroundPixmap(getBaseDisplay()->getXDisplay(),
|
|
|
|
geom_window, geom_pixmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tmp) image_control->removeImage(tmp);
|
|
|
|
|
|
|
|
XSetWindowBorderWidth(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-04-28 19:54:10 +00:00
|
|
|
theme->getBorderWidth());
|
2001-12-11 20:47:02 +00:00
|
|
|
XSetWindowBorder(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-07-20 09:35:01 +00:00
|
|
|
theme->getBorderColor().pixel());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-28 19:54:10 +00:00
|
|
|
//reconfigure menus
|
2001-12-11 20:47:02 +00:00
|
|
|
workspacemenu->reconfigure();
|
|
|
|
iconmenu->reconfigure();
|
|
|
|
|
2002-04-28 19:54:10 +00:00
|
|
|
configmenu->reconfigure();
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
{
|
2002-04-08 22:36:30 +00:00
|
|
|
int remember_sub = rootmenu->currentSubmenu();
|
2002-03-08 12:18:22 +00:00
|
|
|
initMenu();
|
2002-09-08 19:45:59 +00:00
|
|
|
raiseWindows(Workspace::Stack());
|
2002-04-28 19:54:10 +00:00
|
|
|
rootmenu->reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
rootmenu->drawSubmenu(remember_sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toolbar->reconfigure();
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
slit->reconfigure();
|
|
|
|
#endif // SLIT
|
2002-04-28 19:54:10 +00:00
|
|
|
|
|
|
|
//reconfigure workspaces
|
2002-02-08 13:35:20 +00:00
|
|
|
Workspaces::iterator wit = workspacesList.begin();
|
|
|
|
Workspaces::iterator wit_end = workspacesList.end();
|
|
|
|
for (; wit != wit_end; ++wit) {
|
|
|
|
(*wit)->reconfigure();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-28 19:54:10 +00:00
|
|
|
//reconfigure Icons
|
2002-02-08 13:35:20 +00:00
|
|
|
Icons::iterator iit = iconList.begin();
|
|
|
|
Icons::iterator iit_end = iconList.end();
|
|
|
|
for (; iit != iit_end; ++iit) {
|
|
|
|
if ((*iit)->validateClient())
|
|
|
|
(*iit)->reconfigure();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
image_control->timeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::rereadMenu() {
|
2002-03-08 12:18:22 +00:00
|
|
|
initMenu();
|
2002-09-08 19:45:59 +00:00
|
|
|
raiseWindows(Workspace::Stack());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
rootmenu->reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::removeWorkspaceNames() {
|
2002-02-08 13:35:20 +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-09-07 20:22:08 +00:00
|
|
|
m_workspacenames_sig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::addIcon(FluxboxWindow *w) {
|
|
|
|
if (! w) return;
|
|
|
|
|
|
|
|
w->setWorkspace(-1);
|
2002-02-08 13:35:20 +00:00
|
|
|
w->setWindowNumber(iconList.size());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
iconList.push_back(w);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-03 23:04:01 +00:00
|
|
|
iconmenu->insert(w->getIconTitle().c_str());
|
2001-12-11 20:47:02 +00:00
|
|
|
iconmenu->update();
|
|
|
|
toolbar->addIcon(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::removeIcon(FluxboxWindow *w) {
|
2002-09-08 19:45:59 +00:00
|
|
|
if (! w)
|
|
|
|
return;
|
2002-02-20 22:41:13 +00:00
|
|
|
|
2002-02-17 19:19:05 +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) {
|
|
|
|
if (*it == w) {
|
|
|
|
iconList.erase(it);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-02-20 22:41:13 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
iconmenu->remove(w->getWindowNumber());
|
|
|
|
iconmenu->update();
|
|
|
|
toolbar->delIcon(w);
|
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
Icons::iterator it = iconList.begin();
|
2002-02-08 13:35:20 +00:00
|
|
|
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) {
|
|
|
|
Workspaces::iterator it = workspacesList.begin();
|
|
|
|
Workspaces::iterator it_end = workspacesList.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->removeWindow(win);
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
FluxboxWindow *BScreen::getIcon(unsigned int index) {
|
|
|
|
if (index < iconList.size())
|
2002-02-08 13:35:20 +00:00
|
|
|
return iconList[index];
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
return 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
int BScreen::addWorkspace() {
|
2002-02-08 13:35:20 +00:00
|
|
|
Workspace *wkspc = new Workspace(this, workspacesList.size());
|
|
|
|
workspacesList.push_back(wkspc);
|
2002-08-24 18:12:54 +00:00
|
|
|
addWorkspaceName(wkspc->name().c_str()); // update names
|
2002-02-27 23:47:47 +00:00
|
|
|
//add workspace to workspacemenu
|
2002-04-09 23:20:40 +00:00
|
|
|
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
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
workspacemenu->update();
|
2002-02-08 13:35:20 +00:00
|
|
|
saveWorkspaces(workspacesList.size());
|
2001-12-11 20:47:02 +00:00
|
|
|
toolbar->reconfigure();
|
|
|
|
|
|
|
|
updateNetizenWorkspaceCount();
|
|
|
|
|
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
return workspacesList.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
int BScreen::removeLastWorkspace() {
|
2002-02-08 13:35:20 +00:00
|
|
|
if (workspacesList.size() > 1) {
|
|
|
|
Workspace *wkspc = workspacesList.back();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-09 23:20:40 +00:00
|
|
|
if (current_workspace->workspaceID() == wkspc->workspaceID())
|
|
|
|
changeWorkspaceID(current_workspace->workspaceID() - 1);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
wkspc->removeAll();
|
|
|
|
|
2002-04-09 23:20:40 +00:00
|
|
|
workspacemenu->remove(wkspc->workspaceID()+2); // + 2 is where workspaces starts
|
2001-12-11 20:47:02 +00:00
|
|
|
workspacemenu->update();
|
2002-02-27 23:47:47 +00:00
|
|
|
|
|
|
|
//remove last workspace
|
|
|
|
workspacesList.pop_back();
|
2001-12-11 20:47:02 +00:00
|
|
|
delete wkspc;
|
|
|
|
|
|
|
|
toolbar->reconfigure();
|
|
|
|
|
|
|
|
updateNetizenWorkspaceCount();
|
2002-02-08 13:35:20 +00:00
|
|
|
saveWorkspaces(workspacesList.size());
|
|
|
|
return workspacesList.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
void BScreen::changeWorkspaceID(unsigned int id) {
|
|
|
|
if (! current_workspace || id >= workspacesList.size())
|
2001-12-11 20:47:02 +00:00
|
|
|
return;
|
|
|
|
|
2002-04-09 23:20:40 +00:00
|
|
|
if (id != current_workspace->workspaceID()) {
|
2002-04-04 14:28:54 +00:00
|
|
|
XSync(fluxbox->getXDisplay(), true);
|
2002-08-30 14:03:31 +00:00
|
|
|
FluxboxWindow *focused = fluxbox->getFocusedWindow();
|
|
|
|
|
|
|
|
if (focused && focused->isMoving()) {
|
|
|
|
reassociateGroup(focused, id, true);
|
|
|
|
focused->pauseMoving();
|
|
|
|
}
|
|
|
|
|
2002-09-12 14:55:11 +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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
current_workspace->hideAll();
|
|
|
|
|
2002-04-09 23:20:40 +00:00
|
|
|
workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-30 14:03:31 +00:00
|
|
|
if (focused && focused->getScreen() == this &&
|
|
|
|
(! focused->isStuck()) && (!focused->isMoving())) {
|
|
|
|
current_workspace->setLastFocusedWindow(focused);
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox->setFocusedWindow((FluxboxWindow *) 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
current_workspace = getWorkspace(id);
|
|
|
|
|
2002-04-09 23:20:40 +00:00
|
|
|
workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true);
|
2002-04-04 14:28:54 +00:00
|
|
|
toolbar->redrawWorkspaceLabel(true);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
current_workspace->showAll();
|
|
|
|
|
2002-08-30 14:03:31 +00:00
|
|
|
if (*resource.focus_last && current_workspace->getLastFocusedWindow() &&
|
|
|
|
!(focused && focused->isMoving())) {
|
2001-12-19 14:30:44 +00:00
|
|
|
current_workspace->getLastFocusedWindow()->setInputFocus();
|
2002-09-12 14:55:11 +00:00
|
|
|
} else if (focused && focused->isStuck()) {
|
|
|
|
focused->setInputFocus();
|
2002-08-30 14:03:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (focused && focused->isMoving()) {
|
|
|
|
focused->resumeMoving();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateNetizenCurrentWorkspace();
|
|
|
|
}
|
|
|
|
|
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-03-23 15:14:45 +00:00
|
|
|
if (! current_workspace || id >= workspacesList.size())
|
2002-02-26 22:25:53 +00:00
|
|
|
return;
|
|
|
|
|
2002-07-23 13:47:05 +00:00
|
|
|
if (!win)
|
|
|
|
win = fluxbox->getFocusedWindow();
|
|
|
|
|
2002-04-09 23:20:40 +00:00
|
|
|
if (id != current_workspace->workspaceID()) {
|
2002-02-26 22:25:53 +00:00
|
|
|
XSync(fluxbox->getXDisplay(), True);
|
|
|
|
|
|
|
|
if (win && win->getScreen() == this &&
|
|
|
|
(! win->isStuck())) {
|
|
|
|
|
|
|
|
if ( win->getTab() ) {
|
|
|
|
Tab *tab = win->getTab();
|
|
|
|
tab->disconnect();
|
|
|
|
tab->setPosition();
|
|
|
|
}
|
|
|
|
|
2002-09-10 10:59:57 +00:00
|
|
|
if (win->isIconic())
|
|
|
|
win->deiconify();
|
|
|
|
|
2002-02-26 22:25:53 +00:00
|
|
|
win->withdraw();
|
2002-04-04 14:28:54 +00:00
|
|
|
BScreen::reassociateWindow(win, id, true);
|
2002-02-26 22:25:53 +00:00
|
|
|
if (changeWS) {
|
|
|
|
BScreen::changeWorkspaceID(id);
|
|
|
|
win->setInputFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
void BScreen::addNetizen(Netizen *n) {
|
2002-02-08 13:35:20 +00:00
|
|
|
netizenList.push_back(n);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
n->sendWorkspaceCount();
|
|
|
|
n->sendCurrentWorkspace();
|
|
|
|
|
2002-02-08 13:35:20 +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(),
|
2002-04-09 23:20:40 +00:00
|
|
|
(*it)->workspaceID());
|
2002-02-08 13:35:20 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Window f = ((fluxbox->getFocusedWindow()) ?
|
2002-04-09 23:20:40 +00:00
|
|
|
fluxbox->getFocusedWindow()->getClientWindow() : None);
|
2001-12-11 20:47:02 +00:00
|
|
|
n->sendWindowFocus(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::removeNetizen(Window w) {
|
2002-02-08 13:35:20 +00:00
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
if ((*it)->getWindowID() == w) {
|
2002-03-08 12:18:22 +00:00
|
|
|
Netizen *n = *it;
|
2001-12-11 20:47:02 +00:00
|
|
|
delete n;
|
2002-03-08 12:18:22 +00:00
|
|
|
netizenList.erase(it);
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-02-08 13:35:20 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::updateNetizenCurrentWorkspace() {
|
2002-09-07 20:22:08 +00:00
|
|
|
#ifdef NEWWMSPEC
|
2002-02-04 07:01:06 +00:00
|
|
|
//update _NET_WM_CURRENT_DESKTOP
|
|
|
|
int workspace = getCurrentWorkspaceID();
|
|
|
|
XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(),
|
|
|
|
getBaseDisplay()->getNETCurrentDesktopAtom(), XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)&workspace, 1);
|
2002-09-07 20:22:08 +00:00
|
|
|
#endif // NEWWMSPEC
|
|
|
|
|
|
|
|
m_currentworkspace_sig.notify();
|
2002-02-04 07:01:06 +00:00
|
|
|
|
2002-02-08 13:35:20 +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-02-08 13:35:20 +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
|
|
|
#ifdef NEWWMSPEC
|
2002-02-04 07:01:06 +00:00
|
|
|
//update _NET_WM_NUMBER_OF_DESKTOPS
|
|
|
|
int numworkspaces = getCount()-1;
|
|
|
|
XChangeProperty(getBaseDisplay()->getXDisplay(), getRootWindow(),
|
|
|
|
getBaseDisplay()->getNETNumberOfDesktopsAtom(), XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
(unsigned char *)&numworkspaces, 1);
|
2002-09-07 20:22:08 +00:00
|
|
|
#endif // NEWWMSPEC
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
Netizens::iterator it = netizenList.begin();
|
|
|
|
Netizens::iterator it_end = netizenList.end();
|
2002-04-04 14:28:54 +00:00
|
|
|
Window f = ((fluxbox->getFocusedWindow()) ?
|
2002-02-08 13:35:20 +00:00
|
|
|
fluxbox->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-02-08 13:35:20 +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
|
|
|
|
|
|
|
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-02-08 13:35:20 +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
|
|
|
|
|
|
|
m_clientlist_sig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowRaise(Window w) {
|
2002-02-08 13:35:20 +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-02-08 13:35:20 +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-02-08 13:35:20 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
void BScreen::raiseWindows(const Workspace::Stack &workspace_stack) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
Window session_stack[(workspace_stack.size() + workspacesList.size() + rootmenuList.size() + 30)];
|
2002-02-26 22:25:53 +00:00
|
|
|
int i = 0;
|
2002-04-08 22:36:30 +00:00
|
|
|
XRaiseWindow(getBaseDisplay()->getXDisplay(), iconmenu->windowID());
|
|
|
|
session_stack[i++] = iconmenu->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
Workspaces::iterator wit = workspacesList.begin();
|
|
|
|
Workspaces::iterator wit_end = workspacesList.end();
|
|
|
|
for (; wit != wit_end; ++wit) {
|
2002-04-09 23:20:40 +00:00
|
|
|
session_stack[i++] = (*wit)->menu()->windowID();
|
2002-02-08 13:35:20 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
session_stack[i++] = workspacemenu->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
session_stack[i++] = configmenu->getFocusmenu()->windowID();
|
|
|
|
session_stack[i++] = configmenu->getPlacementmenu()->windowID();
|
|
|
|
session_stack[i++] = configmenu->getTabmenu()->windowID();
|
|
|
|
session_stack[i++] = configmenu->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-26 22:25:53 +00:00
|
|
|
#ifdef SLIT
|
2002-08-04 15:48:13 +00:00
|
|
|
session_stack[i++] = slit->menu().getDirectionmenu()->windowID();
|
|
|
|
session_stack[i++] = slit->menu().getPlacementmenu()->windowID();
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (hasXinerama()) {
|
2002-08-04 15:48:13 +00:00
|
|
|
session_stack[i++] = slit->menu().getHeadmenu()->windowID();
|
2002-03-19 14:30:43 +00:00
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
2002-08-04 15:48:13 +00:00
|
|
|
session_stack[i++] = slit->menu().windowID();
|
2002-02-26 22:25:53 +00:00
|
|
|
#endif // SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2001-12-30 12:05:26 +00:00
|
|
|
session_stack[i++] =
|
2002-04-08 22:36:30 +00:00
|
|
|
toolbar->getMenu()->getPlacementmenu()->windowID();
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (hasXinerama()) {
|
2002-04-08 22:36:30 +00:00
|
|
|
session_stack[i++] = toolbar->getMenu()->getHeadmenu()->windowID();
|
2002-03-19 14:30:43 +00:00
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
2002-04-08 22:36:30 +00:00
|
|
|
session_stack[i++] = toolbar->getMenu()->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
Rootmenus::iterator rit = rootmenuList.begin();
|
|
|
|
Rootmenus::iterator rit_end = rootmenuList.end();
|
|
|
|
for (; rit != rit_end; ++rit) {
|
2002-04-08 22:36:30 +00:00
|
|
|
session_stack[i++] = (*rit)->windowID();
|
2002-02-08 13:35:20 +00:00
|
|
|
}
|
2002-04-08 22:36:30 +00:00
|
|
|
session_stack[i++] = rootmenu->windowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (toolbar->isOnTop())
|
2001-12-30 12:05:26 +00:00
|
|
|
session_stack[i++] = toolbar->getWindowID();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-26 22:25:53 +00:00
|
|
|
#ifdef SLIT
|
2001-12-11 20:47:02 +00:00
|
|
|
if (slit->isOnTop())
|
2001-12-30 12:05:26 +00:00
|
|
|
session_stack[i++] = slit->getWindowID();
|
2002-02-26 22:25:53 +00:00
|
|
|
#endif // SLIT
|
2002-09-08 19:45:59 +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
|
|
|
|
|
|
|
XRestackWindows(getBaseDisplay()->getXDisplay(), session_stack, i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_STRFTIME
|
2002-05-17 11:02:30 +00:00
|
|
|
void BScreen::saveStrftimeFormat(const char *format) {
|
|
|
|
//make sure std::string don't get 0 string
|
|
|
|
resource.strftime_format = (format ? format : "");
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
#endif // HAVE_STRFTIME
|
|
|
|
|
|
|
|
|
2002-07-23 17:11:59 +00:00
|
|
|
void BScreen::addWorkspaceName(const char *name) {
|
2002-02-08 13:35:20 +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-03-23 15:14:45 +00:00
|
|
|
if (workspace < workspaceNames.size()) {
|
2002-08-11 22:28:18 +00:00
|
|
|
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) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (! w) return;
|
|
|
|
|
2002-08-24 18:12:54 +00:00
|
|
|
if (wkspc_id >= getCount())
|
2002-04-09 23:20:40 +00:00
|
|
|
wkspc_id = current_workspace->workspaceID();
|
2001-12-11 20:47:02 +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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-18 20:20:09 +00:00
|
|
|
void BScreen::nextFocus(int opts) {
|
2002-04-02 23:14:54 +00:00
|
|
|
bool have_focused = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
int focused_window_number = -1;
|
2002-09-08 19:45:59 +00:00
|
|
|
FluxboxWindow *focused = fluxbox->getFocusedWindow();
|
2002-02-17 18:56:14 +00:00
|
|
|
const int num_windows = getCurrentWorkspace()->getCount();
|
2002-09-12 14:55:11 +00:00
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
if (focused != 0) {
|
2002-07-10 14:51:32 +00:00
|
|
|
if (focused->getScreen()->getScreenNumber() ==
|
|
|
|
getScreenNumber()) {
|
2002-04-02 23:14:54 +00:00
|
|
|
have_focused = true;
|
|
|
|
focused_window_number = focused->getWindowNumber();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-02-17 18:56:14 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-09-12 14:55:11 +00:00
|
|
|
if (num_windows >= 1) {
|
2002-04-02 23:14:54 +00:00
|
|
|
Workspace *wksp = getCurrentWorkspace();
|
2002-09-08 19:45:59 +00:00
|
|
|
Workspace::Windows &wins = wksp->getWindowList();
|
2002-04-02 23:14:54 +00:00
|
|
|
Workspace::Windows::iterator it = wins.begin();
|
2002-09-08 19:45:59 +00:00
|
|
|
|
2002-09-12 14:55:11 +00:00
|
|
|
if (!have_focused) {
|
|
|
|
focused = *it;
|
|
|
|
} else {
|
|
|
|
for (; *it != focused; ++it) //get focused window iterator
|
|
|
|
continue;
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
do {
|
2002-04-02 23:14:54 +00:00
|
|
|
++it;
|
|
|
|
if (it == wins.end())
|
|
|
|
it = wins.begin();
|
|
|
|
// see if the window should be skipped
|
|
|
|
if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) )
|
2002-03-18 20:20:09 +00:00
|
|
|
break;
|
2002-04-02 23:14:54 +00:00
|
|
|
} while (*it != focused);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
if (*it != focused && it != wins.end())
|
2002-04-02 23:14:54 +00:00
|
|
|
wksp->raiseWindow(*it);
|
2002-07-10 14:51:32 +00:00
|
|
|
|
2001-12-11 20:47:02 +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-04-02 23:14:54 +00:00
|
|
|
bool have_focused = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
int focused_window_number = -1;
|
2002-04-02 23:14:54 +00:00
|
|
|
FluxboxWindow *focused;
|
|
|
|
int num_windows = getCurrentWorkspace()->getCount();
|
|
|
|
|
|
|
|
if ((focused = fluxbox->getFocusedWindow())) {
|
|
|
|
if (focused->getScreen()->getScreenNumber() ==
|
|
|
|
getScreenNumber()) {
|
|
|
|
have_focused = true;
|
|
|
|
focused_window_number = focused->getWindowNumber();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-04-02 23:14:54 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-09-12 14:55:11 +00:00
|
|
|
if (num_windows >= 1) {
|
2002-04-02 23:14:54 +00:00
|
|
|
Workspace *wksp = getCurrentWorkspace();
|
2002-09-12 14:55:11 +00:00
|
|
|
Workspace::Windows &wins = wksp->getWindowList();
|
2002-04-02 23:14:54 +00:00
|
|
|
Workspace::Windows::iterator it = wins.begin();
|
2002-09-12 14:55:11 +00:00
|
|
|
|
|
|
|
if (!have_focused) {
|
|
|
|
focused = *it;
|
|
|
|
} else {
|
|
|
|
for (; *it != focused; ++it) //get focused window iterator
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
do {
|
2002-04-02 23:14:54 +00:00
|
|
|
if (it == wins.begin())
|
|
|
|
it = wins.end();
|
|
|
|
--it;
|
|
|
|
// see if the window should be skipped
|
2002-09-12 14:55:11 +00:00
|
|
|
if (! (doSkipWindow(*it, opts) || !(*it)->setInputFocus()) )
|
2002-03-18 20:20:09 +00:00
|
|
|
break;
|
2002-04-02 23:14:54 +00:00
|
|
|
} while (*it != focused);
|
2002-09-12 14:55:11 +00:00
|
|
|
|
|
|
|
if (*it != focused && it != wins.end())
|
2002-04-02 23:14:54 +00:00
|
|
|
wksp->raiseWindow(*it);
|
|
|
|
|
2002-09-12 14:55:11 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------- raiseFocus -----------
|
|
|
|
// Raise the current focused window
|
|
|
|
//--------------------------------
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::raiseFocus() {
|
2002-04-02 23:14:54 +00:00
|
|
|
bool have_focused = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
int focused_window_number = -1;
|
|
|
|
|
|
|
|
if (fluxbox->getFocusedWindow())
|
|
|
|
if (fluxbox->getFocusedWindow()->getScreen()->getScreenNumber() ==
|
2002-04-08 22:36:30 +00:00
|
|
|
getScreenNumber()) {
|
2002-04-02 23:14:54 +00:00
|
|
|
have_focused = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
focused_window_number = fluxbox->getFocusedWindow()->getWindowNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((getCurrentWorkspace()->getCount() > 1) && have_focused)
|
|
|
|
getWorkspace(fluxbox->getFocusedWindow()->getWorkspaceNumber())->
|
|
|
|
raiseWindow(fluxbox->getFocusedWindow());
|
|
|
|
}
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::initMenu() {
|
2001-12-11 20:47:02 +00:00
|
|
|
I18n *i18n = I18n::instance();
|
|
|
|
|
|
|
|
if (rootmenu) {
|
2002-02-08 13:35:20 +00:00
|
|
|
rootmenuList.erase(rootmenuList.begin(), rootmenuList.end());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
while (rootmenu->numberOfItems())
|
2002-04-28 19:54:10 +00:00
|
|
|
rootmenu->remove(0);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
|
|
|
rootmenu = new Rootmenu(this);
|
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
bool defaultMenu = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
if (fluxbox->getMenuFilename()) {
|
2002-01-27 12:45:32 +00:00
|
|
|
ifstream menu_file(fluxbox->getMenuFilename());
|
|
|
|
|
|
|
|
if (!menu_file.fail()) {
|
|
|
|
if (! menu_file.eof()) {
|
|
|
|
string line;
|
|
|
|
int row = 0;
|
|
|
|
while (getline(menu_file, line) && ! menu_file.eof()) {
|
|
|
|
row++;
|
2001-12-11 20:47:02 +00:00
|
|
|
if (line[0] != '#') {
|
2002-01-27 12:45:32 +00:00
|
|
|
string key;
|
|
|
|
int pos=0;
|
|
|
|
int err = StringUtil::getStringBetween(key, line.c_str(), '[', ']');
|
|
|
|
|
|
|
|
if (key == "begin") {
|
|
|
|
pos += err;
|
|
|
|
string label;
|
|
|
|
err = StringUtil::getStringBetween(label, line.c_str()+pos, '(', ')');
|
|
|
|
if (err>0) {
|
|
|
|
rootmenu->setLabel(label.c_str());
|
|
|
|
defaultMenu = parseMenuFile(menu_file, rootmenu, row);
|
|
|
|
} else
|
|
|
|
cerr<<"Error in menufile. Line("<<row<<")"<<endl;
|
2001-12-11 20:47:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile,
|
2001-12-11 20:47:02 +00:00
|
|
|
"%s: Empty menu file"),
|
|
|
|
fluxbox->getMenuFilename());
|
|
|
|
}
|
2002-04-12 14:56:15 +00:00
|
|
|
menu_file.close();
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
|
|
|
perror(fluxbox->getMenuFilename());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defaultMenu) {
|
|
|
|
rootmenu->setInternalMenu();
|
|
|
|
rootmenu->insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::Screenxterm,
|
|
|
|
"xterm"),
|
|
|
|
BScreen::EXECUTE,
|
|
|
|
i18n->getMessage(
|
|
|
|
FBNLS::ScreenSet, FBNLS::Screenxterm,
|
|
|
|
"xterm"));
|
2001-12-11 20:47:02 +00:00
|
|
|
rootmenu->insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenRestart,
|
|
|
|
"Restart"),
|
|
|
|
BScreen::RESTART);
|
2001-12-11 20:47:02 +00:00
|
|
|
rootmenu->insert(i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenExit,
|
|
|
|
"Exit"),
|
|
|
|
BScreen::EXIT);
|
2001-12-11 20:47:02 +00:00
|
|
|
} else
|
|
|
|
fluxbox->saveMenuFilename(fluxbox->getMenuFilename());
|
|
|
|
}
|
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
// looks through a menufile and adds correct items to the root-menu.
|
2002-04-12 14:56:15 +00:00
|
|
|
bool BScreen::parseMenuFile(ifstream &file, Rootmenu *menu, int &row) {
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
|
|
string line;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
while (! file.eof()) {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
if (getline(file, line)) {
|
|
|
|
row++;
|
2002-03-08 12:18:22 +00:00
|
|
|
if (line[0] != '#') { //the line is commented
|
2002-01-27 12:45:32 +00:00
|
|
|
int parse_pos = 0, err = 0;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
std::string str_key, str_label, str_cmd;
|
|
|
|
|
|
|
|
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, '{', '}');
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-01-27 12:45:32 +00:00
|
|
|
} else
|
|
|
|
continue; //read next line
|
|
|
|
|
|
|
|
if (!str_key.size())
|
|
|
|
continue; //read next line
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
I18n *i18n = I18n::instance();
|
2002-01-27 12:45:32 +00:00
|
|
|
if (str_key == "end") {
|
2002-04-08 22:36:30 +00:00
|
|
|
return ((menu->numberOfItems() == 0) ? true : false);
|
2002-01-27 12:45:32 +00:00
|
|
|
} else if (str_key == "nop") {
|
|
|
|
menu->insert(str_label.c_str());
|
|
|
|
} else if (str_key == "exec") { // exec
|
|
|
|
if (!(str_label.size() && str_cmd.size())) {
|
|
|
|
fprintf(stderr,
|
2001-12-11 20:47:02 +00:00
|
|
|
i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenEXECError,
|
|
|
|
"BScreen::parseMenuFile: [exec] error, "
|
|
|
|
"no menu label and/or command defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else
|
|
|
|
menu->insert(str_label.c_str(), BScreen::EXECUTE, str_cmd.c_str());
|
|
|
|
|
|
|
|
} else if (str_key == "exit") { // exit
|
|
|
|
if (!str_label.size()) {
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenEXITError,
|
|
|
|
"BScreen::parseMenuFile: [exit] error, "
|
|
|
|
"no menu label defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else
|
|
|
|
menu->insert(str_label.c_str(), BScreen::EXIT);
|
|
|
|
} // end of exit
|
|
|
|
else if (str_key == "style") { // style
|
|
|
|
if (!( str_label.size() && str_cmd.size())) {
|
|
|
|
fprintf(stderr,
|
2001-12-11 20:47:02 +00:00
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLEError,
|
|
|
|
"BScreen::parseMenuFile: [style] error, "
|
|
|
|
"no menu label and/or filename defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else {
|
|
|
|
// perform shell style ~ home directory expansion
|
2002-08-14 22:21:06 +00:00
|
|
|
// and insert style
|
|
|
|
menu->insert(str_label.c_str(), BScreen::SETSTYLE,
|
|
|
|
StringUtil::expandFilename(str_cmd).c_str());
|
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
}
|
|
|
|
} // end of style
|
|
|
|
|
|
|
|
else if (str_key == "config") {
|
|
|
|
if (! str_label.size()) {
|
|
|
|
fprintf(stderr,
|
2001-12-11 20:47:02 +00:00
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenCONFIGError,
|
|
|
|
"BScreen::parseMenufile: [config] error, "
|
|
|
|
"no label defined"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else
|
|
|
|
menu->insert(str_label.c_str(), configmenu);
|
|
|
|
} // end of config
|
|
|
|
else if ( str_key == "include") { // include
|
|
|
|
if (!str_label.size()) {
|
|
|
|
fprintf(stderr,
|
2001-12-11 20:47:02 +00:00
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenINCLUDEError,
|
|
|
|
"BScreen::parseMenuFile: [include] error, "
|
|
|
|
"no filename defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else { // start of else 'x'
|
|
|
|
// perform shell style ~ home directory expansion
|
2002-08-14 22:21:06 +00:00
|
|
|
string newfile(StringUtil::expandFilename(str_label));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-14 22:21:06 +00:00
|
|
|
if (newfile.size() != 0) {
|
|
|
|
FILE *submenufile = fopen(newfile.c_str(), "r");
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
if (submenufile) {
|
2001-12-11 20:47:02 +00:00
|
|
|
struct stat buf;
|
|
|
|
if (fstat(fileno(submenufile), &buf) ||
|
2002-01-27 12:45:32 +00:00
|
|
|
(! S_ISREG(buf.st_mode))) {
|
2001-12-11 20:47:02 +00:00
|
|
|
fprintf(stderr,
|
2002-01-27 12:45:32 +00:00
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenINCLUDEErrorReg,
|
|
|
|
"BScreen::parseMenuFile: [include] error: "
|
2002-08-14 22:21:06 +00:00
|
|
|
"'%s' is not a regular file\n"), newfile.c_str());
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-01-27 12:45:32 +00:00
|
|
|
|
|
|
|
if (! feof(submenufile)) {
|
|
|
|
fclose(submenufile);
|
2002-08-14 22:21:06 +00:00
|
|
|
ifstream subfile(newfile.c_str());
|
2002-01-27 12:45:32 +00:00
|
|
|
if (! parseMenuFile(subfile, menu, row))
|
2002-08-14 22:21:06 +00:00
|
|
|
fluxbox->saveMenuFilename(newfile.c_str());
|
2002-01-27 12:45:32 +00:00
|
|
|
}
|
|
|
|
} else
|
2002-08-14 22:21:06 +00:00
|
|
|
perror(newfile.c_str());
|
2002-01-27 12:45:32 +00:00
|
|
|
}
|
|
|
|
} // end of else 'x'
|
|
|
|
} // end of include
|
|
|
|
else if (str_key == "submenu") { // sub
|
|
|
|
if (!str_label.size()) {
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSUBMENUError,
|
|
|
|
"BScreen::parseMenuFile: [submenu] error, "
|
|
|
|
"no menu label defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else {
|
|
|
|
Rootmenu *submenu = new Rootmenu(this);
|
|
|
|
|
|
|
|
if (str_cmd.size())
|
|
|
|
submenu->setLabel(str_cmd.c_str());
|
|
|
|
else
|
|
|
|
submenu->setLabel(str_label.c_str());
|
|
|
|
|
2002-04-12 14:56:15 +00:00
|
|
|
parseMenuFile(file, submenu, row);
|
2002-01-27 12:45:32 +00:00
|
|
|
submenu->update();
|
|
|
|
menu->insert(str_label.c_str(), submenu);
|
2002-02-08 13:35:20 +00:00
|
|
|
rootmenuList.push_back(submenu);
|
2002-04-12 14:56:15 +00:00
|
|
|
|
2002-01-27 12:45:32 +00:00
|
|
|
}
|
|
|
|
} // end of sub
|
|
|
|
else if (str_key == "restart") {
|
|
|
|
if (!str_label.size()) {
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenRESTARTError,
|
|
|
|
"BScreen::parseMenuFile: [restart] error, "
|
|
|
|
"no menu label defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else {
|
|
|
|
if (str_cmd.size())
|
|
|
|
menu->insert(str_label.c_str(), BScreen::RESTARTOTHER, str_cmd.c_str());
|
|
|
|
else
|
|
|
|
menu->insert(str_label.c_str(), BScreen::RESTART);
|
|
|
|
}
|
|
|
|
} // end of restart
|
|
|
|
else if (str_key == "reconfig") { // reconf
|
|
|
|
if (!str_label.c_str()) {
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenRECONFIGError,
|
|
|
|
"BScreen::parseMenuFile: [reconfig] error, "
|
|
|
|
"no menu label defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else
|
|
|
|
menu->insert(str_label.c_str(), BScreen::RECONFIGURE);
|
|
|
|
} // end of reconf
|
|
|
|
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(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRError,
|
|
|
|
"BScreen::parseMenuFile: [stylesdir/stylesmenu]"
|
|
|
|
" error, no directory defined\n"));
|
2002-01-27 12:45:32 +00:00
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else { // else 'y'
|
2002-02-17 18:56:14 +00:00
|
|
|
createStyleMenu(menu, newmenu, str_label.c_str(), (newmenu) ? str_cmd.c_str() : str_label.c_str());
|
2002-01-27 12:45:32 +00:00
|
|
|
} // end of else 'y'
|
|
|
|
} // end of stylesdir
|
|
|
|
else if (str_key == "workspaces") {
|
|
|
|
if (!str_label.size()) {
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenWORKSPACESError,
|
2002-01-27 12:45:32 +00:00
|
|
|
"BScreen:parseMenuFile: [workspaces] error, "
|
|
|
|
"no menu label defined\n"));
|
|
|
|
cerr<<"Row: "<<row<<endl;
|
|
|
|
} else
|
|
|
|
menu->insert(str_label.c_str(), workspacemenu);
|
|
|
|
} // end of work
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-08 22:36:30 +00:00
|
|
|
return ((menu->numberOfItems() == 0) ? true : false);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2002-02-17 18:56:14 +00:00
|
|
|
void BScreen::createStyleMenu(Rootmenu *menu, bool newmenu, const char *label, const char *directory) {
|
2002-08-14 22:21:06 +00:00
|
|
|
|
2002-02-17 18:56:14 +00:00
|
|
|
// perform shell style ~ home directory expansion
|
2002-08-14 22:21:06 +00:00
|
|
|
string stylesdir(StringUtil::expandFilename(directory ? directory : ""));
|
|
|
|
|
|
|
|
I18n *i18n = I18n::instance();
|
2002-02-17 18:56:14 +00:00
|
|
|
struct stat statbuf;
|
|
|
|
|
2002-08-14 22:21:06 +00:00
|
|
|
if (! stat(stylesdir.c_str(), &statbuf)) { // stat
|
2002-02-17 18:56:14 +00:00
|
|
|
if (S_ISDIR(statbuf.st_mode)) { // dir
|
|
|
|
Rootmenu *stylesmenu;
|
|
|
|
if (newmenu)
|
|
|
|
stylesmenu = new Rootmenu(this);
|
|
|
|
else
|
|
|
|
stylesmenu = menu;
|
|
|
|
|
2002-08-14 22:21:06 +00:00
|
|
|
DIR *d = opendir(stylesdir.c_str());
|
2002-02-17 18:56:14 +00:00
|
|
|
int entries = 0;
|
|
|
|
struct dirent *p;
|
|
|
|
|
|
|
|
// get the total number of directory entries
|
|
|
|
while ((p = readdir(d))) entries++;
|
|
|
|
|
|
|
|
rewinddir(d);
|
|
|
|
|
|
|
|
char **ls = new char* [entries];
|
|
|
|
int index = 0;
|
|
|
|
while ((p = readdir(d)))
|
|
|
|
ls[index++] = StringUtil::strdup(p->d_name);
|
|
|
|
|
|
|
|
qsort(ls, entries, sizeof(char *), dcmp);
|
|
|
|
|
2002-08-14 22:21:06 +00:00
|
|
|
int n, slen = strlen(stylesdir.c_str());
|
2002-02-17 18:56:14 +00:00
|
|
|
for (n = 0; n < entries; n++) { // for
|
|
|
|
int nlen = strlen(ls[n]);
|
|
|
|
char style[MAXPATHLEN + 1];
|
2002-08-14 22:21:06 +00:00
|
|
|
strncpy(style, stylesdir.c_str(), slen);
|
2002-02-17 18:56:14 +00:00
|
|
|
*(style + slen) = '/';
|
|
|
|
strncpy(style + slen + 1, ls[n], nlen + 1);
|
|
|
|
if ((! stat(style, &statbuf)) && S_ISREG(statbuf.st_mode))
|
|
|
|
stylesmenu->insert(ls[n], BScreen::SETSTYLE, style);
|
|
|
|
delete [] ls[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
delete [] ls;
|
|
|
|
|
|
|
|
stylesmenu->update();
|
|
|
|
if (newmenu) {
|
|
|
|
stylesmenu->setLabel(label);
|
|
|
|
menu->insert(label, stylesmenu);
|
|
|
|
rootmenuList.push_back(stylesmenu);
|
|
|
|
}
|
|
|
|
|
2002-08-14 22:21:06 +00:00
|
|
|
fluxbox->saveMenuFilename(stylesdir.c_str());
|
2002-02-17 18:56:14 +00:00
|
|
|
} else { // dir
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNotDir,
|
2002-02-17 18:56:14 +00:00
|
|
|
"BScreen::parseMenuFile:"
|
|
|
|
" [stylesdir/stylesmenu] error, %s is not a"
|
2002-08-14 22:21:06 +00:00
|
|
|
" directory\n"), stylesdir.c_str());
|
2002-02-17 18:56:14 +00:00
|
|
|
} // end of 'dir'
|
|
|
|
} else { // stat
|
|
|
|
fprintf(stderr,
|
|
|
|
i18n->
|
|
|
|
getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNoExist,
|
|
|
|
"BScreen::parseMenuFile: [stylesdir/stylesmenu]"
|
2002-08-14 22:21:06 +00:00
|
|
|
" error, %s does not exist\n"), stylesdir.c_str());
|
2002-02-17 18:56:14 +00:00
|
|
|
} // end of 'stat'
|
|
|
|
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::shutdown() {
|
2001-12-11 20:47:02 +00:00
|
|
|
fluxbox->grab();
|
|
|
|
|
|
|
|
XSelectInput(getBaseDisplay()->getXDisplay(), getRootWindow(), NoEventMask);
|
|
|
|
XSync(getBaseDisplay()->getXDisplay(), False);
|
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
{
|
|
|
|
Workspaces::iterator it = workspacesList.begin();
|
|
|
|
Workspaces::iterator it_end = workspacesList.end();
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->shutdown();
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-02-08 13:35:20 +00:00
|
|
|
{
|
2002-02-10 22:48:19 +00:00
|
|
|
while (!iconList.empty()) {
|
2002-08-16 11:01:09 +00:00
|
|
|
iconList.back()->restore(true); // restore with remap
|
2002-02-10 22:48:19 +00:00
|
|
|
delete iconList.back(); // the window removes it self from iconlist
|
2002-02-08 13:35:20 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
slit->shutdown();
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
fluxbox->ungrab();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::showPosition(int x, int y) {
|
|
|
|
if (! geom_visible) {
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
unsigned int head = hasXinerama() ? getCurrHead() : 0;
|
|
|
|
|
|
|
|
XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window,
|
|
|
|
getHeadX(head) + (getHeadWidth(head) - geom_w) / 2,
|
|
|
|
getHeadY(head) + (getHeadHeight(head) - geom_h) / 2, geom_w, geom_h);
|
|
|
|
#else // !XINERMA
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-01-20 02:17:23 +00:00
|
|
|
(getWidth() - geom_w) / 2,
|
|
|
|
(getHeight() - geom_h) / 2, geom_w, geom_h);
|
2002-03-19 14:30:43 +00:00
|
|
|
#endif // XINERAMA
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
XMapWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
geom_visible = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
const int label_size = 1024;
|
|
|
|
char label[label_size];
|
|
|
|
|
|
|
|
snprintf(label, label_size,
|
|
|
|
I18n::instance()->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenPositionFormat,
|
|
|
|
"X: %4d x Y: %4d"), x, y);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XClearWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
|
|
|
|
if (I18n::instance()->multibyte())
|
|
|
|
XmbDrawString(getBaseDisplay()->getXDisplay(), geom_window,
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().font.set, theme->getWindowStyle().l_text_focus_gc,
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->getBevelWidth(), theme->getBevelWidth() -
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().font.set_extents->max_ink_extent.y,
|
2001-12-11 20:47:02 +00:00
|
|
|
label, strlen(label));
|
|
|
|
else
|
|
|
|
XDrawString(getBaseDisplay()->getXDisplay(), geom_window,
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().l_text_focus_gc,
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->getBevelWidth(),
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().font.fontstruct->ascent +
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->getBevelWidth(), label, strlen(label));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
|
|
|
|
if (! geom_visible) {
|
2002-03-19 14:30:43 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
unsigned int head = hasXinerama() ? getCurrHead() : 0;
|
|
|
|
|
|
|
|
XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window,
|
|
|
|
getHeadX(head) + (getHeadWidth(head) - geom_w) / 2,
|
|
|
|
getHeadY(head) + (getHeadHeight(head) - geom_h) / 2, geom_w, geom_h);
|
|
|
|
#else // !XINERMA
|
2001-12-11 20:47:02 +00:00
|
|
|
XMoveResizeWindow(getBaseDisplay()->getXDisplay(), geom_window,
|
2002-03-19 14:30:43 +00:00
|
|
|
(getWidth() - geom_w) / 2,
|
|
|
|
(getHeight() - geom_h) / 2, geom_w, geom_h);
|
|
|
|
#endif // XINERAMA
|
2001-12-11 20:47:02 +00:00
|
|
|
XMapWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
XRaiseWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
|
2002-04-04 14:28:54 +00:00
|
|
|
geom_visible = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char label[1024];
|
|
|
|
|
|
|
|
sprintf(label,
|
|
|
|
I18n::instance()->getMessage(
|
2002-04-04 11:28:19 +00:00
|
|
|
FBNLS::ScreenSet, FBNLS::ScreenGeometryFormat,
|
|
|
|
"W: %4d x H: %4d"), gx, gy);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
XClearWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
|
|
|
|
|
|
|
if (I18n::instance()->multibyte())
|
|
|
|
XmbDrawString(getBaseDisplay()->getXDisplay(), geom_window,
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().font.set, theme->getWindowStyle().l_text_focus_gc,
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->getBevelWidth(), theme->getBevelWidth() -
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().font.set_extents->max_ink_extent.y,
|
2001-12-11 20:47:02 +00:00
|
|
|
label, strlen(label));
|
|
|
|
else
|
|
|
|
XDrawString(getBaseDisplay()->getXDisplay(), geom_window,
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().l_text_focus_gc,
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->getBevelWidth(),
|
2001-12-13 20:44:57 +00:00
|
|
|
theme->getWindowStyle().font.fontstruct->ascent +
|
2001-12-11 20:47:02 +00:00
|
|
|
theme->getBevelWidth(), label, strlen(label));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::hideGeometry() {
|
2001-12-11 20:47:02 +00:00
|
|
|
if (geom_visible) {
|
|
|
|
XUnmapWindow(getBaseDisplay()->getXDisplay(), geom_window);
|
2002-04-04 14:28:54 +00:00
|
|
|
geom_visible = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------- nextWorkspace ---------------
|
|
|
|
// Goes to the workspace "right" of the current
|
|
|
|
//--------------------------------------------
|
2002-02-20 23:04:51 +00:00
|
|
|
void BScreen::nextWorkspace(const int delta) {
|
2002-04-04 14:28:54 +00:00
|
|
|
changeWorkspaceID( (getCurrentWorkspaceID()+delta) % getCount());
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------- prevWorkspace ----------------
|
|
|
|
// Goes to the workspace "left" of the current
|
|
|
|
//--------------------------------------------
|
2002-02-20 23:04:51 +00:00
|
|
|
void BScreen::prevWorkspace(const int delta) {
|
2002-04-04 14:28:54 +00:00
|
|
|
changeWorkspaceID( (getCurrentWorkspaceID()-delta+getCount()) % getCount());
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2002-02-02 19:51:15 +00:00
|
|
|
|
|
|
|
//-------------- rightWorkspace ---------------
|
|
|
|
// Goes to the workspace "right" of the current
|
|
|
|
//--------------------------------------------
|
2002-02-20 23:04:51 +00:00
|
|
|
void BScreen::rightWorkspace(const int delta) {
|
|
|
|
if (getCurrentWorkspaceID()+delta < getCount())
|
|
|
|
changeWorkspaceID(getCurrentWorkspaceID()+delta);
|
2002-02-02 19:51:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------- leftWorkspace ----------------
|
|
|
|
// Goes to the workspace "left" of the current
|
|
|
|
//--------------------------------------------
|
2002-02-20 23:04:51 +00:00
|
|
|
void BScreen::leftWorkspace(const int delta) {
|
2002-03-23 15:14:45 +00:00
|
|
|
if (getCurrentWorkspaceID() >= static_cast<unsigned int>(delta))
|
2002-02-20 23:04:51 +00:00
|
|
|
changeWorkspaceID(getCurrentWorkspaceID()-delta);
|
2002-02-02 19:51:15 +00:00
|
|
|
}
|
2002-02-07 14:46:23 +00:00
|
|
|
|
2002-04-02 23:14:54 +00:00
|
|
|
//-------- doSkipWindow
|
|
|
|
// Returns true if the windows should be skiped
|
|
|
|
// else false
|
|
|
|
//----------
|
|
|
|
bool BScreen::doSkipWindow(const FluxboxWindow *w, int opts) {
|
|
|
|
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-08-02 12:58:37 +00:00
|
|
|
//----------- useAutoGroupWindow -------------
|
|
|
|
// Access and clear the auto-group window
|
|
|
|
//--------------------------------------------
|
|
|
|
FluxboxWindow* BScreen::useAutoGroupWindow() {
|
|
|
|
Window w = auto_group_window;
|
|
|
|
auto_group_window = 0;
|
|
|
|
return w ? Fluxbox::instance()->searchWindow(w) : 0;
|
|
|
|
}
|
|
|
|
|