aboutsummaryrefslogtreecommitdiff
path: root/src/UnderMousePlacement.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2006-02-19 11:11:22 (GMT)
committerfluxgen <fluxgen>2006-02-19 11:11:22 (GMT)
commitb772fd969f039f7683d2bd666b7573eeb9d468e3 (patch)
tree3d1ae639f5f314f9f55005aa3dad912524afa181 /src/UnderMousePlacement.cc
parentd099e7673a51f76b2e6f54484152901288f90ae2 (diff)
downloadfluxbox-b772fd969f039f7683d2bd666b7573eeb9d468e3.zip
fluxbox-b772fd969f039f7683d2bd666b7573eeb9d468e3.tar.bz2
moved placement strategies to different PlacementStrategy classes
Diffstat (limited to 'src/UnderMousePlacement.cc')
-rw-r--r--src/UnderMousePlacement.cc75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/UnderMousePlacement.cc b/src/UnderMousePlacement.cc
new file mode 100644
index 0000000..3e2bc41
--- /dev/null
+++ b/src/UnderMousePlacement.cc
@@ -0,0 +1,75 @@
1// UnderMousePlacement.cc
2// Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id$
23
24#include "UnderMousePlacement.hh"
25
26#include "FbTk/App.hh"
27#include "Screen.hh"
28#include "Window.hh"
29
30bool UnderMousePlacement::placeWindow(const std::vector<FluxboxWindow *> &list,
31 const FluxboxWindow &win,
32 int &place_x, int &place_y) {
33
34 int root_x, root_y, ignore_i;
35
36 unsigned int ignore_ui;
37
38 Window ignore_w;
39
40 XQueryPointer(FbTk::App::instance()->display(),
41 win.screen().rootWindow().window(), &ignore_w,
42 &ignore_w, &root_x, &root_y,
43 &ignore_i, &ignore_i, &ignore_ui);
44
45 // 2*border = border on each side of the screen
46 int win_w = win.width() + win.fbWindow().borderWidth()*2,
47 win_h = win.height() + win.fbWindow().borderWidth()*2;
48
49 int test_x = root_x - (win_w / 2);
50 int test_y = root_y - (win_h / 2);
51
52 // keep the window inside the screen
53 int head = (signed) win.screen().getCurrHead();
54 int head_left = (signed) win.screen().maxLeft(head);
55 int head_right = (signed) win.screen().maxRight(head);
56 int head_top = (signed) win.screen().maxTop(head);
57 int head_bot = (signed) win.screen().maxBottom(head);
58
59 if (test_x < head_left)
60 test_x = head_left;
61
62 if (test_x + win_w > head_right)
63 test_x = head_right - win_w;
64
65 if (test_y < head_top)
66 test_y = head_top;
67
68 if (test_y + win_h > head_bot)
69 test_y = head_bot - win_h;
70
71 place_x = test_x;
72 place_y = test_y;
73
74 return true;
75}