]> Dogcows Code - chaz/openbox/blob - src/frame.hh
add an exit callback
[chaz/openbox] / src / frame.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __frame_hh
3 #define __frame_hh
4
5 /*! @file frame.hh
6 */
7
8 extern "C" {
9 #include <X11/Xlib.h>
10 }
11
12 #include "client.hh"
13 #include "backgroundwidget.hh"
14 #include "labelwidget.hh"
15 #include "buttonwidget.hh"
16 #include "otk/strut.hh"
17 #include "otk/rect.hh"
18 #include "otk/screeninfo.hh"
19 #include "otk/renderstyle.hh"
20 #include "otk/widget.hh"
21 #include "otk/ustring.hh"
22
23 #include <string>
24
25 namespace ob {
26
27 //! Holds and decorates a frame around an Client (client window)
28 /*!
29 The frame is responsible for calling XSelectInput on the client window's new
30 parent with the SubstructureRedirectMask so that structure events for the
31 client are sent to the window manager.
32 */
33 class Frame : public otk::Widget, public WidgetBase {
34 public:
35
36 //! The event mask to grab on frame windows
37 static const long event_mask = EnterWindowMask | LeaveWindowMask;
38
39 private:
40 Client *_client;
41 const otk::ScreenInfo *_screen;
42
43 //! The size of the frame on each side of the client window
44 otk::Strut _size;
45
46 //! The size of the frame on each side of the client window inside the border
47 otk::Strut _innersize;
48
49 // decoration windows
50 BackgroundWidget _plate; // sits entirely under the client window
51 BackgroundWidget _titlebar;
52 ButtonWidget _button_close;
53 ButtonWidget _button_iconify;
54 ButtonWidget _button_max;
55 ButtonWidget _button_alldesk;
56 LabelWidget _label;
57 BackgroundWidget _handle;
58 ButtonWidget _grip_left;
59 ButtonWidget _grip_right;
60
61 //! The decorations to display on the window.
62 /*!
63 This is by default the same value as in the Client::decorations, but it
64 is duplicated here so that it can be overridden per-window by the user.
65 */
66 Client::DecorationFlags _decorations;
67
68 public:
69 //! Constructs an Frame object, and reparents the client to itself
70 /*!
71 @param client The client window which will be decorated by the new Frame
72 @param style The style to use to decorate the frame
73 */
74 Frame(Client *client, otk::RenderStyle *style);
75 //! Destroys the Frame object
76 virtual ~Frame();
77
78 //! Returns the size of the frame on each side of the client
79 const otk::Strut& size() const { return _size; }
80
81 //! Set the style to decorate the frame with
82 virtual void setStyle(otk::RenderStyle *style);
83
84 //! Empty overridden method to prevent automatic alignment of children
85 virtual void adjust();
86
87 //! Displays focused decorations
88 virtual void focus();
89 //! Displays unfocused decorations
90 virtual void unfocus();
91
92 void setTitle(const otk::ustring &text);
93
94 //! Reparents the client window from the root window onto the frame
95 void grabClient();
96 //! Reparents the client window back to the root window
97 void releaseClient();
98
99 //! Update the frame's size to match the client
100 void adjustSize();
101 //! Update the frame's position to match the client
102 void adjustPosition();
103 //! Shape the frame window to the client window
104 void adjustShape();
105 //! Update the frame to match the client's new state (for things like toggle
106 //! buttons)
107 void adjustState();
108
109 //! Applies gravity to the client's position to find where the frame should
110 //! be positioned.
111 /*!
112 @return The proper coordinates for the frame, based on the client.
113 */
114 void clientGravity(int &x, int &y);
115
116 //! Reversly applies gravity to the frame's position to find where the client
117 //! should be positioned.
118 /*!
119 @return The proper coordinates for the client, based on the frame.
120 */
121 void frameGravity(int &x, int &y);
122
123 //! Gets the window id of the frame's "plate" subelement
124 inline Window plate() const { return _plate.window(); }
125 //! Gets the window id of the frame's "titlebar" subelement
126 inline Window titlebar() const { return _titlebar.window(); }
127 //! Gets the window id of the frame's "label" subelement
128 inline Window label() const { return _label.window(); }
129 //! Gets the window id of the frame's "close button" subelement
130 inline Window button_close() const { return _button_close.window(); }
131 //! Gets the window id of the frame's "iconify button" subelement
132 inline Window button_iconify() const { return _button_iconify.window(); }
133 //! Gets the window id of the frame's "maximize button" subelement
134 inline Window button_max() const { return _button_max.window(); }
135 //! Gets the window id of the frame's "all desktops button" subelement
136 inline Window button_alldesk() const { return _button_alldesk.window(); }
137 //! Gets the window id of the frame's "handle" subelement
138 inline Window handle() const { return _handle.window(); }
139 //! Gets the window id of the frame's "left grip" subelement
140 inline Window grip_left() const { return _grip_left.window(); }
141 //! Gets the window id of the frame's "right grip" subelement
142 inline Window grip_right() const { return _grip_right.window(); }
143
144 };
145
146 }
147
148 #endif // __frame_hh
This page took 0.038654 seconds and 4 git commands to generate.