2002-11-14 00:23:19 +00:00
|
|
|
// Slit.cc for fluxbox
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2002-11-14 00:23:19 +00:00
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Slit.cc for Blackbox - an X11 Window manager
|
2003-01-12 17:56:15 +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,
|
2003-01-12 17:56:15 +00:00
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
2001-12-11 20:47:02 +00:00
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
#include "Slit.hh"
|
2002-04-08 18:58:47 +00:00
|
|
|
|
2002-03-11 12:29:57 +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 21:47:54 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-05-04 20:50:15 +00:00
|
|
|
#include "config.h"
|
2001-12-11 20:47:02 +00:00
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
|
|
|
#include "Screen.hh"
|
2011-02-24 10:21:16 +00:00
|
|
|
#include "ScreenPlacement.hh"
|
2007-12-30 15:32:53 +00:00
|
|
|
#include "FbTk/ImageControl.hh"
|
|
|
|
#include "FbTk/RefCount.hh"
|
|
|
|
#include "FbTk/EventManager.hh"
|
|
|
|
#include "FbTk/SimpleCommand.hh"
|
|
|
|
#include "FbTk/Theme.hh"
|
|
|
|
#include "FbTk/Transparent.hh"
|
2008-01-28 08:30:31 +00:00
|
|
|
#include "FbTk/MacroCommand.hh"
|
2008-09-21 14:12:36 +00:00
|
|
|
#include "FbTk/MemFun.hh"
|
|
|
|
|
2003-06-22 14:17:17 +00:00
|
|
|
#include "FbCommands.hh"
|
2006-02-27 22:43:42 +00:00
|
|
|
#include "Layer.hh"
|
2003-02-18 15:11:12 +00:00
|
|
|
#include "LayerMenu.hh"
|
2011-02-23 21:49:27 +00:00
|
|
|
#include "FbTk/Layer.hh"
|
2003-04-25 10:46:07 +00:00
|
|
|
#include "RootTheme.hh"
|
2003-05-06 01:45:17 +00:00
|
|
|
#include "FbMenu.hh"
|
2006-02-27 20:58:16 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
#include "SlitTheme.hh"
|
|
|
|
#include "SlitClient.hh"
|
2003-06-22 12:31:37 +00:00
|
|
|
#include "Xutil.hh"
|
2010-03-17 15:35:07 +00:00
|
|
|
#include "Debug.hh"
|
|
|
|
|
2006-02-27 21:43:01 +00:00
|
|
|
#include "FbTk/App.hh"
|
2004-12-02 03:12:55 +00:00
|
|
|
#include "FbTk/MenuSeparator.hh"
|
2004-01-30 11:06:25 +00:00
|
|
|
#include "FbTk/StringUtil.hh"
|
2004-06-07 11:46:05 +00:00
|
|
|
#include "FbTk/I18n.hh"
|
2007-12-27 21:55:24 +00:00
|
|
|
#include "FbTk/BoolMenuItem.hh"
|
|
|
|
#include "FbTk/IntMenuItem.hh"
|
2008-08-04 04:59:14 +00:00
|
|
|
#include "FbTk/RadioMenuItem.hh"
|
2003-05-19 14:26:30 +00:00
|
|
|
|
2002-05-29 06:21:59 +00:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2003-01-12 17:56:15 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2002-05-29 06:21:59 +00:00
|
|
|
#endif // HAVE_SYS_STAT_H
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
#include <X11/Xatom.h>
|
2002-05-29 06:21:59 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
2007-06-29 17:25:24 +00:00
|
|
|
#ifdef HAVE_CSTRING
|
|
|
|
#include <cstring>
|
|
|
|
#else
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
2006-10-27 06:57:43 +00:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::pair;
|
|
|
|
using std::list;
|
|
|
|
using std::ifstream;
|
|
|
|
using std::ofstream;
|
|
|
|
using std::endl;
|
|
|
|
using std::hex;
|
|
|
|
using std::dec;
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2006-03-02 07:49:13 +00:00
|
|
|
namespace FbTk {
|
|
|
|
|
2004-02-10 18:45:26 +00:00
|
|
|
template<>
|
2005-11-22 21:09:14 +00:00
|
|
|
string FbTk::Resource<Slit::Placement>::getString() const {
|
2003-06-23 13:32:30 +00:00
|
|
|
switch (m_value) {
|
|
|
|
case Slit::TOPLEFT:
|
|
|
|
return string("TopLeft");
|
|
|
|
break;
|
2004-06-07 11:46:05 +00:00
|
|
|
case Slit::LEFTCENTER:
|
|
|
|
return string("LeftCenter");
|
2003-06-23 13:32:30 +00:00
|
|
|
break;
|
|
|
|
case Slit::BOTTOMLEFT:
|
|
|
|
return string("BottomLeft");
|
|
|
|
break;
|
|
|
|
case Slit::TOPCENTER:
|
|
|
|
return string("TopCenter");
|
2006-10-27 06:57:43 +00:00
|
|
|
break;
|
2003-06-23 13:32:30 +00:00
|
|
|
case Slit::BOTTOMCENTER:
|
|
|
|
return string("BottomCenter");
|
|
|
|
break;
|
|
|
|
case Slit::TOPRIGHT:
|
|
|
|
return string("TopRight");
|
|
|
|
break;
|
2004-06-07 11:46:05 +00:00
|
|
|
case Slit::RIGHTCENTER:
|
|
|
|
return string("RightCenter");
|
2003-06-23 13:32:30 +00:00
|
|
|
break;
|
|
|
|
case Slit::BOTTOMRIGHT:
|
|
|
|
return string("BottomRight");
|
|
|
|
break;
|
2008-08-06 00:11:55 +00:00
|
|
|
case Slit::LEFTTOP:
|
|
|
|
return string("LeftTop");
|
2003-06-23 13:32:30 +00:00
|
|
|
break;
|
2008-08-06 00:11:55 +00:00
|
|
|
case Slit::RIGHTTOP:
|
|
|
|
return string("RightTop");
|
|
|
|
break;
|
|
|
|
case Slit::LEFTBOTTOM:
|
|
|
|
return string("LeftBottom");
|
|
|
|
break;
|
|
|
|
case Slit::RIGHTBOTTOM:
|
|
|
|
return string("RightBottom");
|
2003-06-23 13:32:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-08-06 00:11:55 +00:00
|
|
|
//default string
|
|
|
|
return string("RightBottom");
|
2003-06-23 13:32:30 +00:00
|
|
|
}
|
2008-08-06 00:11:55 +00:00
|
|
|
|
2010-05-23 10:25:47 +00:00
|
|
|
template<>
|
|
|
|
void FbTk::Resource<Slit::Placement>::setFromString(const char *strval) {
|
|
|
|
if (strcasecmp(strval, "TopLeft")==0)
|
|
|
|
m_value = Slit::TOPLEFT;
|
|
|
|
else if (strcasecmp(strval, "LeftCenter")==0)
|
|
|
|
m_value = Slit::LEFTCENTER;
|
|
|
|
else if (strcasecmp(strval, "BottomLeft")==0)
|
|
|
|
m_value = Slit::BOTTOMLEFT;
|
|
|
|
else if (strcasecmp(strval, "TopCenter")==0)
|
|
|
|
m_value = Slit::TOPCENTER;
|
|
|
|
else if (strcasecmp(strval, "BottomCenter")==0)
|
|
|
|
m_value = Slit::BOTTOMCENTER;
|
|
|
|
else if (strcasecmp(strval, "TopRight")==0)
|
|
|
|
m_value = Slit::TOPRIGHT;
|
|
|
|
else if (strcasecmp(strval, "RightCenter")==0)
|
|
|
|
m_value = Slit::RIGHTCENTER;
|
|
|
|
else if (strcasecmp(strval, "BottomRight")==0)
|
|
|
|
m_value = Slit::BOTTOMRIGHT;
|
|
|
|
else if (strcasecmp(strval, "LeftTop")==0)
|
|
|
|
m_value = Slit::LEFTTOP;
|
|
|
|
else if (strcasecmp(strval, "LeftBottom")==0)
|
|
|
|
m_value = Slit::LEFTBOTTOM;
|
|
|
|
else if (strcasecmp(strval, "RightTop")==0)
|
|
|
|
m_value = Slit::RIGHTTOP;
|
|
|
|
else if (strcasecmp(strval, "RightBottom")==0)
|
|
|
|
m_value = Slit::RIGHTBOTTOM;
|
|
|
|
else
|
|
|
|
setDefaultValue();
|
|
|
|
}
|
|
|
|
|
2006-03-02 07:49:13 +00:00
|
|
|
} // end namespace FbTk
|
2006-10-27 06:57:43 +00:00
|
|
|
namespace {
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2004-12-02 03:12:55 +00:00
|
|
|
class SlitClientMenuItem: public FbTk::MenuItem{
|
2003-01-12 17:56:15 +00:00
|
|
|
public:
|
2008-01-11 07:41:22 +00:00
|
|
|
explicit SlitClientMenuItem(Slit& slit, SlitClient &client, FbTk::RefCount<FbTk::Command<void> > &cmd):
|
2010-09-08 18:17:21 +00:00
|
|
|
FbTk::MenuItem(client.matchName(), cmd), m_slit(slit), m_client(client) {
|
2004-12-02 03:12:55 +00:00
|
|
|
setCommand(cmd);
|
2003-06-20 01:27:28 +00:00
|
|
|
FbTk::MenuItem::setSelected(client.visible());
|
2004-12-02 03:12:55 +00:00
|
|
|
setToggleItem(true);
|
2007-12-18 05:44:17 +00:00
|
|
|
setCloseOnClick(false);
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
2010-09-08 18:17:21 +00:00
|
|
|
const FbTk::BiDiString &label() const {
|
2003-06-20 01:27:28 +00:00
|
|
|
return m_client.matchName();
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
|
|
|
bool isSelected() const {
|
2003-06-20 01:27:28 +00:00
|
|
|
return m_client.visible();
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
2007-12-18 05:44:17 +00:00
|
|
|
void click(int button, int time, unsigned int mods) {
|
2004-12-02 15:30:59 +00:00
|
|
|
if (button == 4 || button == 2) { // wheel up
|
2004-12-02 03:12:55 +00:00
|
|
|
m_slit.clientUp(&m_client);
|
2004-12-02 15:30:59 +00:00
|
|
|
} else if (button == 5 || button == 3) { // wheel down
|
2004-12-02 03:12:55 +00:00
|
|
|
m_slit.clientDown(&m_client);
|
|
|
|
} else {
|
|
|
|
m_client.setVisible(!m_client.visible());
|
|
|
|
FbTk::MenuItem::setSelected(m_client.visible());
|
2007-12-18 05:44:17 +00:00
|
|
|
FbTk::MenuItem::click(button, time, mods);
|
2004-12-02 03:12:55 +00:00
|
|
|
}
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
|
|
|
private:
|
2004-12-02 03:12:55 +00:00
|
|
|
Slit& m_slit;
|
2003-01-12 17:56:15 +00:00
|
|
|
SlitClient &m_client;
|
|
|
|
};
|
|
|
|
|
2008-08-04 04:59:14 +00:00
|
|
|
class PlaceSlitMenuItem: public FbTk::RadioMenuItem {
|
2003-01-12 17:56:15 +00:00
|
|
|
public:
|
2008-01-11 07:41:22 +00:00
|
|
|
PlaceSlitMenuItem(const FbTk::FbString &label, Slit &slit, Slit::Placement place, FbTk::RefCount<FbTk::Command<void> > &cmd):
|
2008-08-04 04:59:14 +00:00
|
|
|
FbTk::RadioMenuItem(label, cmd), m_slit(slit), m_place(place) {
|
2007-12-18 05:44:17 +00:00
|
|
|
setCloseOnClick(false);
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
2008-08-04 04:59:14 +00:00
|
|
|
bool isSelected() const { return m_slit.placement() == m_place; }
|
2007-12-18 05:44:17 +00:00
|
|
|
void click(int button, int time, unsigned int mods) {
|
2003-01-12 17:56:15 +00:00
|
|
|
m_slit.setPlacement(m_place);
|
2008-08-04 04:59:14 +00:00
|
|
|
FbTk::RadioMenuItem::click(button, time, mods);
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
Slit &m_slit;
|
|
|
|
Slit::Placement m_place;
|
|
|
|
};
|
|
|
|
|
2009-09-30 19:02:24 +00:00
|
|
|
} // End anonymous namespace
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
unsigned int Slit::s_eventmask = SubstructureRedirectMask | ButtonPressMask |
|
2003-06-05 11:30:06 +00:00
|
|
|
EnterWindowMask | LeaveWindowMask | ExposureMask;
|
|
|
|
|
2011-02-23 21:49:27 +00:00
|
|
|
Slit::Slit(BScreen &scr, FbTk::Layer &layer, const char *filename)
|
2007-02-17 17:40:50 +00:00
|
|
|
: m_hidden(false), m_visible(false),
|
2003-08-11 16:05:18 +00:00
|
|
|
m_screen(scr),
|
2003-12-18 18:03:23 +00:00
|
|
|
m_clientlist_menu(scr.menuTheme(),
|
2003-05-15 23:30:07 +00:00
|
|
|
scr.imageControl(),
|
2011-03-23 11:02:15 +00:00
|
|
|
*scr.layerManager().getLayer(ResourceLayer::MENU)),
|
2007-01-07 14:07:45 +00:00
|
|
|
m_slitmenu(scr.menuTheme(),
|
|
|
|
scr.imageControl(),
|
2011-03-23 11:02:15 +00:00
|
|
|
*scr.layerManager().getLayer(ResourceLayer::MENU)),
|
2007-08-05 22:36:12 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
m_xineramaheadmenu(0),
|
|
|
|
#endif // XINERAMA
|
2004-09-11 18:58:27 +00:00
|
|
|
frame(scr.rootWindow()),
|
2004-06-07 21:36:06 +00:00
|
|
|
//For KDE dock applets
|
2006-10-27 06:57:43 +00:00
|
|
|
m_kwm1_dockwindow(XInternAtom(FbTk::App::instance()->display(),
|
2003-05-11 17:42:51 +00:00
|
|
|
"KWM_DOCKWINDOW", False)), //KDE v1.x
|
2006-10-27 06:57:43 +00:00
|
|
|
m_kwm2_dockwindow(XInternAtom(FbTk::App::instance()->display(),
|
2003-05-11 17:42:51 +00:00
|
|
|
"_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", False)), //KDE v2.x
|
|
|
|
|
2003-04-25 10:46:07 +00:00
|
|
|
m_layeritem(0),
|
2006-04-22 16:38:20 +00:00
|
|
|
|
2003-08-29 10:30:46 +00:00
|
|
|
m_slit_theme(new SlitTheme(scr.rootWindow().screenNumber())),
|
2003-06-20 01:27:28 +00:00
|
|
|
m_strut(0),
|
2003-06-22 12:31:37 +00:00
|
|
|
// resources
|
2003-07-18 15:40:55 +00:00
|
|
|
// lock in first resource
|
2007-12-25 06:36:22 +00:00
|
|
|
m_rc_kde_dockapp(scr.resourceManager(), true,
|
|
|
|
scr.name() + ".slit.acceptKdeDockapps", scr.altName() + ".Slit.AcceptKdeDockapps"),
|
2006-10-27 06:57:43 +00:00
|
|
|
m_rc_auto_hide(scr.resourceManager().lock(), false,
|
2003-06-20 01:27:28 +00:00
|
|
|
scr.name() + ".slit.autoHide", scr.altName() + ".Slit.AutoHide"),
|
|
|
|
// TODO: this resource name must change
|
|
|
|
m_rc_maximize_over(scr.resourceManager(), false,
|
2003-06-22 12:31:37 +00:00
|
|
|
scr.name() + ".slit.maxOver", scr.altName() + ".Slit.MaxOver"),
|
2008-08-06 00:11:55 +00:00
|
|
|
m_rc_placement(scr.resourceManager(), RIGHTBOTTOM,
|
2003-06-20 01:27:28 +00:00
|
|
|
scr.name() + ".slit.placement", scr.altName() + ".Slit.Placement"),
|
2006-10-27 06:57:43 +00:00
|
|
|
m_rc_alpha(scr.resourceManager(), 255,
|
2003-06-20 01:27:28 +00:00
|
|
|
scr.name() + ".slit.alpha", scr.altName() + ".Slit.Alpha"),
|
|
|
|
m_rc_on_head(scr.resourceManager(), 0,
|
|
|
|
scr.name() + ".slit.onhead", scr.altName() + ".Slit.onHead"),
|
2011-03-23 11:02:15 +00:00
|
|
|
m_rc_layernum(scr.resourceManager(), ResourceLayer(ResourceLayer::DOCK),
|
2003-06-20 01:27:28 +00:00
|
|
|
scr.name() + ".slit.layer", scr.altName() + ".Slit.Layer") {
|
2003-02-18 15:11:12 +00:00
|
|
|
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
|
|
|
|
2012-10-22 15:39:35 +00:00
|
|
|
frame.window.setWindowRole("fluxbox-slit");
|
|
|
|
|
2003-08-29 10:30:46 +00:00
|
|
|
// attach to theme and root window change signal
|
2011-04-29 08:52:28 +00:00
|
|
|
join(theme().reconfigSig(), FbTk::MemFun(*this, &Slit::reconfigure));
|
2008-09-28 16:13:30 +00:00
|
|
|
|
|
|
|
join(scr.resizeSig(),
|
|
|
|
FbTk::MemFun(*this, &Slit::screenSizeChanged));
|
2008-09-21 14:12:36 +00:00
|
|
|
|
|
|
|
join(scr.bgChangeSig(),
|
2011-04-29 08:52:28 +00:00
|
|
|
FbTk::MemFunIgnoreArgs(*this, &Slit::reconfigure));
|
2008-09-21 14:12:36 +00:00
|
|
|
|
2011-05-07 20:32:48 +00:00
|
|
|
join(scr.reconfigureSig(), FbTk::MemFunIgnoreArgs(*this, &Slit::reconfigure));
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
scr.addConfigMenu(_FB_XTEXT(Slit, Slit, "Slit", "The Slit"), m_slitmenu);
|
2006-04-22 16:38:20 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
frame.pixmap = None;
|
2005-03-17 14:24:36 +00:00
|
|
|
// move the frame out of sight for a moment
|
|
|
|
frame.window.move(-frame.window.width(), -frame.window.height());
|
2003-08-11 16:05:18 +00:00
|
|
|
// setup timer
|
2012-08-28 08:51:55 +00:00
|
|
|
m_timer.setTimeout(200L * FbTk::FbTime::IN_MILLISECONDS); // default timeout
|
2003-05-11 17:42:51 +00:00
|
|
|
m_timer.fireOnce(true);
|
2008-01-11 07:41:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command<void> > toggle_hidden(new FbTk::SimpleCommand<Slit>(*this, &Slit::toggleHidden));
|
2003-08-11 16:05:18 +00:00
|
|
|
m_timer.setCommand(toggle_hidden);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
FbTk::EventManager::instance()->add(*this, frame.window);
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-09-12 14:56:20 +00:00
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
|
|
|
frame.window.setOpaque(*m_rc_alpha);
|
|
|
|
} else {
|
|
|
|
frame.window.setAlpha(*m_rc_alpha);
|
|
|
|
}
|
|
|
|
|
2011-02-23 21:49:27 +00:00
|
|
|
m_layeritem.reset(new FbTk::LayerItem(frame.window, layer));
|
2005-06-23 03:07:25 +00:00
|
|
|
|
|
|
|
m_layermenu.reset(new LayerMenu(scr.menuTheme(),
|
|
|
|
scr.imageControl(),
|
|
|
|
*scr.layerManager().
|
2011-03-23 11:02:15 +00:00
|
|
|
getLayer(ResourceLayer::MENU),
|
2005-06-23 03:07:25 +00:00
|
|
|
this,
|
|
|
|
true));
|
2006-06-21 14:41:16 +00:00
|
|
|
m_layermenu->setLabel(_FB_XTEXT(Slit, Layer, "Slit Layer", "Title of Slit Layer Menu"));
|
2005-06-23 03:07:25 +00:00
|
|
|
|
2003-07-18 15:40:55 +00:00
|
|
|
moveToLayer((*m_rc_layernum).getNum());
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
|
2003-07-25 10:03:55 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// Get client list for sorting purposes
|
2003-01-12 17:56:15 +00:00
|
|
|
loadClientList(filename);
|
|
|
|
|
|
|
|
setupMenu();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-07-18 15:40:55 +00:00
|
|
|
scr.resourceManager().unlock();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-06-05 11:30:06 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
Slit::~Slit() {
|
2003-06-18 13:55:17 +00:00
|
|
|
clearStrut();
|
2003-01-12 17:56:15 +00:00
|
|
|
if (frame.pixmap != 0)
|
2003-05-15 23:30:07 +00:00
|
|
|
screen().imageControl().removeImage(frame.pixmap);
|
2003-06-22 12:31:37 +00:00
|
|
|
|
2006-04-24 13:34:14 +00:00
|
|
|
// otherwise it will try to access it on deletion
|
2006-10-27 06:57:43 +00:00
|
|
|
screen().removeConfigMenu(m_slitmenu);
|
2006-04-24 13:34:14 +00:00
|
|
|
|
2003-06-22 12:31:37 +00:00
|
|
|
shutdown();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-06-18 13:55:17 +00:00
|
|
|
void Slit::clearStrut() {
|
|
|
|
if (m_strut != 0) {
|
|
|
|
screen().clearStrut(m_strut);
|
|
|
|
m_strut = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slit::updateStrut() {
|
2003-06-22 14:17:17 +00:00
|
|
|
bool had_strut = m_strut ? true : false;
|
2003-06-18 13:55:17 +00:00
|
|
|
clearStrut();
|
2003-06-22 14:17:17 +00:00
|
|
|
// no need for area if we're autohiding or set maximize over
|
2006-07-06 20:46:38 +00:00
|
|
|
// or if we dont have any clients
|
2007-02-17 17:40:50 +00:00
|
|
|
if (doAutoHide() || *m_rc_maximize_over || !m_visible) {
|
2003-06-22 14:17:17 +00:00
|
|
|
// update screen area if we had a strut before
|
|
|
|
if (had_strut)
|
|
|
|
screen().updateAvailableWorkspaceArea();
|
2003-06-18 13:55:17 +00:00
|
|
|
return;
|
2003-06-22 14:17:17 +00:00
|
|
|
}
|
|
|
|
|
2010-09-08 18:17:21 +00:00
|
|
|
const unsigned int bw = m_slit_theme->borderWidth() * 2;
|
2003-06-18 13:55:17 +00:00
|
|
|
int left = 0, right = 0, top = 0, bottom = 0;
|
|
|
|
switch (placement()) {
|
|
|
|
case TOPLEFT:
|
2010-09-08 18:17:21 +00:00
|
|
|
top = height() + bw;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
case LEFTTOP:
|
2010-09-08 18:17:21 +00:00
|
|
|
left = width() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
|
|
|
case TOPCENTER:
|
2010-09-08 18:17:21 +00:00
|
|
|
top = height() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
|
|
|
case TOPRIGHT:
|
2010-09-08 18:17:21 +00:00
|
|
|
top = height() + bw;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
case RIGHTTOP:
|
2010-09-08 18:17:21 +00:00
|
|
|
right = width() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
|
|
|
case BOTTOMLEFT:
|
2010-09-08 18:17:21 +00:00
|
|
|
bottom = height() + bw;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
case LEFTBOTTOM:
|
2010-09-08 18:17:21 +00:00
|
|
|
left = width() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
|
|
|
case BOTTOMCENTER:
|
2010-09-08 18:17:21 +00:00
|
|
|
bottom = height() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
|
|
|
case BOTTOMRIGHT:
|
2010-09-08 18:17:21 +00:00
|
|
|
bottom = height() + bw;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
case RIGHTBOTTOM:
|
2010-09-08 18:17:21 +00:00
|
|
|
right = width() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
2004-06-07 11:46:05 +00:00
|
|
|
case LEFTCENTER:
|
2010-09-08 18:17:21 +00:00
|
|
|
left = width() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
2004-06-07 11:46:05 +00:00
|
|
|
case RIGHTCENTER:
|
2010-09-08 18:17:21 +00:00
|
|
|
right = width() + bw;
|
2003-06-18 13:55:17 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-04-18 16:05:26 +00:00
|
|
|
|
2004-09-11 13:33:07 +00:00
|
|
|
m_strut = screen().requestStrut(getOnHead(), left, right, top, bottom);
|
2003-06-18 13:55:17 +00:00
|
|
|
screen().updateAvailableWorkspaceArea();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
void Slit::addClient(Window w) {
|
2010-03-17 15:35:07 +00:00
|
|
|
|
|
|
|
fbdbg<<"addClient(w = 0x"<<hex<<w<<dec<<")"<<endl;
|
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
// Can't add non existent window
|
2002-12-01 13:42:15 +00:00
|
|
|
if (w == None)
|
|
|
|
return;
|
|
|
|
|
2007-12-25 06:36:22 +00:00
|
|
|
if (!acceptKdeDockapp() && screen().isKdeDockapp(w))
|
|
|
|
return;
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
// Look for slot in client list by name
|
|
|
|
SlitClient *client = 0;
|
2010-09-08 18:17:21 +00:00
|
|
|
FbTk::FbString match_name = Xutil::getWMClassName(w);
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
|
|
|
SlitClients::iterator it_end = m_client_list.end();
|
2002-12-01 13:42:15 +00:00
|
|
|
bool found_match = false;
|
|
|
|
for (; it != it_end; ++it) {
|
|
|
|
// If the name matches...
|
2010-09-08 18:17:21 +00:00
|
|
|
if ((*it)->matchName().logical() == match_name) {
|
2002-12-01 13:42:15 +00:00
|
|
|
// Use the slot if no window is assigned
|
2003-06-20 01:27:28 +00:00
|
|
|
if ((*it)->window() == None) {
|
2002-12-01 13:42:15 +00:00
|
|
|
client = (*it);
|
2003-02-20 16:41:22 +00:00
|
|
|
client->initialize(&screen(), w);
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Otherwise keep looking for an unused match or a non-match
|
|
|
|
found_match = true; // Possibly redundant
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
} else if (found_match) {
|
|
|
|
// Insert before first non-match after a previously found match?
|
2003-02-20 16:41:22 +00:00
|
|
|
client = new SlitClient(&screen(), w);
|
2003-05-11 17:42:51 +00:00
|
|
|
m_client_list.insert(it, client);
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Append to client list?
|
|
|
|
if (client == 0) {
|
2003-02-20 16:41:22 +00:00
|
|
|
client = new SlitClient(&screen(), w);
|
2003-05-11 17:42:51 +00:00
|
|
|
m_client_list.push_back(client);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-12 17:56:15 +00:00
|
|
|
|
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2002-12-01 13:42:15 +00:00
|
|
|
XWMHints *wmhints = XGetWMHints(disp, w);
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
if (wmhints != 0) {
|
2002-12-01 13:42:15 +00:00
|
|
|
if ((wmhints->flags & IconWindowHint) &&
|
|
|
|
(wmhints->icon_window != None)) {
|
2007-12-25 22:30:34 +00:00
|
|
|
XMoveWindow(disp, client->clientWindow(), -100, -100);
|
2003-06-20 01:27:28 +00:00
|
|
|
XMapWindow(disp, client->clientWindow());
|
|
|
|
client->setIconWindow(wmhints->icon_window);
|
|
|
|
client->setWindow(client->iconWindow());
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-06-20 01:27:28 +00:00
|
|
|
client->setIconWindow(None);
|
|
|
|
client->setWindow(client->clientWindow());
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
2003-06-27 15:05:19 +00:00
|
|
|
XFree((void *) wmhints);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-06-20 01:27:28 +00:00
|
|
|
client->setIconWindow(None);
|
|
|
|
client->setWindow(client->clientWindow());
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2003-06-27 15:05:19 +00:00
|
|
|
Atom *proto = 0;
|
|
|
|
int num_return = 0;
|
|
|
|
|
|
|
|
if (XGetWMProtocols(disp, w, &proto, &num_return)) {
|
|
|
|
XFree((void *) proto);
|
|
|
|
} else {
|
2010-03-17 15:35:07 +00:00
|
|
|
fbdbg<<"Warning: Failed to read WM Protocols. "<<endl;
|
2003-06-27 15:05:19 +00:00
|
|
|
}
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
XWindowAttributes attrib;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
|
|
|
if (screen().isKdeDockapp(w))
|
2003-06-20 01:27:28 +00:00
|
|
|
client->resize(24, 24);
|
2007-12-25 06:49:46 +00:00
|
|
|
else if (XGetWindowAttributes(disp, client->window(), &attrib))
|
|
|
|
client->resize(attrib.width, attrib.height);
|
|
|
|
else // set default size if we failed to get window attributes
|
|
|
|
client->resize(64, 64);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// disable border for client window
|
2003-06-20 01:27:28 +00:00
|
|
|
XSetWindowBorderWidth(disp, client->window(), 0);
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// disable events to frame.window
|
|
|
|
frame.window.setEventMask(NoEventMask);
|
|
|
|
client->disableEvents();
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
XReparentWindow(disp, client->window(), frame.window.window(), 0, 0);
|
|
|
|
XMapRaised(disp, client->window());
|
|
|
|
XChangeSaveSet(disp, client->window(), SetModeInsert);
|
2003-01-12 17:56:15 +00:00
|
|
|
// reactivate events for frame.window
|
2003-05-17 11:00:50 +00:00
|
|
|
frame.window.setEventMask(s_eventmask);
|
2003-01-12 17:56:15 +00:00
|
|
|
// setup event for slit client window
|
|
|
|
client->enableEvents();
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// flush events
|
2004-04-19 22:42:26 +00:00
|
|
|
// XFlush(disp);
|
2003-02-20 16:41:22 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// add slit client to eventmanager
|
2003-06-20 01:27:28 +00:00
|
|
|
FbTk::EventManager::instance()->add(*this, client->clientWindow());
|
|
|
|
FbTk::EventManager::instance()->add(*this, client->iconWindow());
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2004-04-19 22:42:26 +00:00
|
|
|
// frame.window.show();
|
2003-05-13 21:12:18 +00:00
|
|
|
clearWindow();
|
2002-12-01 13:42:15 +00:00
|
|
|
reconfigure();
|
2002-05-29 06:21:59 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
updateClientmenu();
|
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
saveClientList();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::setPlacement(Placement place) {
|
2003-06-20 01:27:28 +00:00
|
|
|
*m_rc_placement = place;
|
2003-01-12 17:56:15 +00:00
|
|
|
reconfigure();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-05-29 06:21:59 +00:00
|
|
|
void Slit::removeClient(SlitClient *client, bool remap, bool destroy) {
|
2003-06-22 12:31:37 +00:00
|
|
|
if (client == 0)
|
|
|
|
return;
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// remove from event manager
|
2003-06-20 01:27:28 +00:00
|
|
|
if (client->clientWindow() != 0)
|
|
|
|
FbTk::EventManager::instance()->remove(client->clientWindow());
|
|
|
|
if (client->iconWindow() != 0)
|
|
|
|
FbTk::EventManager::instance()->remove(client->iconWindow());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
// Destructive removal?
|
|
|
|
if (destroy)
|
2003-05-11 17:42:51 +00:00
|
|
|
m_client_list.remove(client);
|
2002-12-01 13:42:15 +00:00
|
|
|
else // Clear the window info, but keep around to help future sorting?
|
|
|
|
client->initialize();
|
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
if (remap && client->window() != 0) {
|
2003-01-12 17:56:15 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2003-02-20 16:41:22 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
if (!client->visible())
|
|
|
|
client->show();
|
2003-02-20 16:41:22 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
client->disableEvents();
|
|
|
|
// stop events to frame.window temporarly
|
|
|
|
frame.window.setEventMask(NoEventMask);
|
2003-06-20 01:27:28 +00:00
|
|
|
XReparentWindow(disp, client->window(), screen().rootWindow().window(),
|
|
|
|
client->x(), client->y());
|
|
|
|
XChangeSaveSet(disp, client->window(), SetModeDelete);
|
2003-01-12 17:56:15 +00:00
|
|
|
// reactivate events to frame.window
|
2003-05-17 11:00:50 +00:00
|
|
|
frame.window.setEventMask(s_eventmask);
|
2002-12-01 13:42:15 +00:00
|
|
|
XFlush(disp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destructive removal?
|
|
|
|
if (destroy)
|
|
|
|
delete client;
|
2003-02-17 12:53:21 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
updateClientmenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-04 22:33:09 +00:00
|
|
|
void Slit::removeClient(Window w, bool remap) {
|
2003-08-04 12:57:23 +00:00
|
|
|
|
2003-06-05 11:30:06 +00:00
|
|
|
if (w == frame.window)
|
|
|
|
return;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
bool reconf = false;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
|
|
|
SlitClients::iterator it_end = m_client_list.end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2003-06-20 01:27:28 +00:00
|
|
|
if ((*it)->window() == w) {
|
2002-12-01 13:42:15 +00:00
|
|
|
removeClient((*it), remap, false);
|
|
|
|
reconf = true;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (reconf)
|
|
|
|
reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-14 00:23:19 +00:00
|
|
|
void Slit::reconfigure() {
|
2003-06-22 14:17:17 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.width = 0;
|
|
|
|
frame.height = 0;
|
|
|
|
|
|
|
|
// Need to count windows because not all client list entries
|
|
|
|
// actually correspond to mapped windows.
|
|
|
|
int num_windows = 0;
|
2008-01-05 01:39:19 +00:00
|
|
|
const int bevel_width = theme()->bevelWidth();
|
2003-06-20 01:27:28 +00:00
|
|
|
// determine width or height increase
|
|
|
|
bool height_inc = false;
|
2008-08-06 00:11:55 +00:00
|
|
|
switch (placement()) {
|
|
|
|
case LEFTTOP:
|
|
|
|
case RIGHTTOP:
|
|
|
|
case LEFTCENTER:
|
|
|
|
case RIGHTCENTER:
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
case RIGHTBOTTOM:
|
2003-06-20 01:27:28 +00:00
|
|
|
height_inc = true;
|
2008-08-06 00:11:55 +00:00
|
|
|
default:
|
2003-01-12 17:56:15 +00:00
|
|
|
break;
|
2003-06-20 01:27:28 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
SlitClients::iterator client_it = m_client_list.begin();
|
|
|
|
SlitClients::iterator client_it_end = m_client_list.end();
|
|
|
|
for (; client_it != client_it_end; ++client_it) {
|
|
|
|
// client created window?
|
|
|
|
if ((*client_it)->window() != None && (*client_it)->visible()) {
|
|
|
|
num_windows++;
|
2007-07-03 18:50:53 +00:00
|
|
|
|
|
|
|
// get the dockapps to update their backgrounds
|
|
|
|
if (screen().isKdeDockapp((*client_it)->window())) {
|
|
|
|
(*client_it)->hide();
|
|
|
|
(*client_it)->show();
|
|
|
|
}
|
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
if (height_inc) {
|
|
|
|
// increase height of slit for each client (VERTICAL mode)
|
2006-10-27 06:57:43 +00:00
|
|
|
frame.height += (*client_it)->height() + bevel_width;
|
2003-06-20 01:27:28 +00:00
|
|
|
// the slit should always have the width of the largest client
|
2006-10-27 06:57:43 +00:00
|
|
|
if (frame.width < (*client_it)->width())
|
2003-06-20 01:27:28 +00:00
|
|
|
frame.width = (*client_it)->width();
|
|
|
|
} else {
|
|
|
|
// increase width of slit for each client (HORIZONTAL mode)
|
|
|
|
frame.width += (*client_it)->width() + bevel_width;
|
|
|
|
// the slit should always have the width of the largest client
|
|
|
|
if (frame.height < (*client_it)->height())
|
|
|
|
frame.height = (*client_it)->height();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-04 20:50:15 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-05 11:30:06 +00:00
|
|
|
if (frame.width < 1)
|
|
|
|
frame.width = 1;
|
|
|
|
else
|
|
|
|
frame.width += bevel_width;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-05 11:30:06 +00:00
|
|
|
if (frame.height < 1)
|
|
|
|
frame.height = 1;
|
|
|
|
else
|
|
|
|
frame.height += bevel_width*2;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
Display *disp = FbTk::App::instance()->display();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
frame.window.setBorderWidth(theme()->borderWidth());
|
|
|
|
frame.window.setBorderColor(theme()->borderColor());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
Pixmap tmp = frame.pixmap;
|
2003-05-15 23:30:07 +00:00
|
|
|
FbTk::ImageControl &image_ctrl = screen().imageControl();
|
2003-04-25 10:46:07 +00:00
|
|
|
const FbTk::Texture &texture = m_slit_theme->texture();
|
2003-12-07 16:39:43 +00:00
|
|
|
if (!texture.usePixmap()) {
|
|
|
|
frame.pixmap = 0;
|
2003-01-12 17:56:15 +00:00
|
|
|
frame.window.setBackgroundColor(texture.color());
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-05-15 23:30:07 +00:00
|
|
|
frame.pixmap = image_ctrl.renderImage(frame.width, frame.height,
|
2003-06-20 01:27:28 +00:00
|
|
|
texture);
|
2003-05-13 13:28:28 +00:00
|
|
|
if (frame.pixmap == 0)
|
|
|
|
frame.window.setBackgroundColor(texture.color());
|
|
|
|
else
|
|
|
|
frame.window.setBackgroundPixmap(frame.pixmap);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
if (tmp)
|
2003-05-15 23:30:07 +00:00
|
|
|
image_ctrl.removeImage(tmp);
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2007-01-06 19:03:33 +00:00
|
|
|
// could have changed types, so we must set both
|
2004-09-12 14:56:20 +00:00
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
2007-01-06 19:03:33 +00:00
|
|
|
frame.window.setAlpha(255);
|
2004-09-12 14:56:20 +00:00
|
|
|
frame.window.setOpaque(*m_rc_alpha);
|
|
|
|
} else {
|
|
|
|
frame.window.setAlpha(*m_rc_alpha);
|
2007-01-06 19:03:33 +00:00
|
|
|
frame.window.setOpaque(255);
|
2004-09-12 14:56:20 +00:00
|
|
|
}
|
2006-04-21 16:20:56 +00:00
|
|
|
// reposition clears the bg
|
|
|
|
reposition();
|
|
|
|
|
|
|
|
// did we actually use slit slots
|
|
|
|
if (num_windows == 0)
|
2007-02-17 17:40:50 +00:00
|
|
|
hide();
|
2006-04-21 16:20:56 +00:00
|
|
|
else
|
2007-02-17 17:40:50 +00:00
|
|
|
show();
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
int x = 0, y = 0;
|
2008-08-06 00:11:55 +00:00
|
|
|
if (height_inc)
|
2003-04-25 10:46:07 +00:00
|
|
|
y = bevel_width;
|
2008-08-06 00:11:55 +00:00
|
|
|
else
|
2003-04-25 10:46:07 +00:00
|
|
|
x = bevel_width;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
client_it = m_client_list.begin();
|
|
|
|
for (; client_it != client_it_end; ++client_it) {
|
|
|
|
if ((*client_it)->window() == None)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//client created window?
|
2006-10-27 06:57:43 +00:00
|
|
|
if ((*client_it)->visible())
|
2003-06-20 01:27:28 +00:00
|
|
|
(*client_it)->show();
|
|
|
|
else {
|
|
|
|
(*client_it)->disableEvents();
|
|
|
|
(*client_it)->hide();
|
|
|
|
(*client_it)->enableEvents();
|
|
|
|
continue;
|
|
|
|
}
|
2003-06-22 12:31:37 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
if (height_inc)
|
|
|
|
x = (frame.width - (*client_it)->width()) / 2;
|
|
|
|
else
|
|
|
|
y = (frame.height - (*client_it)->height()) / 2;
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
XMoveResizeWindow(disp, (*client_it)->window(), x, y,
|
|
|
|
(*client_it)->width(), (*client_it)->height());
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
// for ICCCM compliance
|
|
|
|
(*client_it)->move(x, y);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
XEvent event;
|
|
|
|
event.type = ConfigureNotify;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
event.xconfigure.display = disp;
|
|
|
|
event.xconfigure.event = (*client_it)->window();
|
|
|
|
event.xconfigure.window = (*client_it)->window();
|
|
|
|
event.xconfigure.x = (*client_it)->x();
|
|
|
|
event.xconfigure.y = (*client_it)->y();
|
|
|
|
event.xconfigure.width = (*client_it)->width();
|
|
|
|
event.xconfigure.height = (*client_it)->height();
|
|
|
|
event.xconfigure.border_width = 0;
|
|
|
|
event.xconfigure.above = frame.window.window();
|
|
|
|
event.xconfigure.override_redirect = False;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
XSendEvent(disp, (*client_it)->window(), False, StructureNotifyMask,
|
|
|
|
&event);
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-06-20 01:27:28 +00:00
|
|
|
if (height_inc)
|
|
|
|
y += (*client_it)->height() + bevel_width;
|
|
|
|
else
|
|
|
|
x += (*client_it)->width() + bevel_width;
|
|
|
|
} // end for
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
if (doAutoHide() && !isHidden() && !m_timer.isTiming())
|
2003-05-11 17:42:51 +00:00
|
|
|
m_timer.start();
|
2003-12-20 19:10:49 +00:00
|
|
|
else if (!doAutoHide() && isHidden())
|
|
|
|
toggleHidden(); // restore visible
|
2003-05-01 15:03:36 +00:00
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
m_slitmenu.reconfigure();
|
2003-01-12 17:56:15 +00:00
|
|
|
updateClientmenu();
|
2003-06-18 13:55:17 +00:00
|
|
|
updateStrut();
|
2003-06-22 12:31:37 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-14 21:51:07 +00:00
|
|
|
void Slit::reposition() {
|
2002-12-01 13:42:15 +00:00
|
|
|
int head_x = 0,
|
|
|
|
head_y = 0,
|
|
|
|
head_w,
|
|
|
|
head_h;
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2003-05-19 14:26:30 +00:00
|
|
|
if (screen().hasXinerama()) {
|
2003-06-20 01:27:28 +00:00
|
|
|
int head = *m_rc_on_head;
|
2003-05-19 14:26:30 +00:00
|
|
|
head_x = screen().getHeadX(head);
|
|
|
|
head_y = screen().getHeadY(head);
|
|
|
|
head_w = screen().getHeadWidth(head);
|
|
|
|
head_h = screen().getHeadHeight(head);
|
2003-05-19 15:32:47 +00:00
|
|
|
} else {
|
2003-05-19 14:26:30 +00:00
|
|
|
head_w = screen().width();
|
|
|
|
head_h = screen().height();
|
|
|
|
}
|
|
|
|
|
2008-01-05 01:39:19 +00:00
|
|
|
int border_width = theme()->borderWidth();
|
2009-07-24 07:56:04 +00:00
|
|
|
int pixel = (border_width == 0 ? 1 : 0);
|
2002-12-01 13:42:15 +00:00
|
|
|
// place the slit in the appropriate place
|
2003-01-12 17:56:15 +00:00
|
|
|
switch (placement()) {
|
2002-12-01 13:42:15 +00:00
|
|
|
case TOPLEFT:
|
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.x_hidden = head_x;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.y_hidden = head_y + pixel - border_width - frame.height;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFTTOP:
|
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.x_hidden = head_x + pixel - border_width - frame.width;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.y_hidden = head_y;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
2004-06-07 11:46:05 +00:00
|
|
|
case LEFTCENTER:
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y + (head_h - frame.height) / 2;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.x_hidden = head_x + pixel - border_width - frame.width;
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.y_hidden = frame.y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOTTOMLEFT:
|
|
|
|
frame.x = head_x;
|
2007-04-20 20:26:57 +00:00
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.x_hidden = head_x;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.y_hidden = head_y + head_h - pixel - border_width;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFTBOTTOM:
|
|
|
|
frame.x = head_x;
|
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.x_hidden = head_x + pixel - border_width - frame.width;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOPCENTER:
|
|
|
|
frame.x = head_x + ((head_w - frame.width) / 2);
|
|
|
|
frame.y = head_y;
|
|
|
|
frame.x_hidden = frame.x;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.y_hidden = head_y + pixel - border_width - frame.height;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BOTTOMCENTER:
|
|
|
|
frame.x = head_x + ((head_w - frame.width) / 2);
|
2003-04-25 10:46:07 +00:00
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.y_hidden = head_y + head_h - pixel - border_width;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TOPRIGHT:
|
2003-04-25 10:46:07 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.y = head_y;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.y_hidden = head_y + pixel - border_width - frame.height;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RIGHTTOP:
|
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
|
|
|
frame.y = head_y;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.x_hidden = head_x + head_w - pixel - border_width;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.y_hidden = head_y;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
|
2004-06-07 11:46:05 +00:00
|
|
|
case RIGHTCENTER:
|
2003-04-25 10:46:07 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.y = head_y + ((head_h - frame.height) / 2);
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.x_hidden = head_x + head_w - pixel - border_width;
|
2002-12-01 13:42:15 +00:00
|
|
|
frame.y_hidden = frame.y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOTTOMRIGHT:
|
2003-04-25 10:46:07 +00:00
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.x_hidden = frame.x;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.y_hidden = head_y + head_h - pixel - border_width;
|
2008-08-06 00:11:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RIGHTBOTTOM:
|
|
|
|
default:
|
|
|
|
frame.x = head_x + head_w - frame.width - border_width*2;
|
|
|
|
frame.y = head_y + head_h - frame.height - border_width*2;
|
2009-07-24 07:56:04 +00:00
|
|
|
frame.x_hidden = head_x + head_w - pixel - border_width;
|
2008-08-06 00:11:55 +00:00
|
|
|
frame.y_hidden = frame.y;
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
if (isHidden()) {
|
2003-05-13 13:28:28 +00:00
|
|
|
frame.window.moveResize(frame.x_hidden, frame.y_hidden,
|
|
|
|
frame.width, frame.height);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2003-05-13 13:28:28 +00:00
|
|
|
frame.window.moveResize(frame.x, frame.y,
|
|
|
|
frame.width, frame.height);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2006-04-21 16:23:24 +00:00
|
|
|
frame.window.updateBackground(true);
|
2006-04-21 16:20:56 +00:00
|
|
|
if (*m_rc_alpha != 255)
|
|
|
|
clearWindow();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-14 21:51:07 +00:00
|
|
|
void Slit::shutdown() {
|
2002-12-01 13:42:15 +00:00
|
|
|
saveClientList();
|
2003-05-11 17:42:51 +00:00
|
|
|
while (!m_client_list.empty())
|
|
|
|
removeClient(m_client_list.front(), true, true);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2004-12-02 03:12:55 +00:00
|
|
|
void Slit::clientUp(SlitClient* client) {
|
|
|
|
if (!client || m_client_list.size() < 2)
|
|
|
|
return;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-12-06 22:09:58 +00:00
|
|
|
if (client == m_client_list.front()) {
|
|
|
|
cycleClientsUp();
|
|
|
|
return;
|
|
|
|
}
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-12-02 03:12:55 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
2011-11-02 17:33:38 +00:00
|
|
|
for(++it; it != m_client_list.end(); ++it) {
|
2004-12-02 03:12:55 +00:00
|
|
|
if ((*it) == client) {
|
2004-12-06 22:09:58 +00:00
|
|
|
SlitClients::iterator prev = it;
|
|
|
|
prev--;
|
|
|
|
iter_swap(it, prev);
|
2004-12-02 03:12:55 +00:00
|
|
|
reconfigure();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slit::clientDown(SlitClient* client) {
|
|
|
|
if (!client || m_client_list.size() < 2)
|
|
|
|
return;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-12-06 22:09:58 +00:00
|
|
|
if (client == m_client_list.back()) {
|
|
|
|
cycleClientsDown();
|
|
|
|
return;
|
|
|
|
}
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-12-02 03:12:55 +00:00
|
|
|
SlitClients::reverse_iterator it = m_client_list.rbegin();
|
2011-11-02 17:33:38 +00:00
|
|
|
for(++it; it != m_client_list.rend(); ++it) {
|
2004-12-02 03:12:55 +00:00
|
|
|
if ((*it) == client) {
|
2004-12-06 22:09:58 +00:00
|
|
|
SlitClients::reverse_iterator next = it;
|
|
|
|
next--;
|
|
|
|
iter_swap(it, next);
|
2004-12-02 03:12:55 +00:00
|
|
|
reconfigure();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::cycleClientsUp() {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (m_client_list.size() < 2)
|
2003-01-12 23:52:37 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// rotate client list up, ie the first goes last
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
2003-01-12 17:56:15 +00:00
|
|
|
SlitClient *client = *it;
|
2003-05-11 17:42:51 +00:00
|
|
|
m_client_list.erase(it);
|
|
|
|
m_client_list.push_back(client);
|
2003-01-12 17:56:15 +00:00
|
|
|
reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slit::cycleClientsDown() {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (m_client_list.size() < 2)
|
2003-01-12 23:52:37 +00:00
|
|
|
return;
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// rotate client list down, ie the last goes first
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClient *client = m_client_list.back();
|
|
|
|
m_client_list.remove(client);
|
|
|
|
m_client_list.push_front(client);
|
2003-01-12 17:56:15 +00:00
|
|
|
reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Slit::handleEvent(XEvent &event) {
|
2003-02-20 16:41:22 +00:00
|
|
|
if (event.type == ConfigureRequest) {
|
|
|
|
configureRequestEvent(event.xconfigurerequest);
|
|
|
|
} else if (event.type == DestroyNotify) {
|
2003-01-12 17:56:15 +00:00
|
|
|
removeClient(event.xdestroywindow.window, false);
|
2003-11-01 00:12:53 +00:00
|
|
|
} else if (event.type == UnmapNotify && event.xany.send_event) {
|
|
|
|
// we ignore server-generated events, which can occur
|
|
|
|
// on restart. The ICCCM says that a client must send
|
|
|
|
// a synthetic event for the withdrawn state
|
2003-08-15 13:50:42 +00:00
|
|
|
removeClient(event.xunmap.window);
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-03 20:30:21 +00:00
|
|
|
void Slit::buttonPressEvent(XButtonEvent &be) {
|
|
|
|
if (be.window != frame.window.window())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
|
2007-06-03 20:30:21 +00:00
|
|
|
if (be.button == Button3) {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (! m_slitmenu.isVisible()) {
|
2011-02-24 10:21:16 +00:00
|
|
|
screen().placementStrategy()
|
|
|
|
.placeAndShowMenu(m_slitmenu, be.x_root, be.y_root, false);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else
|
2003-05-11 17:42:51 +00:00
|
|
|
m_slitmenu.hide();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::enterNotifyEvent(XCrossingEvent &) {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (! doAutoHide())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
if (isHidden()) {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (! m_timer.isTiming())
|
2003-05-11 17:42:51 +00:00
|
|
|
m_timer.start();
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_timer.isTiming())
|
2003-05-11 17:42:51 +00:00
|
|
|
m_timer.stop();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::leaveNotifyEvent(XCrossingEvent &ev) {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (! doAutoHide())
|
2002-12-01 13:42:15 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
if (isHidden()) {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_timer.isTiming())
|
2003-05-11 17:42:51 +00:00
|
|
|
m_timer.stop();
|
2003-05-01 15:03:36 +00:00
|
|
|
} else {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (! m_timer.isTiming()) {
|
2003-05-01 15:35:24 +00:00
|
|
|
// the menu is open, keep it firing until it closes
|
2006-10-27 06:57:43 +00:00
|
|
|
if (m_slitmenu.isVisible())
|
2003-05-11 17:42:51 +00:00
|
|
|
m_timer.fireOnce(false);
|
|
|
|
m_timer.start();
|
2003-05-01 15:35:24 +00:00
|
|
|
}
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-11-14 00:23:19 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::configureRequestEvent(XConfigureRequestEvent &event) {
|
2002-12-01 13:42:15 +00:00
|
|
|
bool reconf = false;
|
|
|
|
XWindowChanges xwc;
|
2002-11-14 00:23:19 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
xwc.x = event.x;
|
|
|
|
xwc.y = event.y;
|
|
|
|
xwc.width = event.width;
|
|
|
|
xwc.height = event.height;
|
2002-12-01 13:42:15 +00:00
|
|
|
xwc.border_width = 0;
|
2003-01-12 17:56:15 +00:00
|
|
|
xwc.sibling = event.above;
|
|
|
|
xwc.stack_mode = event.detail;
|
2002-11-14 00:23:19 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
XConfigureWindow(FbTk::App::instance()->display(),
|
2003-01-12 17:56:15 +00:00
|
|
|
event.window, event.value_mask, &xwc);
|
2002-11-14 00:23:19 +00:00
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
|
|
|
SlitClients::iterator it_end = m_client_list.end();
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2003-06-20 01:27:28 +00:00
|
|
|
if ((*it)->window() == event.window) {
|
|
|
|
if ((*it)->width() != ((unsigned) event.width) ||
|
|
|
|
(*it)->height() != ((unsigned) event.height)) {
|
2008-08-14 05:53:38 +00:00
|
|
|
(*it)->resize(event.width, event.height);
|
2002-11-14 00:23:19 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
reconf = true; //requires reconfiguration
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
if (reconf)
|
2002-12-01 13:42:15 +00:00
|
|
|
reconfigure();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-05-13 13:28:28 +00:00
|
|
|
void Slit::exposeEvent(XExposeEvent &ev) {
|
2006-10-27 06:57:43 +00:00
|
|
|
// we don't need to clear the entire window
|
2003-06-24 13:48:34 +00:00
|
|
|
// just the are that gets exposed
|
|
|
|
frame.window.clearArea(ev.x, ev.y, ev.width, ev.height);
|
2003-05-13 21:12:18 +00:00
|
|
|
}
|
|
|
|
|
2008-09-28 16:13:30 +00:00
|
|
|
void Slit::screenSizeChanged(BScreen &screen) {
|
2003-08-29 10:30:46 +00:00
|
|
|
reconfigure();
|
2007-08-05 22:36:12 +00:00
|
|
|
#ifdef XINERAMA
|
2008-09-28 16:13:30 +00:00
|
|
|
if (m_xineramaheadmenu)
|
2007-08-05 22:36:12 +00:00
|
|
|
m_xineramaheadmenu->reloadHeads();
|
|
|
|
#endif // XINERAMA
|
2003-08-29 10:30:46 +00:00
|
|
|
}
|
|
|
|
|
2003-05-13 21:12:18 +00:00
|
|
|
void Slit::clearWindow() {
|
2003-05-07 22:53:21 +00:00
|
|
|
frame.window.clear();
|
|
|
|
}
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-08-11 16:05:18 +00:00
|
|
|
void Slit::toggleHidden() {
|
2003-05-11 17:42:51 +00:00
|
|
|
if (doAutoHide()) {
|
|
|
|
if (!m_slitmenu.isVisible()) {
|
|
|
|
m_timer.fireOnce(true);
|
2006-10-27 06:57:43 +00:00
|
|
|
} else
|
2003-05-01 15:35:24 +00:00
|
|
|
return;
|
2006-10-27 06:57:43 +00:00
|
|
|
} else
|
2003-05-11 17:42:51 +00:00
|
|
|
if (!isHidden()) return;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
m_hidden = ! m_hidden; // toggle hidden state
|
|
|
|
if (isHidden())
|
2003-01-12 17:56:15 +00:00
|
|
|
frame.window.move(frame.x_hidden, frame.y_hidden);
|
2002-12-01 13:42:15 +00:00
|
|
|
else
|
2003-01-12 17:56:15 +00:00
|
|
|
frame.window.move(frame.x, frame.y);
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::loadClientList(const char *filename) {
|
2004-01-30 11:06:25 +00:00
|
|
|
if (filename == 0 || filename[0] == '\0')
|
2003-01-12 17:56:15 +00:00
|
|
|
return;
|
|
|
|
|
2004-01-30 11:06:25 +00:00
|
|
|
// save filename so we can save client list later
|
2004-02-20 09:29:07 +00:00
|
|
|
m_filename = filename;
|
2006-10-27 06:57:43 +00:00
|
|
|
string real_filename= FbTk::StringUtil::expandFilename(filename);
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
struct stat buf;
|
2004-02-20 09:29:07 +00:00
|
|
|
if (stat(real_filename.c_str(), &buf) == 0) {
|
2006-10-27 06:57:43 +00:00
|
|
|
ifstream file(real_filename.c_str());
|
|
|
|
string name;
|
2002-12-01 13:42:15 +00:00
|
|
|
while (! file.eof()) {
|
|
|
|
name = "";
|
2006-10-27 06:57:43 +00:00
|
|
|
getline(file, name); // get the entire line
|
2004-02-06 12:09:14 +00:00
|
|
|
if (name.empty())
|
2004-01-30 11:06:25 +00:00
|
|
|
continue;
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2004-01-30 11:06:25 +00:00
|
|
|
// remove whitespaces from start and end
|
|
|
|
FbTk::StringUtil::removeFirstWhitespace(name);
|
|
|
|
|
|
|
|
// the cleaned string could still be a comment, or blank
|
2004-02-06 12:09:14 +00:00
|
|
|
if ( name.empty() || name[0] == '#' || name[0] == '!' )
|
2004-01-30 11:06:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// trailing whitespace won't affect the above test
|
|
|
|
FbTk::StringUtil::removeTrailingWhitespace(name);
|
|
|
|
|
|
|
|
SlitClient *client = new SlitClient(name.c_str());
|
|
|
|
m_client_list.push_back(client);
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-29 06:21:59 +00:00
|
|
|
}
|
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
void Slit::updateClientmenu() {
|
2006-10-27 06:57:43 +00:00
|
|
|
if (screen().isShuttingdown())
|
2004-01-10 02:58:21 +00:00
|
|
|
return;
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2004-01-10 02:58:21 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// clear old items
|
2003-05-11 17:42:51 +00:00
|
|
|
m_clientlist_menu.removeAll();
|
2006-06-21 14:41:16 +00:00
|
|
|
m_clientlist_menu.setLabel(_FB_XTEXT(Slit, ClientsMenu, "Clients", "Slit client menu"));
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2008-01-11 07:41:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command<void> > cycle_up(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsUp));
|
|
|
|
FbTk::RefCount<FbTk::Command<void> > cycle_down(new FbTk::SimpleCommand<Slit>(*this, &Slit::cycleClientsDown));
|
2006-06-21 14:41:16 +00:00
|
|
|
m_clientlist_menu.insert(_FB_XTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up);
|
|
|
|
m_clientlist_menu.insert(_FB_XTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down);
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2004-12-02 03:12:55 +00:00
|
|
|
m_clientlist_menu.insert(new FbTk::MenuSeparator());
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2008-01-11 07:41:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command<void> > reconfig(new FbTk::SimpleCommand<Slit>(*this, &Slit::reconfigure));
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
|
|
|
for (; it != m_client_list.end(); ++it) {
|
2003-06-20 01:27:28 +00:00
|
|
|
if ((*it) != 0 && (*it)->window() != 0)
|
2004-12-02 03:12:55 +00:00
|
|
|
m_clientlist_menu.insert(new SlitClientMenuItem(*this, *(*it), reconfig));
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
|
|
|
|
2004-12-02 03:12:55 +00:00
|
|
|
m_clientlist_menu.insert(new FbTk::MenuSeparator());
|
2008-01-11 07:41:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command<void> > savecmd(new FbTk::SimpleCommand<Slit>(*this, &Slit::saveClientList));
|
2006-10-27 06:57:43 +00:00
|
|
|
m_clientlist_menu.insert(_FB_XTEXT(Slit,
|
2004-12-02 03:12:55 +00:00
|
|
|
SaveSlitList,
|
2006-10-27 06:57:43 +00:00
|
|
|
"Save SlitList", "Saves the current order in the slit"),
|
2004-12-02 03:12:55 +00:00
|
|
|
savecmd);
|
|
|
|
|
2004-12-13 14:03:17 +00:00
|
|
|
m_clientlist_menu.updateMenu();
|
2003-01-12 17:56:15 +00:00
|
|
|
}
|
|
|
|
|
2002-11-14 00:23:19 +00:00
|
|
|
void Slit::saveClientList() {
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2006-10-27 06:57:43 +00:00
|
|
|
ofstream file(FbTk::StringUtil::expandFilename(m_filename).c_str());
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients::iterator it = m_client_list.begin();
|
|
|
|
SlitClients::iterator it_end = m_client_list.end();
|
2006-10-27 06:57:43 +00:00
|
|
|
string prevName;
|
|
|
|
string name;
|
2002-12-01 13:42:15 +00:00
|
|
|
for (; it != it_end; ++it) {
|
2010-09-08 18:17:21 +00:00
|
|
|
name = (*it)->matchName().logical();
|
2002-12-01 13:42:15 +00:00
|
|
|
if (name != prevName)
|
2006-10-27 06:57:43 +00:00
|
|
|
file << name.c_str() << endl;
|
2002-12-01 13:42:15 +00:00
|
|
|
|
|
|
|
prevName = name;
|
|
|
|
}
|
2002-05-29 06:21:59 +00:00
|
|
|
}
|
2003-01-12 17:56:15 +00:00
|
|
|
|
|
|
|
void Slit::setupMenu() {
|
2004-06-07 11:46:05 +00:00
|
|
|
_FB_USES_NLS;
|
2003-01-12 17:56:15 +00:00
|
|
|
using namespace FbTk;
|
|
|
|
|
2003-04-16 16:18:06 +00:00
|
|
|
FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
|
2003-05-13 21:12:18 +00:00
|
|
|
FbTk::MacroCommand *s_a_reconf_slit_macro = new FbTk::MacroCommand();
|
2008-01-11 07:41:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command<void> > saverc_cmd(new FbCommands::SaveResources());
|
|
|
|
FbTk::RefCount<FbTk::Command<void> > reconf_cmd(new FbCommands::ReconfigureFluxboxCmd());
|
|
|
|
FbTk::RefCount<FbTk::Command<void> > reconf_slit_cmd(new FbTk::SimpleCommand<Slit>(*this, &Slit::reconfigure));
|
2003-05-13 21:12:18 +00:00
|
|
|
|
2003-04-16 16:18:06 +00:00
|
|
|
s_a_reconf_macro->add(saverc_cmd);
|
|
|
|
s_a_reconf_macro->add(reconf_cmd);
|
2003-05-13 21:12:18 +00:00
|
|
|
|
|
|
|
s_a_reconf_slit_macro->add(saverc_cmd);
|
|
|
|
s_a_reconf_slit_macro->add(reconf_slit_cmd);
|
|
|
|
|
2008-01-11 07:41:22 +00:00
|
|
|
FbTk::RefCount<FbTk::Command<void> > save_and_reconfigure(s_a_reconf_macro);
|
|
|
|
FbTk::RefCount<FbTk::Command<void> > save_and_reconfigure_slit(s_a_reconf_slit_macro);
|
2003-04-16 16:18:06 +00:00
|
|
|
|
2006-04-22 16:38:20 +00:00
|
|
|
|
|
|
|
// it'll be freed by the slitmenu (since not marked internal)
|
|
|
|
FbMenu *placement_menu = new FbMenu(m_screen.menuTheme(),
|
|
|
|
m_screen.imageControl(),
|
2011-03-23 11:02:15 +00:00
|
|
|
*m_screen.layerManager().getLayer(::ResourceLayer::MENU));
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2006-04-22 16:38:20 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// setup base menu
|
2006-06-21 14:41:16 +00:00
|
|
|
m_slitmenu.setLabel(_FB_XTEXT(Slit, Slit, "Slit", "The Slit"));
|
|
|
|
m_slitmenu.insert(_FB_XTEXT(Menu, Placement, "Placement", "Title of Placement menu"),
|
2006-04-22 16:38:20 +00:00
|
|
|
placement_menu);
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
m_slitmenu.insert(_FB_XTEXT(Menu, Layer, "Layer...", "Title of Layer menu"), m_layermenu.get());
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2003-05-19 14:26:30 +00:00
|
|
|
#ifdef XINERAMA
|
|
|
|
if (screen().hasXinerama()) {
|
2006-06-21 14:41:16 +00:00
|
|
|
m_slitmenu.insert(_FB_XTEXT(Menu, OnHead, "On Head...", "Title of On Head menu"),
|
2007-08-05 22:36:12 +00:00
|
|
|
m_xineramaheadmenu =
|
2004-06-07 11:46:05 +00:00
|
|
|
new XineramaHeadMenu<Slit>(
|
|
|
|
screen().menuTheme(),
|
|
|
|
screen(),
|
|
|
|
screen().imageControl(),
|
2011-03-23 11:02:15 +00:00
|
|
|
*screen().layerManager().getLayer(::ResourceLayer::MENU),
|
2004-06-07 11:46:05 +00:00
|
|
|
*this,
|
2006-06-21 14:41:16 +00:00
|
|
|
_FB_XTEXT(Slit, OnHead, "Slit on Head", "Title of Slits On Head menu")
|
2004-06-07 11:46:05 +00:00
|
|
|
));
|
2003-05-19 14:26:30 +00:00
|
|
|
}
|
|
|
|
#endif //XINERAMA
|
2006-02-27 22:43:42 +00:00
|
|
|
|
2007-12-27 21:55:24 +00:00
|
|
|
m_slitmenu.insert(new FbTk::BoolMenuItem(_FB_XTEXT(Common, AutoHide, "Auto hide", "This thing automatically hides when not close by"),
|
|
|
|
m_rc_auto_hide,
|
2003-05-13 21:12:18 +00:00
|
|
|
save_and_reconfigure_slit));
|
|
|
|
|
2007-12-27 21:55:24 +00:00
|
|
|
m_slitmenu.insert(new FbTk::BoolMenuItem(_FB_XTEXT(Common, MaximizeOver,"Maximize Over", "Maximize over this thing when maximizing"),
|
|
|
|
m_rc_maximize_over,
|
2003-06-22 12:31:37 +00:00
|
|
|
save_and_reconfigure_slit));
|
|
|
|
|
2003-06-24 13:48:34 +00:00
|
|
|
// this saves resources and clears the slit window to update alpha value
|
2006-10-27 06:57:43 +00:00
|
|
|
FbTk::MenuItem *alpha_menuitem =
|
2007-12-27 21:55:24 +00:00
|
|
|
new FbTk::IntMenuItem(_FB_XTEXT(Common, Alpha, "Alpha", "Transparency level"),
|
2004-06-07 11:46:05 +00:00
|
|
|
m_rc_alpha,
|
2005-05-03 13:53:25 +00:00
|
|
|
0, 255, m_slitmenu);
|
2003-06-24 20:19:36 +00:00
|
|
|
// setup command for alpha value
|
2006-10-27 06:57:43 +00:00
|
|
|
MacroCommand *alpha_macrocmd = new MacroCommand();
|
2008-01-11 07:41:22 +00:00
|
|
|
RefCount<Command<void> > alpha_cmd(new SimpleCommand<Slit>(*this, &Slit::updateAlpha));
|
2003-06-24 20:19:36 +00:00
|
|
|
alpha_macrocmd->add(saverc_cmd);
|
2004-09-12 14:56:20 +00:00
|
|
|
alpha_macrocmd->add(alpha_cmd);
|
2008-01-11 07:41:22 +00:00
|
|
|
RefCount<Command<void> > set_alpha_cmd(alpha_macrocmd);
|
2003-06-24 13:48:34 +00:00
|
|
|
alpha_menuitem->setCommand(set_alpha_cmd);
|
2003-06-24 20:19:36 +00:00
|
|
|
|
2003-05-13 21:12:18 +00:00
|
|
|
m_slitmenu.insert(alpha_menuitem);
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2006-06-21 14:41:16 +00:00
|
|
|
m_slitmenu.insert(_FB_XTEXT(Slit, ClientsMenu, "Clients", "Slit client menu"), &m_clientlist_menu);
|
2004-12-13 14:03:17 +00:00
|
|
|
m_slitmenu.updateMenu();
|
2003-01-12 17:56:15 +00:00
|
|
|
|
|
|
|
// setup sub menu
|
2006-06-21 14:41:16 +00:00
|
|
|
placement_menu->setLabel(_FB_XTEXT(Slit, Placement, "Slit Placement", "Slit Placement"));
|
2011-01-15 20:31:37 +00:00
|
|
|
placement_menu->setMinimumColumns(3);
|
2003-05-24 13:13:22 +00:00
|
|
|
m_layermenu->setInternalMenu();
|
|
|
|
m_clientlist_menu.setInternalMenu();
|
2006-04-22 16:38:20 +00:00
|
|
|
m_slitmenu.setInternalMenu();
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2006-05-20 15:08:14 +00:00
|
|
|
typedef pair<FbTk::FbString, Slit::Placement> PlacementP;
|
2004-08-31 19:27:21 +00:00
|
|
|
typedef list<PlacementP> Placements;
|
2004-06-07 11:46:05 +00:00
|
|
|
Placements place_menu;
|
|
|
|
|
|
|
|
// menu is 3 wide, 5 down
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopLeft, "Top Left", "Top Left"), Slit::TOPLEFT));
|
2008-08-06 00:11:55 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftTop, "Left Top", "Left Top"), Slit::LEFTTOP));
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftCenter, "Left Center", "Left Center"), Slit::LEFTCENTER));
|
2008-08-06 00:11:55 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, LeftBottom, "Left Bottom", "Left Bottom"), Slit::LEFTBOTTOM));
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomLeft, "Bottom Left", "Bottom Left"), Slit::BOTTOMLEFT));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopCenter, "Top Center", "Top Center"), Slit::TOPCENTER));
|
2006-05-20 15:08:14 +00:00
|
|
|
place_menu.push_back(PlacementP("", Slit::TOPLEFT));
|
2008-08-06 00:11:55 +00:00
|
|
|
place_menu.push_back(PlacementP("", Slit::TOPLEFT));
|
|
|
|
place_menu.push_back(PlacementP("", Slit::TOPLEFT));
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomCenter, "Bottom Center", "Bottom Center"), Slit::BOTTOMCENTER));
|
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, TopRight, "Top Right", "Top Right"), Slit::TOPRIGHT));
|
2008-08-06 00:11:55 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightTop, "Right Top", "Right Top"), Slit::RIGHTTOP));
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightCenter, "Right Center", "Right Center"), Slit::RIGHTCENTER));
|
2008-08-06 00:11:55 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, RightBottom, "Right Bottom", "Right Bottom"), Slit::RIGHTBOTTOM));
|
2006-06-21 14:41:16 +00:00
|
|
|
place_menu.push_back(PlacementP(_FB_XTEXT(Align, BottomRight, "Bottom Right", "Bottom Right"), Slit::BOTTOMRIGHT));
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
|
|
|
|
// create items in sub menu
|
2008-08-06 00:11:55 +00:00
|
|
|
for (size_t i=0; i<15; ++i) {
|
2006-05-20 15:08:14 +00:00
|
|
|
const FbTk::FbString &str = place_menu.front().first;
|
2004-06-07 11:46:05 +00:00
|
|
|
Slit::Placement placement = place_menu.front().second;
|
|
|
|
|
2006-05-20 15:08:14 +00:00
|
|
|
if (str == "") {
|
2006-04-22 16:38:20 +00:00
|
|
|
placement_menu->insert("");
|
|
|
|
placement_menu->setItemEnabled(i, false);
|
2002-12-01 13:42:15 +00:00
|
|
|
} else {
|
2006-04-22 16:38:20 +00:00
|
|
|
placement_menu->insert(new PlaceSlitMenuItem(str, *this,
|
2006-10-27 06:57:43 +00:00
|
|
|
placement,
|
2003-06-24 13:48:34 +00:00
|
|
|
save_and_reconfigure));
|
2006-10-27 06:57:43 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2004-06-07 11:46:05 +00:00
|
|
|
place_menu.pop_front();
|
2002-12-01 13:42:15 +00:00
|
|
|
}
|
2004-06-07 11:46:05 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// finaly update sub menu
|
2006-04-22 16:38:20 +00:00
|
|
|
placement_menu->updateMenu();
|
2001-12-11 20:47:02 +00:00
|
|
|
}
|
2003-04-16 16:18:06 +00:00
|
|
|
|
|
|
|
void Slit::moveToLayer(int layernum) {
|
|
|
|
m_layeritem->moveToLayer(layernum);
|
2003-07-06 07:09:53 +00:00
|
|
|
*m_rc_layernum = layernum;
|
2003-04-16 16:18:06 +00:00
|
|
|
}
|
2003-07-19 11:55:49 +00:00
|
|
|
|
|
|
|
void Slit::saveOnHead(int head) {
|
|
|
|
m_rc_on_head = head;
|
|
|
|
// reposition
|
|
|
|
reconfigure();
|
|
|
|
}
|
|
|
|
|
2004-09-12 14:56:20 +00:00
|
|
|
void Slit::updateAlpha() {
|
|
|
|
// called when the alpha resource is changed
|
|
|
|
if (FbTk::Transparent::haveComposite()) {
|
|
|
|
frame.window.setOpaque(*m_rc_alpha);
|
|
|
|
} else {
|
|
|
|
frame.window.setAlpha(*m_rc_alpha);
|
2006-04-21 16:23:24 +00:00
|
|
|
frame.window.updateBackground(true);
|
2004-09-12 14:56:20 +00:00
|
|
|
clearWindow();
|
|
|
|
}
|
|
|
|
}
|