]> Dogcows Code - chaz/openbox/blob - src/frame.hh
link in python not guile
[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/style.hh"
20 #include "otk/widget.hh"
21
22 #include <string>
23
24 namespace ob {
25
26 //! Holds and decorates a frame around an OBClient (client window)
27 /*!
28 The frame is responsible for calling XSelectInput on the client window's new
29 parent with the SubstructureRedirectMask so that structure events for the
30 client are sent to the window manager.
31 */
32 class OBFrame : public otk::OtkWidget, public OBWidget {
33 public:
34
35 //! The event mask to grab on frame windows
36 static const long event_mask = EnterWindowMask | LeaveWindowMask |
37 ButtonPressMask | ButtonReleaseMask |
38 ButtonMotionMask;
39
40 private:
41 OBClient *_client;
42 const otk::ScreenInfo *_screen;
43
44 //! The style to use for size and display the decorations
45 otk::Style *_style;
46
47 //! The size of the frame on each side of the client window
48 otk::Strut _size;
49
50 //! The size of the frame on each side of the client window inside the border
51 otk::Strut _innersize;
52
53 // decoration windows
54 OBBackgroundWidget _plate; // sits entirely under the client window
55 OBBackgroundWidget _titlebar;
56 OBButtonWidget _button_close;
57 OBButtonWidget _button_iconify;
58 OBButtonWidget _button_max;
59 OBButtonWidget _button_stick;
60 OBLabelWidget _label;
61 OBBackgroundWidget _handle;
62 OBButtonWidget _grip_left;
63 OBButtonWidget _grip_right;
64
65 //! The decorations to display on the window.
66 /*!
67 This is by default the same value as in the OBClient::decorations, but it
68 is duplicated here so that it can be overridden per-window by the user.
69 */
70 OBClient::DecorationFlags _decorations;
71
72 //! Reparents the client window from the root window onto the frame
73 void grabClient();
74 //! Reparents the client window back to the root window
75 /*!
76 @param remap Re-map the client window when we're done reparenting?
77 */
78 void releaseClient(bool remap);
79
80 //! Shape the frame window to the client window
81 void adjustShape();
82
83 public:
84 //! Constructs an OBFrame object, and reparents the client to itself
85 /*!
86 @param client The client window which will be decorated by the new OBFrame
87 @param style The style to use to decorate the frame
88 */
89 OBFrame(OBClient *client, otk::Style *style);
90 //! Destroys the OBFrame object
91 virtual ~OBFrame();
92
93 //! Set the style to decorate the frame with
94 virtual void setStyle(otk::Style *style);
95
96 //! Update the frame's size to match the client
97 void adjustSize();
98 //! Update the frame's position to match the client
99 void adjustPosition();
100
101 //! Applies gravity to the client's position to find where the frame should
102 //! be positioned.
103 /*!
104 @return The proper coordinates for the frame, based on the client.
105 */
106 void clientGravity(int &x, int &y);
107
108 //! Reversly applies gravity to the frame's position to find where the client
109 //! should be positioned.
110 /*!
111 @return The proper coordinates for the client, based on the frame.
112 */
113 void frameGravity(int &x, int &y);
114
115 //! Gets the window id of the frame's "plate" subelement
116 inline Window plate() const { return _plate.getWindow(); }
117 //! Gets the window id of the frame's "titlebar" subelement
118 inline Window titlebar() const { return _titlebar.getWindow(); }
119 //! Gets the window id of the frame's "label" subelement
120 inline Window label() const { return _label.getWindow(); }
121 //! Gets the window id of the frame's "close button" subelement
122 inline Window button_close() const { return _button_close.getWindow(); }
123 //! Gets the window id of the frame's "iconify button" subelement
124 inline Window button_iconify() const { return _button_iconify.getWindow(); }
125 //! Gets the window id of the frame's "maximize button" subelement
126 inline Window button_max() const { return _button_max.getWindow(); }
127 //! Gets the window id of the frame's "sticky button" subelement
128 inline Window button_stick() const { return _button_stick.getWindow(); }
129 //! Gets the window id of the frame's "handle" subelement
130 inline Window handle() const { return _handle.getWindow(); }
131 //! Gets the window id of the frame's "left grip" subelement
132 inline Window grip_left() const { return _grip_left.getWindow(); }
133 //! Gets the window id of the frame's "right grip" subelement
134 inline Window grip_right() const { return _grip_right.getWindow(); }
135
136 };
137
138 }
139
140 #endif // __frame_hh
This page took 0.039468 seconds and 4 git commands to generate.