Merge lp:~cimi/overlay-scrollbar/hide-thumb-on-selection into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 220
Merged at revision: 235
Proposed branch: lp:~cimi/overlay-scrollbar/hide-thumb-on-selection
Merge into: lp:overlay-scrollbar
Diff against target: 122 lines (+83/-1)
1 file modified
os/os-scrollbar.c (+83/-1)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/hide-thumb-on-selection
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Mirco Müller Pending
Review via email: mp+58296@code.launchpad.net

Description of the change

store a gboolean that is set to TRUE when mouse clicking, and FALSE on mouse release

To post a comment you must log in.
213. By Andrea Cimitan

User the filter func for the LeaveNotify, as it is not called when moving in internal gdkwindows

214. By Andrea Cimitan

Moved the leave_notify_event in toplevel_filter_func

215. By Andrea Cimitan

indent

Revision history for this message
Mirco Müller (macslow) wrote :

As a general rule of thumb, I would _always_ initialize variables upon declaration and also always check any pointers (xev, gdkevent) against NULL upon function-entry.

Revision history for this message
Mirco Müller (macslow) wrote :

There's a lot of math going on to check for thresholds/limits. I would put those into functions (or macros) to make the condition-checking (if-statements) more readable and make any potential/later changes to them less tedious and error-prone.

216. By Andrea Cimitan

reverted change in variable name

217. By Andrea Cimitan

ops, I suddenly merged a different branch, now ok

Revision history for this message
Ted Gould (ted) wrote :

top_level_button_press needs to be initialized to FALSE.

review: Needs Fixing
218. By Andrea Cimitan

Initialize toplevel_button_press

219. By Andrea Cimitan

Merged trunk

220. By Andrea Cimitan

should enter leavenotify also when toplevel_button_press is FALSE

Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-05-17 17:04:30 +0000
+++ os/os-scrollbar.c 2011-05-17 17:23:23 +0000
@@ -65,6 +65,7 @@
65 gboolean active_window;65 gboolean active_window;
66 gboolean can_deactivate_pager;66 gboolean can_deactivate_pager;
67 gboolean can_hide;67 gboolean can_hide;
68 gboolean toplevel_button_press;
68 gboolean filter;69 gboolean filter;
69 gboolean fullsize;70 gboolean fullsize;
70 gboolean internal;71 gboolean internal;
@@ -1433,6 +1434,85 @@
14331434
1434 if (!priv->fullsize)1435 if (!priv->fullsize)
1435 {1436 {
1437 if (xevent->type == ButtonPress)
1438 {
1439 priv->toplevel_button_press = TRUE;
1440 gtk_widget_hide (priv->thumb);
1441 }
1442
1443 if (priv->toplevel_button_press && xevent->type == ButtonRelease)
1444 {
1445 priv->toplevel_button_press = FALSE;
1446
1447 /* proximity area */
1448 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1449 {
1450 if ((priv->thumb_all.x - xevent->xbutton.x <= PROXIMITY_WIDTH &&
1451 priv->thumb_all.x - xevent->xbutton.x >= 0) &&
1452 (xevent->xbutton.y >= priv->thumb_all.y + priv->overlay.y &&
1453 xevent->xbutton.y <= priv->thumb_all.y + priv->overlay.y + priv->overlay.height))
1454 {
1455 priv->can_hide = FALSE;
1456
1457 if (priv->lock_position)
1458 return GDK_FILTER_CONTINUE;
1459
1460 if (priv->overlay.height > priv->slider.height)
1461 {
1462 gint x, y, x_pos, y_pos;
1463
1464 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
1465
1466 x = priv->thumb_all.x;
1467 y = CLAMP (xevent->xbutton.y - priv->slider.height / 2,
1468 priv->thumb_all.y + priv->overlay.y,
1469 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
1470
1471 os_scrollbar_move_thumb (scrollbar, x_pos + x, y_pos + y);
1472 }
1473 else
1474 {
1475 os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1476 }
1477
1478 gtk_widget_show (GTK_WIDGET (priv->thumb));
1479 }
1480 }
1481 else
1482 {
1483 if ((priv->thumb_all.y - xevent->xbutton.y <= PROXIMITY_WIDTH &&
1484 priv->thumb_all.y - xevent->xbutton.y >= 0) &&
1485 (xevent->xbutton.x >= priv->thumb_all.x + priv->overlay.x &&
1486 xevent->xbutton.x <= priv->thumb_all.x + priv->overlay.x + priv->overlay.width))
1487 {
1488 priv->can_hide = FALSE;
1489
1490 if (priv->lock_position)
1491 return GDK_FILTER_CONTINUE;
1492
1493 if (priv->overlay.width > priv->slider.width)
1494 {
1495 gint x, y, x_pos, y_pos;
1496
1497 gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
1498
1499 x = CLAMP (xevent->xbutton.x - priv->slider.width / 2,
1500 priv->thumb_all.x + priv->overlay.x,
1501 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
1502 y = priv->thumb_all.y;
1503
1504 os_scrollbar_move_thumb (scrollbar, x_pos + x, y_pos + y);
1505 }
1506 else
1507 {
1508 os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1509 }
1510
1511 gtk_widget_show (GTK_WIDGET (priv->thumb));
1512 }
1513 }
1514 }
1515
1436 /* after a scroll-event, without motion,1516 /* after a scroll-event, without motion,
1437 * pager becomes inactive because the timeout in1517 * pager becomes inactive because the timeout in
1438 * leave-notify-event starts,1518 * leave-notify-event starts,
@@ -1457,6 +1537,7 @@
1457 scrollbar);1537 scrollbar);
1458 }1538 }
14591539
1540 priv->toplevel_button_press = FALSE;
1460 priv->can_hide = TRUE;1541 priv->can_hide = TRUE;
14611542
1462 if (priv->source_hide_thumb_id != 0)1543 if (priv->source_hide_thumb_id != 0)
@@ -1475,7 +1556,7 @@
1475 }1556 }
14761557
1477 /* get the motion_notify_event trough XEvent */1558 /* get the motion_notify_event trough XEvent */
1478 if (xevent->type == MotionNotify)1559 if (!priv->toplevel_button_press && xevent->type == MotionNotify)
1479 {1560 {
1480 /* react to motion_notify_event1561 /* react to motion_notify_event
1481 * and set the state accordingly. */1562 * and set the state accordingly. */
@@ -1642,6 +1723,7 @@
1642 priv->internal = FALSE;1723 priv->internal = FALSE;
1643 priv->lock_position = FALSE;1724 priv->lock_position = FALSE;
1644 priv->proximity = FALSE;1725 priv->proximity = FALSE;
1726 priv->toplevel_button_press = FALSE;
1645 priv->source_deactivate_pager_id = 0;1727 priv->source_deactivate_pager_id = 0;
1646 priv->source_hide_thumb_id = 0;1728 priv->source_hide_thumb_id = 0;
1647 priv->source_unlock_thumb_id = 0;1729 priv->source_unlock_thumb_id = 0;

Subscribers

People subscribed via source and target branches