2002-01-09 14:11:20 +00:00
|
|
|
// Screen.cc for Fluxbox Window Manager
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2001 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
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.
|
|
|
|
|
2004-11-17 01:21:50 +00:00
|
|
|
// $Id$
|
2002-10-25 20:58:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "Screen.hh"
|
|
|
|
|
|
|
|
#include "fluxbox.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Workspace.hh"
|
2002-11-17 11:29:06 +00:00
|
|
|
#include "Netizen.hh"
|
2004-05-02 21:12:22 +00:00
|
|
|
|
2006-03-16 18:25:33 +00:00
|
|
|
#include "Layer.hh"
|
2006-02-18 11:39:38 +00:00
|
|
|
#include "FocusControl.hh"
|
2006-02-19 11:11:22 +00:00
|
|
|
#include "ScreenPlacement.hh"
|
2006-02-18 11:39:38 +00:00
|
|
|
|
2006-05-13 15:35:47 +00:00
|
|
|
#include "STLUtil.hh"
|
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
// themes
|
2003-04-25 11:05:11 +00:00
|
|
|
#include "FbWinFrameTheme.hh"
|
2003-01-07 02:06:06 +00:00
|
|
|
#include "MenuTheme.hh"
|
2003-04-25 11:05:11 +00:00
|
|
|
#include "RootTheme.hh"
|
2003-04-28 22:43:26 +00:00
|
|
|
#include "WinButtonTheme.hh"
|
2004-05-02 21:12:22 +00:00
|
|
|
#include "SlitTheme.hh"
|
|
|
|
|
|
|
|
// menu items
|
2003-01-12 17:59:20 +00:00
|
|
|
#include "BoolMenuItem.hh"
|
2003-02-17 12:35:59 +00:00
|
|
|
#include "IntResMenuItem.hh"
|
2004-05-02 21:12:22 +00:00
|
|
|
#include "FocusModelMenuItem.hh"
|
|
|
|
|
|
|
|
// menus
|
2003-02-18 15:11:12 +00:00
|
|
|
#include "FbMenu.hh"
|
|
|
|
#include "LayerMenu.hh"
|
2004-05-02 21:12:22 +00:00
|
|
|
|
|
|
|
#include "MenuCreator.hh"
|
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
#include "WinClient.hh"
|
2003-05-15 11:17:29 +00:00
|
|
|
#include "FbWinFrame.hh"
|
2003-06-18 13:42:21 +00:00
|
|
|
#include "Strut.hh"
|
2003-06-30 15:31:54 +00:00
|
|
|
#include "CommandParser.hh"
|
2004-04-19 22:44:42 +00:00
|
|
|
#include "AtomHandler.hh"
|
2004-09-11 13:33:07 +00:00
|
|
|
#include "HeadArea.hh"
|
2002-01-09 14:11:20 +00:00
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
|
2004-06-07 11:46:05 +00:00
|
|
|
#include "FbTk/I18n.hh"
|
2003-12-19 00:34:23 +00:00
|
|
|
#include "FbTk/Subject.hh"
|
2004-05-02 21:12:22 +00:00
|
|
|
#include "FbTk/FbWindow.hh"
|
2003-12-19 00:34:23 +00:00
|
|
|
#include "FbTk/SimpleCommand.hh"
|
|
|
|
#include "FbTk/MultLayers.hh"
|
|
|
|
#include "FbTk/XLayerItem.hh"
|
|
|
|
#include "FbTk/MacroCommand.hh"
|
|
|
|
#include "FbTk/StringUtil.hh"
|
|
|
|
#include "FbTk/ImageControl.hh"
|
2004-04-19 22:44:42 +00:00
|
|
|
#include "FbTk/EventManager.hh"
|
2004-09-12 14:56:20 +00:00
|
|
|
#include "FbTk/Transparent.hh"
|
2005-05-02 12:10:01 +00:00
|
|
|
#include "FbTk/Select2nd.hh"
|
|
|
|
#include "FbTk/Compose.hh"
|
2006-05-07 10:08:25 +00:00
|
|
|
#include "FbTk/FbString.hh"
|
2003-12-19 00:34:23 +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"
|
2004-04-19 22:44:42 +00:00
|
|
|
#include "SlitClient.hh"
|
2003-10-28 17:39:59 +00:00
|
|
|
#else
|
|
|
|
// fill it in
|
|
|
|
class Slit {};
|
2001-12-11 20:47:02 +00:00
|
|
|
#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_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_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-01-27 12:45:32 +00:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2003-06-12 15:24:37 +00:00
|
|
|
#include <X11/cursorfont.h>
|
2002-01-27 12:45:32 +00:00
|
|
|
|
2003-05-19 14:26:30 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
extern "C" {
|
|
|
|
#include <X11/extensions/Xinerama.h>
|
|
|
|
}
|
|
|
|
#endif // XINERAMA
|
|
|
|
|
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>
|
2003-04-14 15:01:55 +00:00
|
|
|
#include <functional>
|
2004-05-02 21:12:22 +00:00
|
|
|
#include <stack>
|
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 *) {
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2006-06-21 14:41:16 +00:00
|
|
|
cerr<<_FB_CONSOLETEXT(Screen, AnotherWMRunning,
|
2004-06-07 11:46:05 +00:00
|
|
|
"BScreen::BScreen: an error occured while querying the X server.\n"
|
|
|
|
" another window manager already running on display ",
|
|
|
|
"Message when another WM is found already active on all screens")
|
|
|
|
<<DisplayString(display)<<endl;
|
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
|
|
|
|
2003-05-17 11:05:33 +00:00
|
|
|
return -1;
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 16:45:23 +00:00
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
class TabPlacementMenuItem: public FbTk::MenuItem {
|
|
|
|
public:
|
2006-05-20 15:08:14 +00:00
|
|
|
TabPlacementMenuItem(FbTk::FbString & label, BScreen &screen,
|
2006-04-02 21:37:44 +00:00
|
|
|
FbWinFrame::TabPlacement place,
|
|
|
|
FbTk::RefCount<FbTk::Command> &cmd):
|
2006-03-22 12:23:17 +00:00
|
|
|
FbTk::MenuItem(label, cmd),
|
|
|
|
m_screen(screen),
|
|
|
|
m_place(place) { }
|
|
|
|
|
|
|
|
bool isEnabled() const { return m_screen.getTabPlacement() != m_place; }
|
|
|
|
void click(int button, int time) {
|
|
|
|
m_screen.saveTabPlacement(m_place);
|
|
|
|
FbTk::MenuItem::click(button, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
BScreen &m_screen;
|
|
|
|
FbWinFrame::TabPlacement m_place;
|
|
|
|
};
|
2003-01-09 17:41:02 +00:00
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
} // end anonymous namespace
|
2002-01-20 02:17:23 +00:00
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace FbTk {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
void FbTk::Resource<FbWinFrame::TabPlacement>::
|
|
|
|
setFromString(const char *strval) {
|
|
|
|
if (strcasecmp(strval, "TopLeft")==0)
|
|
|
|
m_value = FbWinFrame::TOPLEFT;
|
|
|
|
else if (strcasecmp(strval, "BottomLeft")==0)
|
|
|
|
m_value = FbWinFrame::BOTTOMLEFT;
|
|
|
|
else if (strcasecmp(strval, "TopRight")==0)
|
|
|
|
m_value = FbWinFrame::TOPRIGHT;
|
|
|
|
else if (strcasecmp(strval, "BottomRight")==0)
|
|
|
|
m_value = FbWinFrame::BOTTOMRIGHT;
|
|
|
|
else if (strcasecmp(strval, "LeftTop") == 0)
|
|
|
|
m_value = FbWinFrame::LEFTTOP;
|
|
|
|
else if (strcasecmp(strval, "LeftBottom") == 0)
|
|
|
|
m_value = FbWinFrame::LEFTBOTTOM;
|
|
|
|
else if (strcasecmp(strval, "RightTop") == 0)
|
|
|
|
m_value = FbWinFrame::RIGHTTOP;
|
|
|
|
else if (strcasecmp(strval, "RightBottom") == 0)
|
|
|
|
m_value = FbWinFrame::RIGHTBOTTOM;
|
|
|
|
else
|
|
|
|
setDefaultValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
string FbTk::Resource<FbWinFrame::TabPlacement>::
|
|
|
|
getString() const {
|
|
|
|
switch (m_value) {
|
|
|
|
case FbWinFrame::TOPLEFT:
|
|
|
|
return string("TopLeft");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::BOTTOMLEFT:
|
|
|
|
return string("BottomLeft");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::TOPRIGHT:
|
|
|
|
return string("TopRight");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::BOTTOMRIGHT:
|
|
|
|
return string("BottomRight");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::LEFTTOP:
|
|
|
|
return string("LeftTop");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::LEFTBOTTOM:
|
|
|
|
return string("LeftBottom");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::RIGHTTOP:
|
|
|
|
return string("RightTop");
|
|
|
|
break;
|
|
|
|
case FbWinFrame::RIGHTBOTTOM:
|
|
|
|
return string("RightBottom");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//default string
|
|
|
|
return string("TopLeft");
|
|
|
|
}
|
|
|
|
} // end namespace FbTk
|
|
|
|
|
|
|
|
|
2003-05-18 22:01:14 +00:00
|
|
|
BScreen::ScreenResource::ScreenResource(FbTk::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
|
|
|
image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"),
|
2003-12-19 00:34:23 +00:00
|
|
|
opaque_move(rm, false, scrname + ".opaqueMove", altscrname+".OpaqueMove"),
|
2002-12-01 13:42:15 +00:00
|
|
|
full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"),
|
|
|
|
workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"),
|
|
|
|
desktop_wheeling(rm, true, scrname+".desktopwheeling", altscrname+".DesktopWheeling"),
|
2006-04-16 12:03:31 +00:00
|
|
|
reverse_wheeling(rm, false, scrname+".reversewheeling", altscrname+".ReverseWheeling"),
|
2002-12-01 13:42:15 +00:00
|
|
|
show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"),
|
2003-02-22 16:09:44 +00:00
|
|
|
auto_raise(rm, false, scrname+".autoRaise", altscrname+".AutoRaise"),
|
2003-04-16 00:38:06 +00:00
|
|
|
click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"),
|
2004-03-30 13:48:38 +00:00
|
|
|
decorate_transient(rm, false, scrname+".decorateTransient", altscrname+".DecorateTransient"),
|
2002-12-01 13:42:15 +00:00
|
|
|
rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
|
2004-10-18 01:24:24 +00:00
|
|
|
resize_model(rm, BOTTOMRESIZE, scrname+".resizeMode", altscrname+".ResizeMode"),
|
2006-03-22 12:23:17 +00:00
|
|
|
tab_placement(rm, FbWinFrame::TOPLEFT, scrname+".tab.placement", altscrname+".Tab.Placement"),
|
2004-05-02 21:12:22 +00:00
|
|
|
windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"),
|
2004-10-16 22:18:56 +00:00
|
|
|
follow_model(rm, IGNORE_OTHER_WORKSPACES, scrname+".followModel", altscrname+".followModel"),
|
2002-12-01 13:42:15 +00:00
|
|
|
workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"),
|
|
|
|
edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"),
|
2004-09-12 14:56:20 +00:00
|
|
|
focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"),
|
|
|
|
unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"),
|
|
|
|
menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"),
|
2003-12-12 18:18:49 +00:00
|
|
|
menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"),
|
|
|
|
menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"),
|
2006-03-22 13:06:00 +00:00
|
|
|
tab_width(rm, 64, scrname + ".tab.width", altscrname+".Tab.Width"),
|
2003-12-19 00:34:23 +00:00
|
|
|
menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"),
|
2006-02-19 11:11:22 +00:00
|
|
|
|
2004-03-22 21:01:42 +00:00
|
|
|
gc_line_width(rm, 1, scrname+".overlay.lineWidth", altscrname+".Overlay.LineWidth"),
|
|
|
|
gc_line_style(rm,
|
|
|
|
FbTk::GContext::LINESOLID,
|
|
|
|
scrname+".overlay.lineStyle",
|
|
|
|
altscrname+".Overlay.LineStyle"),
|
|
|
|
gc_join_style(rm,
|
|
|
|
FbTk::GContext::JOINMITER,
|
|
|
|
scrname+".overlay.joinStyle",
|
|
|
|
altscrname+".Overlay.JoinStyle"),
|
|
|
|
gc_cap_style(rm,
|
|
|
|
FbTk::GContext::CAPNOTLAST,
|
|
|
|
scrname+".overlay.capStyle",
|
2005-09-07 16:46:17 +00:00
|
|
|
altscrname+".overlay.CapStyle"),
|
|
|
|
scroll_action(rm, "", scrname+".windowScrollAction", altscrname+".WindowScrollAction"),
|
2006-03-20 11:31:24 +00:00
|
|
|
scroll_reverse(rm, false, scrname+".windowScrollReverse", altscrname+".WindowScrollReverse"),
|
2006-04-24 11:23:01 +00:00
|
|
|
default_internal_tabs(rm, false /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") {
|
2005-09-07 16:46:17 +00:00
|
|
|
|
2002-01-20 02:17:23 +00:00
|
|
|
|
2003-12-19 00:34:23 +00:00
|
|
|
}
|
2002-01-20 02:17:23 +00:00
|
|
|
|
2003-05-18 22:01:14 +00:00
|
|
|
BScreen::BScreen(FbTk::ResourceManager &rm,
|
2006-04-25 02:19:04 +00:00
|
|
|
const std::string &screenname,
|
|
|
|
const std::string &altscreenname,
|
2003-04-28 00:38:42 +00:00
|
|
|
int scrn, int num_layers) :
|
|
|
|
m_clientlist_sig(*this), // client signal
|
2003-09-08 16:37:27 +00:00
|
|
|
m_iconlist_sig(*this), // icon list signal
|
2003-04-28 00:38:42 +00:00
|
|
|
m_workspacecount_sig(*this), // workspace count signal
|
|
|
|
m_workspacenames_sig(*this), // workspace names signal
|
2004-01-19 18:29:43 +00:00
|
|
|
m_workspace_area_sig(*this), // workspace area signal
|
2003-04-28 00:38:42 +00:00
|
|
|
m_currentworkspace_sig(*this), // current workspace signal
|
2003-07-01 12:39:09 +00:00
|
|
|
m_reconfigure_sig(*this), // reconfigure signal
|
2003-08-24 13:07:01 +00:00
|
|
|
m_resize_sig(*this),
|
2003-04-28 00:38:42 +00:00
|
|
|
m_layermanager(num_layers),
|
|
|
|
m_windowtheme(new FbWinFrameTheme(scrn)),
|
2003-04-28 22:43:26 +00:00
|
|
|
// the order of windowtheme and winbutton theme is important
|
|
|
|
// because winbutton need to rescale the pixmaps in winbutton theme
|
|
|
|
// after fbwinframe have resized them
|
2003-08-22 15:03:28 +00:00
|
|
|
m_winbutton_theme(new WinButtonTheme(scrn, *m_windowtheme)),
|
2003-07-10 11:29:45 +00:00
|
|
|
m_menutheme(new MenuTheme(scrn)),
|
2003-05-10 22:59:32 +00:00
|
|
|
m_root_window(scrn),
|
2004-09-16 10:10:37 +00:00
|
|
|
m_geom_window(m_root_window,
|
|
|
|
0, 0, 10, 10,
|
|
|
|
false, // override redirect
|
|
|
|
true), // save under
|
|
|
|
m_pos_window(m_root_window,
|
|
|
|
0, 0, 10, 10,
|
|
|
|
false, // override redirect
|
|
|
|
true), // save under
|
2003-04-28 22:43:26 +00:00
|
|
|
resource(rm, screenname, altscreenname),
|
2006-02-18 11:39:38 +00:00
|
|
|
m_resource_manager(rm),
|
2003-06-20 01:30:08 +00:00
|
|
|
m_name(screenname),
|
|
|
|
m_altname(altscreenname),
|
2006-02-18 11:39:38 +00:00
|
|
|
m_focus_control(new FocusControl(*this)),
|
2006-02-19 11:11:22 +00:00
|
|
|
m_placement_strategy(new ScreenPlacement(*this)),
|
2003-08-12 12:21:42 +00:00
|
|
|
m_xinerama_headinfo(0),
|
|
|
|
m_shutdown(false) {
|
2003-04-28 00:38:42 +00:00
|
|
|
|
2003-12-29 01:23:04 +00:00
|
|
|
|
2005-11-22 21:59:48 +00:00
|
|
|
Display *disp = m_root_window.display();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-19 15:32:47 +00:00
|
|
|
initXinerama();
|
2003-05-19 14:26:30 +00:00
|
|
|
|
2003-06-20 01:48:06 +00:00
|
|
|
// setup error handler to catch "screen already managed by other wm"
|
2002-12-01 13:42:15 +00:00
|
|
|
XErrorHandler old = XSetErrorHandler((XErrorHandler) anotherWMRunning);
|
2003-06-12 15:24:37 +00:00
|
|
|
|
|
|
|
rootWindow().setEventMask(ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
|
|
|
|
SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask);
|
2003-05-12 04:28:46 +00:00
|
|
|
|
2005-11-22 21:59:48 +00:00
|
|
|
FbTk::App::instance()->sync(false);
|
2003-06-12 15:24:37 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XSetErrorHandler((XErrorHandler) old);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
managed = running;
|
2006-04-22 15:37:04 +00:00
|
|
|
if (! managed) {
|
|
|
|
delete m_placement_strategy; m_placement_strategy = 0;
|
|
|
|
delete m_focus_control; m_focus_control = 0;
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2006-04-22 15:37:04 +00:00
|
|
|
}
|
2004-09-11 13:33:07 +00:00
|
|
|
|
|
|
|
// TODO fluxgen: check if this is the right place
|
|
|
|
m_head_areas = new HeadArea[numHeads() ? numHeads() : 1];
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
fprintf(stderr, _FB_CONSOLETEXT(Screen, ManagingScreen,
|
2004-06-07 11:46:05 +00:00
|
|
|
"BScreen::BScreen: managing screen %d "
|
|
|
|
"using visual 0x%lx, depth %d\n",
|
2006-05-20 15:08:14 +00:00
|
|
|
"informational message saying screen number (%d), visual (%lx), and colour depth (%d)").c_str(),
|
2003-05-15 12:00:46 +00:00
|
|
|
screenNumber(), XVisualIDFromVisual(rootWindow().visual()),
|
2003-05-10 22:59:32 +00:00
|
|
|
rootWindow().depth());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-12 15:24:37 +00:00
|
|
|
|
|
|
|
rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-10-31 10:37:09 +00:00
|
|
|
// load this screens resources
|
2005-11-22 21:59:48 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
2003-10-31 10:37:09 +00:00
|
|
|
fluxbox->load_rc(*this);
|
|
|
|
|
2003-06-20 01:48:06 +00:00
|
|
|
// setup image cache engine
|
2005-11-22 21:59:48 +00:00
|
|
|
m_image_control.reset(new FbTk::ImageControl(scrn, true,
|
|
|
|
fluxbox->colorsPerChannel(),
|
2003-06-12 15:24:37 +00:00
|
|
|
fluxbox->getCacheLife(), fluxbox->getCacheMax()));
|
2003-05-15 23:30:07 +00:00
|
|
|
imageControl().installRootColormap();
|
2002-12-01 13:42:15 +00:00
|
|
|
root_colormap_installed = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2005-11-22 21:59:48 +00:00
|
|
|
m_root_theme.reset(new RootTheme(*resource.rootcommand, imageControl()));
|
|
|
|
|
2004-09-12 14:56:20 +00:00
|
|
|
m_windowtheme->setFocusedAlpha(*resource.focused_alpha);
|
|
|
|
m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha);
|
2003-07-19 03:59:56 +00:00
|
|
|
m_menutheme->setAlpha(*resource.menu_alpha);
|
2003-12-12 18:18:49 +00:00
|
|
|
m_menutheme->setMenuMode(*resource.menu_mode);
|
2003-12-18 15:27:21 +00:00
|
|
|
// clamp values
|
|
|
|
if (*resource.menu_delay > 5000)
|
|
|
|
*resource.menu_delay = 5000;
|
|
|
|
if (*resource.menu_delay < 0)
|
|
|
|
*resource.menu_delay = 0;
|
|
|
|
|
|
|
|
if (*resource.menu_delay_close > 5000)
|
|
|
|
*resource.menu_delay_close = 5000;
|
|
|
|
if (*resource.menu_delay_close < 0)
|
|
|
|
*resource.menu_delay_close = 0;
|
|
|
|
|
2003-12-12 18:18:49 +00:00
|
|
|
m_menutheme->setDelayOpen(*resource.menu_delay);
|
|
|
|
m_menutheme->setDelayClose(*resource.menu_delay_close);
|
2003-04-25 11:05:11 +00:00
|
|
|
|
2003-05-15 23:30:07 +00:00
|
|
|
imageControl().setDither(*resource.image_dither);
|
2002-01-11 10:21:44 +00:00
|
|
|
|
2003-08-25 13:15:53 +00:00
|
|
|
winFrameTheme().reconfigSig().attach(this);// for geom window
|
|
|
|
|
2004-09-16 10:10:37 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
geom_visible = false;
|
2003-06-12 15:24:37 +00:00
|
|
|
geom_pixmap = 0;
|
2004-01-16 11:47:07 +00:00
|
|
|
pos_visible = false;
|
|
|
|
pos_pixmap = 0;
|
|
|
|
|
2004-09-16 10:10:37 +00:00
|
|
|
renderGeomWindow();
|
2004-01-16 11:47:07 +00:00
|
|
|
renderPosWindow();
|
|
|
|
|
2003-06-20 01:48:06 +00:00
|
|
|
// setup workspaces and workspace menu
|
2005-04-27 09:52:30 +00:00
|
|
|
int nr_ws = *resource.workspaces;
|
|
|
|
addWorkspace(); // at least one
|
|
|
|
for (int i = 1; i < nr_ws; ++i) {
|
|
|
|
addWorkspace();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
m_current_workspace = m_workspaces_list.front();
|
2006-03-22 12:23:17 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-06-25 05:47:23 +00:00
|
|
|
//!! TODO: we shouldn't do this more than once, but since slit handles their
|
2003-06-23 13:31:47 +00:00
|
|
|
// own resources we must do this.
|
|
|
|
fluxbox->load_rc(*this);
|
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
m_configmenu.reset(createMenu(_FB_XTEXT(Menu, Configuration,
|
- Usage of xft-fonts is prefered, except a font-description starts with '-'
- Removed "antialias"-option completly, to enable/disable "antialias"
use either <fontname>:antialias=<bool> in the style or use
Xft.antialias: <bool> in your .Xdefaults
- Added new styleresources:
*.font.effect: <halo|shadow>
*.font.shadow.x : <int> - shadow x offset
*.font.shadow.y : <int> - shadow y offset
*.font.shadow.color : <color> - color of shadow
*.font.halo.color : <color> - color of halo
- Removed 'shadow' and 'halo' options from fontdefinitions:
!! Style authors have to update their styles !!
- Simplified XmbFontImp to not try all possible fonts to match locale
- Style authors may specify multiple fonts:
<font1>|<font2>|<font3>
if loading of font1 fails, fluxbox probes <font2>, etc. The last font is
"fixed". Hints for style authors:
- if xft tries to load a font it will _ALWAYS_ return a valid font,
it doesnt have to look like the one you want to have, read more
about it: http://fontconfig.org/fontconfig-user.html
- export XFT_DEBUG=1 before running fluxbox helps to see
which fonts are picked.
eg:
*.font: Verdana,Arial-12:antialias=true|-artwiz-snap-*-
if fluxbox is compiled with xft this will NEVER try to
load "-artwiz-snap-*-" since xft gives for sure a font,
most likely Verdana or Arial but noone knows. So, if
fluxbox has no xft support the first fontpattern fails
and fluxbox tries the next one, which might be successful.
if everything fails, it will use "fixed"
- Added caching of fonts, fonts are only loaded once.
- Fixed #1090902 (slow utf8 start)
2005-06-03 07:25:48 +00:00
|
|
|
"Configuration", "Title of configuration menu")));
|
2003-01-12 17:59:20 +00:00
|
|
|
setupConfigmenu(*m_configmenu.get());
|
2003-04-18 12:51:14 +00:00
|
|
|
m_configmenu->setInternalMenu();
|
2003-01-12 17:59:20 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// start with workspace 0
|
|
|
|
changeWorkspaceID(0);
|
|
|
|
updateNetizenWorkspaceCount();
|
2003-12-31 00:38:40 +00:00
|
|
|
|
|
|
|
// we need to load win frame theme before we create any fluxbox window
|
|
|
|
// and after we've load the resources
|
|
|
|
// else we get some bad handle/grip height/width
|
2004-01-02 13:29:01 +00:00
|
|
|
// FbTk::ThemeManager::instance().loadTheme(*m_windowtheme.get());
|
|
|
|
//!! TODO: For some strange reason we must load everything,
|
|
|
|
// else the focus label doesn't get updated
|
|
|
|
// So we lock root theme temporary so it doesn't uses RootTheme::reconfigTheme
|
|
|
|
// This must be fixed in the future.
|
|
|
|
m_root_theme->lock(true);
|
2005-03-16 22:44:48 +00:00
|
|
|
FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(),
|
2005-11-16 22:08:05 +00:00
|
|
|
fluxbox->getStyleOverlayFilename(),
|
2005-03-16 22:44:48 +00:00
|
|
|
m_root_theme->screenNum());
|
2004-01-02 13:29:01 +00:00
|
|
|
m_root_theme->lock(false);
|
2004-03-22 21:01:42 +00:00
|
|
|
m_root_theme->setLineAttributes(*resource.gc_line_width,
|
|
|
|
*resource.gc_line_style,
|
|
|
|
*resource.gc_cap_style,
|
|
|
|
*resource.gc_join_style);
|
2003-12-31 00:38:40 +00:00
|
|
|
|
2004-06-07 21:22:42 +00:00
|
|
|
#ifdef SLIT
|
2006-02-20 21:04:35 +00:00
|
|
|
m_slit.reset(new Slit(*this, *layerManager().getLayer(Layer::DESKTOP),
|
2004-09-09 14:29:10 +00:00
|
|
|
fluxbox->getSlitlistFilename().c_str()));
|
2004-06-07 21:22:42 +00:00
|
|
|
#endif // SLIT
|
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
rm.unlock();
|
2005-06-23 03:07:25 +00:00
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
XFlush(disp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BScreen::~BScreen() {
|
2004-09-05 01:11:41 +00:00
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
if (! managed)
|
|
|
|
return;
|
2004-09-06 13:17:56 +00:00
|
|
|
|
|
|
|
if (m_rootmenu.get() != 0)
|
|
|
|
m_rootmenu->removeAll();
|
|
|
|
|
2004-09-05 01:11:41 +00:00
|
|
|
// Since workspacemenu holds client list menus (from workspace)
|
|
|
|
// we need to destroy it before we destroy workspaces
|
|
|
|
m_workspacemenu.reset(0);
|
2004-04-19 22:44:42 +00:00
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
ExtraMenus::iterator mit = m_extramenus.begin();
|
|
|
|
ExtraMenus::iterator mit_end = m_extramenus.end();
|
|
|
|
for (; mit != mit_end; ++mit) {
|
|
|
|
// we set them to NOT internal so that they will be deleted when the
|
|
|
|
// menu is cleaned up. We can't delete them here because they are
|
|
|
|
// still in the menu
|
|
|
|
// (They need to be internal for most of the time so that if we
|
|
|
|
// rebuild the menu, then they won't be removed.
|
|
|
|
if (mit->second->parent() == 0) {
|
|
|
|
// not attached to our windowmenu
|
|
|
|
// so we clean it up
|
|
|
|
delete mit->second;
|
|
|
|
} else {
|
|
|
|
// let the parent clean it up
|
|
|
|
mit->second->setInternalMenu(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
if (geom_pixmap != None)
|
|
|
|
imageControl().removeImage(geom_pixmap);
|
|
|
|
|
|
|
|
if (pos_pixmap != None)
|
|
|
|
imageControl().removeImage(pos_pixmap);
|
|
|
|
|
|
|
|
removeWorkspaceNames();
|
2006-05-13 15:35:47 +00:00
|
|
|
using namespace STLUtil;
|
|
|
|
destroyAndClear(m_workspaces_list);
|
|
|
|
destroyAndClear(m_netizen_list);
|
|
|
|
destroyAndClear(m_managed_resources);
|
2004-04-19 22:44:42 +00:00
|
|
|
|
2006-05-13 15:35:47 +00:00
|
|
|
//why not destroyAndClear(m_icon_list); ?
|
2004-11-20 18:12:51 +00:00
|
|
|
//problem with that: a delete FluxboxWindow* calls m_diesig.notify()
|
|
|
|
//which leads to screen.removeWindow() which leads to removeIcon(win)
|
|
|
|
//which would modify the m_icon_list anyways...
|
|
|
|
Icons tmp;
|
|
|
|
tmp = m_icon_list;
|
|
|
|
while(!tmp.empty()) {
|
|
|
|
removeWindow(tmp.back());
|
|
|
|
tmp.back()->restore(true);
|
|
|
|
delete (tmp.back());
|
|
|
|
tmp.pop_back();
|
|
|
|
}
|
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
if (hasXinerama() && m_xinerama_headinfo) {
|
|
|
|
delete [] m_xinerama_headinfo;
|
|
|
|
}
|
2004-09-11 13:33:07 +00:00
|
|
|
|
2004-11-20 18:12:51 +00:00
|
|
|
// slit must be destroyed before headAreas (Struts)
|
|
|
|
m_slit.reset(0);
|
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
// TODO fluxgen: check if this is the right place
|
|
|
|
delete [] m_head_areas;
|
2006-02-19 11:11:22 +00:00
|
|
|
|
2006-02-19 08:11:10 +00:00
|
|
|
delete m_focus_control;
|
2006-02-19 11:11:22 +00:00
|
|
|
delete m_placement_strategy;
|
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::initWindows() {
|
2002-12-01 13:42:15 +00:00
|
|
|
unsigned int nchild;
|
|
|
|
Window r, p, *children;
|
2004-04-19 22:44:42 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2003-05-10 22:59:32 +00:00
|
|
|
XQueryTree(disp, rootWindow().window(), &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
|
2004-09-09 14:29:10 +00:00
|
|
|
for (unsigned int i = 0; i < nchild; i++) {
|
2004-11-22 19:40:34 +00:00
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
if (children[i] == None)
|
2004-07-14 12:13:29 +00:00
|
|
|
continue;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
XWMHints *wmhints = XGetWMHints(disp, children[i]);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
if (wmhints) {
|
|
|
|
if ((wmhints->flags & IconWindowHint) &&
|
|
|
|
(wmhints->icon_window != children[i]))
|
2004-09-09 14:29:10 +00:00
|
|
|
for (unsigned int j = 0; j < nchild; j++) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if (children[j] == wmhints->icon_window) {
|
2004-07-14 18:28:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"BScreen::initWindows(): children[j] = 0x"<<hex<<children[j]<<dec<<endl;
|
|
|
|
cerr<<"BScreen::initWindows(): = icon_window"<<endl;
|
|
|
|
#endif // DEBUG
|
2002-12-01 13:42:15 +00:00
|
|
|
children[j] = None;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
XFree(wmhints);
|
|
|
|
}
|
2004-07-14 12:13:29 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 21:04:35 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// manage shown windows
|
2004-07-14 18:28:05 +00:00
|
|
|
// complexity: O(n^2) if we have lots of transients to transient_for
|
|
|
|
// but usually O(n)
|
2004-11-22 19:40:34 +00:00
|
|
|
Window transient_for = 0;
|
2004-09-09 14:29:10 +00:00
|
|
|
for (unsigned int i = 0; i < nchild; ++i) {
|
2004-07-14 18:28:05 +00:00
|
|
|
if (children[i] == None)
|
|
|
|
continue;
|
|
|
|
else if (!fluxbox->validateWindow(children[i])) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"BScreen::initWindows(): not valid window = "<<hex<<children[i]<<dec<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
children[i] = None;
|
|
|
|
continue;
|
2004-07-14 12:13:29 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
// if we have a transient_for window and it isn't created yet...
|
|
|
|
// postpone creation of this window and find transient_for window
|
2004-11-22 19:40:34 +00:00
|
|
|
// in the list and swap place with it so we can create transient_for window
|
2004-07-14 18:28:05 +00:00
|
|
|
// first
|
|
|
|
if (XGetTransientForHint(disp, children[i], &transient_for) &&
|
|
|
|
fluxbox->searchWindow(transient_for) == 0) {
|
|
|
|
// search forward for transient_for
|
|
|
|
// and swap place with it so it gets created first
|
2004-09-09 14:29:10 +00:00
|
|
|
unsigned int j = i + 1;
|
2004-07-14 18:28:05 +00:00
|
|
|
for (; j < nchild; ++j) {
|
2004-11-22 19:40:34 +00:00
|
|
|
if (children[j] == transient_for) {
|
2004-07-14 18:28:05 +00:00
|
|
|
swap(children[i], children[j]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// reevaluate window
|
|
|
|
if (!fluxbox->validateWindow(children[i]))
|
|
|
|
continue;
|
2004-11-22 19:40:34 +00:00
|
|
|
|
2004-07-14 12:13:29 +00:00
|
|
|
#ifdef DEBUG
|
2004-07-14 18:28:05 +00:00
|
|
|
cerr<<"BScreen::initWindows(): j = "<<j<<" i = "<<i<<" nchild = "<<nchild<<endl;
|
2004-11-22 19:40:34 +00:00
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
if (j < nchild)
|
|
|
|
cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[j]<<dec<<endl;
|
|
|
|
else
|
|
|
|
cerr<<"BScreen::initWindows(): postpone creation of 0x"<<hex<<children[i]<<dec<<endl;
|
|
|
|
cerr<<"BScreen::initWindows(): transient_for = 0x"<<hex<<transient_for<<dec<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
}
|
2004-07-14 12:13:29 +00:00
|
|
|
|
2004-11-22 19:40:34 +00:00
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
XWindowAttributes attrib;
|
|
|
|
if (XGetWindowAttributes(disp, children[i],
|
|
|
|
&attrib)) {
|
|
|
|
if (attrib.override_redirect) {
|
|
|
|
children[i] = None; // we dont need this anymore, since we already created a window for it
|
|
|
|
continue;
|
|
|
|
}
|
2004-07-14 12:13:29 +00:00
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
if (attrib.map_state != IsUnmapped) {
|
|
|
|
FluxboxWindow *win = createWindow(children[i]);
|
2003-01-05 22:26:56 +00:00
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
if (win) {
|
|
|
|
XMapRequestEvent mre;
|
|
|
|
mre.window = children[i];
|
|
|
|
win->mapRequestEvent(mre);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-14 18:28:05 +00:00
|
|
|
children[i] = None; // we dont need this anymore, since we already created a window for it
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
2004-07-14 18:28:05 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XFree(children);
|
2003-08-11 16:27:23 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-05-15 12:00:46 +00:00
|
|
|
unsigned int BScreen::currentWorkspaceID() const {
|
2003-05-19 22:45:51 +00:00
|
|
|
return m_current_workspace->workspaceID();
|
2003-04-25 11:05:11 +00:00
|
|
|
}
|
2003-04-25 11:56:13 +00:00
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
const Strut* BScreen::availableWorkspaceArea(int head) const {
|
|
|
|
return m_head_areas[head ? head-1 : 0].availableWorkspaceArea();
|
|
|
|
}
|
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
unsigned int BScreen::maxLeft(int head) const {
|
2004-09-11 13:33:07 +00:00
|
|
|
|
2003-06-30 18:04:48 +00:00
|
|
|
// we ignore strut if we're doing full maximization
|
2003-05-20 11:03:11 +00:00
|
|
|
if (hasXinerama())
|
2003-06-30 18:04:48 +00:00
|
|
|
return doFullMax() ? getHeadX(head) :
|
2004-09-11 13:33:07 +00:00
|
|
|
getHeadX(head) + availableWorkspaceArea(head)->left();
|
2003-06-30 18:04:48 +00:00
|
|
|
else
|
2004-09-11 13:33:07 +00:00
|
|
|
return doFullMax() ? 0 : availableWorkspaceArea(head)->left();
|
2003-01-05 22:26:56 +00:00
|
|
|
}
|
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
unsigned int BScreen::maxRight(int head) const {
|
2003-06-30 18:04:48 +00:00
|
|
|
// we ignore strut if we're doing full maximization
|
2003-05-20 11:03:11 +00:00
|
|
|
if (hasXinerama())
|
2003-06-30 18:04:48 +00:00
|
|
|
return doFullMax() ? getHeadX(head) + getHeadWidth(head) :
|
2004-09-11 13:33:07 +00:00
|
|
|
getHeadX(head) + getHeadWidth(head) - availableWorkspaceArea(head)->right();
|
2003-06-30 18:04:48 +00:00
|
|
|
else
|
2004-09-11 13:33:07 +00:00
|
|
|
return doFullMax() ? width() : width() - availableWorkspaceArea(head)->right();
|
2003-01-05 22:26:56 +00:00
|
|
|
}
|
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
unsigned int BScreen::maxTop(int head) const {
|
2003-06-30 18:04:48 +00:00
|
|
|
// we ignore strut if we're doing full maximization
|
2004-11-22 19:40:34 +00:00
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
if (hasXinerama())
|
2004-09-11 13:33:07 +00:00
|
|
|
return doFullMax() ? getHeadY(head) : getHeadY(head) + availableWorkspaceArea(head)->top();
|
2003-06-30 18:04:48 +00:00
|
|
|
else
|
2004-09-11 13:33:07 +00:00
|
|
|
return doFullMax() ? 0 : availableWorkspaceArea(head)->top();
|
2003-01-05 22:26:56 +00:00
|
|
|
}
|
2003-05-19 22:45:51 +00:00
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
unsigned int BScreen::maxBottom(int head) const {
|
2003-06-30 18:04:48 +00:00
|
|
|
// we ignore strut if we're doing full maximization
|
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
if (hasXinerama())
|
2003-06-30 18:04:48 +00:00
|
|
|
return doFullMax() ? getHeadY(head) + getHeadHeight(head) :
|
2004-09-11 13:33:07 +00:00
|
|
|
getHeadY(head) + getHeadHeight(head) - availableWorkspaceArea(head)->bottom();
|
2003-06-30 18:04:48 +00:00
|
|
|
else
|
2004-09-11 13:33:07 +00:00
|
|
|
return doFullMax() ? height() : height() - availableWorkspaceArea(head)->bottom();
|
2003-01-05 22:26:56 +00:00
|
|
|
}
|
|
|
|
|
2003-08-25 13:15:53 +00:00
|
|
|
void BScreen::update(FbTk::Subject *subj) {
|
|
|
|
// for now we're only listening to the theme sig, so no object check
|
|
|
|
// if another signal is added later, will need to differentiate here
|
|
|
|
|
|
|
|
renderGeomWindow();
|
2004-01-16 11:47:07 +00:00
|
|
|
renderPosWindow();
|
2006-06-26 11:45:14 +00:00
|
|
|
|
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
|
|
|
|
|
|
|
// and update frame extents on theme changes
|
|
|
|
Workspaces::iterator w_it = getWorkspacesList().begin();
|
|
|
|
const Workspaces::iterator w_it_end = getWorkspacesList().end();
|
|
|
|
for (; w_it != w_it_end; ++w_it) {
|
|
|
|
Workspace::Windows::iterator win_it = (*w_it)->windowList().begin();
|
|
|
|
const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end();
|
|
|
|
for (; win_it != win_it_end; ++win_it)
|
|
|
|
fluxbox->updateFrameExtents(**win_it);
|
|
|
|
}
|
|
|
|
|
|
|
|
Icons::iterator it = iconList().begin();
|
|
|
|
const Icons::iterator it_end = iconList().end();
|
|
|
|
for (; it != it_end; ++it)
|
|
|
|
fluxbox->updateFrameExtents(**it);
|
|
|
|
|
2003-08-25 13:15:53 +00:00
|
|
|
}
|
|
|
|
|
2003-12-10 23:08:06 +00:00
|
|
|
FbTk::Menu *BScreen::createMenu(const std::string &label) {
|
2003-12-18 18:03:23 +00:00
|
|
|
FbTk::Menu *menu = new FbMenu(menuTheme(),
|
2003-12-10 23:08:06 +00:00
|
|
|
imageControl(),
|
2006-02-20 21:04:35 +00:00
|
|
|
*layerManager().getLayer(Layer::MENU));
|
2003-12-10 23:08:06 +00:00
|
|
|
if (!label.empty())
|
2006-05-20 15:08:14 +00:00
|
|
|
menu->setLabel(label);
|
2003-12-10 23:08:06 +00:00
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
2006-03-22 12:23:17 +00:00
|
|
|
FbTk::Menu *BScreen::createToggleMenu(const std::string &label) {
|
|
|
|
FbTk::Menu *menu = new ToggleMenu(menuTheme(),
|
|
|
|
imageControl(),
|
|
|
|
*layerManager().getLayer(Layer::MENU));
|
|
|
|
if (!label.empty())
|
2006-05-20 15:08:14 +00:00
|
|
|
menu->setLabel(label);
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
2003-12-10 23:08:06 +00:00
|
|
|
|
2006-05-20 15:08:14 +00:00
|
|
|
void BScreen::addExtraWindowMenu(const FbTk::FbString &label, FbTk::Menu *menu) {
|
2005-06-23 03:07:25 +00:00
|
|
|
menu->setInternalMenu();
|
|
|
|
menu->disableTitle();
|
|
|
|
m_extramenus.push_back(std::make_pair(label, menu));
|
|
|
|
// recreate window menu
|
|
|
|
m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber()));
|
2006-04-24 13:34:14 +00:00
|
|
|
m_windowmenu->setInternalMenu();
|
2005-06-23 03:07:25 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 16:06:22 +00:00
|
|
|
void BScreen::hideMenus() {
|
|
|
|
// hide extra menus
|
|
|
|
Fluxbox::instance()->hideExtraMenus(*this);
|
|
|
|
|
|
|
|
#ifdef SLIT
|
|
|
|
// hide slit menu
|
|
|
|
if (slit())
|
|
|
|
slit()->menu().hide();
|
|
|
|
#endif // SLIT
|
|
|
|
|
|
|
|
// hide icon menus
|
2006-06-26 11:45:14 +00:00
|
|
|
if (!iconList().empty()) {
|
2005-07-04 18:18:32 +00:00
|
|
|
Icons::iterator it = iconList().begin();
|
|
|
|
const Icons::iterator it_end = iconList().end();
|
2004-01-11 16:06:22 +00:00
|
|
|
for (; it != it_end; ++it)
|
|
|
|
(*it)->menu().hide();
|
|
|
|
}
|
|
|
|
// hide all client menus
|
2004-04-12 23:05:10 +00:00
|
|
|
hideWindowMenus();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::hideWindowMenus(const FluxboxWindow* except) {
|
2004-01-11 16:06:22 +00:00
|
|
|
Workspaces::iterator w_it = getWorkspacesList().begin();
|
|
|
|
const Workspaces::iterator w_it_end = getWorkspacesList().end();
|
|
|
|
for (; w_it != w_it_end; ++w_it) {
|
2006-06-26 11:45:14 +00:00
|
|
|
if (!(*w_it)->windowList().empty()) {
|
2004-01-11 16:06:22 +00:00
|
|
|
Workspace::Windows::iterator win_it = (*w_it)->windowList().begin();
|
|
|
|
const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end();
|
|
|
|
for (; win_it != win_it_end; ++win_it) {
|
2004-04-12 23:05:10 +00:00
|
|
|
if (*win_it != except)
|
2004-09-05 01:11:41 +00:00
|
|
|
(*win_it)->menu().hide();
|
2004-01-11 16:06:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-12 23:05:10 +00:00
|
|
|
}
|
2004-01-11 16:06:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::reconfigure() {
|
2005-10-21 19:23:57 +00:00
|
|
|
Fluxbox *fluxbox = Fluxbox::instance();
|
2005-04-27 09:52:30 +00:00
|
|
|
|
2004-09-12 14:56:20 +00:00
|
|
|
m_windowtheme->setFocusedAlpha(*resource.focused_alpha);
|
|
|
|
m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha);
|
2003-07-19 03:59:56 +00:00
|
|
|
m_menutheme->setAlpha(*resource.menu_alpha);
|
2003-12-12 18:18:49 +00:00
|
|
|
m_menutheme->setMenuMode(*resource.menu_mode);
|
2003-12-18 15:27:21 +00:00
|
|
|
|
|
|
|
// clamp values
|
|
|
|
if (*resource.menu_delay > 5000)
|
|
|
|
*resource.menu_delay = 5000;
|
|
|
|
if (*resource.menu_delay < 0)
|
|
|
|
*resource.menu_delay = 0;
|
|
|
|
|
|
|
|
if (*resource.menu_delay_close > 5000)
|
|
|
|
*resource.menu_delay_close = 5000;
|
|
|
|
if (*resource.menu_delay_close < 0)
|
|
|
|
*resource.menu_delay_close = 0;
|
|
|
|
|
2004-03-23 09:21:29 +00:00
|
|
|
m_root_theme->setLineAttributes(*resource.gc_line_width,
|
|
|
|
*resource.gc_line_style,
|
|
|
|
*resource.gc_cap_style,
|
|
|
|
*resource.gc_join_style);
|
|
|
|
|
2003-12-12 18:18:49 +00:00
|
|
|
m_menutheme->setDelayOpen(*resource.menu_delay);
|
|
|
|
m_menutheme->setDelayClose(*resource.menu_delay_close);
|
|
|
|
|
2003-06-12 15:24:37 +00:00
|
|
|
renderGeomWindow();
|
2004-01-16 11:47:07 +00:00
|
|
|
renderPosWindow();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2005-04-27 09:52:30 +00:00
|
|
|
// realize the number of workspaces from the init-file
|
2006-01-16 18:46:39 +00:00
|
|
|
const unsigned int nr_ws = *resource.workspaces;
|
2005-04-27 09:52:30 +00:00
|
|
|
if (nr_ws > m_workspaces_list.size()) {
|
|
|
|
while(nr_ws != m_workspaces_list.size()) {
|
|
|
|
addWorkspace();
|
|
|
|
}
|
|
|
|
} else if (nr_ws < m_workspaces_list.size()) {
|
|
|
|
while(nr_ws != m_workspaces_list.size()) {
|
|
|
|
removeLastWorkspace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
//reconfigure menus
|
2004-05-02 21:12:22 +00:00
|
|
|
m_workspacemenu->reconfigure();
|
2003-01-12 17:59:20 +00:00
|
|
|
m_configmenu->reconfigure();
|
2005-06-23 03:07:25 +00:00
|
|
|
// recreate window menu
|
|
|
|
m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber()));
|
2006-04-24 13:34:14 +00:00
|
|
|
m_windowmenu->setInternalMenu();
|
2003-05-13 00:23:05 +00:00
|
|
|
|
|
|
|
// We need to check to see if the timestamps
|
|
|
|
// changed before we actually can restore the menus
|
|
|
|
// in the same way, since we can't really say if
|
|
|
|
// any submenu is in the same place as before if the
|
|
|
|
// menu changed.
|
|
|
|
|
|
|
|
// if timestamp changed then no restoring
|
2006-02-18 11:39:38 +00:00
|
|
|
bool restore_menus = ! fluxbox->menuTimestampsChanged();
|
2003-05-13 00:23:05 +00:00
|
|
|
|
|
|
|
// destroy old timestamps
|
2006-02-18 11:39:38 +00:00
|
|
|
fluxbox->clearMenuFilenames();
|
2003-05-13 00:23:05 +00:00
|
|
|
|
|
|
|
// save submenu index so we can restore them afterwards
|
|
|
|
vector<int> remember_sub;
|
|
|
|
if (restore_menus) {
|
|
|
|
FbTk::Menu *menu = m_rootmenu.get();
|
|
|
|
while (menu) {
|
|
|
|
int r = menu->currentSubmenu();
|
|
|
|
if (r < 0) break;
|
|
|
|
remember_sub.push_back(r);
|
|
|
|
menu = menu->find(r)->submenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-01 12:39:09 +00:00
|
|
|
rereadMenu();
|
2003-02-16 16:45:23 +00:00
|
|
|
|
2003-05-13 00:23:05 +00:00
|
|
|
if (restore_menus) {
|
|
|
|
// restore submenus, no timestamp changed
|
|
|
|
FbTk::Menu *menu = m_rootmenu.get();
|
2006-04-02 21:37:44 +00:00
|
|
|
for (size_t i = 0; i < remember_sub.size(); i++ ) {
|
2003-05-13 00:23:05 +00:00
|
|
|
int sub = remember_sub[i];
|
|
|
|
if (!menu || sub < 0)
|
|
|
|
break;
|
|
|
|
FbTk::MenuItem *item = menu->find(sub);
|
|
|
|
if (item != 0) {
|
|
|
|
menu->drawSubmenu(sub);
|
|
|
|
menu = item->submenu();
|
|
|
|
} else
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-08-04 12:57:23 +00:00
|
|
|
// reconfigure workspaces
|
2003-05-19 22:45:51 +00:00
|
|
|
for_each(m_workspaces_list.begin(),
|
|
|
|
m_workspaces_list.end(),
|
2003-04-14 15:01:55 +00:00
|
|
|
mem_fun(&Workspace::reconfigure));
|
2005-11-22 21:59:48 +00:00
|
|
|
|
2003-08-04 12:57:23 +00:00
|
|
|
// reconfigure Icons
|
2003-05-19 22:45:51 +00:00
|
|
|
for_each(m_icon_list.begin(),
|
|
|
|
m_icon_list.end(),
|
2003-04-14 15:01:55 +00:00
|
|
|
mem_fun(&FluxboxWindow::reconfigure));
|
2005-11-22 21:59:48 +00:00
|
|
|
|
2003-08-11 16:27:23 +00:00
|
|
|
imageControl().cleanCache();
|
2003-07-01 12:39:09 +00:00
|
|
|
// notify objects that the screen is reconfigured
|
|
|
|
m_reconfigure_sig.notify();
|
2004-03-23 09:21:29 +00:00
|
|
|
|
2005-10-21 19:23:57 +00:00
|
|
|
// Reload style
|
|
|
|
FbTk::ThemeManager::instance().load(fluxbox->getStyleFilename(),
|
2005-11-16 22:08:05 +00:00
|
|
|
fluxbox->getStyleOverlayFilename(),
|
2005-10-21 19:23:57 +00:00
|
|
|
m_root_theme->screenNum());
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
reconfigureTabs();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::reconfigureTabs() {
|
|
|
|
Workspaces::iterator w_it = getWorkspacesList().begin();
|
|
|
|
const Workspaces::iterator w_it_end = getWorkspacesList().end();
|
|
|
|
for (; w_it != w_it_end; ++w_it) {
|
2006-06-26 11:45:14 +00:00
|
|
|
if (!(*w_it)->windowList().empty()) {
|
2006-03-22 12:23:17 +00:00
|
|
|
Workspace::Windows::iterator win_it = (*w_it)->windowList().begin();
|
|
|
|
const Workspace::Windows::iterator win_it_end = (*w_it)->windowList().end();
|
|
|
|
for (; win_it != win_it_end; ++win_it) {
|
2006-03-22 13:06:00 +00:00
|
|
|
(*win_it)->frame().updateTabProperties();
|
2006-03-22 12:23:17 +00:00
|
|
|
if (*resource.default_internal_tabs)
|
|
|
|
(*win_it)->frame().setTabMode(FbWinFrame::INTERNAL);
|
|
|
|
else
|
|
|
|
(*win_it)->frame().setTabMode(FbWinFrame::EXTERNAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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();
|
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() {
|
2003-08-24 11:19:45 +00:00
|
|
|
m_workspace_names.clear();
|
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) {
|
2004-05-02 21:12:22 +00:00
|
|
|
if (w == 0)
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2004-09-05 01:11:41 +00:00
|
|
|
// make sure we have a unique list
|
2005-07-04 18:18:32 +00:00
|
|
|
if (find(iconList().begin(), iconList().end(), w) != iconList().end())
|
2004-09-05 01:11:41 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
m_icon_list.push_back(w);
|
2004-09-05 01:11:41 +00:00
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
// notify listeners
|
2003-09-08 16:37:27 +00:00
|
|
|
m_iconlist_sig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::removeIcon(FluxboxWindow *w) {
|
2004-05-02 21:12:22 +00:00
|
|
|
if (w == 0)
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2004-11-20 18:12:51 +00:00
|
|
|
|
2005-07-04 18:18:32 +00:00
|
|
|
Icons::iterator erase_it = remove_if(iconList().begin(),
|
|
|
|
iconList().end(),
|
2003-04-14 15:01:55 +00:00
|
|
|
bind2nd(equal_to<FluxboxWindow *>(), w));
|
2004-09-05 01:11:41 +00:00
|
|
|
// no need to send iconlist signal if we didn't
|
|
|
|
// change the iconlist
|
|
|
|
if (erase_it != m_icon_list.end()) {
|
2005-07-04 18:18:32 +00:00
|
|
|
iconList().erase(erase_it);
|
2004-09-05 01:11:41 +00:00
|
|
|
m_iconlist_sig.notify();
|
|
|
|
}
|
2003-07-28 18:28:03 +00:00
|
|
|
}
|
|
|
|
|
2002-09-08 19:45:59 +00:00
|
|
|
void BScreen::removeWindow(FluxboxWindow *win) {
|
2004-09-05 01:11:41 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"BScreen::removeWindow("<<win<<")"<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
// extra precaution, if for some reason, the
|
|
|
|
// icon list should be out of sync
|
|
|
|
removeIcon(win);
|
|
|
|
// remove from workspace
|
|
|
|
Workspace *space = getWorkspace(win->workspaceNumber());
|
|
|
|
if (space != 0)
|
|
|
|
space->removeWindow(win, false);
|
2002-09-08 19:45:59 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-04-15 00:50:25 +00:00
|
|
|
|
|
|
|
void BScreen::removeClient(WinClient &client) {
|
2003-07-28 18:28:03 +00:00
|
|
|
|
2006-02-18 11:39:38 +00:00
|
|
|
focusControl().removeClient(client);
|
2003-09-24 14:26:01 +00:00
|
|
|
|
2003-08-12 01:04:16 +00:00
|
|
|
for_each(getWorkspacesList().begin(), getWorkspacesList().end(),
|
|
|
|
mem_fun(&Workspace::updateClientmenu));
|
2003-05-14 12:08:19 +00:00
|
|
|
|
2005-05-02 12:10:01 +00:00
|
|
|
using namespace FbTk;
|
|
|
|
|
2003-06-23 14:16:05 +00:00
|
|
|
// remove any grouping this is expecting
|
2005-05-02 12:10:01 +00:00
|
|
|
Groupables::iterator erase_it = find_if(m_expecting_groups.begin(),
|
|
|
|
m_expecting_groups.end(),
|
|
|
|
Compose(bind2nd(equal_to<WinClient *>(), &client),
|
|
|
|
Select2nd<Groupables::value_type>()));
|
|
|
|
|
|
|
|
if (erase_it != m_expecting_groups.end())
|
|
|
|
m_expecting_groups.erase(erase_it);
|
|
|
|
|
2003-07-28 18:28:03 +00:00
|
|
|
// the client could be on icon menu so we update it
|
2004-05-02 21:12:22 +00:00
|
|
|
//!! TODO: check this with the new icon menu
|
|
|
|
// updateIconMenu();
|
2003-08-12 01:04:16 +00:00
|
|
|
|
2003-04-15 00:50:25 +00:00
|
|
|
}
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
int BScreen::addWorkspace() {
|
2005-04-27 09:52:30 +00:00
|
|
|
|
|
|
|
bool save_name = getNameOfWorkspace(m_workspaces_list.size()) != "" ? false : true;
|
2003-06-12 15:24:37 +00:00
|
|
|
Workspace *wkspc = new Workspace(*this, m_layermanager,
|
2005-04-27 09:52:30 +00:00
|
|
|
getNameOfWorkspace(m_workspaces_list.size()),
|
2003-06-12 15:24:37 +00:00
|
|
|
m_workspaces_list.size());
|
2003-05-19 22:45:51 +00:00
|
|
|
m_workspaces_list.push_back(wkspc);
|
2005-04-27 09:52:30 +00:00
|
|
|
|
|
|
|
if (save_name)
|
|
|
|
addWorkspaceName(wkspc->name().c_str()); //update names
|
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
saveWorkspaces(m_workspaces_list.size());
|
2003-03-03 21:51:13 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
updateNetizenWorkspaceCount();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
return m_workspaces_list.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() {
|
2003-05-19 22:45:51 +00:00
|
|
|
if (m_workspaces_list.size() <= 1)
|
2002-12-01 13:42:15 +00:00
|
|
|
return 0;
|
2003-05-19 22:45:51 +00:00
|
|
|
Workspace *wkspc = m_workspaces_list.back();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
if (m_current_workspace->workspaceID() == wkspc->workspaceID())
|
|
|
|
changeWorkspaceID(m_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
|
|
|
//remove last workspace
|
2003-05-19 22:45:51 +00:00
|
|
|
m_workspaces_list.pop_back();
|
2004-12-30 14:33:38 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
updateNetizenWorkspaceCount();
|
2003-05-19 22:45:51 +00:00
|
|
|
saveWorkspaces(m_workspaces_list.size());
|
2004-12-30 14:33:38 +00:00
|
|
|
// must be deleted after we send notify!!
|
|
|
|
// so we dont get bad pointers somewhere
|
|
|
|
// while processing the notify signal
|
|
|
|
delete wkspc;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
return m_workspaces_list.size();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-23 15:14:45 +00:00
|
|
|
void BScreen::changeWorkspaceID(unsigned int id) {
|
2003-09-14 10:13:54 +00:00
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
if (! m_current_workspace || id >= m_workspaces_list.size() ||
|
|
|
|
id == m_current_workspace->workspaceID())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2003-05-11 11:47:19 +00:00
|
|
|
|
2004-11-30 22:19:35 +00:00
|
|
|
FbTk::App::instance()->sync(false);
|
2003-10-05 02:31:23 +00:00
|
|
|
|
2006-02-18 20:19:22 +00:00
|
|
|
WinClient *focused_client = FocusControl::focusedWindow();
|
2003-07-28 15:06:36 +00:00
|
|
|
FluxboxWindow *focused = 0;
|
|
|
|
if (focused_client)
|
|
|
|
focused = focused_client->fbwindow();
|
|
|
|
|
2003-05-11 11:47:19 +00:00
|
|
|
if (focused && focused->isMoving()) {
|
|
|
|
if (doOpaqueMove())
|
|
|
|
reassociateWindow(focused, id, true);
|
|
|
|
// don't reassociate if not opaque moving
|
|
|
|
focused->pauseMoving();
|
|
|
|
}
|
2002-08-30 14:03:31 +00:00
|
|
|
|
2003-05-11 11:47:19 +00:00
|
|
|
// reassociate all windows that are stuck to the new workspace
|
2003-05-15 12:00:46 +00:00
|
|
|
Workspace *wksp = currentWorkspace();
|
2003-05-11 17:14:41 +00:00
|
|
|
Workspace::Windows wins = wksp->windowList();
|
2003-05-11 11:47:19 +00:00
|
|
|
Workspace::Windows::iterator it = wins.begin();
|
|
|
|
for (; it != wins.end(); ++it) {
|
|
|
|
if ((*it)->isStuck()) {
|
|
|
|
reassociateWindow(*it, id, true);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-05-11 11:47:19 +00:00
|
|
|
}
|
2002-09-12 14:55:11 +00:00
|
|
|
|
2004-05-13 01:48:18 +00:00
|
|
|
currentWorkspace()->hideAll(false);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-11 11:47:19 +00:00
|
|
|
// set new workspace
|
2003-05-19 22:45:51 +00:00
|
|
|
m_current_workspace = getWorkspace(id);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-09-14 10:13:54 +00:00
|
|
|
// This is a little tricks to reduce flicker
|
|
|
|
// this way we can set focus pixmap on frame before we show it
|
|
|
|
// and using ExposeEvent to redraw without flicker
|
2004-01-19 18:29:43 +00:00
|
|
|
/*
|
|
|
|
WinClient *win = getLastFocusedWindow(currentWorkspaceID());
|
|
|
|
if (win && win->fbwindow())
|
|
|
|
win->fbwindow()->setFocusFlag(true);
|
2003-12-18 15:27:21 +00:00
|
|
|
*/
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
currentWorkspace()->showAll();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-09-14 10:13:54 +00:00
|
|
|
if (focused && (focused->isStuck() || focused->isMoving()))
|
2003-05-11 11:47:19 +00:00
|
|
|
focused->setInputFocus();
|
2003-09-14 10:13:54 +00:00
|
|
|
else
|
2006-02-18 20:19:22 +00:00
|
|
|
FocusControl::revertFocus(*this);
|
2002-08-30 14:03:31 +00:00
|
|
|
|
2003-09-14 10:13:54 +00:00
|
|
|
if (focused && focused->isMoving())
|
2003-05-11 11:47:19 +00:00
|
|
|
focused->resumeMoving();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
updateNetizenCurrentWorkspace();
|
2004-01-19 18:29:43 +00:00
|
|
|
FbTk::App::instance()->sync(false);
|
2003-09-14 10:13:54 +00:00
|
|
|
|
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) {
|
2003-12-18 15:27:21 +00:00
|
|
|
if (! m_current_workspace || id >= m_workspaces_list.size())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
2002-02-26 22:25:53 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
if (!win) {
|
2006-02-18 20:19:22 +00:00
|
|
|
WinClient *client = FocusControl::focusedWindow();
|
2003-07-28 15:06:36 +00:00
|
|
|
if (client)
|
|
|
|
win = client->fbwindow();
|
|
|
|
}
|
2002-07-23 13:47:05 +00:00
|
|
|
|
2002-02-26 22:25:53 +00:00
|
|
|
|
2004-11-30 22:19:35 +00:00
|
|
|
FbTk::App::instance()->sync(false);
|
2002-02-26 22:25:53 +00:00
|
|
|
|
2003-12-04 00:08:55 +00:00
|
|
|
if (win && &win->screen() == this &&
|
|
|
|
(! win->isStuck())) {
|
|
|
|
|
2003-12-18 15:27:21 +00:00
|
|
|
// if iconified, deiconify it before we send it somewhere
|
|
|
|
if (win->isIconic())
|
2003-12-04 00:08:55 +00:00
|
|
|
win->deiconify();
|
2002-09-10 10:59:57 +00:00
|
|
|
|
2003-12-18 15:27:21 +00:00
|
|
|
// if the window isn't on current workspace, hide it
|
2005-06-23 03:07:25 +00:00
|
|
|
if (id != currentWorkspace()->workspaceID())
|
2004-05-13 01:48:18 +00:00
|
|
|
win->withdraw(true);
|
2003-12-04 00:08:55 +00:00
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
windowMenu().hide();
|
|
|
|
|
2003-12-04 00:08:55 +00:00
|
|
|
reassociateWindow(win, id, true);
|
2003-12-18 15:27:21 +00:00
|
|
|
|
|
|
|
// if the window is on current workspace, show it.
|
2003-12-04 00:08:55 +00:00
|
|
|
if (id == currentWorkspace()->workspaceID())
|
|
|
|
win->deiconify(false, false);
|
2002-02-26 22:25:53 +00:00
|
|
|
|
2003-12-04 00:08:55 +00:00
|
|
|
// change workspace ?
|
|
|
|
if (changeWS && id != currentWorkspace()->workspaceID()) {
|
|
|
|
changeWorkspaceID(id);
|
|
|
|
win->setInputFocus();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2002-10-11 10:22:06 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-12-04 00:08:55 +00:00
|
|
|
|
2002-02-26 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-11 17:14:41 +00:00
|
|
|
void BScreen::addNetizen(Window win) {
|
|
|
|
Netizen *net = new Netizen(*this, win);
|
2003-05-19 22:45:51 +00:00
|
|
|
m_netizen_list.push_back(net);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-11 17:14:41 +00:00
|
|
|
net->sendWorkspaceCount();
|
|
|
|
net->sendCurrentWorkspace();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-11 17:14:41 +00:00
|
|
|
// send all windows to netizen
|
2003-05-19 22:45:51 +00:00
|
|
|
Workspaces::iterator it = m_workspaces_list.begin();
|
|
|
|
Workspaces::iterator it_end = m_workspaces_list.end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2003-05-11 17:14:41 +00:00
|
|
|
Workspace::Windows::iterator win_it = (*it)->windowList().begin();
|
|
|
|
Workspace::Windows::iterator win_it_end = (*it)->windowList().end();
|
|
|
|
for (; win_it != win_it_end; ++win_it) {
|
2003-05-15 11:17:29 +00:00
|
|
|
net->sendWindowAdd((*win_it)->clientWindow(),
|
2003-08-24 11:19:45 +00:00
|
|
|
(*it)->workspaceID());
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2006-02-18 20:19:22 +00:00
|
|
|
Window f = ((FocusControl::focusedWindow()) ?
|
|
|
|
FocusControl::focusedWindow()->window() : None);
|
2003-05-11 17:14:41 +00:00
|
|
|
net->sendWindowFocus(f);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::removeNetizen(Window w) {
|
2003-05-19 22:45:51 +00:00
|
|
|
Netizens::iterator it = m_netizen_list.begin();
|
|
|
|
Netizens::iterator it_end = m_netizen_list.end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2003-05-10 18:15:23 +00:00
|
|
|
if ((*it)->window() == w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
Netizen *n = *it;
|
|
|
|
delete n;
|
2003-05-19 22:45:51 +00:00
|
|
|
m_netizen_list.erase(it);
|
2002-12-01 13:42:15 +00:00
|
|
|
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();
|
2003-05-19 22:45:51 +00:00
|
|
|
for_each(m_netizen_list.begin(),
|
|
|
|
m_netizen_list.end(),
|
2003-04-14 15:01:55 +00:00
|
|
|
mem_fun(&Netizen::sendCurrentWorkspace));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::updateNetizenWorkspaceCount() {
|
2003-05-19 22:45:51 +00:00
|
|
|
for_each(m_netizen_list.begin(),
|
|
|
|
m_netizen_list.end(),
|
2003-04-14 15:01:55 +00:00
|
|
|
mem_fun(&Netizen::sendWorkspaceCount));
|
2002-12-01 13:42:15 +00:00
|
|
|
m_workspacecount_sig.notify();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::updateNetizenWindowFocus() {
|
2006-02-18 20:19:22 +00:00
|
|
|
Window f = ((FocusControl::focusedWindow()) ?
|
|
|
|
FocusControl::focusedWindow()->window() : None);
|
2003-08-24 11:19:45 +00:00
|
|
|
for_each(m_netizen_list.begin(),
|
|
|
|
m_netizen_list.end(),
|
|
|
|
bind2nd(mem_fun(&Netizen::sendWindowFocus), f));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) {
|
2005-06-02 01:39:31 +00:00
|
|
|
|
|
|
|
// update the list of clients
|
|
|
|
m_clientlist_sig.notify();
|
|
|
|
|
|
|
|
// and then send the signal to listeners
|
2003-05-19 22:45:51 +00:00
|
|
|
Netizens::iterator it = m_netizen_list.begin();
|
|
|
|
Netizens::iterator it_end = m_netizen_list.end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
(*it)->sendWindowAdd(w, p);
|
|
|
|
}
|
2002-02-20 22:41:13 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowDel(Window w) {
|
2003-08-24 11:19:45 +00:00
|
|
|
for_each(m_netizen_list.begin(),
|
|
|
|
m_netizen_list.end(),
|
|
|
|
bind2nd(mem_fun(&Netizen::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) {
|
2003-08-24 11:19:45 +00:00
|
|
|
for_each(m_netizen_list.begin(),
|
|
|
|
m_netizen_list.end(),
|
|
|
|
bind2nd(mem_fun(&Netizen::sendWindowRaise), w));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::updateNetizenWindowLower(Window w) {
|
2003-08-24 11:19:45 +00:00
|
|
|
for_each(m_netizen_list.begin(),
|
|
|
|
m_netizen_list.end(),
|
|
|
|
bind2nd(mem_fun(&Netizen::sendWindowLower), w));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-06-24 14:57:54 +00:00
|
|
|
void BScreen::updateNetizenConfigNotify(XEvent &e) {
|
2003-05-19 22:45:51 +00:00
|
|
|
Netizens::iterator it = m_netizen_list.begin();
|
|
|
|
Netizens::iterator it_end = m_netizen_list.end();
|
2003-08-24 11:19:45 +00:00
|
|
|
for (; it != it_end; ++it)
|
2002-12-01 13:42:15 +00:00
|
|
|
(*it)->sendConfigNotify(e);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
bool BScreen::isKdeDockapp(Window client) const {
|
|
|
|
//Check and see if client is KDE dock applet.
|
|
|
|
//If so add to Slit
|
|
|
|
bool iskdedockapp = false;
|
|
|
|
Atom ajunk;
|
|
|
|
int ijunk;
|
|
|
|
unsigned long *data = 0, uljunk;
|
|
|
|
Display *disp = FbTk::App::instance()->display();
|
|
|
|
// Check if KDE v2.x dock applet
|
|
|
|
if (XGetWindowProperty(disp, client,
|
|
|
|
XInternAtom(FbTk::App::instance()->display(),
|
|
|
|
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False),
|
|
|
|
0l, 1l, False,
|
|
|
|
XA_WINDOW, &ajunk, &ijunk, &uljunk,
|
|
|
|
&uljunk, (unsigned char **) &data) == Success) {
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
iskdedockapp = true;
|
|
|
|
XFree((void *) data);
|
|
|
|
data = 0;
|
|
|
|
}
|
2003-07-28 20:11:55 +00:00
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
// Check if KDE v1.x dock applet
|
|
|
|
if (!iskdedockapp) {
|
|
|
|
Atom kwm1 = XInternAtom(FbTk::App::instance()->display(),
|
|
|
|
"KWM_DOCKWINDOW", False);
|
2003-07-28 20:11:55 +00:00
|
|
|
if (XGetWindowProperty(disp, client,
|
2004-04-19 22:44:42 +00:00
|
|
|
kwm1, 0l, 1l, False,
|
|
|
|
kwm1, &ajunk, &ijunk, &uljunk,
|
|
|
|
&uljunk, (unsigned char **) &data) == Success && data) {
|
|
|
|
iskdedockapp = (data && data[0] != 0);
|
2003-07-28 20:11:55 +00:00
|
|
|
XFree((void *) data);
|
|
|
|
data = 0;
|
|
|
|
}
|
2004-04-19 22:44:42 +00:00
|
|
|
}
|
2003-07-28 20:11:55 +00:00
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
return iskdedockapp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BScreen::addKdeDockapp(Window client) {
|
|
|
|
|
|
|
|
XSelectInput(FbTk::App::instance()->display(), client, StructureNotifyMask);
|
|
|
|
char intbuff[16];
|
|
|
|
sprintf(intbuff, "%d", screenNumber());
|
|
|
|
std::string atom_name("_NET_SYSTEM_TRAY_S");
|
|
|
|
atom_name += intbuff; // append number
|
2004-05-02 21:12:22 +00:00
|
|
|
// find the right atomhandler that has the name: _NET_SYSTEM_TRAY_S<num>
|
2004-04-19 22:44:42 +00:00
|
|
|
AtomHandler *handler = Fluxbox::instance()->getAtomHandler(atom_name);
|
|
|
|
FbTk::EventHandler *evh = 0;
|
|
|
|
FbTk::EventManager *evm = FbTk::EventManager::instance();
|
|
|
|
if (handler == 0) {
|
|
|
|
#ifdef SLIT
|
|
|
|
if (slit() != 0)
|
|
|
|
slit()->addClient(client);
|
|
|
|
else
|
|
|
|
#endif // SLIT
|
|
|
|
return false;
|
|
|
|
} else {
|
2004-05-02 21:12:22 +00:00
|
|
|
// this handler is a special case
|
|
|
|
// so we call setupClient in it
|
2004-04-19 22:44:42 +00:00
|
|
|
WinClient winclient(client, *this);
|
|
|
|
handler->setupClient(winclient);
|
|
|
|
// we need to save old handler and re-add it later
|
|
|
|
evh = evm->find(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (evh != 0) // re-add handler
|
|
|
|
evm->add(*evh, client);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
FluxboxWindow *BScreen::createWindow(Window client) {
|
|
|
|
FbTk::App::instance()->sync(false);
|
2003-07-28 20:11:55 +00:00
|
|
|
|
|
|
|
|
2005-04-29 02:52:36 +00:00
|
|
|
if (isKdeDockapp(client) && addKdeDockapp(client)) {
|
|
|
|
return 0; // dont create a FluxboxWindow for this one
|
2004-04-19 22:44:42 +00:00
|
|
|
}
|
2003-07-28 20:11:55 +00:00
|
|
|
|
2003-06-23 14:16:05 +00:00
|
|
|
WinClient *winclient = new WinClient(client, *this);
|
|
|
|
|
2003-06-27 15:05:19 +00:00
|
|
|
if (winclient->initial_state == WithdrawnState) {
|
|
|
|
delete winclient;
|
2003-01-05 22:26:56 +00:00
|
|
|
#ifdef SLIT
|
2004-04-19 22:44:42 +00:00
|
|
|
if (slit())
|
|
|
|
slit()->addClient(client);
|
2003-06-24 14:57:54 +00:00
|
|
|
#endif // SLIT
|
2003-05-17 11:05:33 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-01-05 22:26:56 +00:00
|
|
|
|
2003-06-23 14:16:05 +00:00
|
|
|
// check if it should be grouped with something else
|
|
|
|
FluxboxWindow *win;
|
|
|
|
if ((win = findGroupLeft(*winclient)) != 0) {
|
|
|
|
win->attachClient(*winclient);
|
2003-07-04 01:03:41 +00:00
|
|
|
Fluxbox::instance()->attachSignals(*winclient);
|
2003-01-05 22:26:56 +00:00
|
|
|
} else {
|
2003-06-23 14:16:05 +00:00
|
|
|
|
2003-07-04 01:03:41 +00:00
|
|
|
Fluxbox::instance()->attachSignals(*winclient);
|
|
|
|
if (winclient->fbwindow()) // may have been set in an atomhandler
|
|
|
|
win = winclient->fbwindow();
|
|
|
|
else {
|
2003-12-18 18:03:23 +00:00
|
|
|
win = new FluxboxWindow(*winclient,
|
2003-07-10 11:29:45 +00:00
|
|
|
winFrameTheme(),
|
2006-02-20 21:04:35 +00:00
|
|
|
*layerManager().getLayer(Layer::NORMAL));
|
2003-07-04 01:03:41 +00:00
|
|
|
|
|
|
|
if (!win->isManaged()) {
|
|
|
|
delete win;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// always put on end of focused list, if it gets focused it'll get pushed up
|
|
|
|
// there is only the one win client at this stage
|
2006-07-06 04:10:34 +00:00
|
|
|
focusControl().addFocusBack(*winclient);
|
2006-02-18 11:39:38 +00:00
|
|
|
if (focusControl().focusNew())
|
2006-07-06 04:10:34 +00:00
|
|
|
FocusControl::setFocusedWindow(winclient);
|
|
|
|
|
2003-06-23 14:16:05 +00:00
|
|
|
// we also need to check if another window expects this window to the left
|
|
|
|
// and if so, then join it.
|
|
|
|
FluxboxWindow *otherwin = 0;
|
|
|
|
// TODO: does this do the right stuff focus-wise?
|
2003-07-04 01:03:41 +00:00
|
|
|
if ((otherwin = findGroupRight(*winclient)) && otherwin != win) {
|
2003-06-23 14:16:05 +00:00
|
|
|
win->attachClient(otherwin->winClient());
|
2003-07-04 01:03:41 +00:00
|
|
|
}
|
2003-06-23 14:16:05 +00:00
|
|
|
|
2004-01-19 18:29:43 +00:00
|
|
|
m_clientlist_sig.notify();
|
|
|
|
|
2003-12-04 21:31:02 +00:00
|
|
|
FbTk::App::instance()->sync(false);
|
2003-01-05 22:26:56 +00:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2004-04-19 22:44:42 +00:00
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
FluxboxWindow *BScreen::createWindow(WinClient &client) {
|
2005-01-04 10:51:38 +00:00
|
|
|
|
|
|
|
if (isKdeDockapp(client.window()) && addKdeDockapp(client.window())) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-12-18 18:03:23 +00:00
|
|
|
FluxboxWindow *win = new FluxboxWindow(client,
|
2003-07-10 11:29:45 +00:00
|
|
|
winFrameTheme(),
|
2006-02-20 21:04:35 +00:00
|
|
|
*layerManager().getLayer(Layer::NORMAL));
|
2004-04-19 22:44:42 +00:00
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
#ifdef SLIT
|
2005-01-05 01:56:19 +00:00
|
|
|
if (win->initialState() == WithdrawnState && slit() != 0) {
|
|
|
|
slit()->addClient(win->clientWindow());
|
|
|
|
}
|
2003-04-14 15:01:55 +00:00
|
|
|
#endif // SLIT
|
2004-04-19 22:44:42 +00:00
|
|
|
|
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
if (!win->isManaged()) {
|
|
|
|
delete win;
|
|
|
|
return 0;
|
|
|
|
}
|
2003-12-14 01:09:00 +00:00
|
|
|
|
2006-07-06 04:10:34 +00:00
|
|
|
if (focusControl().focusNew() || FocusControl::focusedWindow() == &client)
|
|
|
|
FocusControl::setFocusedWindow(&client);
|
|
|
|
|
2004-01-19 18:29:43 +00:00
|
|
|
m_clientlist_sig.notify();
|
|
|
|
|
2003-04-14 15:01:55 +00:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
Strut *BScreen::requestStrut(int head, int left, int right, int top, int bottom) {
|
|
|
|
if (head > numHeads() && head != 1) {
|
|
|
|
// head does not exist (if head == 1, then numHeads() == 0,
|
|
|
|
// which means no xinerama, but there's a head after all
|
|
|
|
head = numHeads();
|
|
|
|
}
|
2003-06-18 13:42:21 +00:00
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
int begin = head-1;
|
|
|
|
int end = head;
|
2003-06-18 13:42:21 +00:00
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
if (head == 0) { // all heads (or no xinerama)
|
|
|
|
begin = 0;
|
|
|
|
end = (numHeads() ? numHeads() : 1);
|
2003-06-18 13:42:21 +00:00
|
|
|
}
|
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
Strut* next = 0;
|
|
|
|
for (int i = begin; i != end; i++) {
|
|
|
|
next = m_head_areas[i].requestStrut(i+1, left, right, top, bottom, next);
|
|
|
|
}
|
|
|
|
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::clearStrut(Strut *str) {
|
|
|
|
if (str->next())
|
|
|
|
clearStrut(str->next());
|
|
|
|
int head = str->head() ? str->head() - 1 : 0;
|
|
|
|
m_head_areas[head].clearStrut(str);
|
|
|
|
// str is invalid now
|
|
|
|
}
|
2003-06-18 13:42:21 +00:00
|
|
|
|
|
|
|
void BScreen::updateAvailableWorkspaceArea() {
|
2004-09-11 13:33:07 +00:00
|
|
|
size_t n = (numHeads() ? numHeads() : 1);
|
|
|
|
bool updated = false;
|
2003-06-18 13:42:21 +00:00
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
for (size_t i = 0; i < n; i++) {
|
|
|
|
updated = m_head_areas[i].updateAvailableWorkspaceArea() || updated;
|
|
|
|
}
|
2004-01-19 18:29:43 +00:00
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
if (updated)
|
2004-01-19 18:29:43 +00:00
|
|
|
m_workspace_area_sig.notify();
|
2003-06-18 13:42:21 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-07-23 17:11:59 +00:00
|
|
|
void BScreen::addWorkspaceName(const char *name) {
|
2006-05-07 10:08:25 +00:00
|
|
|
m_workspace_names.push_back(FbTk::FbStringUtil::LocaleStrToFb(name));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-11 22:28:18 +00:00
|
|
|
string BScreen::getNameOfWorkspace(unsigned int workspace) const {
|
2003-12-14 01:09:00 +00:00
|
|
|
if (workspace < m_workspace_names.size())
|
2003-05-19 22:45:51 +00:00
|
|
|
return m_workspace_names[workspace];
|
2003-12-14 01:09:00 +00:00
|
|
|
else
|
2002-12-01 13:42:15 +00:00
|
|
|
return "";
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-04-28 00:38:42 +00:00
|
|
|
void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id,
|
|
|
|
bool ignore_sticky) {
|
2003-04-14 15:01:55 +00:00
|
|
|
if (w == 0)
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2005-07-04 18:18:32 +00:00
|
|
|
if (wkspc_id >= numberOfWorkspaces())
|
2003-05-19 22:45:51 +00:00
|
|
|
wkspc_id = currentWorkspace()->workspaceID();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-05-15 11:17:29 +00:00
|
|
|
if (!w->isIconic() && w->workspaceNumber() == wkspc_id)
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
|
2003-02-16 17:57:54 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (w->isIconic()) {
|
|
|
|
removeIcon(w);
|
2003-04-14 15:01:55 +00:00
|
|
|
getWorkspace(wkspc_id)->addWindow(*w);
|
2004-01-19 22:07:24 +00:00
|
|
|
// client list need to notify now even though
|
|
|
|
// we didn't remove/add any window,
|
|
|
|
// so listeners that uses the client list to
|
|
|
|
// show whats on current/other workspace
|
|
|
|
// gets updated
|
|
|
|
m_clientlist_sig.notify();
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (ignore_sticky || ! w->isStuck()) {
|
2005-01-05 01:56:19 +00:00
|
|
|
// fresh windows have workspaceNumber == -1, which leads to
|
|
|
|
// an invalid workspace (unsigned int)
|
|
|
|
if (getWorkspace(w->workspaceNumber()))
|
|
|
|
getWorkspace(w->workspaceNumber())->removeWindow(w, true);
|
2003-04-14 15:01:55 +00:00
|
|
|
getWorkspace(wkspc_id)->addWindow(*w);
|
2004-01-19 22:07:24 +00:00
|
|
|
// see comment above
|
|
|
|
m_clientlist_sig.notify();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
void BScreen::initMenus() {
|
|
|
|
m_workspacemenu.reset(MenuCreator::createMenuType("workspacemenu", screenNumber()));
|
2005-06-23 03:07:25 +00:00
|
|
|
m_windowmenu.reset(MenuCreator::createMenuType("windowmenu", screenNumber()));
|
2006-04-24 13:34:14 +00:00
|
|
|
m_windowmenu->setInternalMenu();
|
2004-05-02 21:12:22 +00:00
|
|
|
initMenu();
|
|
|
|
}
|
2003-04-20 12:21:35 +00:00
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::initMenu() {
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-13 20:19:05 +00:00
|
|
|
if (m_rootmenu.get()) {
|
2003-04-26 15:00:25 +00:00
|
|
|
// since all menus in root is submenus in m_rootmenu
|
2003-05-19 22:45:51 +00:00
|
|
|
// just remove every item in m_rootmenu and then clear m_rootmenu_list
|
2002-12-13 20:19:05 +00:00
|
|
|
while (m_rootmenu->numberOfItems())
|
2003-04-18 12:51:14 +00:00
|
|
|
m_rootmenu->remove(0);
|
2003-05-19 22:45:51 +00:00
|
|
|
m_rootmenu_list.clear();
|
2003-04-26 15:00:25 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else
|
2003-12-10 23:08:06 +00:00
|
|
|
m_rootmenu.reset(createMenu(""));
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
Fluxbox * const fb = Fluxbox::instance();
|
2006-06-26 11:45:14 +00:00
|
|
|
if (!fb->getMenuFilename().empty()) {
|
2004-05-02 21:12:22 +00:00
|
|
|
m_rootmenu.reset(MenuCreator::createFromFile(fb->getMenuFilename(),
|
2004-10-04 15:37:58 +00:00
|
|
|
screenNumber(), true));
|
2004-05-02 21:12:22 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
if (m_rootmenu.get() == 0) {
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2006-06-21 14:41:16 +00:00
|
|
|
m_rootmenu.reset(createMenu(_FB_XTEXT(Menu, DefaultRootMenu, "Fluxbox default menu", "Title of fallback root menu")));
|
2004-05-02 21:12:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command> restart_fb(CommandParser::instance().parseLine("restart"));
|
|
|
|
FbTk::RefCount<FbTk::Command> exit_fb(CommandParser::instance().parseLine("exit"));
|
|
|
|
FbTk::RefCount<FbTk::Command> execute_xterm(CommandParser::instance().parseLine("exec xterm"));
|
2002-12-13 20:19:05 +00:00
|
|
|
m_rootmenu->setInternalMenu();
|
2006-03-18 22:03:23 +00:00
|
|
|
m_rootmenu->insert("xterm", execute_xterm);
|
2006-06-21 14:41:16 +00:00
|
|
|
m_rootmenu->insert(_FB_XTEXT(Menu, Restart, "Restart", "Restart command"),
|
2003-01-09 17:41:02 +00:00
|
|
|
restart_fb);
|
2006-06-21 14:41:16 +00:00
|
|
|
m_rootmenu->insert(_FB_XTEXT(Menu, Exit, "Exit", "Exit command"),
|
2003-01-09 17:41:02 +00:00
|
|
|
exit_fb);
|
2003-08-10 12:50:04 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2004-12-13 14:03:17 +00:00
|
|
|
m_rootmenu->updateMenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2004-05-02 21:12:22 +00:00
|
|
|
|
2006-05-20 15:08:14 +00:00
|
|
|
void BScreen::addConfigMenu(const FbTk::FbString &label, FbTk::Menu &menu) {
|
2003-07-20 02:45:57 +00:00
|
|
|
m_configmenu_list.push_back(std::make_pair(label, &menu));
|
|
|
|
setupConfigmenu(*m_configmenu.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BScreen::removeConfigMenu(FbTk::Menu &menu) {
|
2005-05-02 12:10:01 +00:00
|
|
|
Configmenus::iterator erase_it = find_if(m_configmenu_list.begin(),
|
|
|
|
m_configmenu_list.end(),
|
|
|
|
FbTk::Compose(bind2nd(equal_to<FbTk::Menu *>(), &menu),
|
|
|
|
FbTk::Select2nd<Configmenus::value_type>()));
|
|
|
|
if (erase_it != m_configmenu_list.end())
|
|
|
|
m_configmenu_list.erase(erase_it);
|
2006-04-24 13:34:14 +00:00
|
|
|
|
2003-07-20 02:45:57 +00:00
|
|
|
setupConfigmenu(*m_configmenu.get());
|
2004-06-14 12:25:31 +00:00
|
|
|
|
2003-07-20 02:45:57 +00:00
|
|
|
}
|
|
|
|
|
2006-03-18 22:03:23 +00:00
|
|
|
|
|
|
|
void BScreen::addManagedResource(FbTk::Resource_base *resource) {
|
|
|
|
m_managed_resources.push_back(resource);
|
|
|
|
}
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
void BScreen::setupConfigmenu(FbTk::Menu &menu) {
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2003-01-12 17:59:20 +00:00
|
|
|
|
2003-07-20 02:45:57 +00:00
|
|
|
menu.removeAll();
|
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
|
2006-03-22 12:23:17 +00:00
|
|
|
FbTk::MacroCommand *s_a_reconftabs_macro = new FbTk::MacroCommand();
|
|
|
|
FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(
|
|
|
|
*Fluxbox::instance(),
|
|
|
|
&Fluxbox::save_rc));
|
2004-05-02 21:12:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command> reconf_cmd(CommandParser::instance().parseLine("reconfigure"));
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
FbTk::RefCount<FbTk::Command> reconftabs_cmd(new FbTk::SimpleCommand<BScreen>(
|
|
|
|
*this,
|
|
|
|
&BScreen::reconfigureTabs));
|
2003-01-12 17:59:20 +00:00
|
|
|
s_a_reconf_macro->add(saverc_cmd);
|
|
|
|
s_a_reconf_macro->add(reconf_cmd);
|
2006-03-22 12:23:17 +00:00
|
|
|
s_a_reconftabs_macro->add(saverc_cmd);
|
|
|
|
s_a_reconftabs_macro->add(reconftabs_cmd);
|
2003-01-12 17:59:20 +00:00
|
|
|
FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro);
|
2006-03-22 12:23:17 +00:00
|
|
|
FbTk::RefCount<FbTk::Command> save_and_reconftabs(s_a_reconftabs_macro);
|
2003-02-20 23:31:13 +00:00
|
|
|
// create focus menu
|
2003-04-26 15:00:25 +00:00
|
|
|
// we don't set this to internal menu so will
|
|
|
|
// be deleted toghether with the parent
|
2006-06-21 14:41:16 +00:00
|
|
|
FbTk::FbString focusmenu_label = _FB_XTEXT(Configmenu, FocusModel,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Focus Model",
|
|
|
|
"Method used to give focus to windows");
|
2006-05-20 15:08:14 +00:00
|
|
|
FbTk::Menu *focus_menu = createMenu(focusmenu_label);
|
2003-02-20 23:31:13 +00:00
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
#define _BOOLITEM(m,a, b, c, d, e, f) (m).insert(new BoolMenuItem(_FB_XTEXT(a, b, c, d), e, f))
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
|
2006-02-18 11:39:38 +00:00
|
|
|
#define _FOCUSITEM(a, b, c, d, e) \
|
2006-06-21 14:41:16 +00:00
|
|
|
focus_menu->insert(new FocusModelMenuItem(_FB_XTEXT(a, b, c, d), focusControl(), \
|
2006-02-18 11:39:38 +00:00
|
|
|
e, save_and_reconfigure))
|
2004-05-02 21:12:22 +00:00
|
|
|
|
2005-07-20 18:29:01 +00:00
|
|
|
_FOCUSITEM(Configmenu, ClickFocus,
|
2004-06-07 11:46:05 +00:00
|
|
|
"Click To Focus", "Click to focus",
|
2006-02-18 11:39:38 +00:00
|
|
|
FocusControl::CLICKFOCUS);
|
2005-07-20 18:29:01 +00:00
|
|
|
_FOCUSITEM(Configmenu, MouseFocus,
|
|
|
|
"Mouse Focus", "Mouse Focus",
|
2006-02-18 11:39:38 +00:00
|
|
|
FocusControl::MOUSEFOCUS);
|
|
|
|
#undef _FOCUSITEM
|
2005-07-20 18:29:01 +00:00
|
|
|
|
2006-02-18 11:39:38 +00:00
|
|
|
focus_menu->insert(new TabFocusModelMenuItem("ClickTabFocus", focusControl(),
|
|
|
|
FocusControl::CLICKTABFOCUS,
|
|
|
|
save_and_reconfigure));
|
|
|
|
focus_menu->insert(new TabFocusModelMenuItem("MouseTabFocus", focusControl(),
|
|
|
|
FocusControl::MOUSETABFOCUS,
|
|
|
|
save_and_reconfigure));
|
2005-07-20 18:29:01 +00:00
|
|
|
|
2003-08-04 12:57:23 +00:00
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
focus_menu->insert(new BoolMenuItem(_FB_XTEXT(Configmenu,
|
2004-06-07 11:46:05 +00:00
|
|
|
AutoRaise,
|
|
|
|
"Auto Raise",
|
|
|
|
"Auto Raise windows on sloppy"),
|
2003-02-22 16:09:44 +00:00
|
|
|
*resource.auto_raise,
|
2003-02-20 23:31:13 +00:00
|
|
|
save_and_reconfigure));
|
|
|
|
|
2004-12-13 14:03:17 +00:00
|
|
|
focus_menu->updateMenu();
|
2003-04-16 00:38:06 +00:00
|
|
|
|
2003-07-25 10:03:55 +00:00
|
|
|
menu.insert(focusmenu_label, focus_menu);
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
// END focus menu
|
|
|
|
|
|
|
|
// BEGIN tab menu
|
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
FbTk::FbString tabmenu_label = _FB_XTEXT(Configmenu, TabMenu,
|
2006-03-22 12:23:17 +00:00
|
|
|
"Tab Options",
|
|
|
|
"heading for tab-related options");
|
2006-05-20 15:08:14 +00:00
|
|
|
FbTk::Menu *tab_menu = createMenu(tabmenu_label);
|
2006-06-21 14:41:16 +00:00
|
|
|
FbTk::FbString tabplacement_label = _FB_XTEXT(Menu, Placement, "Placement", "Title of Placement menu");
|
2006-03-22 12:23:17 +00:00
|
|
|
FbTk::Menu *tabplacement_menu = createToggleMenu(tabplacement_label);
|
|
|
|
|
|
|
|
tab_menu->insert(tabplacement_label, tabplacement_menu);
|
|
|
|
|
|
|
|
_BOOLITEM(*tab_menu,Configmenu, TabsInTitlebar,
|
|
|
|
"Tabs in Titlebar", "Tabs in Titlebar",
|
|
|
|
*resource.default_internal_tabs, save_and_reconftabs);
|
|
|
|
|
2006-03-22 13:06:00 +00:00
|
|
|
FbTk::MenuItem *tab_width_item =
|
2006-06-21 14:41:16 +00:00
|
|
|
new IntResMenuItem(_FB_XTEXT(Configmenu, ExternalTabWidth,
|
2006-03-22 13:06:00 +00:00
|
|
|
"External Tab Width",
|
|
|
|
"Width of external-style tabs"),
|
|
|
|
resource.tab_width, 10, 3000, /* silly number */
|
|
|
|
*tab_menu);
|
|
|
|
tab_width_item->setCommand(save_and_reconftabs);
|
|
|
|
tab_menu->insert(tab_width_item);
|
|
|
|
|
|
|
|
|
2006-05-20 15:08:14 +00:00
|
|
|
typedef pair<FbTk::FbString, FbWinFrame::TabPlacement> PlacementP;
|
2006-03-22 12:23:17 +00:00
|
|
|
typedef list<PlacementP> Placements;
|
|
|
|
Placements place_menu;
|
|
|
|
|
2006-03-22 13:06:00 +00:00
|
|
|
// menu is 2 wide, 2 down
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), FbWinFrame::TOPLEFT));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), FbWinFrame::LEFTTOP));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), FbWinFrame::LEFTBOTTOM));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), FbWinFrame::BOTTOMLEFT));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), FbWinFrame::TOPRIGHT));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), FbWinFrame::RIGHTTOP));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), FbWinFrame::RIGHTBOTTOM));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), FbWinFrame::BOTTOMRIGHT));
|
2006-03-22 12:23:17 +00:00
|
|
|
|
|
|
|
tabplacement_menu->setMinimumSublevels(2);
|
|
|
|
// create items in sub menu
|
|
|
|
size_t i=0;
|
|
|
|
while (!place_menu.empty()) {
|
|
|
|
i++;
|
2006-05-20 15:08:14 +00:00
|
|
|
FbTk::FbString &str = place_menu.front().first;
|
2006-03-22 12:23:17 +00:00
|
|
|
FbWinFrame::TabPlacement placement = place_menu.front().second;
|
|
|
|
|
2006-05-20 15:08:14 +00:00
|
|
|
tabplacement_menu->insert(new TabPlacementMenuItem(str, *this, placement, save_and_reconftabs));
|
2006-03-22 12:23:17 +00:00
|
|
|
place_menu.pop_front();
|
|
|
|
}
|
|
|
|
tabplacement_menu->updateMenu();
|
|
|
|
|
|
|
|
menu.insert(tabmenu_label, tab_menu);
|
|
|
|
|
2003-07-20 02:45:57 +00:00
|
|
|
Configmenus::iterator it = m_configmenu_list.begin();
|
|
|
|
Configmenus::iterator it_end = m_configmenu_list.end();
|
|
|
|
for (; it != it_end; ++it)
|
|
|
|
menu.insert(it->first, it->second);
|
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, ImageDithering,
|
2004-06-07 11:46:05 +00:00
|
|
|
"Image Dithering", "Image Dithering",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.image_dither, save_and_reconfigure);
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, OpaqueMove,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Opaque Window Moving",
|
|
|
|
"Window Moving with whole window visible (as opposed to outline moving)",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.opaque_move, saverc_cmd);
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, FullMax,
|
2004-06-07 11:46:05 +00:00
|
|
|
"Full Maximization", "Maximise over slit, toolbar, etc",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.full_max, saverc_cmd);
|
2006-02-18 11:39:38 +00:00
|
|
|
try {
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, FocusNew,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Focus New Windows", "Focus newly created windows",
|
|
|
|
*m_resource_manager.getResource<bool>(name() + ".focusNewWindows"),
|
|
|
|
saverc_cmd);
|
|
|
|
} catch (FbTk::ResourceException e) {
|
|
|
|
cerr<<e.what()<<endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, FocusLast,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Focus Last Window on Workspace", "Focus Last Window on Workspace",
|
|
|
|
*resourceManager().getResource<bool>(name() + ".focusLastWindow"),
|
|
|
|
saverc_cmd);
|
|
|
|
} catch (FbTk::ResourceException e) {
|
|
|
|
cerr<<e.what()<<endl;
|
|
|
|
}
|
|
|
|
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, WorkspaceWarping,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Workspace Warping",
|
|
|
|
"Workspace Warping - dragging windows to the edge and onto the next workspace",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.workspace_warping, saverc_cmd);
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, DesktopWheeling,
|
2004-06-07 11:46:05 +00:00
|
|
|
"Desktop MouseWheel Switching", "Workspace switching using mouse wheel",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.desktop_wheeling, saverc_cmd);
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, DecorateTransient,
|
2004-06-07 11:46:05 +00:00
|
|
|
"Decorate Transient Windows", "Decorate Transient Windows",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.decorate_transient, saverc_cmd);
|
2006-03-22 12:23:17 +00:00
|
|
|
_BOOLITEM(menu, Configmenu, ClickRaises,
|
2004-06-07 11:46:05 +00:00
|
|
|
"Click Raises", "Click Raises",
|
2004-05-02 21:12:22 +00:00
|
|
|
*resource.click_raises, saverc_cmd);
|
|
|
|
|
2004-08-30 11:33:23 +00:00
|
|
|
#ifdef HAVE_XRENDER
|
2004-09-12 14:56:20 +00:00
|
|
|
if (FbTk::Transparent::haveRender() ||
|
|
|
|
FbTk::Transparent::haveComposite()) {
|
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
FbTk::FbString alphamenu_label = _FB_XTEXT(Configmenu, Transparency,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Transparency",
|
|
|
|
"Menu containing various transparency options");
|
2006-05-20 15:08:14 +00:00
|
|
|
FbTk::Menu *alpha_menu = createMenu(alphamenu_label);
|
2004-09-12 14:56:20 +00:00
|
|
|
|
|
|
|
if (FbTk::Transparent::haveComposite(true)) {
|
2006-06-21 14:41:16 +00:00
|
|
|
alpha_menu->insert(new BoolMenuItem(_FB_XTEXT(Configmenu, ForcePseudoTrans,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Force Pseudo-Transparency",
|
|
|
|
"When composite is available, still use old pseudo-transparency"),
|
2004-09-12 14:56:20 +00:00
|
|
|
Fluxbox::instance()->getPseudoTrans(), save_and_reconfigure));
|
|
|
|
}
|
|
|
|
|
2006-02-18 11:39:38 +00:00
|
|
|
FbTk::MenuItem *focused_alpha_item =
|
2006-06-21 14:41:16 +00:00
|
|
|
new IntResMenuItem(_FB_XTEXT(Configmenu, FocusedAlpha,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Focused Window Alpha",
|
|
|
|
"Transparency level of the focused window"),
|
2005-05-03 13:53:25 +00:00
|
|
|
resource.focused_alpha, 0, 255, *alpha_menu);
|
2004-09-12 14:56:20 +00:00
|
|
|
focused_alpha_item->setCommand(saverc_cmd);
|
|
|
|
alpha_menu->insert(focused_alpha_item);
|
|
|
|
|
2006-02-18 11:39:38 +00:00
|
|
|
FbTk::MenuItem *unfocused_alpha_item =
|
2006-06-21 14:41:16 +00:00
|
|
|
new IntResMenuItem(_FB_XTEXT(Configmenu,
|
2006-02-18 11:39:38 +00:00
|
|
|
UnfocusedAlpha,
|
|
|
|
"Unfocused Window Alpha",
|
|
|
|
"Transparency level of unfocused windows"),
|
|
|
|
|
2005-05-03 13:53:25 +00:00
|
|
|
resource.unfocused_alpha, 0, 255, *alpha_menu);
|
2004-09-12 14:56:20 +00:00
|
|
|
unfocused_alpha_item->setCommand(saverc_cmd);
|
|
|
|
alpha_menu->insert(unfocused_alpha_item);
|
|
|
|
|
2006-02-18 11:39:38 +00:00
|
|
|
FbTk::MenuItem *menu_alpha_item =
|
2006-06-21 14:41:16 +00:00
|
|
|
new IntResMenuItem(_FB_XTEXT(Configmenu, MenuAlpha,
|
2006-02-18 11:39:38 +00:00
|
|
|
"Menu Alpha", "Transparency level of menu"),
|
2005-05-03 13:53:25 +00:00
|
|
|
resource.menu_alpha, 0, 255, *alpha_menu);
|
2004-09-12 14:56:20 +00:00
|
|
|
menu_alpha_item->setCommand(saverc_cmd);
|
|
|
|
alpha_menu->insert(menu_alpha_item);
|
|
|
|
|
2004-12-13 14:03:17 +00:00
|
|
|
alpha_menu->updateMenu();
|
2004-09-12 14:56:20 +00:00
|
|
|
menu.insert(alphamenu_label, alpha_menu);
|
|
|
|
}
|
2004-08-30 11:33:23 +00:00
|
|
|
#endif // HAVE_XRENDER
|
2004-09-12 14:56:20 +00:00
|
|
|
#undef _BOOLITEM
|
2003-04-20 13:46:18 +00:00
|
|
|
|
2003-01-12 17:59:20 +00:00
|
|
|
// finaly update menu
|
2004-12-13 14:03:17 +00:00
|
|
|
menu.updateMenu();
|
2003-01-12 17:59:20 +00:00
|
|
|
}
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-08-02 12:58:37 +00:00
|
|
|
void BScreen::shutdown() {
|
2003-05-10 22:59:32 +00:00
|
|
|
rootWindow().setEventMask(NoEventMask);
|
2003-12-04 21:31:02 +00:00
|
|
|
FbTk::App::instance()->sync(false);
|
2003-08-12 12:21:42 +00:00
|
|
|
m_shutdown = true;
|
2003-05-19 22:45:51 +00:00
|
|
|
for_each(m_workspaces_list.begin(),
|
|
|
|
m_workspaces_list.end(),
|
2003-04-14 15:01:55 +00:00
|
|
|
mem_fun(&Workspace::shutdown));
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BScreen::showPosition(int x, int y) {
|
2004-06-07 11:46:05 +00:00
|
|
|
if (!doShowWindowPos())
|
2003-12-10 22:28:07 +00:00
|
|
|
return;
|
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
if (! pos_visible) {
|
2003-05-19 22:45:51 +00:00
|
|
|
if (hasXinerama()) {
|
|
|
|
unsigned int head = getCurrHead();
|
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
m_pos_window.move(getHeadX(head) + (getHeadWidth(head) - m_pos_window.width()) / 2,
|
|
|
|
getHeadY(head) + (getHeadHeight(head) - m_pos_window.height()) / 2);
|
2003-05-19 22:45:51 +00:00
|
|
|
|
|
|
|
} else {
|
2006-02-18 11:39:38 +00:00
|
|
|
m_pos_window.move((width() - m_pos_window.width()) / 2,
|
|
|
|
(height() - m_pos_window.height()) / 2);
|
2003-05-19 22:45:51 +00:00
|
|
|
}
|
2002-03-19 14:30:43 +00:00
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
m_pos_window.show();
|
|
|
|
m_pos_window.raise();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
pos_visible = true;
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2004-06-07 11:46:05 +00:00
|
|
|
|
2006-03-18 22:03:23 +00:00
|
|
|
char label[256];
|
2006-06-10 17:24:48 +00:00
|
|
|
sprintf(label, "X:%5d x Y:%5d", x, y);
|
2003-02-16 01:14:54 +00:00
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
m_pos_window.clear();
|
2003-02-16 01:14:54 +00:00
|
|
|
|
2004-09-11 23:01:34 +00:00
|
|
|
winFrameTheme().font().drawText(m_pos_window,
|
2003-05-15 12:00:46 +00:00
|
|
|
screenNumber(),
|
|
|
|
winFrameTheme().labelTextFocusGC(),
|
|
|
|
label, strlen(label),
|
2003-09-12 23:35:31 +00:00
|
|
|
winFrameTheme().bevelWidth(),
|
|
|
|
winFrameTheme().bevelWidth() +
|
2003-05-15 12:00:46 +00:00
|
|
|
winFrameTheme().font().ascent());
|
2002-10-15 17:17:00 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
void BScreen::hidePosition() {
|
|
|
|
if (pos_visible) {
|
|
|
|
m_pos_window.hide();
|
|
|
|
pos_visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
void BScreen::showGeometry(unsigned int gx, unsigned int gy) {
|
2003-12-10 22:28:07 +00:00
|
|
|
if (!doShowWindowPos())
|
|
|
|
return;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
if (! geom_visible) {
|
2003-05-19 22:45:51 +00:00
|
|
|
if (hasXinerama()) {
|
|
|
|
unsigned int head = getCurrHead();
|
|
|
|
|
|
|
|
m_geom_window.move(getHeadX(head) + (getHeadWidth(head) - m_geom_window.width()) / 2,
|
2006-02-18 11:39:38 +00:00
|
|
|
getHeadY(head) + (getHeadHeight(head) - m_geom_window.height()) / 2);
|
2003-05-19 22:45:51 +00:00
|
|
|
} else {
|
2006-02-18 11:39:38 +00:00
|
|
|
m_geom_window.move((width() - m_geom_window.width()) / 2,
|
|
|
|
(height() - m_geom_window.height()) / 2);
|
2003-05-19 22:45:51 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
m_geom_window.show();
|
|
|
|
m_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
|
|
|
|
2003-02-20 23:31:13 +00:00
|
|
|
char label[256];
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
sprintf(label,
|
2006-06-21 14:41:16 +00:00
|
|
|
_FB_XTEXT(Screen, GeometryFormat,
|
2004-06-07 11:46:05 +00:00
|
|
|
"W: %4d x H: %4d",
|
2006-05-20 15:08:14 +00:00
|
|
|
"Format for width and height window, %4d for width, and %4d for height").c_str(),
|
2004-06-07 11:46:05 +00:00
|
|
|
gx, gy);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-05-19 22:45:51 +00:00
|
|
|
m_geom_window.clear();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-08-18 11:26:17 +00:00
|
|
|
//!! TODO: geom window again?! repeated
|
2004-09-11 23:01:34 +00:00
|
|
|
winFrameTheme().font().drawText(m_geom_window,
|
2003-05-15 12:00:46 +00:00
|
|
|
screenNumber(),
|
|
|
|
winFrameTheme().labelTextFocusGC(),
|
|
|
|
label, strlen(label),
|
2003-09-12 23:35:31 +00:00
|
|
|
winFrameTheme().bevelWidth(),
|
|
|
|
winFrameTheme().bevelWidth() +
|
2003-05-15 12:00:46 +00:00
|
|
|
winFrameTheme().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-05-19 22:45:51 +00:00
|
|
|
m_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) {
|
2005-07-04 18:18:32 +00:00
|
|
|
changeWorkspaceID( (currentWorkspaceID() + delta) % numberOfWorkspaces());
|
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) {
|
2006-04-11 18:26:00 +00:00
|
|
|
changeWorkspaceID( (static_cast<signed>(numberOfWorkspaces()) + currentWorkspaceID() - (delta % numberOfWorkspaces())) % numberOfWorkspaces());
|
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) {
|
2005-07-04 18:18:32 +00:00
|
|
|
if (currentWorkspaceID()+delta < numberOfWorkspaces())
|
2003-05-15 12:00:46 +00:00
|
|
|
changeWorkspaceID(currentWorkspaceID()+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) {
|
2003-05-15 12:00:46 +00:00
|
|
|
if (currentWorkspaceID() >= static_cast<unsigned int>(delta))
|
|
|
|
changeWorkspaceID(currentWorkspaceID()-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
|
|
|
|
2003-06-12 15:24:37 +00:00
|
|
|
void BScreen::renderGeomWindow() {
|
2006-03-18 22:03:23 +00:00
|
|
|
|
|
|
|
char label[256];
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2003-08-25 13:15:53 +00:00
|
|
|
|
2006-03-18 22:03:23 +00:00
|
|
|
sprintf(label,
|
2006-06-21 14:41:16 +00:00
|
|
|
_FB_XTEXT(Screen, GeometryFormat,
|
2006-06-10 17:24:48 +00:00
|
|
|
"W: %04d x H: %04d", "Representative maximum sized text for width and height dialog").c_str(),
|
2006-03-18 22:03:23 +00:00
|
|
|
0, 0);
|
2003-08-25 13:15:53 +00:00
|
|
|
|
2003-09-12 23:35:31 +00:00
|
|
|
int geom_h = winFrameTheme().font().height() + winFrameTheme().bevelWidth()*2;
|
2006-03-18 22:03:23 +00:00
|
|
|
int geom_w = winFrameTheme().font().textWidth(label, strlen(label)) + winFrameTheme().bevelWidth()*2;
|
2003-08-25 13:15:53 +00:00
|
|
|
m_geom_window.resize(geom_w, geom_h);
|
|
|
|
|
2003-08-25 16:07:09 +00:00
|
|
|
m_geom_window.setBorderWidth(winFrameTheme().border().width());
|
|
|
|
m_geom_window.setBorderColor(winFrameTheme().border().color());
|
2003-08-25 13:15:53 +00:00
|
|
|
|
|
|
|
|
2003-06-12 15:24:37 +00:00
|
|
|
Pixmap tmp = geom_pixmap;
|
|
|
|
|
|
|
|
if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) {
|
2003-12-07 16:39:43 +00:00
|
|
|
if (!winFrameTheme().titleFocusTexture().usePixmap()) {
|
2003-06-12 15:24:37 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
m_geom_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color());
|
|
|
|
} else {
|
|
|
|
geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
|
|
|
|
winFrameTheme().titleFocusTexture());
|
|
|
|
m_geom_window.setBackgroundPixmap(geom_pixmap);
|
|
|
|
}
|
|
|
|
} else {
|
2003-12-07 16:39:43 +00:00
|
|
|
if (!winFrameTheme().labelFocusTexture().usePixmap()) {
|
2003-06-12 15:24:37 +00:00
|
|
|
geom_pixmap = None;
|
|
|
|
m_geom_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color());
|
|
|
|
} else {
|
|
|
|
geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
|
|
|
|
winFrameTheme().labelFocusTexture());
|
|
|
|
m_geom_window.setBackgroundPixmap(geom_pixmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
imageControl().removeImage(tmp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-01-16 11:47:07 +00:00
|
|
|
|
|
|
|
void BScreen::renderPosWindow() {
|
|
|
|
|
|
|
|
int pos_h = winFrameTheme().font().height() + winFrameTheme().bevelWidth()*2;
|
2006-06-10 17:24:48 +00:00
|
|
|
int pos_w = winFrameTheme().font().textWidth("0:00000 x 0:00000", 17) + winFrameTheme().bevelWidth()*2;
|
2004-01-16 11:47:07 +00:00
|
|
|
m_pos_window.resize(pos_w, pos_h);
|
|
|
|
|
|
|
|
m_pos_window.setBorderWidth(winFrameTheme().border().width());
|
|
|
|
m_pos_window.setBorderColor(winFrameTheme().border().color());
|
|
|
|
|
|
|
|
|
|
|
|
Pixmap tmp = pos_pixmap;
|
|
|
|
|
|
|
|
if (winFrameTheme().labelFocusTexture().type() & FbTk::Texture::PARENTRELATIVE) {
|
|
|
|
if (!winFrameTheme().titleFocusTexture().usePixmap()) {
|
|
|
|
pos_pixmap = None;
|
|
|
|
m_pos_window.setBackgroundColor(winFrameTheme().titleFocusTexture().color());
|
|
|
|
} else {
|
|
|
|
pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(),
|
|
|
|
winFrameTheme().titleFocusTexture());
|
|
|
|
m_pos_window.setBackgroundPixmap(pos_pixmap);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!winFrameTheme().labelFocusTexture().usePixmap()) {
|
|
|
|
pos_pixmap = None;
|
|
|
|
m_pos_window.setBackgroundColor(winFrameTheme().labelFocusTexture().color());
|
|
|
|
} else {
|
|
|
|
pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(),
|
|
|
|
winFrameTheme().labelFocusTexture());
|
|
|
|
m_pos_window.setBackgroundPixmap(pos_pixmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp)
|
|
|
|
imageControl().removeImage(tmp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-04-15 00:50:25 +00:00
|
|
|
/**
|
|
|
|
Called when a set of watched modifiers has been released
|
|
|
|
*/
|
|
|
|
void BScreen::notifyReleasedKeys(XKeyEvent &ke) {
|
2006-02-18 11:39:38 +00:00
|
|
|
focusControl().stopCyclingFocus();
|
2004-03-21 09:00:25 +00:00
|
|
|
}
|
|
|
|
|
2003-05-12 04:28:46 +00:00
|
|
|
void BScreen::updateSize() {
|
2003-12-18 15:27:21 +00:00
|
|
|
// force update geometry
|
2003-05-12 04:28:46 +00:00
|
|
|
rootWindow().updateGeometry();
|
|
|
|
|
2003-05-12 04:47:34 +00:00
|
|
|
// reset background
|
|
|
|
m_root_theme->reconfigTheme();
|
|
|
|
|
2003-12-18 15:27:21 +00:00
|
|
|
// send resize notify
|
2003-08-24 13:07:01 +00:00
|
|
|
m_resize_sig.notify();
|
2003-05-12 04:28:46 +00:00
|
|
|
}
|
2003-05-19 14:26:30 +00:00
|
|
|
|
2003-05-19 15:32:47 +00:00
|
|
|
|
2003-06-23 14:16:05 +00:00
|
|
|
/**
|
|
|
|
* Find the group of windows to this window's left
|
|
|
|
* So, we check the leftgroup hint, and see if we know any windows
|
|
|
|
*/
|
|
|
|
FluxboxWindow *BScreen::findGroupLeft(WinClient &winclient) {
|
|
|
|
Window w = winclient.getGroupLeftWindow();
|
|
|
|
if (w == None)
|
|
|
|
return 0;
|
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
WinClient *have_client = Fluxbox::instance()->searchWindow(w);
|
2003-06-23 14:16:05 +00:00
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
if (!have_client) {
|
2003-06-23 14:16:05 +00:00
|
|
|
// not found, add it to expecting
|
|
|
|
m_expecting_groups[w] = &winclient;
|
2003-07-28 15:06:36 +00:00
|
|
|
} else if (&have_client->screen() != &winclient.screen())
|
2003-06-23 14:16:05 +00:00
|
|
|
// something is not consistent
|
|
|
|
return 0;
|
|
|
|
|
2003-07-28 15:06:36 +00:00
|
|
|
if (have_client)
|
|
|
|
return have_client->fbwindow();
|
|
|
|
else
|
|
|
|
return 0;
|
2003-06-23 14:16:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FluxboxWindow *BScreen::findGroupRight(WinClient &winclient) {
|
|
|
|
Groupables::iterator it = m_expecting_groups.find(winclient.window());
|
|
|
|
if (it == m_expecting_groups.end())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// yay, this'll do.
|
|
|
|
WinClient *other = it->second;
|
|
|
|
m_expecting_groups.erase(it); // don't expect it anymore
|
|
|
|
|
|
|
|
// forget about it if it isn't the left-most client in the group, plus
|
|
|
|
// it must have the atom set on it (i.e. previously encountered by fluxbox)
|
|
|
|
// for us to check our expecting
|
|
|
|
if (!winclient.hasGroupLeftWindow() ||
|
|
|
|
other->getGroupLeftWindow() != None)
|
|
|
|
return 0;
|
|
|
|
|
2005-04-29 02:52:36 +00:00
|
|
|
return other->fbwindow();
|
2003-06-23 14:16:05 +00:00
|
|
|
}
|
2003-05-19 15:32:47 +00:00
|
|
|
void BScreen::initXinerama() {
|
2003-05-19 14:26:30 +00:00
|
|
|
#ifdef XINERAMA
|
2003-05-19 15:32:47 +00:00
|
|
|
Display *display = FbTk::App::instance()->display();
|
2003-05-19 14:26:30 +00:00
|
|
|
|
|
|
|
if (!XineramaIsActive(display)) {
|
2004-09-11 13:33:07 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"BScreen::initXinerama(): dont have Xinerama"<<endl;
|
|
|
|
#endif // DEBUG
|
2003-05-19 14:26:30 +00:00
|
|
|
m_xinerama_avail = false;
|
|
|
|
m_xinerama_headinfo = 0;
|
2003-05-22 01:17:15 +00:00
|
|
|
m_xinerama_num_heads = 0;
|
2003-05-19 14:26:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-09-11 13:33:07 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"BScreen::initXinerama(): have Xinerama"<<endl;
|
|
|
|
#endif // DEBUG
|
2003-05-19 14:26:30 +00:00
|
|
|
m_xinerama_avail = true;
|
|
|
|
|
|
|
|
XineramaScreenInfo *screen_info;
|
|
|
|
int number;
|
|
|
|
screen_info = XineramaQueryScreens(display, &number);
|
|
|
|
m_xinerama_headinfo = new XineramaHeadInfo[number];
|
|
|
|
m_xinerama_num_heads = number;
|
|
|
|
for (int i=0; i < number; i++) {
|
|
|
|
m_xinerama_headinfo[i].x = screen_info[i].x_org;
|
|
|
|
m_xinerama_headinfo[i].y = screen_info[i].y_org;
|
|
|
|
m_xinerama_headinfo[i].width = screen_info[i].width;
|
|
|
|
m_xinerama_headinfo[i].height = screen_info[i].height;
|
|
|
|
}
|
2004-11-22 19:40:34 +00:00
|
|
|
XFree(screen_info);
|
2004-09-11 13:33:07 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
cerr<<"BScreen::initXinerama(): number of heads ="<<number<<endl;
|
|
|
|
#endif // DEBUG
|
|
|
|
|
2003-05-19 15:32:47 +00:00
|
|
|
#else // XINERAMA
|
2003-05-19 22:45:51 +00:00
|
|
|
// no xinerama
|
2003-05-19 15:32:47 +00:00
|
|
|
m_xinerama_avail = false;
|
|
|
|
m_xinerama_num_heads = 0;
|
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int BScreen::getHead(int x, int y) const {
|
|
|
|
if (!hasXinerama()) return 0;
|
2003-05-19 15:32:47 +00:00
|
|
|
#ifdef XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
|
|
|
|
for (int i=0; i < m_xinerama_num_heads; i++) {
|
|
|
|
if (x >= m_xinerama_headinfo[i].x &&
|
|
|
|
x < (m_xinerama_headinfo[i].x + m_xinerama_headinfo[i].width) &&
|
|
|
|
y >= m_xinerama_headinfo[i].y &&
|
|
|
|
y < (m_xinerama_headinfo[i].y + m_xinerama_headinfo[i].height)) {
|
|
|
|
return i+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-19 15:32:47 +00:00
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-05-20 11:03:11 +00:00
|
|
|
int BScreen::getHead(FbTk::FbWindow &win) const {
|
|
|
|
if (hasXinerama())
|
|
|
|
return getHead(win.x() + win.width()/2, win.y() + win.height()/2);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-19 14:26:30 +00:00
|
|
|
int BScreen::getCurrHead() const {
|
|
|
|
if (!hasXinerama()) return 0;
|
2003-05-19 15:32:47 +00:00
|
|
|
int root_x = 0, root_y = 0;
|
|
|
|
#ifdef XINERAMA
|
|
|
|
int ignore_i;
|
2003-05-19 14:26:30 +00:00
|
|
|
unsigned int ignore_ui;
|
|
|
|
|
|
|
|
Window ignore_w;
|
|
|
|
|
|
|
|
XQueryPointer(FbTk::App::instance()->display(),
|
|
|
|
rootWindow().window(), &ignore_w,
|
|
|
|
&ignore_w, &root_x, &root_y,
|
|
|
|
&ignore_i, &ignore_i, &ignore_ui);
|
2003-05-19 15:32:47 +00:00
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
return getHead(root_x, root_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
int BScreen::getHeadX(int head) const {
|
2003-05-19 15:32:47 +00:00
|
|
|
#ifdef XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
if (head == 0 || head > m_xinerama_num_heads) return 0;
|
|
|
|
return m_xinerama_headinfo[head-1].x;
|
2003-05-19 15:32:47 +00:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BScreen::getHeadY(int head) const {
|
2003-05-19 15:32:47 +00:00
|
|
|
#ifdef XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
if (head == 0 || head > m_xinerama_num_heads) return 0;
|
|
|
|
return m_xinerama_headinfo[head-1].y;
|
2003-05-19 15:32:47 +00:00
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BScreen::getHeadWidth(int head) const {
|
2003-05-19 15:32:47 +00:00
|
|
|
#ifdef XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
if (head == 0 || head > m_xinerama_num_heads) return width();
|
|
|
|
return m_xinerama_headinfo[head-1].width;
|
2003-05-19 15:32:47 +00:00
|
|
|
#else
|
|
|
|
return width();
|
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int BScreen::getHeadHeight(int head) const {
|
2003-05-19 15:32:47 +00:00
|
|
|
#ifdef XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
if (head == 0 || head > m_xinerama_num_heads) return height();
|
|
|
|
return m_xinerama_headinfo[head-1].height;
|
2003-05-19 15:32:47 +00:00
|
|
|
#else
|
|
|
|
return height();
|
|
|
|
#endif // XINERAMA
|
2003-05-19 14:26:30 +00:00
|
|
|
}
|
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
pair<int,int> BScreen::clampToHead(int head, int x, int y, int w, int h) const {
|
|
|
|
|
|
|
|
// if there are multiple heads, head=0 is not valid
|
|
|
|
// a better way would be to search the closest head
|
|
|
|
if (head == 0 && numHeads() != 0)
|
|
|
|
head = 1;
|
|
|
|
|
|
|
|
int hx = getHeadX(head);
|
|
|
|
int hy = getHeadY(head);
|
|
|
|
int hw = getHeadWidth(head);
|
|
|
|
int hh = getHeadHeight(head);
|
|
|
|
|
|
|
|
if (x + w > hx + hw)
|
|
|
|
x = hx + hw - w;
|
|
|
|
if (y + h > hy + hh)
|
|
|
|
y = hy + hh - h;
|
|
|
|
|
|
|
|
if (x < hx)
|
|
|
|
x = hx;
|
|
|
|
if (y < hy)
|
|
|
|
y = hy;
|
|
|
|
|
|
|
|
return make_pair(x,y);
|
|
|
|
}
|
|
|
|
|
2003-06-23 13:10:52 +00:00
|
|
|
// TODO: when toolbar gets its resources moved into Toolbar.hh/cc, then
|
|
|
|
// this can be gone and a consistent interface for the two used
|
|
|
|
// on the actual objects
|
|
|
|
|
2004-12-21 16:09:36 +00:00
|
|
|
template<>
|
|
|
|
void BScreen::setOnHead<FluxboxWindow>(FluxboxWindow& win, int head) {
|
|
|
|
if (head > 0 && head <= numHeads()) {
|
|
|
|
int current_head = getHead(win.fbWindow());
|
|
|
|
win.move(getHeadX(head) + win.frame().x() - getHeadX(current_head),
|
|
|
|
getHeadY(head) + win.frame().y() - getHeadY(current_head));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|