[gnome-commander] notebook: fix for false tab identification in find_tab_num_at_pos()
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] notebook: fix for false tab identification in find_tab_num_at_pos()
- Date: Fri, 29 Jul 2011 19:42:40 +0000 (UTC)
commit 61c5fbe48ccaef090f92ffc491a0011ca4fe864f
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Fri Jul 29 21:41:03 2011 +0200
notebook: fix for false tab identification in find_tab_num_at_pos()
src/gnome-cmd-notebook.cc | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/gnome-cmd-notebook.cc b/src/gnome-cmd-notebook.cc
index 2a0fe9c..5288787 100644
--- a/src/gnome-cmd-notebook.cc
+++ b/src/gnome-cmd-notebook.cc
@@ -121,14 +121,34 @@ int GnomeCmdNotebook::find_tab_num_at_pos(gint screen_x, gint screen_y) const
gdk_window_get_origin (tab->window, &x_root, &y_root);
- int max_x = x_root + tab->allocation.x + tab->allocation.width;
- int max_y = y_root + tab->allocation.y + tab->allocation.height;
-
- if ((tab_pos == GTK_POS_TOP || tab_pos == GTK_POS_BOTTOM) && screen_x <= max_x)
- return page_num;
-
- if ((tab_pos == GTK_POS_LEFT || tab_pos == GTK_POS_RIGHT) && screen_y <= max_y)
- return page_num;
+ switch (tab_pos)
+ {
+ case GTK_POS_TOP:
+ case GTK_POS_BOTTOM:
+ {
+ gint y = screen_y - y_root - tab->allocation.y;
+
+ if (y < 0 || y > tab->allocation.height)
+ return -1;
+
+ if (screen_x <= x_root + tab->allocation.x + tab->allocation.width)
+ return page_num;
+ }
+ break;
+
+ case GTK_POS_LEFT:
+ case GTK_POS_RIGHT:
+ {
+ gint x = screen_x - x_root - tab->allocation.x;
+
+ if (x < 0 || x > tab->allocation.width)
+ return -1;
+
+ if (screen_y <= y_root + tab->allocation.y + tab->allocation.height)
+ return page_num;
+ }
+ break;
+ }
}
return -1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]