aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc165
1 files changed, 64 insertions, 101 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 0fb674c..a76beff 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -44,6 +44,7 @@
44#include "IconButton.hh" 44#include "IconButton.hh"
45#include "ScreenPlacement.hh" 45#include "ScreenPlacement.hh"
46#include "RectangleUtil.hh" 46#include "RectangleUtil.hh"
47#include "Debug.hh"
47 48
48#include "FbTk/StringUtil.hh" 49#include "FbTk/StringUtil.hh"
49#include "FbTk/Compose.hh" 50#include "FbTk/Compose.hh"
@@ -87,7 +88,6 @@
87#include <functional> 88#include <functional>
88#include <algorithm> 89#include <algorithm>
89 90
90using std::cerr;
91using std::endl; 91using std::endl;
92using std::string; 92using std::string;
93using std::vector; 93using std::vector;
@@ -96,13 +96,10 @@ using std::mem_fun;
96using std::equal_to; 96using std::equal_to;
97using std::max; 97using std::max;
98using std::swap; 98using std::swap;
99
100using namespace FbTk;
101
102#ifdef DEBUG
103using std::dec; 99using std::dec;
104using std::hex; 100using std::hex;
105#endif // DEBUG 101
102using namespace FbTk;
106 103
107namespace { 104namespace {
108 105
@@ -332,13 +329,11 @@ FluxboxWindow::~FluxboxWindow() {
332 } 329 }
333 330
334 331
335#ifdef DEBUG
336 const char* title = m_client ? m_client->title().c_str() : "" ; 332 const char* title = m_client ? m_client->title().c_str() : "" ;
337 cerr<<__FILE__<<"("<<__LINE__<<"): starting ~FluxboxWindow("<<this<<","<<title<<")"<<endl; 333 fbdbg<<"starting ~FluxboxWindow("<<this<<","<<title<<")"<<endl;
338 cerr<<__FILE__<<"("<<__LINE__<<"): num clients = "<<numClients()<<endl; 334 fbdbg<<"num clients = "<<numClients()<<endl;
339 cerr<<__FILE__<<"("<<__LINE__<<"): curr client = "<<m_client<<endl; 335 fbdbg<<"curr client = "<<m_client<<endl;
340 cerr<<__FILE__<<"("<<__LINE__<<"): m_labelbuttons.size = "<<m_labelbuttons.size()<<endl; 336 fbdbg<<"m_labelbuttons.size = "<<m_labelbuttons.size()<<endl;
341#endif // DEBUG
342 337
343 if (moving) 338 if (moving)
344 stopMoving(true); 339 stopMoving(true);
@@ -368,7 +363,7 @@ FluxboxWindow::~FluxboxWindow() {
368 m_client = 0; 363 m_client = 0;
369 364
370 if (m_clientlist.size() > 1) { 365 if (m_clientlist.size() > 1) {
371 cerr<<__FILE__<<"(~FluxboxWindow()) WARNING! clientlist > 1"<<endl; 366 fbdbg<<"(~FluxboxWindow()) WARNING! clientlist > 1"<<endl;
372 while (!m_clientlist.empty()) { 367 while (!m_clientlist.empty()) {
373 detachClient(*m_clientlist.back()); 368 detachClient(*m_clientlist.back());
374 } 369 }
@@ -377,9 +372,8 @@ FluxboxWindow::~FluxboxWindow() {
377 if (!screen().isShuttingdown()) 372 if (!screen().isShuttingdown())
378 screen().focusControl().removeWindow(*this); 373 screen().focusControl().removeWindow(*this);
379 374
380#ifdef DEBUG 375
381 cerr<<__FILE__<<"("<<__LINE__<<"): ~FluxboxWindow("<<this<<")"<<endl; 376 fbdbg<<"~FluxboxWindow("<<this<<")"<<endl;
382#endif // DEBUG
383} 377}
384 378
385 379
@@ -406,11 +400,9 @@ void FluxboxWindow::init() {
406 //!! TODO init of client should be better 400 //!! TODO init of client should be better
407 // we don't want to duplicate code here and in attachClient 401 // we don't want to duplicate code here and in attachClient
408 m_clientlist.push_back(m_client); 402 m_clientlist.push_back(m_client);
409#ifdef DEBUG
410 cerr<<__FILE__<<": FluxboxWindow::init(this="<<this<<", client="<<hex<<
411 m_client->window()<<", frame = "<<frame().window().window()<<dec<<")"<<endl;
412 403
413#endif // DEBUG 404 fbdbg<<"FluxboxWindow::init(this="<<this<<", client="<<hex<<
405 m_client->window()<<", frame = "<<frame().window().window()<<dec<<")"<<endl;
414 406
415 Fluxbox &fluxbox = *Fluxbox::instance(); 407 Fluxbox &fluxbox = *Fluxbox::instance();
416 408
@@ -495,14 +487,13 @@ void FluxboxWindow::init() {
495 } else // if no parent then set default layer 487 } else // if no parent then set default layer
496 moveToLayer(m_state.layernum, m_state.layernum != ::Layer::NORMAL); 488 moveToLayer(m_state.layernum, m_state.layernum != ::Layer::NORMAL);
497 489
498#ifdef DEBUG 490 fbdbg<<"FluxboxWindow::init("<<title()<<") transientFor: "<<
499 cerr<<"FluxboxWindow::init("<<title()<<") transientFor: "<< 491 m_client->transientFor()<<endl;
500 m_client->transientFor()<<endl;
501 if (m_client->transientFor() && m_client->transientFor()->fbwindow()) { 492 if (m_client->transientFor() && m_client->transientFor()->fbwindow()) {
502 cerr<<"FluxboxWindow::init("<<title()<<") transientFor->title(): "<< 493 fbdbg<<"FluxboxWindow::init("<<title()<<") transientFor->title(): "<<
503 m_client->transientFor()->fbwindow()->title()<<endl; 494 m_client->transientFor()->fbwindow()->title()<<endl;
504 } 495 }
505#endif // DEBUG 496
506 497
507 unsigned int real_width = frame().width(), real_height = frame().height(); 498 unsigned int real_width = frame().width(), real_height = frame().height();
508 frame().applySizeHints(real_width, real_height); 499 frame().applySizeHints(real_width, real_height);
@@ -699,9 +690,9 @@ bool FluxboxWindow::removeClient(WinClient &client) {
699 if (client.fbwindow() != this || numClients() == 0) 690 if (client.fbwindow() != this || numClients() == 0)
700 return false; 691 return false;
701 692
702#ifdef DEBUG 693
703 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl; 694 fbdbg<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl;
704#endif // DEBUG 695
705 696
706 // if it is our active client, deal with it... 697 // if it is our active client, deal with it...
707 if (m_client == &client) { 698 if (m_client == &client) {
@@ -735,9 +726,7 @@ bool FluxboxWindow::removeClient(WinClient &client) {
735 frame().reconfigure(); 726 frame().reconfigure();
736 updateClientLeftWindow(); 727 updateClientLeftWindow();
737 728
738#ifdef DEBUG 729 fbdbg<<"("<<__FUNCTION__<<")["<<this<<"] numClients = "<<numClients()<<endl;
739 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"] numClients = "<<numClients()<<endl;
740#endif // DEBUG
741 730
742 return true; 731 return true;
743} 732}
@@ -995,10 +984,8 @@ bool FluxboxWindow::setCurrentClient(WinClient &client, bool setinput) {
995 old->focusSig().notify(); 984 old->focusSig().notify();
996 } 985 }
997 986
998#ifdef DEBUG 987 fbdbg<<"FluxboxWindow::"<<__FUNCTION__<<": labelbutton[client] = "<<
999 cerr<<"FluxboxWindow::"<<__FUNCTION__<<": labelbutton[client] = "<<
1000 button<<endl; 988 button<<endl;
1001#endif // DEBUG
1002 989
1003 if (old != &client) { 990 if (old != &client) {
1004 titleSig().notify(); 991 titleSig().notify();
@@ -1300,23 +1287,19 @@ bool FluxboxWindow::focus() {
1300 // FocusControl::revertFocus will return before FocusIn events arrive 1287 // FocusControl::revertFocus will return before FocusIn events arrive
1301 m_screen.focusControl().setScreenFocusedWindow(*m_client); 1288 m_screen.focusControl().setScreenFocusedWindow(*m_client);
1302 1289
1303#ifdef DEBUG 1290
1304 cerr<<"FluxboxWindow::"<<__FUNCTION__<<" isModal() = "<<m_client->isModal()<<endl; 1291 fbdbg<<"FluxboxWindow::"<<__FUNCTION__<<" isModal() = "<<m_client->isModal()<<endl;
1305 cerr<<"FluxboxWindow::"<<__FUNCTION__<<" transient size = "<<m_client->transients.size()<<endl; 1292 fbdbg<<"FluxboxWindow::"<<__FUNCTION__<<" transient size = "<<m_client->transients.size()<<endl;
1306#endif // DEBUG 1293
1307 if (!m_client->transients.empty() && m_client->isModal()) { 1294 if (!m_client->transients.empty() && m_client->isModal()) {
1308#ifdef DEBUG 1295 fbdbg<<__FUNCTION__<<": isModal and have transients client = "<<
1309 cerr<<__FUNCTION__<<": isModal and have transients client = "<<
1310 hex<<m_client->window()<<dec<<endl; 1296 hex<<m_client->window()<<dec<<endl;
1311 cerr<<__FUNCTION__<<": this = "<<this<<endl; 1297 fbdbg<<__FUNCTION__<<": this = "<<this<<endl;
1312#endif // DEBUG
1313 1298
1314 WinClient::TransientList::iterator it = m_client->transients.begin(); 1299 WinClient::TransientList::iterator it = m_client->transients.begin();
1315 WinClient::TransientList::iterator it_end = m_client->transients.end(); 1300 WinClient::TransientList::iterator it_end = m_client->transients.end();
1316 for (; it != it_end; ++it) { 1301 for (; it != it_end; ++it) {
1317#ifdef DEBUG 1302 fbdbg<<__FUNCTION__<<": transient 0x"<<(*it)<<endl;
1318 cerr<<__FUNCTION__<<": transient 0x"<<(*it)<<endl;
1319#endif // DEBUG
1320 if ((*it)->isStateModal()) 1303 if ((*it)->isStateModal())
1321 return (*it)->focus(); 1304 return (*it)->focus();
1322 } 1305 }
@@ -1330,9 +1313,8 @@ bool FluxboxWindow::focus() {
1330 1313
1331// don't hide the frame directly, use this function 1314// don't hide the frame directly, use this function
1332void FluxboxWindow::hide(bool interrupt_moving) { 1315void FluxboxWindow::hide(bool interrupt_moving) {
1333#ifdef DEBUG 1316 fbdbg<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl;
1334 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl; 1317
1335#endif // DEBUG
1336 // resizing always stops on hides 1318 // resizing always stops on hides
1337 if (resizing) 1319 if (resizing)
1338 stopResizing(true); 1320 stopResizing(true);
@@ -1555,9 +1537,7 @@ void FluxboxWindow::setWorkspace(int n) {
1555 1537
1556 // notify workspace change 1538 // notify workspace change
1557 if (m_initialized && old_wkspc != m_workspace_number) { 1539 if (m_initialized && old_wkspc != m_workspace_number) {
1558#ifdef DEBUG 1540 fbdbg<<this<<" notify workspace signal"<<endl;
1559 cerr<<this<<" notify workspace signal"<<endl;
1560#endif // DEBUG
1561 m_workspacesig.notify(); 1541 m_workspacesig.notify();
1562 } 1542 }
1563} 1543}
@@ -1566,10 +1546,7 @@ void FluxboxWindow::setLayerNum(int layernum) {
1566 m_state.layernum = layernum; 1546 m_state.layernum = layernum;
1567 1547
1568 if (m_initialized) { 1548 if (m_initialized) {
1569#ifdef DEBUG 1549 fbdbg<<this<<" notify layer signal"<<endl;
1570 cerr<<this<<" notify layer signal"<<endl;
1571#endif // DEBUG
1572
1573 m_layersig.notify(); 1550 m_layersig.notify();
1574 } 1551 }
1575} 1552}
@@ -1643,9 +1620,9 @@ void FluxboxWindow::setIconic(bool val) {
1643void FluxboxWindow::raise() { 1620void FluxboxWindow::raise() {
1644 if (isIconic()) 1621 if (isIconic())
1645 return; 1622 return;
1646#ifdef DEBUG 1623
1647 cerr<<"FluxboxWindow("<<title()<<")::raise()[layer="<<layerNum()<<"]"<<endl; 1624 fbdbg<<"FluxboxWindow("<<title()<<")::raise()[layer="<<layerNum()<<"]"<<endl;
1648#endif // DEBUG 1625
1649 // get root window 1626 // get root window
1650 WinClient *client = getRootTransientFor(m_client); 1627 WinClient *client = getRootTransientFor(m_client);
1651 1628
@@ -1671,9 +1648,8 @@ void FluxboxWindow::raise() {
1671void FluxboxWindow::lower() { 1648void FluxboxWindow::lower() {
1672 if (isIconic()) 1649 if (isIconic())
1673 return; 1650 return;
1674#ifdef DEBUG 1651
1675 cerr<<"FluxboxWindow("<<title()<<")::lower()"<<endl; 1652 fbdbg<<"FluxboxWindow("<<title()<<")::lower()"<<endl;
1676#endif // DEBUG
1677 1653
1678 /* Ignore all EnterNotify events until the pointer actually moves */ 1654 /* Ignore all EnterNotify events until the pointer actually moves */
1679 screen().focusControl().ignoreAtPointer(); 1655 screen().focusControl().ignoreAtPointer();
@@ -1703,9 +1679,8 @@ void FluxboxWindow::changeLayer(int diff) {
1703} 1679}
1704 1680
1705void FluxboxWindow::moveToLayer(int layernum, bool force) { 1681void FluxboxWindow::moveToLayer(int layernum, bool force) {
1706#ifdef DEBUG 1682
1707 cerr<<"FluxboxWindow("<<title()<<")::moveToLayer("<<layernum<<")"<<endl; 1683 fbdbg<<"FluxboxWindow("<<title()<<")::moveToLayer("<<layernum<<")"<<endl;
1708#endif // DEBUG
1709 1684
1710 // don't let it set its layer into menu area 1685 // don't let it set its layer into menu area
1711 if (layernum <= ::Layer::MENU) 1686 if (layernum <= ::Layer::MENU)
@@ -1769,9 +1744,9 @@ void FluxboxWindow::setFocusFlag(bool focus) {
1769 1744
1770 bool was_focused = isFocused(); 1745 bool was_focused = isFocused();
1771 m_focused = focus; 1746 m_focused = focus;
1772#ifdef DEBUG 1747
1773 cerr<<"FluxboxWindow("<<title()<<")::setFocusFlag("<<focus<<")"<<endl; 1748 fbdbg<<"FluxboxWindow("<<title()<<")::setFocusFlag("<<focus<<")"<<endl;
1774#endif // DEBUG 1749
1775 1750
1776 installColormap(focus); 1751 installColormap(focus);
1777 1752
@@ -1961,9 +1936,7 @@ void FluxboxWindow::popupMenu() {
1961void FluxboxWindow::handleEvent(XEvent &event) { 1936void FluxboxWindow::handleEvent(XEvent &event) {
1962 switch (event.type) { 1937 switch (event.type) {
1963 case ConfigureRequest: 1938 case ConfigureRequest:
1964#ifdef DEBUG 1939 fbdbg<<"ConfigureRequest("<<title()<<")"<<endl;
1965 cerr<<"ConfigureRequest("<<title()<<")"<<endl;
1966#endif // DEBUG
1967 1940
1968 configureRequestEvent(event.xconfigurerequest); 1941 configureRequestEvent(event.xconfigurerequest);
1969 break; 1942 break;
@@ -1978,7 +1951,7 @@ void FluxboxWindow::handleEvent(XEvent &event) {
1978 1951
1979#ifdef DEBUG 1952#ifdef DEBUG
1980 char *atomname = XGetAtomName(display, event.xproperty.atom); 1953 char *atomname = XGetAtomName(display, event.xproperty.atom);
1981 cerr<<"PropertyNotify("<<title()<<"), property = "<<atomname<<endl; 1954 fbdbg<<"PropertyNotify("<<title()<<"), property = "<<atomname<<endl;
1982 if (atomname) 1955 if (atomname)
1983 XFree(atomname); 1956 XFree(atomname);
1984#endif // DEBUG 1957#endif // DEBUG
@@ -1993,9 +1966,9 @@ void FluxboxWindow::handleEvent(XEvent &event) {
1993#ifdef SHAPE 1966#ifdef SHAPE
1994 if (Fluxbox::instance()->haveShape() && 1967 if (Fluxbox::instance()->haveShape() &&
1995 event.type == Fluxbox::instance()->shapeEventbase() + ShapeNotify) { 1968 event.type == Fluxbox::instance()->shapeEventbase() + ShapeNotify) {
1996#ifdef DEBUG 1969
1997 cerr<<"ShapeNotify("<<title()<<")"<<endl; 1970 fbdbg<<"ShapeNotify("<<title()<<")"<<endl;
1998#endif // DEBUG 1971
1999 XShapeEvent *shape_event = (XShapeEvent *)&event; 1972 XShapeEvent *shape_event = (XShapeEvent *)&event;
2000 1973
2001 if (shape_event->shaped) 1974 if (shape_event->shaped)
@@ -2017,9 +1990,7 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) {
2017 // we're only concerned about client window event 1990 // we're only concerned about client window event
2018 WinClient *client = findClient(re.window); 1991 WinClient *client = findClient(re.window);
2019 if (client == 0) { 1992 if (client == 0) {
2020#ifdef DEBUG 1993 fbdbg<<"("<<__FUNCTION__<<"): Can't find client!"<<endl;
2021 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Can't find client!"<<endl;
2022#endif // DEBUG
2023 return; 1994 return;
2024 } 1995 }
2025 1996
@@ -2089,10 +2060,9 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) {
2089 if (client == 0) 2060 if (client == 0)
2090 return; 2061 return;
2091 2062
2092#ifdef DEBUG 2063
2093 cerr<<__FILE__<<"("<<__FUNCTION__<<"): 0x"<<hex<<client->window()<<dec<<endl; 2064 fbdbg<<"("<<__FUNCTION__<<"): 0x"<<hex<<client->window()<<dec<<endl;
2094 cerr<<__FILE__<<"("<<__FUNCTION__<<"): title="<<client->title()<<endl; 2065 fbdbg<<"("<<__FUNCTION__<<"): title="<<client->title()<<endl;
2095#endif // DEBUG
2096 2066
2097 restore(client, false); 2067 restore(client, false);
2098 2068
@@ -2105,9 +2075,7 @@ void FluxboxWindow::unmapNotifyEvent(XUnmapEvent &ue) {
2105*/ 2075*/
2106void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) { 2076void FluxboxWindow::destroyNotifyEvent(XDestroyWindowEvent &de) {
2107 if (de.window == m_client->window()) { 2077 if (de.window == m_client->window()) {
2108#ifdef DEBUG 2078 fbdbg<<"DestroyNotifyEvent this="<<this<<" title = "<<title()<<endl;
2109 cerr<<__FILE__<<"("<<__LINE__<<"): DestroyNotifyEvent this="<<this<<" title = "<<title()<<endl;
2110#endif // DEBUG
2111 delete m_client; 2079 delete m_client;
2112 if (numClients() == 0) 2080 if (numClients() == 0)
2113 delete this; 2081 delete this;
@@ -2149,9 +2117,7 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) {
2149 break; 2117 break;
2150 2118
2151 case XA_WM_NORMAL_HINTS: { 2119 case XA_WM_NORMAL_HINTS: {
2152#ifdef DEBUG 2120 fbdbg<<"XA_WM_NORMAL_HINTS("<<title()<<")"<<endl;
2153 cerr<<"XA_WM_NORMAL_HINTS("<<title()<<")"<<endl;
2154#endif // DEBUG
2155 unsigned int old_max_width = client.maxWidth(); 2121 unsigned int old_max_width = client.maxWidth();
2156 unsigned int old_min_width = client.minWidth(); 2122 unsigned int old_min_width = client.minWidth();
2157 unsigned int old_min_height = client.minHeight(); 2123 unsigned int old_min_height = client.minHeight();
@@ -2396,9 +2362,8 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
2396 frame().tabcontainer().window() == be.window) { 2362 frame().tabcontainer().window() == be.window) {
2397 if (screen().clickRaises()) 2363 if (screen().clickRaises())
2398 raise(); 2364 raise();
2399#ifdef DEBUG 2365
2400 cerr<<"FluxboxWindow::buttonPressEvent: AllowEvent"<<endl; 2366 fbdbg<<"FluxboxWindow::buttonPressEvent: AllowEvent"<<endl;
2401#endif // DEBUG
2402 2367
2403 XAllowEvents(display, ReplayPointer, be.time); 2368 XAllowEvents(display, ReplayPointer, be.time);
2404 2369
@@ -3317,10 +3282,9 @@ void FluxboxWindow::restore(WinClient *client, bool remap) {
3317 XEvent xev; 3282 XEvent xev;
3318 if (! XCheckTypedWindowEvent(display, client->window(), ReparentNotify, 3283 if (! XCheckTypedWindowEvent(display, client->window(), ReparentNotify,
3319 &xev)) { 3284 &xev)) {
3320#ifdef DEBUG
3321 cerr<<"FluxboxWindow::restore: reparent 0x"<<hex<<client->window()<<dec<<" to root"<<endl;
3322 3285
3323#endif // DEBUG 3286 fbdbg<<"FluxboxWindow::restore: reparent 0x"<<hex<<client->window()<<dec<<" to root"<<endl;
3287
3324 // reparent to root window 3288 // reparent to root window
3325 client->reparent(screen().rootWindow(), wx, wy, false); 3289 client->reparent(screen().rootWindow(), wx, wy, false);
3326 3290
@@ -3336,10 +3300,9 @@ void FluxboxWindow::restore(WinClient *client, bool remap) {
3336 delete client; 3300 delete client;
3337 3301
3338 3302
3339#ifdef DEBUG 3303 fbdbg<<"FluxboxWindow::restore: remap = "<<remap<<endl;
3340 cerr<<"FluxboxWindow::restore: remap = "<<remap<<endl; 3304 fbdbg<<"("<<__FUNCTION__<<"): numClients() = "<<numClients()<<endl;
3341 cerr<<__FILE__<<"("<<__FUNCTION__<<"): numClients() = "<<numClients()<<endl; 3305
3342#endif // DEBUG
3343 if (numClients() == 0) 3306 if (numClients() == 0)
3344 delete this; 3307 delete this;
3345 3308
@@ -3348,9 +3311,9 @@ void FluxboxWindow::restore(WinClient *client, bool remap) {
3348void FluxboxWindow::restore(bool remap) { 3311void FluxboxWindow::restore(bool remap) {
3349 if (numClients() == 0) 3312 if (numClients() == 0)
3350 return; 3313 return;
3351#ifdef DEBUG 3314
3352 cerr<<"restore("<<remap<<")"<<endl; 3315 fbdbg<<"restore("<<remap<<")"<<endl;
3353#endif // DEBUG 3316
3354 while (!clientList().empty()) { 3317 while (!clientList().empty()) {
3355 restore(clientList().back(), remap); 3318 restore(clientList().back(), remap);
3356 // deleting winClient removes it from the clientList 3319 // deleting winClient removes it from the clientList