]>
Dogcows Code - chaz/openbox/blob - src/frame.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
13 #include "otk/strut.hh"
14 #include "otk/rect.hh"
15 #include "otk/renderstyle.hh"
16 #include "otk/ustring.hh"
17 #include "otk/surface.hh"
18 #include "otk/eventhandler.hh"
27 //! Varius geometry settings in the frame decorations
28 struct FrameGeometry
{
29 int width
; // title and handle
31 int title_height() { return font_height
+ bevel
*2; }
33 int label_height() { return font_height
; }
34 int handle_height
; // static, from the style
35 int icon_x
; // x-position of the window icon button
37 int button_size
; // static, from the style
38 int grip_width() { return button_size
* 2; }
39 int bevel
; // static, from the style
40 int bwidth
; // frame elements' border width
41 int cbwidth
; // client border width
44 //! Holds and decorates a frame around an Client (client window)
46 The frame is responsible for calling XSelectInput on the client window's new
47 parent with the SubstructureRedirectMask so that structure events for the
48 client are sent to the window manager.
50 class Frame
: public otk::StyleNotify
, public otk::EventHandler
{
53 //! The event mask to grab on frame windows
54 static const long event_mask
= EnterWindowMask
| LeaveWindowMask
;
59 //! The size of the frame on each side of the client window
62 //! The size of the frame on each side of the client window inside the border
63 otk::Strut _innersize
;
65 //! The position and size of the entire frame (including borders)
71 Window _frame
; // sits under everything
72 Window _plate
; // sits entirely under the client window
73 Window _title
; // the titlebar
74 Window _label
; // the section of the titlebar which shows the window name
75 Window _handle
; // bottom bar
76 Window _lgrip
; // lefthand resize grab on the handle
77 Window _rgrip
; // righthand resize grab on the handle
78 Window _max
; // maximize button
79 Window _desk
; // all-desktops button
80 Window _iconify
; // iconify button
81 Window _icon
; // window icon button
82 Window _close
; // close button
85 otk::Surface
*_frame_sur
;
86 otk::Surface
*_title_sur
;
87 otk::Surface
*_label_sur
;
88 otk::Surface
*_handle_sur
;
89 otk::Surface
*_grip_sur
;
90 otk::Surface
*_max_sur
;
91 otk::Surface
*_desk_sur
;
92 otk::Surface
*_iconify_sur
;
93 otk::Surface
*_icon_sur
;
94 otk::Surface
*_close_sur
;
96 std::string _layout
; // layout of the titlebar
103 unsigned int _press_button
; // mouse button that started the press
107 void applyStyle(const otk::RenderStyle
&style
);
112 void renderIconify();
117 //! Constructs an Frame object for a client
119 @param client The client which will be decorated by the new Frame
121 Frame(Client
*client
);
122 //! Destroys the Frame object
125 //! Returns the size of the frame on each side of the client
126 const otk::Strut
& size() const { return _size
; }
128 //! Set the style to decorate the frame with
129 virtual void styleChanged(const otk::RenderStyle
&style
);
131 //! Reparents the client window from the root window onto the frame
133 //! Reparents the client window back to the root window
134 void releaseClient();
136 //! Update the frame's size to match the client
138 //! Update the frame's position to match the client
139 void adjustPosition();
140 //! Shape the frame window to the client window
142 //! Update the frame to match the client's new state (for things like toggle
143 //! buttons, focus, and the title) XXX break this up
148 //! Applies gravity to the client's position to find where the frame should
151 @return The proper coordinates for the frame, based on the client.
153 void clientGravity(int &x
, int &y
);
155 //! Reversly applies gravity to the frame's position to find where the client
156 //! should be positioned.
158 @return The proper coordinates for the client, based on the frame.
160 void frameGravity(int &x
, int &y
);
162 //! The position and size of the frame window
163 inline const otk::Rect
& area() const { return _area
; }
165 //! Returns if the frame is visible
166 inline bool visible() const { return _visible
; }
173 void buttonPressHandler(const XButtonEvent
&e
);
174 void buttonReleaseHandler(const XButtonEvent
&e
);
176 //! Returns the MouseContext for the given window id
178 Returns '-1' if no valid mouse context exists in the frame for the given
181 ob::MouseContext::MC
mouseContext(Window win
) const;
183 //! Gets the window id of the frame's base top-level parent
184 inline Window
window() const { return _frame
; }
185 //! Gets the window id of the client's parent window
186 inline Window
plate() const { return _plate
; }
188 //! Returns a null terminated array of the window ids that make up the
189 //! frame's decorations.
190 Window
*allWindows() const;
This page took 0.040583 seconds and 4 git commands to generate.