]> icculus.org git repositories - mikachu/openbox.git/blob - src/frame.hh
add --copy
[mikachu/openbox.git] / 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 "otk/strut.hh"
14 #include "otk/rect.hh"
15 #include "otk/screeninfo.hh"
16 #include "otk/style.hh"
17 #include "otk/widget.hh"
18 #include "otk/button.hh"
19 #include "otk/focuswidget.hh"
20 #include "otk/focuslabel.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 {
33 public:
34
35   //! The event mask to grab on frame windows
36   static const long event_mask = EnterWindowMask | LeaveWindowMask;
37
38 private:
39   OBClient *_client;
40   const otk::ScreenInfo *_screen;
41
42   //! The style to use for size and display the decorations
43   otk::Style *_style;
44
45   //! The size of the frame on each side of the client window
46   otk::Strut _size;
47
48   //! The size of the frame on each side of the client window inside the border
49   otk::Strut _innersize;
50
51   // decoration windows
52   otk::OtkFocusWidget _plate;   // sits entirely under the client window
53   otk::OtkFocusWidget _titlebar;
54   otk::OtkButton      _button_close;
55   otk::OtkButton      _button_iconify;
56   otk::OtkButton      _button_max;
57   otk::OtkButton      _button_stick;
58   otk::OtkFocusLabel  _label;
59   otk::OtkFocusWidget _handle;
60   otk::OtkButton      _grip_left;
61   otk::OtkButton      _grip_right;
62
63   //! The decorations to display on the window.
64   /*!
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.
67   */
68   OBClient::DecorationFlags _decorations;
69
70   //! Reparents the client window from the root window onto the frame
71   void grabClient();
72   //! Reparents the client window back to the root window
73   /*!
74     @param remap Re-map the client window when we're done reparenting?
75   */
76   void releaseClient(bool remap);
77
78   //! Shape the frame window to the client window
79   void adjustShape();
80
81 public:
82   //! Constructs an OBFrame object, and reparents the client to itself
83   /*!
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
86   */
87   OBFrame(OBClient *client, otk::Style *style);
88   //! Destroys the OBFrame object
89   virtual ~OBFrame();
90
91   //! Set the style to decorate the frame with
92   virtual void setStyle(otk::Style *style);
93
94   //! Update the frame's size to match the client
95   void adjustSize();
96   //! Update the frame's position to match the client
97   void adjustPosition();
98
99   //! Applies gravity to the client's position to find where the frame should
100   //! be positioned.
101   /*!
102     @return The proper coordinates for the frame, based on the client.
103   */
104   void clientGravity(int &x, int &y);
105
106   //! Reversly applies gravity to the frame's position to find where the client
107   //! should be positioned.
108   /*!
109     @return The proper coordinates for the client, based on the frame.
110   */
111   void frameGravity(int &x, int &y);
112
113 };
114
115 }
116
117 #endif // __frame_hh