summaryrefslogtreecommitdiff
path: root/src/FocusControl.cc
diff options
context:
space:
mode:
authorJim Ramsay <i.am@jimramsay.com>2009-10-14 01:05:49 (GMT)
committerJim Ramsay <i.am@jimramsay.com>2009-10-14 01:05:49 (GMT)
commit839ea523164caecd8c779e60539b78c2a748a81f (patch)
tree0019d04f27a1a258bc7a900e3cf77b916dca6493 /src/FocusControl.cc
parent4d3aa646c1d1d1de4fdb31f938f6ea62fd5dd21e (diff)
parent8def80cec337a986b762cdbb5e2555c6da809353 (diff)
downloadfluxbox_lack-testing/argb.zip
fluxbox_lack-testing/argb.tar.bz2
Merge branch 'master' into argbtesting/argbargb
Conflicts: src/FbTk/FbWindow.cc
Diffstat (limited to 'src/FocusControl.cc')
-rw-r--r--src/FocusControl.cc89
1 files changed, 57 insertions, 32 deletions
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index 78752bb..bf79d3e 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -62,29 +62,30 @@ bool doSkipWindow(const Focusable &win, const ClientPattern *pat) {
62 return false; // else don't skip 62 return false; // else don't skip
63} 63}
64 64
65}; // end anonymous namespace 65} // end anonymous namespace
66 66
67FocusControl::FocusControl(BScreen &screen): 67FocusControl::FocusControl(BScreen &screen):
68 m_screen(screen), 68 m_screen(screen),
69 m_focus_model(screen.resourceManager(), 69 m_focus_model(screen.resourceManager(),
70 CLICKFOCUS, 70 CLICKFOCUS,
71 screen.name()+".focusModel", 71 screen.name()+".focusModel",
72 screen.altName()+".FocusModel"), 72 screen.altName()+".FocusModel"),
73 m_tab_focus_model(screen.resourceManager(), 73 m_tab_focus_model(screen.resourceManager(),
74 CLICKTABFOCUS, 74 CLICKTABFOCUS,
75 screen.name()+".tabFocusModel", 75 screen.name()+".tabFocusModel",
76 screen.altName()+".TabFocusModel"), 76 screen.altName()+".TabFocusModel"),
77 m_focus_new(screen.resourceManager(), true, 77 m_focus_new(screen.resourceManager(), true,
78 screen.name()+".focusNewWindows", 78 screen.name()+".focusNewWindows",
79 screen.altName()+".FocusNewWindows"), 79 screen.altName()+".FocusNewWindows"),
80 m_focused_list(screen), m_creation_order_list(screen), 80 m_focused_list(screen), m_creation_order_list(screen),
81 m_focused_win_list(screen), m_creation_order_win_list(screen), 81 m_focused_win_list(screen), m_creation_order_win_list(screen),
82 m_cycling_list(0), 82 m_cycling_list(0),
83 m_was_iconic(false), 83 m_was_iconic(false),
84 m_cycling_last(0) { 84 m_cycling_last(0),
85 m_ignore_mouse_x(-1), m_ignore_mouse_y(-1) {
85 86
86 m_cycling_window = m_focused_list.clientList().end(); 87 m_cycling_window = m_focused_list.clientList().end();
87 88
88} 89}
89 90
90void FocusControl::cycleFocus(const FocusableList &window_list, 91void FocusControl::cycleFocus(const FocusableList &window_list,
@@ -251,7 +252,7 @@ Focusable *FocusControl::lastFocusedWindow(int workspace) {
251 if (workspace < 0 || workspace >= (int) m_screen.numberOfWorkspaces()) 252 if (workspace < 0 || workspace >= (int) m_screen.numberOfWorkspaces())
252 return m_focused_list.clientList().front(); 253 return m_focused_list.clientList().front();
253 254
254 Focusables::iterator it = m_focused_list.clientList().begin(); 255 Focusables::iterator it = m_focused_list.clientList().begin();
255 Focusables::iterator it_end = m_focused_list.clientList().end(); 256 Focusables::iterator it_end = m_focused_list.clientList().end();
256 for (; it != it_end; ++it) { 257 for (; it != it_end; ++it) {
257 if ((*it)->fbwindow() && (*it)->acceptsFocus() && 258 if ((*it)->fbwindow() && (*it)->acceptsFocus() &&
@@ -306,11 +307,11 @@ void FocusControl::dirFocus(FluxboxWindow &win, FocusDir dir) {
306 307
307 // we scan through the list looking for the window that is "closest" 308 // we scan through the list looking for the window that is "closest"
308 // in the given direction 309 // in the given direction
309 310
310 FluxboxWindow *foundwin = 0; 311 FluxboxWindow *foundwin = 0;
311 int weight = 999999, exposure = 0; // extreme values 312 int weight = 999999, exposure = 0; // extreme values
312 int borderW = win.frame().window().borderWidth(), 313 int borderW = win.frame().window().borderWidth(),
313 top = win.y() + borderW, 314 top = win.y() + borderW,
314 bottom = win.y() + win.height() + borderW, 315 bottom = win.y() + win.height() + borderW,
315 left = win.x() + borderW, 316 left = win.x() + borderW,
316 right = win.x() + win.width() + borderW; 317 right = win.x() + win.width() + borderW;
@@ -318,17 +319,17 @@ void FocusControl::dirFocus(FluxboxWindow &win, FocusDir dir) {
318 Workspace::Windows &wins = m_screen.currentWorkspace()->windowList(); 319 Workspace::Windows &wins = m_screen.currentWorkspace()->windowList();
319 Workspace::Windows::iterator it = wins.begin(); 320 Workspace::Windows::iterator it = wins.begin();
320 for (; it != wins.end(); ++it) { 321 for (; it != wins.end(); ++it) {
321 if ((*it) == &win 322 if ((*it) == &win
322 || (*it)->isIconic() 323 || (*it)->isIconic()
323 || (*it)->isFocusHidden() 324 || (*it)->isFocusHidden()
324 || !(*it)->acceptsFocus()) 325 || !(*it)->acceptsFocus())
325 continue; // skip self 326 continue; // skip self
326 327
327 // we check things against an edge, and within the bounds (draw a picture) 328 // we check things against an edge, and within the bounds (draw a picture)
328 int edge=0, upper=0, lower=0, oedge=0, oupper=0, olower=0; 329 int edge=0, upper=0, lower=0, oedge=0, oupper=0, olower=0;
329 330
330 int otop = (*it)->y() + borderW, 331 int otop = (*it)->y() + borderW,
331 // 2 * border = border on each side 332 // 2 * border = border on each side
332 obottom = (*it)->y() + (*it)->height() + borderW, 333 obottom = (*it)->y() + (*it)->height() + borderW,
333 oleft = (*it)->x() + borderW, 334 oleft = (*it)->x() + borderW,
334 // 2 * border = border on each side 335 // 2 * border = border on each side
@@ -370,7 +371,7 @@ void FocusControl::dirFocus(FluxboxWindow &win, FocusDir dir) {
370 break; 371 break;
371 } 372 }
372 373
373 if (oedge < edge) 374 if (oedge < edge)
374 continue; // not in the right direction 375 continue; // not in the right direction
375 376
376 if (olower <= upper || oupper >= lower) { 377 if (olower <= upper || oupper >= lower) {
@@ -395,11 +396,33 @@ void FocusControl::dirFocus(FluxboxWindow &win, FocusDir dir) {
395 } // else not improvement 396 } // else not improvement
396 } 397 }
397 398
398 if (foundwin) 399 if (foundwin)
399 foundwin->focus(); 400 foundwin->focus();
400 401
401} 402}
402 403
404void FocusControl::ignoreAtPointer()
405{
406 int ignore_i;
407 unsigned int ignore_ui;
408 Window ignore_w;
409
410 XQueryPointer(m_screen.rootWindow().display(),
411 m_screen.rootWindow().window(), &ignore_w, &ignore_w,
412 &m_ignore_mouse_x, &m_ignore_mouse_y,
413 &ignore_i, &ignore_i, &ignore_ui);
414}
415
416void FocusControl::ignoreAt(int x, int y)
417{
418 m_ignore_mouse_x = x; m_ignore_mouse_y = y;
419}
420
421bool FocusControl::isIgnored(int x, int y)
422{
423 return x == m_ignore_mouse_x && y == m_ignore_mouse_y;
424}
425
403void FocusControl::removeClient(WinClient &client) { 426void FocusControl::removeClient(WinClient &client) {
404 if (client.screen().isShuttingdown()) 427 if (client.screen().isShuttingdown())
405 return; 428 return;
@@ -493,7 +516,7 @@ void FocusControl::revertFocus(BScreen &screen) {
493 * assumption: client has focus 516 * assumption: client has focus
494 */ 517 */
495void FocusControl::unfocusWindow(WinClient &client, 518void FocusControl::unfocusWindow(WinClient &client,
496 bool full_revert, 519 bool full_revert,
497 bool unfocus_frame) { 520 bool unfocus_frame) {
498 // go up the transient tree looking for a focusable window 521 // go up the transient tree looking for a focusable window
499 522
@@ -524,8 +547,8 @@ void FocusControl::setFocusedWindow(WinClient *client) {
524 return; 547 return;
525 548
526 BScreen *screen = client ? &client->screen() : 0; 549 BScreen *screen = client ? &client->screen() : 0;
527 BScreen *old_screen = 550 BScreen *old_screen =
528 FocusControl::focusedWindow() ? 551 FocusControl::focusedWindow() ?
529 &FocusControl::focusedWindow()->screen() : 0; 552 &FocusControl::focusedWindow()->screen() : 0;
530 553
531#ifdef DEBUG 554#ifdef DEBUG
@@ -544,10 +567,10 @@ void FocusControl::setFocusedWindow(WinClient *client) {
544 567
545 if (client && client->fbwindow() && !client->fbwindow()->isIconic()) { 568 if (client && client->fbwindow() && !client->fbwindow()->isIconic()) {
546 // screen should be ok 569 // screen should be ok
547 s_focused_fbwindow = client->fbwindow(); 570 s_focused_fbwindow = client->fbwindow();
548 s_focused_window = client; // update focused window 571 s_focused_window = client; // update focused window
549 s_expecting_focus = 0; 572 s_expecting_focus = 0;
550 s_focused_fbwindow->setCurrentClient(*client, 573 s_focused_fbwindow->setCurrentClient(*client,
551 false); // don't set inputfocus 574 false); // don't set inputfocus
552 s_focused_fbwindow->setFocusFlag(true); // set focus flag 575 s_focused_fbwindow->setFocusFlag(true); // set focus flag
553 576
@@ -581,9 +604,9 @@ std::string FbTk::Resource<FocusControl::FocusModel>::getString() const {
581template<> 604template<>
582void FbTk::Resource<FocusControl::FocusModel>:: 605void FbTk::Resource<FocusControl::FocusModel>::
583setFromString(char const *strval) { 606setFromString(char const *strval) {
584 if (strcasecmp(strval, "MouseFocus") == 0) 607 if (strcasecmp(strval, "MouseFocus") == 0)
585 m_value = FocusControl::MOUSEFOCUS; 608 m_value = FocusControl::MOUSEFOCUS;
586 else if (strcasecmp(strval, "ClickToFocus") == 0) 609 else if (strcasecmp(strval, "ClickToFocus") == 0)
587 m_value = FocusControl::CLICKFOCUS; 610 m_value = FocusControl::CLICKFOCUS;
588 else 611 else
589 setDefaultValue(); 612 setDefaultValue();
@@ -607,9 +630,11 @@ setFromString(char const *strval) {
607 630
608 if (strcasecmp(strval, "SloppyTabFocus") == 0 ) 631 if (strcasecmp(strval, "SloppyTabFocus") == 0 )
609 m_value = FocusControl::MOUSETABFOCUS; 632 m_value = FocusControl::MOUSETABFOCUS;
610 else if (strcasecmp(strval, "ClickToTabFocus") == 0) 633 else if (strcasecmp(strval, "ClickToTabFocus") == 0)
611 m_value = FocusControl::CLICKTABFOCUS; 634 m_value = FocusControl::CLICKTABFOCUS;
612 else 635 else
613 setDefaultValue(); 636 setDefaultValue();
614} 637}
638
615} // end namespace FbTk 639} // end namespace FbTk
640