fluxbox/src/WinClient.hh

210 lines
7.5 KiB
C++
Raw Normal View History

2003-04-14 12:13:36 +00:00
// WinClient.hh for Fluxbox - an X11 Window manager
2006-02-16 06:53:05 +00:00
// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
2003-04-14 12:13:36 +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.
#ifndef WINCLIENT_HH
#define WINCLIENT_HH
2003-05-10 14:16:38 +00:00
#include "Window.hh"
2007-12-30 15:32:53 +00:00
#include "FbTk/FbWindow.hh"
#include "FbTk/FbString.hh"
2003-04-14 12:13:36 +00:00
#include <X11/Xutil.h>
class BScreen;
class Strut;
2003-04-14 12:13:36 +00:00
/// Holds client window info
2007-10-13 21:51:37 +00:00
class WinClient: public Focusable, public FbTk::FbWindow {
2003-04-14 12:13:36 +00:00
public:
typedef std::list<WinClient *> TransientList;
// this structure only contains 3 elements... the Motif 2.0 structure contains
// 5... we only need the first 3... so that is all we will define
typedef struct MwmHints {
unsigned long flags; // Motif wm flags
unsigned long functions; // Motif wm functions
unsigned long decorations; // Motif wm decorations
} MwmHints;
2003-04-14 12:13:36 +00:00
2008-08-15 11:02:14 +00:00
typedef struct SizeHints {
unsigned int min_width;
unsigned int max_width;
unsigned int min_height;
unsigned int max_height;
unsigned int width_inc;
unsigned int height_inc;
unsigned int min_aspect_x;
unsigned int max_aspect_x;
unsigned int min_aspect_y;
unsigned int max_aspect_y;
unsigned int base_width;
unsigned int base_height;
} SizeHints;
WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin = 0);
2003-04-14 12:13:36 +00:00
~WinClient();
2003-07-21 15:26:57 +00:00
bool sendFocus(); // returns whether we sent a message or not
// i.e. whether we assume the focus will get taken
bool acceptsFocus() const; // will this window accept focus (according to hints)
void sendClose(bool forceful = false);
2003-09-21 12:49:48 +00:00
// not aware of anything that makes this false at present
bool isClosable() const { return true; }
2003-06-15 18:36:40 +00:00
/// updates from wm class hints
void updateWMClassHint();
2003-07-28 15:46:00 +00:00
void updateWMProtocols();
2003-06-15 18:36:40 +00:00
// override the title with this
void setTitle(const FbTk::FbString &title);
2003-04-14 12:13:36 +00:00
void updateTitle();
/// updates transient window information
void updateTransientInfo();
// override the icon with this
void setIcon(const FbTk::PixmapWithMask& pm);
// update some thints
void updateMWMHints();
void updateWMHints();
void updateWMNormalHints();
2003-04-14 12:13:36 +00:00
void setStrut(Strut *strut);
void clearStrut();
bool focus(); // calls Window->setCurrentClient to give focus to this client
2007-10-13 21:51:37 +00:00
bool isFocused() const;
void setAttentionState(bool value);
2007-11-05 17:05:58 +00:00
const std::string &title() const { return m_title; }
/**
* Changes width and height to the nearest (lower) value
* that conforms to it's size hints.
*
* display_* give the values that would be displayed
* to the user when resizing.
* We use pointers for display_* since they are optional.
*/
void applySizeHints(int &width, int &height, int *display_width = 0,
int *display_height = 0, bool maximizing = false);
bool checkSizeHints(unsigned int width, unsigned int height);
void setGroupLeftWindow(Window win);
void saveBlackboxAttribs(FluxboxWindow::BlackboxAttributes &blackbox_attribs, int nelements);
2005-04-29 02:52:36 +00:00
void setFluxboxWindow(FluxboxWindow *win);
// does this client have a pending unmap or destroy event?
bool validateClient() const;
//
// accessors
//
bool getAttrib(XWindowAttributes &attr) const;
bool getWMName(XTextProperty &textprop) const;
bool getWMIconName(XTextProperty &textprop) const;
2007-10-13 21:51:37 +00:00
std::string getWMRole() const;
2007-11-05 17:05:58 +00:00
Focusable::WindowType getWindowType() const { return m_window_type; }
void setWindowType(Focusable::WindowType type) { m_window_type = type; }
WinClient *transientFor() { return transient_for; }
const WinClient *transientFor() const { return transient_for; }
TransientList &transientList() { return transients; }
const TransientList &transientList() const { return transients; }
bool isTransient() const { return transient_for != 0; }
bool isModal() const { return m_modal_count > 0; }
bool isStateModal() const { return m_modal; }
void setStateModal(bool state);
int gravity() const { return m_win_gravity; }
2003-09-11 19:55:27 +00:00
bool hasGroupLeftWindow() const;
// grouping is tracked by remembering the window to the left in the group
Window getGroupLeftWindow() const;
const MwmHints *getMwmHint() const { return m_mwm_hint; }
2008-08-15 11:02:14 +00:00
unsigned int minWidth() const { return m_size_hints.min_width; }
unsigned int minHeight() const { return m_size_hints.min_height; }
unsigned int maxWidth() const { return m_size_hints.max_width; }
unsigned int maxHeight() const { return m_size_hints.max_height; }
unsigned int widthInc() const { return m_size_hints.width_inc; }
unsigned int heightInc() const { return m_size_hints.height_inc; }
2006-04-23 21:24:05 +00:00
static const int PropMwmHintsElements = 3;
2003-04-14 12:13:36 +00:00
/**
!! TODO !!
remove or move these to private
*/
WinClient *transient_for; // which window are we a transient for?
std::list<WinClient *> transients; // which windows are our transients?
2003-04-14 12:13:36 +00:00
Window window_group;
int x, y, old_bw;
unsigned long initial_state, normal_hint_flags, wm_hint_flags;
private:
2005-04-29 02:52:36 +00:00
/// removes client from any waiting list and clears empty waiting lists
void removeTransientFromWaitingList();
// some transient of ours (or us) is modal
void addModal() { ++m_modal_count; }
// some transient (or us) is no longer modal
void removeModal() { --m_modal_count; }
// number of transients which we are modal for
int m_modal_count;
bool m_modal;
2007-11-05 17:05:58 +00:00
bool accepts_input, send_focus_message, send_close_message;
2003-09-11 19:55:27 +00:00
int m_win_gravity;
2007-11-05 17:05:58 +00:00
bool m_title_override;
bool m_icon_override;
2007-11-05 17:05:58 +00:00
Focusable::WindowType m_window_type;
MwmHints *m_mwm_hint;
2008-08-15 11:02:14 +00:00
SizeHints m_size_hints;
Strut *m_strut;
2005-04-29 02:52:36 +00:00
// map transient_for X window to winclient transient
// (used if transient_for FbWindow was created after transient)
// Since a lot of transients can be created before transient_for
// we need to map transient_for window to a list of transients
//
// Stuff to worry about:
// 1) If transients die before the transient_for is created
// 2) If transients changes to a new transient_for before old transient_for is created
// ( 3) Transient_for is never created
// This is not a big deal since the key value will be cleared
// once the list is empty )
typedef std::map<Window, TransientList> TransientWaitMap;
static TransientWaitMap s_transient_wait;
2003-04-14 12:13:36 +00:00
};
#endif // WINCLIENT_HH