From 906b341b177e5947710107eceb9ab2e4ee09528c Mon Sep 17 00:00:00 2001 From: Eleni Maria Stea Date: Tue, 26 Feb 2013 23:07:30 +0200 Subject: [PATCH] fixed focus: get_window_at_pos now searches back to front in root_window children --- Makefile | 4 ++-- src/window.cc | 1 + src/wm.cc | 17 ++++++++++------- src/wm.h | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index a894e52..4242187 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,8 @@ else endif CXX = g++ -CXXFLAGS = -pedantic -Wall $(dbg) $(opt) $(inc) $(def) -LDFLAGS = $(libs) +CXXFLAGS = -pedantic -Wall $(dbg) $(opt) $(inc) $(def) `freetype-config --cflags` +LDFLAGS = $(libs) `freetype-config --libs` $(bin): $(obj) $(CXX) -o $@ $(obj) $(LDFLAGS) diff --git a/src/window.cc b/src/window.cc index ab1e3e7..768c2ea 100644 --- a/src/window.cc +++ b/src/window.cc @@ -102,6 +102,7 @@ void Window::draw(Rect *dirty_region) dirty = false; draw_children(abs_rect); + *dirty_region = rect_union(*dirty_region, abs_rect); } } diff --git a/src/wm.cc b/src/wm.cc index c9b8959..056c6e7 100644 --- a/src/wm.cc +++ b/src/wm.cc @@ -221,19 +221,22 @@ Window *WindowManager::get_focused_window() Window *WindowManager::get_window_at_pos(int pointer_x, int pointer_y) { - std::list::reverse_iterator rit = windows.rbegin(); - while(rit != windows.rend()) { - Window *w = *rit++; - Window *parent = w->get_parent(); - - if(parent == root_win && w->contains_point(pointer_x, pointer_y)) { - return w; + Window *root_win = wm->get_root_window(); + Window **children = root_win->get_children(); + for(int i=root_win->get_children_count() - 1; i>=0; i--) { + if(children[i]->contains_point(pointer_x, pointer_y)) { + return children[i]; } } return 0; } +Window *WindowManager::get_root_window() const +{ + return root_win; +} + void WindowManager::set_focused_frame_color(int r, int g, int b) { frame_fcolor[0] = r; diff --git a/src/wm.h b/src/wm.h index b675539..7e677c2 100644 --- a/src/wm.h +++ b/src/wm.h @@ -44,6 +44,7 @@ public: Window *get_focused_window(); Window *get_window_at_pos(int pointer_x, int pointer_y); + Window *get_root_window() const; void set_focused_frame_color(int r, int g, int b); void get_focused_frame_color(int *r, int *g, int *b); -- 1.7.10.4