2002-03-19 00:07:00 +00:00
|
|
|
// Slit.hh for Fluxbox
|
2006-02-16 06:53:05 +00:00
|
|
|
// Copyright (c) 2002 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
|
2002-03-19 00:07:00 +00:00
|
|
|
//
|
2001-12-11 20:47:02 +00:00
|
|
|
// Slit.hh for Blackbox - an X11 Window manager
|
2003-01-05 23:42:27 +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,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
2002-03-19 00:07:00 +00:00
|
|
|
|
2004-11-19 11:37:27 +00:00
|
|
|
/// $Id$
|
2003-01-05 23:42:27 +00:00
|
|
|
|
2002-03-19 00:07:00 +00:00
|
|
|
#ifndef SLIT_HH
|
|
|
|
#define SLIT_HH
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
|
2003-02-18 15:11:12 +00:00
|
|
|
#include "LayerMenu.hh"
|
2006-02-20 21:04:35 +00:00
|
|
|
#include "Layer.hh"
|
2005-06-23 03:07:25 +00:00
|
|
|
|
|
|
|
#include "FbTk/Menu.hh"
|
|
|
|
#include "FbTk/FbWindow.hh"
|
|
|
|
#include "FbTk/Timer.hh"
|
|
|
|
#include "FbTk/Resource.hh"
|
|
|
|
#include "FbTk/XLayerItem.hh"
|
2002-11-14 00:15:10 +00:00
|
|
|
|
2001-12-11 20:47:02 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
2002-02-04 22:33:09 +00:00
|
|
|
#include <list>
|
2002-05-29 06:21:59 +00:00
|
|
|
#include <string>
|
2002-11-14 00:15:10 +00:00
|
|
|
#include <memory>
|
2003-02-20 16:38:17 +00:00
|
|
|
|
2003-04-25 10:45:02 +00:00
|
|
|
class SlitTheme;
|
2003-01-12 17:56:15 +00:00
|
|
|
class SlitClient;
|
2003-04-16 16:18:06 +00:00
|
|
|
class BScreen;
|
2003-05-06 01:45:17 +00:00
|
|
|
class FbMenu;
|
2003-06-18 13:55:17 +00:00
|
|
|
class Strut;
|
2006-02-20 21:04:35 +00:00
|
|
|
class Layer;
|
2001-12-11 20:47:02 +00:00
|
|
|
|
2003-01-05 23:42:27 +00:00
|
|
|
/// Handles dock apps
|
2005-06-23 03:07:25 +00:00
|
|
|
class Slit: public FbTk::EventHandler, public FbTk::Observer, public LayerObject {
|
2001-12-11 20:47:02 +00:00
|
|
|
public:
|
2004-04-19 22:42:26 +00:00
|
|
|
typedef std::list<SlitClient *> SlitClients;
|
2003-01-12 17:56:15 +00:00
|
|
|
/**
|
|
|
|
Client alignment
|
|
|
|
*/
|
|
|
|
enum Direction { VERTICAL = 1, HORIZONTAL };
|
|
|
|
/**
|
2003-04-25 16:55:39 +00:00
|
|
|
Placement on screen
|
2003-01-12 17:56:15 +00:00
|
|
|
*/
|
2004-06-07 11:46:05 +00:00
|
|
|
enum Placement { TOPLEFT = 1, LEFTCENTER, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER,
|
|
|
|
TOPRIGHT, RIGHTCENTER, BOTTOMRIGHT };
|
2003-06-20 01:26:16 +00:00
|
|
|
|
2003-04-25 16:55:39 +00:00
|
|
|
Slit(BScreen &screen, FbTk::XLayer &layer, const char *filename = 0);
|
2002-12-01 13:42:15 +00:00
|
|
|
virtual ~Slit();
|
|
|
|
|
2007-02-17 17:40:50 +00:00
|
|
|
void show() { frame.window.show(); m_visible = true; }
|
|
|
|
void hide() { frame.window.hide(); m_visible = false; }
|
2003-01-12 17:56:15 +00:00
|
|
|
void setDirection(Direction dir);
|
|
|
|
void setPlacement(Placement place);
|
2002-12-01 13:42:15 +00:00
|
|
|
void addClient(Window clientwin);
|
2003-04-25 16:55:39 +00:00
|
|
|
void removeClient(Window clientwin, bool remap = true);
|
2002-12-01 13:42:15 +00:00
|
|
|
void reconfigure();
|
|
|
|
void reposition();
|
|
|
|
void shutdown();
|
2003-01-12 17:56:15 +00:00
|
|
|
/// save clients name in a file
|
2002-12-01 13:42:15 +00:00
|
|
|
void saveClientList();
|
2004-12-02 03:12:55 +00:00
|
|
|
/// move client one position up
|
|
|
|
void clientUp(SlitClient*);
|
|
|
|
/// move client one position down
|
|
|
|
void clientDown(SlitClient*);
|
2003-01-12 17:56:15 +00:00
|
|
|
/// cycle slit clients up one step
|
|
|
|
void cycleClientsUp();
|
|
|
|
/// cycle slit clients down one step
|
|
|
|
void cycleClientsDown();
|
2002-12-01 13:42:15 +00:00
|
|
|
/**
|
|
|
|
@name eventhandlers
|
|
|
|
*/
|
|
|
|
//@{
|
2003-01-12 17:56:15 +00:00
|
|
|
void handleEvent(XEvent &event);
|
|
|
|
void buttonPressEvent(XButtonEvent &event);
|
|
|
|
void enterNotifyEvent(XCrossingEvent &event);
|
|
|
|
void leaveNotifyEvent(XCrossingEvent &event);
|
|
|
|
void configureRequestEvent(XConfigureRequestEvent &event);
|
2003-05-07 22:53:21 +00:00
|
|
|
void exposeEvent(XExposeEvent &event);
|
2002-12-01 13:42:15 +00:00
|
|
|
//@}
|
2003-08-29 10:30:46 +00:00
|
|
|
|
|
|
|
void update(FbTk::Subject *subj);
|
2002-08-04 15:55:13 +00:00
|
|
|
|
2003-04-16 16:18:06 +00:00
|
|
|
void moveToLayer(int layernum);
|
2003-08-11 16:02:38 +00:00
|
|
|
void toggleHidden();
|
|
|
|
|
|
|
|
BScreen &screen() { return m_screen; }
|
|
|
|
const BScreen &screen() const { return m_screen; }
|
|
|
|
SlitTheme &theme() { return *m_slit_theme.get(); }
|
|
|
|
const SlitTheme &theme() const { return *m_slit_theme.get(); }
|
|
|
|
|
2005-06-23 03:07:25 +00:00
|
|
|
int layerNumber() const { return m_layeritem->getLayerNum(); }
|
|
|
|
|
2003-08-11 16:02:38 +00:00
|
|
|
inline bool isHidden() const { return m_hidden; }
|
|
|
|
inline bool doAutoHide() const { return *m_rc_auto_hide; }
|
|
|
|
inline Direction direction() const { return *m_rc_direction; }
|
|
|
|
inline Placement placement() const { return *m_rc_placement; }
|
|
|
|
inline int getOnHead() const { return *m_rc_on_head; }
|
|
|
|
void saveOnHead(int head);
|
|
|
|
FbTk::Menu &menu() { return m_slitmenu; }
|
|
|
|
|
|
|
|
inline const FbTk::FbWindow &window() const { return frame.window; }
|
2003-02-18 15:11:12 +00:00
|
|
|
|
2003-08-11 16:02:38 +00:00
|
|
|
inline int x() const { return (m_hidden ? frame.x_hidden : frame.x); }
|
|
|
|
inline int y() const { return (m_hidden ? frame.y_hidden : frame.y); }
|
2002-12-01 13:42:15 +00:00
|
|
|
|
2003-08-11 16:02:38 +00:00
|
|
|
inline unsigned int width() const { return frame.width; }
|
|
|
|
inline unsigned int height() const { return frame.height; }
|
2004-04-19 22:42:26 +00:00
|
|
|
const SlitClients &clients() const { return m_client_list; }
|
|
|
|
SlitClients &clients() { return m_client_list; }
|
2002-03-19 00:07:00 +00:00
|
|
|
private:
|
2004-09-12 14:56:20 +00:00
|
|
|
void updateAlpha();
|
2003-05-13 21:12:18 +00:00
|
|
|
void clearWindow();
|
2003-01-12 17:56:15 +00:00
|
|
|
void setupMenu();
|
2002-03-19 00:07:00 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
void removeClient(SlitClient *client, bool remap, bool destroy);
|
2003-01-12 17:56:15 +00:00
|
|
|
void loadClientList(const char *filename);
|
|
|
|
void updateClientmenu();
|
2003-06-18 13:55:17 +00:00
|
|
|
void clearStrut();
|
|
|
|
void updateStrut();
|
2003-01-12 17:56:15 +00:00
|
|
|
|
2007-02-17 17:40:50 +00:00
|
|
|
// m_hidden is for autohide, m_visible is the FbWindow state
|
|
|
|
bool m_hidden, m_visible;
|
2002-08-04 15:55:13 +00:00
|
|
|
|
2003-02-20 16:38:17 +00:00
|
|
|
BScreen &m_screen;
|
2003-05-11 17:42:51 +00:00
|
|
|
FbTk::Timer m_timer;
|
2002-03-19 00:07:00 +00:00
|
|
|
|
2003-05-11 17:42:51 +00:00
|
|
|
SlitClients m_client_list;
|
2005-06-23 03:07:25 +00:00
|
|
|
std::auto_ptr<LayerMenu> m_layermenu;
|
2007-01-07 14:07:45 +00:00
|
|
|
FbMenu m_clientlist_menu, m_slitmenu;
|
2003-01-12 17:56:15 +00:00
|
|
|
std::string m_filename;
|
2002-03-19 00:07:00 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
struct frame {
|
2004-09-11 18:58:27 +00:00
|
|
|
frame(const FbTk::FbWindow &parent):
|
|
|
|
window(parent, 0, 0, 10, 10,
|
|
|
|
SubstructureRedirectMask | ButtonPressMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask | ExposureMask,
|
|
|
|
true), // override redirect
|
|
|
|
x(0), y(0), x_hidden(0), y_hidden(0),
|
|
|
|
width(10), height(10) {}
|
2002-12-01 13:42:15 +00:00
|
|
|
Pixmap pixmap;
|
2003-01-12 17:56:15 +00:00
|
|
|
FbTk::FbWindow window;
|
2002-03-19 00:07:00 +00:00
|
|
|
|
2002-12-01 13:42:15 +00:00
|
|
|
int x, y, x_hidden, y_hidden;
|
|
|
|
unsigned int width, height;
|
|
|
|
} frame;
|
2003-05-11 17:42:51 +00:00
|
|
|
|
2003-01-12 17:56:15 +00:00
|
|
|
// for KDE
|
2003-05-11 17:42:51 +00:00
|
|
|
Atom m_kwm1_dockwindow, m_kwm2_dockwindow;
|
2003-02-18 15:11:12 +00:00
|
|
|
|
2003-02-20 16:38:17 +00:00
|
|
|
std::auto_ptr<FbTk::XLayerItem> m_layeritem;
|
2003-04-25 10:45:02 +00:00
|
|
|
std::auto_ptr<SlitTheme> m_slit_theme;
|
2003-05-17 11:00:50 +00:00
|
|
|
static unsigned int s_eventmask;
|
2003-06-18 13:55:17 +00:00
|
|
|
Strut *m_strut;
|
2003-06-20 01:26:16 +00:00
|
|
|
|
|
|
|
FbTk::Resource<bool> m_rc_auto_hide, m_rc_maximize_over;
|
|
|
|
FbTk::Resource<Slit::Placement> m_rc_placement;
|
|
|
|
FbTk::Resource<Slit::Direction> m_rc_direction;
|
|
|
|
FbTk::Resource<int> m_rc_alpha, m_rc_on_head;
|
2006-02-20 21:04:35 +00:00
|
|
|
FbTk::Resource<Layer> m_rc_layernum;
|
2001-12-11 20:47:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-08-04 15:55:13 +00:00
|
|
|
#endif // SLIT_HH
|