aboutsummaryrefslogtreecommitdiff
path: root/src/Window.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.hh')
-rw-r--r--src/Window.hh170
1 files changed, 106 insertions, 64 deletions
diff --git a/src/Window.hh b/src/Window.hh
index 92431ab..d001284 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -32,11 +32,13 @@
32#include "FbTk/EventHandler.hh" 32#include "FbTk/EventHandler.hh"
33#include "FbTk/XLayerItem.hh" 33#include "FbTk/XLayerItem.hh"
34#include "FbWinFrame.hh" 34#include "FbWinFrame.hh"
35#include "Focusable.hh"
35#include "WinButton.hh" 36#include "WinButton.hh"
36 37
37#include <X11/Xlib.h> 38#include <X11/Xlib.h>
38#include <X11/Xutil.h> 39#include <X11/Xutil.h>
39 40
41#include <sys/time.h>
40#include <vector> 42#include <vector>
41#include <string> 43#include <string>
42#include <memory> 44#include <memory>
@@ -56,17 +58,8 @@ class Menu;
56} 58}
57 59
58/// Creates the window frame and handles any window event for it 60/// Creates the window frame and handles any window event for it
59class FluxboxWindow: public FbTk::EventHandler { 61class FluxboxWindow: public Focusable, public FbTk::EventHandler {
60public: 62public:
61 /// Represents certain "preset" sets of decorations.
62 enum Decoration {
63 DECOR_NONE=0, ///< no decor at all
64 DECOR_NORMAL, ///< normal normal
65 DECOR_TINY, ///< tiny decoration
66 DECOR_TOOL, ///< decor tool
67 DECOR_TAB ///< decor tab (border + tab)
68 };
69
70 /// Motif wm Hints 63 /// Motif wm Hints
71 enum { 64 enum {
72 MwmHintsFunctions = (1l << 0), ///< use motif wm functions 65 MwmHintsFunctions = (1l << 0), ///< use motif wm functions
@@ -96,14 +89,14 @@ public:
96 89
97 /// attributes for BlackboxHints 90 /// attributes for BlackboxHints
98 enum Attrib { 91 enum Attrib {
99 ATTRIB_SHADED = 0x01, 92 ATTRIB_SHADED = 0x01, ///< shaded
100 ATTRIB_MAXHORIZ = 0x02, 93 ATTRIB_MAXHORIZ = 0x02, ///< maximized horizontal
101 ATTRIB_MAXVERT = 0x04, 94 ATTRIB_MAXVERT = 0x04, ///< maximized vertical
102 ATTRIB_OMNIPRESENT = 0x08, 95 ATTRIB_OMNIPRESENT = 0x08, ///< omnipresent (sticky)
103 ATTRIB_WORKSPACE = 0x10, 96 ATTRIB_WORKSPACE = 0x10, ///< workspace
104 ATTRIB_STACK = 0x20, 97 ATTRIB_STACK = 0x20, ///< stack
105 ATTRIB_DECORATION = 0x40, 98 ATTRIB_DECORATION = 0x40, ///< decorations
106 ATTRIB_HIDDEN = 0x80, 99 ATTRIB_HIDDEN = 0x80, ///< hidden
107 }; 100 };
108 101
109 /** 102 /**
@@ -135,7 +128,18 @@ public:
135 DECORM_LAST = (1<<11) // useful for getting "All" 128 DECORM_LAST = (1<<11) // useful for getting "All"
136 }; 129 };
137 130
131 enum Decoration {
132 DECOR_NONE = 0,
133 DECOR_NORMAL = DECORM_LAST - 1,
134 DECOR_TINY = DECORM_TITLEBAR|DECORM_ICONIFY|DECORM_MENU|DECORM_TAB,
135 DECOR_TOOL = DECORM_TITLEBAR|DECORM_MENU,
136 DECOR_BORDER = DECORM_BORDER|DECORM_MENU,
137 DECOR_TAB = DECORM_BORDER|DECORM_MENU|DECORM_TAB
138 };
138 139
140 /**
141 * Resize direction while resizing
142 */
139 enum ResizeDirection { 143 enum ResizeDirection {
140 NOCORNER = -1, 144 NOCORNER = -1,
141 LEFTTOP = 0, 145 LEFTTOP = 0,
@@ -149,11 +153,7 @@ public:
149 ALLCORNERS = 8 153 ALLCORNERS = 8
150 }; 154 };
151 155
152 typedef struct _blackbox_hints { 156 /// holds old blackbox attributes
153 unsigned long flags, attrib, workspace, stack;
154 long decoration;
155 } BlackboxHints;
156
157 typedef struct _blackbox_attributes { 157 typedef struct _blackbox_attributes {
158 unsigned long flags, attrib, workspace, stack; 158 unsigned long flags, attrib, workspace, stack;
159 long premax_x, premax_y; 159 long premax_x, premax_y;
@@ -179,33 +179,76 @@ public:
179 bool removeClient(WinClient &client); 179 bool removeClient(WinClient &client);
180 /// set new current client and raise it 180 /// set new current client and raise it
181 bool setCurrentClient(WinClient &client, bool setinput = true); 181 bool setCurrentClient(WinClient &client, bool setinput = true);
182 void setLabelButtonFocus(WinClient &client, bool value = true); 182 /**
183 void setAttentionState(bool value); 183 * Searches for a client
184 bool getAttentionState() { return m_attention_state; } 184 * @param win the client X window
185 * @return pointer to client matching the window or NULL
186 */
185 WinClient *findClient(Window win); 187 WinClient *findClient(Window win);
188 /// select next client
186 void nextClient(); 189 void nextClient();
190 /// select previous client
187 void prevClient(); 191 void prevClient();
192 /// move the current client to the left
188 void moveClientLeft(); 193 void moveClientLeft();
194 /// move the current client to the right
189 void moveClientRight(); 195 void moveClientRight();
196 /**
197 * Move a client to the right of dest.
198 * @param win the client to move
199 * @param dest the left-of-client
200 */
190 void moveClientRightOf(WinClient &win, WinClient &dest); 201 void moveClientRightOf(WinClient &win, WinClient &dest);
202 /**
203 * Move a client to the right of dest.
204 * @param win the client to move
205 * @param dest the left-of-client
206 */
191 void moveClientLeftOf(WinClient &win, WinClient &dest); 207 void moveClientLeftOf(WinClient &win, WinClient &dest);
208 /**
209 * Move client to place specified by pixel position
210 * @param win the client to move
211 * @param x position
212 * @param y position
213 */
192 void moveClientTo(WinClient &win, int x, int y); 214 void moveClientTo(WinClient &win, int x, int y);
215 /**
216 * Calculates insertition position in the list by
217 * using pixel position x and y.
218 * @param x position
219 * @param y position
220 * @return iterator position for insertion
221 */
193 ClientList::iterator getClientInsertPosition(int x, int y); 222 ClientList::iterator getClientInsertPosition(int x, int y);
223 /**
224 * Take focus.
225 * @see Focusable
226 * @return true if it took focus.
227 */
228 bool focus();
229 bool allowsFocusFromClient();
194 230
195 bool setInputFocus(); 231 /// Raises the window and takes focus (if possible).
196 void raiseAndFocus() { raise(); setInputFocus(); } 232 void raiseAndFocus() { raise(); focus(); }
233 /// sets the internal focus flag
197 void setFocusFlag(bool flag); 234 void setFocusFlag(bool flag);
198 // map this window 235 /// make this window visible
199 void show(); 236 void show();
200 // unmap this window 237 /// hide window
201 void hide(bool interrupt_moving = true); 238 void hide(bool interrupt_moving = true);
239 /// iconify window
202 void iconify(); 240 void iconify();
241 /**
242 * Deiconify window
243 * @param reassoc reassociate the window to the current workspace
244 * @param do_raise raise the window when its been deiconfied
245 */
203 void deiconify(bool reassoc = true, bool do_raise = true); 246 void deiconify(bool reassoc = true, bool do_raise = true);
204 247
205 // ------------------ 248 // ------------------
206 // Per window transparency addons 249 // Per window transparency addons
207 unsigned char getFocusedAlpha() const { return frame().getAlpha(true); } 250 unsigned char getFocusedAlpha() const { return frame().getAlpha(true); }
208 unsigned char getUnfocusedAlpha() const { return frame().getAlpha(false); } 251 unsigned char getUnfocusedAlpha() const { return frame().getAlpha(false); }
209 void setFocusedAlpha(unsigned char alpha) { frame().setAlpha(true, alpha); } 252 void setFocusedAlpha(unsigned char alpha) { frame().setAlpha(true, alpha); }
210 void setUnfocusedAlpha(unsigned char alpha) { frame().setAlpha(false, alpha); } 253 void setUnfocusedAlpha(unsigned char alpha) { frame().setAlpha(false, alpha); }
211 void updateAlpha(bool focused, unsigned char alpha) { frame().setAlpha(focused, alpha); } 254 void updateAlpha(bool focused, unsigned char alpha) { frame().setAlpha(focused, alpha); }
@@ -218,8 +261,6 @@ public:
218 void close(); 261 void close();
219 /// kill current client 262 /// kill current client
220 void kill(); 263 void kill();
221 /// set the window in withdrawn state
222 void withdraw(bool interrupt_moving);
223 /// set fullscreen 264 /// set fullscreen
224 void setFullscreen(bool flag); 265 void setFullscreen(bool flag);
225 /// toggle maximize 266 /// toggle maximize
@@ -245,8 +286,11 @@ public:
245 void tempRaise(); 286 void tempRaise();
246 void raiseLayer(); 287 void raiseLayer();
247 void lowerLayer(); 288 void lowerLayer();
289 /// moves the window to a new layer
248 void moveToLayer(int layernum, bool force = false); 290 void moveToLayer(int layernum, bool force = false);
291 /// sets the window focus hidden state
249 void setFocusHidden(bool value); 292 void setFocusHidden(bool value);
293 /// sets the window icon hidden state
250 void setIconHidden(bool value); 294 void setIconHidden(bool value);
251 void reconfigure(); 295 void reconfigure();
252 296
@@ -262,11 +306,21 @@ public:
262 void moveResize(int x, int y, unsigned int width, unsigned int height, bool send_event = false); 306 void moveResize(int x, int y, unsigned int width, unsigned int height, bool send_event = false);
263 /// move to pos x,y and resize client window to size width, height 307 /// move to pos x,y and resize client window to size width, height
264 void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity, unsigned int client_bw = 0); 308 void moveResizeForClient(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity, unsigned int client_bw = 0);
309 /**
310 * Determines maximum size using all clients that this window can have.
311 * @param width will be filled in with maximum width
312 * @param height will be filled in with maximum height
313 */
314 void maxSize(unsigned int &width, unsigned int &height);
265 void setWorkspace(int n); 315 void setWorkspace(int n);
266 void changeBlackboxHints(const BlackboxHints &bh);
267 void updateFunctions(); 316 void updateFunctions();
268 void restoreAttributes(); 317 void restoreAttributes();
269 void showMenu(int mx, int my, WinClient *client = 0); 318 /**
319 * Show window meny at at given position
320 * @param mx position
321 * @param my position
322 */
323 void showMenu(int mx, int my);
270 // popup menu on last button press position 324 // popup menu on last button press position
271 void popupMenu(); 325 void popupMenu();
272 326
@@ -277,6 +331,7 @@ public:
277 */ 331 */
278 //@{ 332 //@{
279 void handleEvent(XEvent &event); 333 void handleEvent(XEvent &event);
334 void keyPressEvent(XKeyEvent &ke);
280 void buttonPressEvent(XButtonEvent &be); 335 void buttonPressEvent(XButtonEvent &be);
281 void buttonReleaseEvent(XButtonEvent &be); 336 void buttonReleaseEvent(XButtonEvent &be);
282 void motionNotifyEvent(XMotionEvent &me); 337 void motionNotifyEvent(XMotionEvent &me);
@@ -291,7 +346,6 @@ public:
291 void leaveNotifyEvent(XCrossingEvent &ev); 346 void leaveNotifyEvent(XCrossingEvent &ev);
292 //@} 347 //@}
293 348
294 void setDecoration(Decoration decoration, bool apply = true);
295 void applyDecorations(bool initial = false); 349 void applyDecorations(bool initial = false);
296 void toggleDecoration(); 350 void toggleDecoration();
297 351
@@ -333,7 +387,6 @@ public:
333 inline bool isFocusHidden() const { return m_focus_hidden; } 387 inline bool isFocusHidden() const { return m_focus_hidden; }
334 inline bool isIconHidden() const { return m_icon_hidden; } 388 inline bool isIconHidden() const { return m_icon_hidden; }
335 inline bool isManaged() const { return m_initialized; } 389 inline bool isManaged() const { return m_initialized; }
336 inline bool isFocused() const { return focused; }
337 bool isVisible() const; 390 bool isVisible() const;
338 inline bool isIconic() { return iconic; } 391 inline bool isIconic() { return iconic; }
339 inline bool isIconic() const { return iconic; } 392 inline bool isIconic() const { return iconic; }
@@ -360,8 +413,7 @@ public:
360 inline WinClient &winClient() { return *m_client; } 413 inline WinClient &winClient() { return *m_client; }
361 inline const WinClient &winClient() const { return *m_client; } 414 inline const WinClient &winClient() const { return *m_client; }
362 415
363 inline const BScreen &screen() const { return m_screen; } 416 bool isTyping();
364 inline BScreen &screen() { return m_screen; }
365 417
366 inline const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); } 418 inline const FbTk::XLayerItem &layerItem() const { return m_frame.layerItem(); }
367 inline FbTk::XLayerItem &layerItem() { return m_frame.layerItem(); } 419 inline FbTk::XLayerItem &layerItem() { return m_frame.layerItem(); }
@@ -377,13 +429,13 @@ public:
377 const FbTk::FbWindow &parent() const { return m_parent; } 429 const FbTk::FbWindow &parent() const { return m_parent; }
378 FbTk::FbWindow &parent() { return m_parent; } 430 FbTk::FbWindow &parent() { return m_parent; }
379 431
380 const FbTk::FbPixmap &iconPixmap() const; 432 bool acceptsFocus() const;
381 const FbTk::FbPixmap &iconMask() const; 433 const FbTk::PixmapWithMask &icon() const;
382 const bool usePixmap() const;
383 const bool useMask() const;
384
385 const std::string &title() const; 434 const std::string &title() const;
386 const std::string &iconTitle() const; 435 const std::string &getWMClassName() const;
436 const std::string &getWMClassClass() const;
437 std::string getWMRole() const;
438
387 inline int x() const { return frame().x(); } 439 inline int x() const { return frame().x(); }
388 inline int y() const { return frame().y(); } 440 inline int y() const { return frame().y(); }
389 inline unsigned int width() const { return frame().width(); } 441 inline unsigned int width() const { return frame().width(); }
@@ -425,11 +477,6 @@ public:
425 const FbTk::Subject &hintSig() const { return m_hintsig; } 477 const FbTk::Subject &hintSig() const { return m_hintsig; }
426 FbTk::Subject &workspaceSig() { return m_workspacesig; } 478 FbTk::Subject &workspaceSig() { return m_workspacesig; }
427 const FbTk::Subject &workspaceSig() const { return m_workspacesig; } 479 const FbTk::Subject &workspaceSig() const { return m_workspacesig; }
428 FbTk::Subject &dieSig() { return m_diesig; }
429 const FbTk::Subject &dieSig() const { return m_diesig; }
430 FbTk::Subject &focusSig() { return m_focussig; }
431 FbTk::Subject &titleSig() { return m_titlesig; }
432 FbTk::Subject &attentionSig() { return m_attentionsig; }
433 /** @} */ // end group signals 480 /** @} */ // end group signals
434 481
435 void reconfigTheme(); 482 void reconfigTheme();
@@ -464,9 +511,7 @@ private:
464 /// gets title string from client window and updates frame's title 511 /// gets title string from client window and updates frame's title
465 void updateTitleFromClient(WinClient &client); 512 void updateTitleFromClient(WinClient &client);
466 /// gets icon name from client window 513 /// gets icon name from client window
467 void updateIconNameFromClient(WinClient &client);
468 void updateMWMHintsFromClient(WinClient &client); 514 void updateMWMHintsFromClient(WinClient &client);
469 void updateBlackboxHintsFromClient(const WinClient &client);
470 void updateRememberStateFromClient(WinClient &client); 515 void updateRememberStateFromClient(WinClient &client);
471 void saveBlackboxAttribs(); 516 void saveBlackboxAttribs();
472 void associateClientWindow(bool use_attrs = false, int x = 0, int y = 0, unsigned int width = 1, unsigned int height = 1, int gravity = ForgetGravity, unsigned int client_bw = 0); 517 void associateClientWindow(bool use_attrs = false, int x = 0, int y = 0, unsigned int width = 1, unsigned int height = 1, int gravity = ForgetGravity, unsigned int client_bw = 0);
@@ -479,7 +524,7 @@ private:
479 void fixsize(int *user_w = 0, int *user_h = 0, bool maximizing = false); 524 void fixsize(int *user_w = 0, int *user_h = 0, bool maximizing = false);
480 void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height); 525 void moveResizeClient(WinClient &client, int x, int y, unsigned int width, unsigned int height);
481 /// sends configurenotify to all clients 526 /// sends configurenotify to all clients
482 void sendConfigureNotify(bool send_to_netizens = true); 527 void sendConfigureNotify();
483 528
484 static void grabPointer(Window grab_window, 529 static void grabPointer(Window grab_window,
485 Bool owner_events, 530 Bool owner_events,
@@ -496,10 +541,7 @@ private:
496 WinSubject m_hintsig, 541 WinSubject m_hintsig,
497 m_statesig, 542 m_statesig,
498 m_layersig, 543 m_layersig,
499 m_workspacesig, 544 m_workspacesig;
500 m_diesig, m_focussig,
501 m_titlesig,
502 m_attentionsig;
503 545
504 class ThemeListener: public FbTk::Observer { 546 class ThemeListener: public FbTk::Observer {
505 public: 547 public:
@@ -516,14 +558,12 @@ private:
516 558
517 // Window states 559 // Window states
518 bool moving, resizing, shaded, iconic, 560 bool moving, resizing, shaded, iconic,
519 focused, stuck, m_initialized, fullscreen; 561 stuck, m_initialized, fullscreen;
520 562
521 int maximized; 563 int maximized;
522 564
523 WinClient *m_attaching_tab; 565 WinClient *m_attaching_tab;
524 566
525 bool m_attention_state;
526 BScreen &m_screen; /// screen on which this window exist
527 FbTk::Timer m_timer; 567 FbTk::Timer m_timer;
528 Display *display; /// display connection 568 Display *display; /// display connection
529 BlackboxAttributes m_blackbox_attrib; 569 BlackboxAttributes m_blackbox_attrib;
@@ -533,6 +573,8 @@ private:
533 int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving 573 int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving
534 unsigned int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" 574 unsigned int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window"
535 575
576 timeval m_last_keypress_time;
577
536 unsigned int m_workspace_number; 578 unsigned int m_workspace_number;
537 unsigned long m_current_state; // NormalState | IconicState | Withdrawn 579 unsigned long m_current_state; // NormalState | IconicState | Withdrawn
538 580
@@ -540,7 +582,7 @@ private:
540 582
541 ClientList m_clientlist; 583 ClientList m_clientlist;
542 WinClient *m_client; ///< current client 584 WinClient *m_client; ///< current client
543 typedef std::map<WinClient *, FbTk::TextButton *> Client2ButtonMap; 585 typedef std::map<WinClient *, IconButton *> Client2ButtonMap;
544 Client2ButtonMap m_labelbuttons; 586 Client2ButtonMap m_labelbuttons;
545 587
546 // just temporary solution 588 // just temporary solution
@@ -564,14 +606,14 @@ private:
564 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state 606 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state
565 int m_last_button_x, ///< last known x position of the mouse button 607 int m_last_button_x, ///< last known x position of the mouse button
566 m_last_button_y; ///< last known y position of the mouse button 608 m_last_button_y; ///< last known y position of the mouse button
567 FbWinFrame m_frame; 609 FbWinFrame m_frame; ///< the actuall window frame
568 610
569 int m_layernum; 611 int m_layernum;
570 int m_old_layernum; 612 int m_old_layernum;
571 613
572 FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window") 614 FbTk::FbWindow &m_parent; ///< window on which we draw move/resize rectangle (the "root window")
573 615
574 ResizeDirection m_resize_corner; 616 ResizeDirection m_resize_corner; //< the current resize corner used while resizing
575 617
576 static int s_num_grabs; ///< number of XGrabPointer's 618 static int s_num_grabs; ///< number of XGrabPointer's
577}; 619};