1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
13 #include "backgroundwidget.hh"
14 #include "otk/strut.hh"
15 #include "otk/rect.hh"
16 #include "otk/screeninfo.hh"
17 #include "otk/style.hh"
18 #include "otk/widget.hh"
19 #include "otk/button.hh"
20 #include "otk/focuswidget.hh"
21 #include "otk/focuslabel.hh"
27 //! Holds and decorates a frame around an OBClient (client window)
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.
33 class OBFrame
: public otk::OtkWidget
{
36 //! The event mask to grab on frame windows
37 static const long event_mask
= EnterWindowMask
| LeaveWindowMask
;
41 const otk::ScreenInfo
*_screen
;
43 //! The style to use for size and display the decorations
46 //! The size of the frame on each side of the client window
49 //! The size of the frame on each side of the client window inside the border
50 otk::Strut _innersize
;
53 OBBackgroundWidget _plate
; // sits entirely under the client window
54 OBBackgroundWidget _titlebar
;
55 otk::OtkButton _button_close
;
56 otk::OtkButton _button_iconify
;
57 otk::OtkButton _button_max
;
58 otk::OtkButton _button_stick
;
59 otk::OtkFocusLabel _label
;
60 OBBackgroundWidget _handle
;
61 otk::OtkButton _grip_left
;
62 otk::OtkButton _grip_right
;
64 //! The decorations to display on the window.
66 This is by default the same value as in the OBClient::decorations, but it
67 is duplicated here so that it can be overridden per-window by the user.
69 OBClient::DecorationFlags _decorations
;
71 //! Reparents the client window from the root window onto the frame
73 //! Reparents the client window back to the root window
75 @param remap Re-map the client window when we're done reparenting?
77 void releaseClient(bool remap
);
79 //! Shape the frame window to the client window
83 //! Constructs an OBFrame object, and reparents the client to itself
85 @param client The client window which will be decorated by the new OBFrame
86 @param style The style to use to decorate the frame
88 OBFrame(OBClient
*client
, otk::Style
*style
);
89 //! Destroys the OBFrame object
92 //! Set the style to decorate the frame with
93 virtual void setStyle(otk::Style
*style
);
95 //! Update the frame's size to match the client
97 //! Update the frame's position to match the client
98 void adjustPosition();
100 //! Applies gravity to the client's position to find where the frame should
103 @return The proper coordinates for the frame, based on the client.
105 void clientGravity(int &x
, int &y
);
107 //! Reversly applies gravity to the frame's position to find where the client
108 //! should be positioned.
110 @return The proper coordinates for the client, based on the frame.
112 void frameGravity(int &x
, int &y
);