1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
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"
26 //! Holds and decorates a frame around an OBClient (client window)
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.
32 class OBFrame
: public otk::OtkWidget
{
35 //! The event mask to grab on frame windows
36 static const long event_mask
= EnterWindowMask
| LeaveWindowMask
;
40 const otk::ScreenInfo
*_screen
;
42 //! The style to use for size and display the decorations
45 //! The size of the frame on each side of the client window
48 //! The size of the frame on each side of the client window inside the border
49 otk::Strut _innersize
;
52 OBBackgroundWidget _plate
; // sits entirely under the client window
53 OBBackgroundWidget _titlebar
;
54 OBButtonWidget _button_close
;
55 OBButtonWidget _button_iconify
;
56 OBButtonWidget _button_max
;
57 OBButtonWidget _button_stick
;
59 OBBackgroundWidget _handle
;
60 OBButtonWidget _grip_left
;
61 OBButtonWidget _grip_right
;
63 //! The decorations to display on the window.
65 This is by default the same value as in the OBClient::decorations, but it
66 is duplicated here so that it can be overridden per-window by the user.
68 OBClient::DecorationFlags _decorations
;
70 //! Reparents the client window from the root window onto the frame
72 //! Reparents the client window back to the root window
74 @param remap Re-map the client window when we're done reparenting?
76 void releaseClient(bool remap
);
78 //! Shape the frame window to the client window
82 //! Constructs an OBFrame object, and reparents the client to itself
84 @param client The client window which will be decorated by the new OBFrame
85 @param style The style to use to decorate the frame
87 OBFrame(OBClient
*client
, otk::Style
*style
);
88 //! Destroys the OBFrame object
91 //! Set the style to decorate the frame with
92 virtual void setStyle(otk::Style
*style
);
94 //! Update the frame's size to match the client
96 //! Update the frame's position to match the client
97 void adjustPosition();
99 //! Applies gravity to the client's position to find where the frame should
102 @return The proper coordinates for the frame, based on the client.
104 void clientGravity(int &x
, int &y
);
106 //! Reversly applies gravity to the frame's position to find where the client
107 //! should be positioned.
109 @return The proper coordinates for the client, based on the frame.
111 void frameGravity(int &x
, int &y
);