aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Remember.cc12
-rw-r--r--src/Window.cc53
-rw-r--r--src/Window.hh2
3 files changed, 48 insertions, 19 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index c490e51..cfd0d61 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -319,15 +319,15 @@ Application * Remember::add(WinClient &winclient) {
319 Application *app = new Application(false); 319 Application *app = new Application(false);
320 320
321 // by default, we match against the WMClass of a window. 321 // by default, we match against the WMClass of a window.
322 string win_name = p->getProperty(ClientPattern::NAME, winclient); 322 string win_class = p->getProperty(ClientPattern::CLASS, winclient);
323 323
324 // replace special chars like ( ) and [ ] with \( \) and \[ \] 324 // replace special chars like ( ) and [ ] with \( \) and \[ \]
325 win_name = FbTk::StringUtil::replaceString(win_name, "(", "\\("); 325 win_class = FbTk::StringUtil::replaceString(win_class, "(", "\\(");
326 win_name = FbTk::StringUtil::replaceString(win_name, ")", "\\)"); 326 win_class = FbTk::StringUtil::replaceString(win_class, ")", "\\)");
327 win_name = FbTk::StringUtil::replaceString(win_name, "[", "\\["); 327 win_class = FbTk::StringUtil::replaceString(win_class, "[", "\\[");
328 win_name = FbTk::StringUtil::replaceString(win_name, "]", "\\]"); 328 win_class = FbTk::StringUtil::replaceString(win_class, "]", "\\]");
329 329
330 p->addTerm(win_name, ClientPattern::NAME); 330 p->addTerm(win_class, ClientPattern::CLASS);
331 m_clients[&winclient] = app; 331 m_clients[&winclient] = app;
332 p->addMatch(); 332 p->addMatch();
333 m_pats->push_back(make_pair(p, app)); 333 m_pats->push_back(make_pair(p, app));
diff --git a/src/Window.cc b/src/Window.cc
index eb2f398..74deb9b 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -246,6 +246,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
246 m_layersig(*this), 246 m_layersig(*this),
247 m_workspacesig(*this), 247 m_workspacesig(*this),
248 m_themelistener(*this), 248 m_themelistener(*this),
249 m_creation_time(0),
249 moving(false), resizing(false), shaded(false), iconic(false), 250 moving(false), resizing(false), shaded(false), iconic(false),
250 stuck(false), m_initialized(false), fullscreen(false), 251 stuck(false), m_initialized(false), fullscreen(false),
251 maximized(MAX_NONE), 252 maximized(MAX_NONE),
@@ -551,6 +552,10 @@ void FluxboxWindow::init() {
551 m_focused = false; 552 m_focused = false;
552 } 553 }
553 554
555 struct timeval now;
556 gettimeofday(&now, NULL);
557 m_creation_time = now.tv_sec;
558
554 sendConfigureNotify(); 559 sendConfigureNotify();
555 560
556 if (m_shaped) 561 if (m_shaped)
@@ -2567,23 +2572,49 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) {
2567 if (client == 0 || isIconic()) 2572 if (client == 0 || isIconic())
2568 return; 2573 return;
2569 2574
2570 int cx = frame().x(), cy = frame().y(), ignore = 0; 2575 int old_x = frame().x(), old_y = frame().y();
2571 unsigned int cw = frame().width(), ch = frame().height(); 2576 unsigned int old_w = frame().width();
2577 unsigned int old_h = frame().height() - frame().titlebarHeight()
2578 + frame().handleHeight();
2579 int cx = old_x, cy = old_y, ignore = 0;
2580 unsigned int cw = old_w, ch = old_h;
2572 2581
2573 // make sure the new width/height would be ok with all clients, or else they 2582 // make sure the new width/height would be ok with all clients, or else they
2574 // could try to resize the window back and forth 2583 // could try to resize the window back and forth
2575 if (client != m_client && 2584 if (cr.value_mask & CWWidth || cr.value_mask & CWHeight) {
2576 cr.value_mask & CWWidth && cr.value_mask & CWHeight) { 2585 int new_w = (cr.value_mask & CWWidth) ? cr.width : cw;
2586 int new_h = (cr.value_mask & CWHeight) ? cr.height : ch;
2577 ClientList::iterator it = clientList().begin(); 2587 ClientList::iterator it = clientList().begin();
2578 ClientList::iterator it_end = clientList().end(); 2588 ClientList::iterator it_end = clientList().end();
2579 for (; it != it_end; ++it) { 2589 for (; it != it_end; ++it) {
2580 if (!m_client->checkSizeHints(cr.width, cr.height)) { 2590 if (*it != client && !(*it)->checkSizeHints(new_w, new_h)) {
2581 sendConfigureNotify(); 2591 sendConfigureNotify();
2582 return; 2592 return;
2583 } 2593 }
2584 } 2594 }
2585 } 2595 }
2586 2596
2597#ifdef REMEMBER
2598 // don't let misbehaving clients (e.g. MPlayer) move/resize their windows
2599 // just after creation if the user has a saved position/size
2600 if (m_creation_time) {
2601 struct timeval now;
2602 gettimeofday(&now, NULL);
2603
2604 if (now.tv_sec > m_creation_time + 1)
2605 m_creation_time = 0;
2606 else {
2607 if (Remember::instance().isRemembered(*client,
2608 Remember::REM_DIMENSIONS))
2609 cr.value_mask = cr.value_mask & ~(CWWidth | CWHeight);
2610
2611 if (Remember::instance().isRemembered(*client,
2612 Remember::REM_POSITION))
2613 cr.value_mask = cr.value_mask & ~(CWX | CWY);
2614 }
2615 }
2616#endif // REMEMBER
2617
2587 if (cr.value_mask & CWBorderWidth) 2618 if (cr.value_mask & CWBorderWidth)
2588 client->old_bw = cr.border_width; 2619 client->old_bw = cr.border_width;
2589 2620
@@ -2603,24 +2634,20 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) {
2603 frame().setActiveGravity(client->gravity(), client->old_bw); 2634 frame().setActiveGravity(client->gravity(), client->old_bw);
2604 } 2635 }
2605 2636
2606 if (cr.value_mask & CWWidth) { 2637 if (cr.value_mask & CWWidth)
2607 cw = cr.width; 2638 cw = cr.width;
2608 // we must set this now, or else window grows when height not specified
2609 ch -= (frame().titlebarHeight() + frame().handleHeight());
2610 }
2611 2639
2612 if (cr.value_mask & CWHeight) 2640 if (cr.value_mask & CWHeight)
2613 ch = cr.height; 2641 ch = cr.height;
2614 2642
2615 // whether we should send ConfigureNotify to netizens 2643 // whether we should send ConfigureNotify to netizens
2616 // the request is for client window so we resize the frame to it first 2644 // the request is for client window so we resize the frame to it first
2617 // NOTE: this might not work correctly if client actually requests that size 2645 if (old_w != cw || old_h != ch) {
2618 if (frame().width() != cw || frame().height() != ch) { 2646 if (old_x != cx || old_y != cy)
2619 if (frame().x() != cx || frame().y() != cy)
2620 frame().moveResizeForClient(cx, cy, cw, ch); 2647 frame().moveResizeForClient(cx, cy, cw, ch);
2621 else 2648 else
2622 frame().resizeForClient(cw, ch); 2649 frame().resizeForClient(cw, ch);
2623 } else if (frame().x() != cx || frame().y() != cy) { 2650 } else if (old_x != cx || old_y != cy) {
2624 frame().move(cx, cy); 2651 frame().move(cx, cy);
2625 } 2652 }
2626 2653
diff --git a/src/Window.hh b/src/Window.hh
index fa5b305..cb32768 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -566,6 +566,8 @@ private:
566 }; 566 };
567 ThemeListener m_themelistener; 567 ThemeListener m_themelistener;
568 568
569 time_t m_creation_time;
570
569 // Window states 571 // Window states
570 bool moving, resizing, shaded, iconic, 572 bool moving, resizing, shaded, iconic,
571 stuck, m_initialized, fullscreen; 573 stuck, m_initialized, fullscreen;