aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-02-22 15:10:43 (GMT)
committerrathnor <rathnor>2003-02-22 15:10:43 (GMT)
commitcc2f023a22db212b4097d7756379bb6b9e866b11 (patch)
tree33cd8f790e760965960d54406250dd73ab0aec93 /src/Window.cc
parent7cf8c0863e6dd07e1023207964605de12f7d0a3c (diff)
downloadfluxbox-cc2f023a22db212b4097d7756379bb6b9e866b11.zip
fluxbox-cc2f023a22db212b4097d7756379bb6b9e866b11.tar.bz2
fix focus models for new event handler and Resource setup
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc66
1 files changed, 60 insertions, 6 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 73afefc..ec0d7f3 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.122 2003/02/20 23:17:36 fluxgen Exp $ 25// $Id: Window.cc,v 1.123 2003/02/22 15:10:43 rathnor Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -93,6 +93,26 @@ void grabButton(Display *display, unsigned int button,
93 93
94} 94}
95 95
96// X event scanner for enter/leave notifies - adapted from twm
97typedef struct scanargs {
98 Window w;
99 Bool leave, inferior, enter;
100} scanargs;
101
102// look for valid enter or leave events (that may invalidate the earlier one we are interested in)
103static Bool queueScanner(Display *, XEvent *e, char *args) {
104 if ((e->type == LeaveNotify) &&
105 (e->xcrossing.window == ((scanargs *) args)->w) &&
106 (e->xcrossing.mode == NotifyNormal)) {
107 ((scanargs *) args)->leave = True;
108 ((scanargs *) args)->inferior = (e->xcrossing.detail == NotifyInferior);
109 } else if ((e->type == EnterNotify) &&
110 (e->xcrossing.mode == NotifyUngrab))
111 ((scanargs *) args)->enter = True;
112
113 return False;
114}
115
96/// raise window and do the same for each transient it holds 116/// raise window and do the same for each transient it holds
97void raiseFluxboxWindow(FluxboxWindow &win) { 117void raiseFluxboxWindow(FluxboxWindow &win) {
98 118
@@ -2066,12 +2086,12 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2066 m_frame.x() < int(me.x_root - button_grab_x - screen->getBorderWidth())) { 2086 m_frame.x() < int(me.x_root - button_grab_x - screen->getBorderWidth())) {
2067 //warp right 2087 //warp right
2068 new_id = (cur_id + 1) % screen->getCount(); 2088 new_id = (cur_id + 1) % screen->getCount();
2069 dx = - me.x_root; 2089 dx = - me.x_root; // move mouse back to x=0
2070 } else if (me.x_root <= warpPad && 2090 } else if (me.x_root <= warpPad &&
2071 m_frame.x() > int(me.x_root - button_grab_x - screen->getBorderWidth())) { 2091 m_frame.x() > int(me.x_root - button_grab_x - screen->getBorderWidth())) {
2072 //warp left 2092 //warp left
2073 new_id = (cur_id - 1 + screen->getCount()) % screen->getCount(); 2093 new_id = (cur_id - 1 + screen->getCount()) % screen->getCount();
2074 dx = screen->getWidth() - me.x_root-1; 2094 dx = screen->getWidth() - me.x_root-1; // move mouse to screen width - 1
2075 } 2095 }
2076 2096
2077 if (new_id != cur_id) { 2097 if (new_id != cur_id) {
@@ -2081,8 +2101,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2081 2101
2082 last_resize_x = me.x_root + dx; 2102 last_resize_x = me.x_root + dx;
2083 2103
2084 dx += m_frame.x(); // for window in correct position 2104 // change dx to be relative to window rather than motion event
2085 2105 dx += m_frame.x();
2086 } 2106 }
2087 } 2107 }
2088 2108
@@ -2098,7 +2118,6 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2098 last_move_x = dx; 2118 last_move_x = dx;
2099 last_move_y = dy; 2119 last_move_y = dy;
2100 } else { 2120 } else {
2101
2102 moveResize(dx, dy, m_frame.width(), m_frame.height()); 2121 moveResize(dx, dy, m_frame.width(), m_frame.height());
2103 } 2122 }
2104 2123
@@ -2154,6 +2173,41 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2154 2173
2155} 2174}
2156 2175
2176void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) {
2177
2178 // ignore grab activates, or if we're not visible
2179 if (ev.mode == NotifyGrab ||
2180 !isVisible()) {
2181 return;
2182 }
2183
2184 if (ev.window == getFrameWindow() ||
2185 (!getFrameWindow() && ev.window == client.window)) {
2186 if ((screen->isSloppyFocus() || screen->isSemiSloppyFocus())
2187 && !isFocused()) {
2188 Fluxbox::instance()->grab();
2189
2190 // check that there aren't any subsequent leave notify events in the
2191 // X event queue
2192 XEvent dummy;
2193 scanargs sa;
2194 sa.w = ev.window;
2195 sa.enter = sa.leave = False;
2196 XCheckIfEvent(display, &dummy, queueScanner, (char *) &sa);
2197
2198 if ((!sa.leave || sa.inferior) && setInputFocus())
2199 installColormap(True);
2200
2201 Fluxbox::instance()->ungrab();
2202 }
2203 }
2204}
2205
2206void FluxboxWindow::leaveNotifyEvent(XCrossingEvent &ev) {
2207 if (ev.window == getFrameWindow())
2208 installColormap(False);
2209}
2210
2157// TODO: functions should not be affected by decoration 2211// TODO: functions should not be affected by decoration
2158void FluxboxWindow::setDecoration(Decoration decoration) { 2212void FluxboxWindow::setDecoration(Decoration decoration) {
2159 switch (decoration) { 2213 switch (decoration) {