fluxbox/src/Slit.hh

207 lines
5.7 KiB
C++
Raw Normal View History

2002-03-19 00:07:00 +00:00
// Slit.hh for Fluxbox
2003-01-05 23:42:27 +00:00
// Copyright (c) 2002 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
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
2003-01-05 23:42:27 +00:00
/// $Id: Slit.hh,v 1.16 2003/01/05 23:42:27 fluxgen Exp $
2002-03-19 00:07:00 +00:00
#ifndef SLIT_HH
#define SLIT_HH
2001-12-11 20:47:02 +00:00
2002-11-14 00:15:10 +00:00
#include "Basemenu.hh"
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>
// forward declaration
class Slit;
2001-12-11 20:47:02 +00:00
2003-01-05 23:42:27 +00:00
/// menu in slit
2001-12-11 20:47:02 +00:00
class Slitmenu : public Basemenu {
2002-03-20 14:08:45 +00:00
public:
2002-12-01 13:42:15 +00:00
explicit Slitmenu(Slit &theslist);
virtual ~Slitmenu();
2002-03-20 14:08:45 +00:00
2002-12-01 13:42:15 +00:00
const Basemenu &getDirectionmenu() const { return m_directionmenu; }
const Basemenu &getPlacementmenu() const { return m_placementmenu; }
2002-11-14 00:15:10 +00:00
2002-03-20 14:08:45 +00:00
#ifdef XINERAMA
2002-12-01 13:42:15 +00:00
const Basemenu *getHeadmenu() const { return m_headmenu.get(); }
2002-03-20 14:08:45 +00:00
#endif // XINERAMA
2002-12-01 13:42:15 +00:00
void reconfigure();
2002-03-20 14:08:45 +00:00
2002-11-14 00:15:10 +00:00
protected:
2002-12-01 13:42:15 +00:00
virtual void itemSelected(int button, unsigned int index);
virtual void internal_hide();
2002-11-14 00:15:10 +00:00
2001-12-11 20:47:02 +00:00
private:
2002-12-01 13:42:15 +00:00
class Directionmenu : public Basemenu {
public:
Directionmenu(Slitmenu &sm);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
protected:
virtual void itemSelected(int button, unsigned int index);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
private:
Slitmenu &slitmenu;
};
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
class Placementmenu : public Basemenu {
public:
Placementmenu(Slitmenu &sm);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
protected:
virtual void itemSelected(int button, unsigned int index);
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
private:
Slitmenu &slitmenu;
};
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
Slit &slit;
2002-11-14 00:15:10 +00:00
2002-03-19 14:30:43 +00:00
#ifdef XINERAMA
2002-12-01 13:42:15 +00:00
class Headmenu : public Basemenu {
public:
Headmenu(Slitmenu &sm);
protected:
virtual void itemSelected(int button, unsigned int index);
private:
Slitmenu &slitmenu;
};
friend class Headmenu;
std::auto_ptr<Headmenu> m_headmenu;
2002-03-19 14:30:43 +00:00
#endif // XINERAMA
2002-12-01 13:42:15 +00:00
Placementmenu m_placementmenu;
Directionmenu m_directionmenu;
2001-12-11 20:47:02 +00:00
2002-12-01 13:42:15 +00:00
friend class Directionmenu;
friend class Placementmenu;
2001-12-11 20:47:02 +00:00
};
2003-01-05 23:42:27 +00:00
/// Handles dock apps
2001-12-11 20:47:02 +00:00
class Slit : public TimeoutHandler {
public:
2002-12-01 13:42:15 +00:00
explicit Slit(BScreen *screen);
virtual ~Slit();
inline bool isOnTop() const { return on_top; }
inline bool isHidden() const { return hidden; }
inline bool doAutoHide() const { return do_auto_hide; }
Slitmenu &menu() { return slitmenu; }
inline const Window &getWindowID() const { return frame.window; }
inline int x() const { return ((hidden) ? frame.x_hidden : frame.x); }
inline int y() const { return ((hidden) ? frame.y_hidden : frame.y); }
inline unsigned int width() const { return frame.width; }
inline unsigned int height() const { return frame.height; }
void setOnTop(bool val);
void setAutoHide(bool val);
void addClient(Window clientwin);
void removeClient(Window clientwin, bool = true);
void reconfigure();
void reposition();
void shutdown();
void saveClientList();
BScreen *screen() { return m_screen; }
const BScreen *screen() const { return m_screen; }
/**
@name eventhandlers
*/
//@{
void buttonPressEvent(XButtonEvent *bp);
void enterNotifyEvent(XCrossingEvent *en);
void leaveNotifyEvent(XCrossingEvent *ln);
void configureRequestEvent(XConfigureRequestEvent *cr);
//@}
2002-08-04 15:55:13 +00:00
2002-12-01 13:42:15 +00:00
virtual void timeout();
/**
Client alignment
*/
enum { VERTICAL = 1, HORIZONTAL };
/**
Screen placement
*/
enum { TOPLEFT = 1, CENTERLEFT, BOTTOMLEFT, TOPCENTER, BOTTOMCENTER,
TOPRIGHT, CENTERRIGHT, BOTTOMRIGHT };
2001-12-11 20:47:02 +00:00
2002-03-19 00:07:00 +00:00
private:
2002-12-01 13:42:15 +00:00
class SlitClient {
public:
SlitClient(BScreen *screen, Window client_window); // For adding an actual window
SlitClient(const char *name); // For adding a placeholder
// Now we pre-initialize a list of slit clients with names for
// comparison with incoming client windows. This allows the slit
// to maintain a sorted order based on a saved window name list.
// Incoming windows not found in the list are appended. Matching
// duplicates are inserted after the last found instance of the
// matching name.
std::string match_name;
Window window, client_window, icon_window;
int x, y;
unsigned int width, height;
void initialize(BScreen *screen = 0, Window client_window= None);
};
2002-03-19 00:07:00 +00:00
2002-12-01 13:42:15 +00:00
void removeClient(SlitClient *client, bool remap, bool destroy);
void loadClientList();
2002-03-19 00:07:00 +00:00
2002-12-01 13:42:15 +00:00
bool on_top, hidden, do_auto_hide;
2002-08-04 15:55:13 +00:00
2002-12-01 13:42:15 +00:00
BScreen *m_screen;
BTimer timer;
2002-03-19 00:07:00 +00:00
2002-12-01 13:42:15 +00:00
typedef std::list<SlitClient *> SlitClients;
2002-03-19 00:07:00 +00:00
2002-12-01 13:42:15 +00:00
SlitClients clientList;
Slitmenu slitmenu;
std::string clientListPath;
2002-03-19 00:07:00 +00:00
2002-12-01 13:42:15 +00:00
struct frame {
Pixmap pixmap;
Window 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;
2002-03-19 00:07:00 +00:00
2001-12-11 20:47:02 +00:00
};
2002-08-04 15:55:13 +00:00
#endif // SLIT_HH