Merge lp:~cimi/overlay-scrollbar/internal-thumb into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 137
Proposed branch: lp:~cimi/overlay-scrollbar/internal-thumb
Merge into: lp:overlay-scrollbar
Diff against target: 209 lines (+79/-15)
1 file modified
os/os-scrollbar.c (+79/-15)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/internal-thumb
Reviewer Review Type Date Requested Status
Loïc Molinari (community) Approve
Review via email: mp+52101@code.launchpad.net

Description of the change

The thumb should be inside the screen, for example for maximized windows with a scrollbar on its edge, so this patch looks at the screen dimensions and moves the thumb internally (before the pager) when needed.

To post a comment you must log in.
Revision history for this message
Loïc Molinari (loic.molinari) :
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-03-03 16:23:53 +0000
+++ os/os-scrollbar.c 2011-03-03 17:23:44 +0000
@@ -28,6 +28,9 @@
28#include "os-private.h"28#include "os-private.h"
29#include <gdk/gdkx.h>29#include <gdk/gdkx.h>
3030
31/* Default size of the pager in pixels. */
32#define DEFAULT_PAGER_WIDTH 3
33
31/* Default size of the scrollbar in pixels. */34/* Default size of the scrollbar in pixels. */
32#define DEFAULT_SCROLLBAR_WIDTH 1535#define DEFAULT_SCROLLBAR_WIDTH 15
33#define DEFAULT_SCROLLBAR_HEIGHT 8036#define DEFAULT_SCROLLBAR_HEIGHT 80
@@ -86,8 +89,11 @@
86static void os_scrollbar_hide_thumb (OsScrollbar *scrollbar);89static void os_scrollbar_hide_thumb (OsScrollbar *scrollbar);
87static gboolean os_scrollbar_hide_thumb_cb (gpointer user_data);90static gboolean os_scrollbar_hide_thumb_cb (gpointer user_data);
88static void os_scrollbar_move (OsScrollbar *scrollbar, gint mouse_x, gint mouse_y);91static void os_scrollbar_move (OsScrollbar *scrollbar, gint mouse_x, gint mouse_y);
92static void os_scrollbar_move_thumb (OsScrollbar *scrollbar, gint x, gint y);
89static void os_scrollbar_notify_adjustment_cb (GObject *object, gpointer user_data);93static void os_scrollbar_notify_adjustment_cb (GObject *object, gpointer user_data);
90static void os_scrollbar_notify_orientation_cb (GObject *object, gpointer user_data);94static void os_scrollbar_notify_orientation_cb (GObject *object, gpointer user_data);
95static gint os_scrollbar_sanitize_x (OsScrollbar *scrollbar, gint x);
96static gint os_scrollbar_sanitize_y (OsScrollbar *scrollbar, gint y);
91static void os_scrollbar_store_window_position (OsScrollbar *scrollbar);97static void os_scrollbar_store_window_position (OsScrollbar *scrollbar);
92static void os_scrollbar_swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment);98static void os_scrollbar_swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment);
93static void os_scrollbar_swap_parent (OsScrollbar *scrollbar, GtkWidget *parent);99static void os_scrollbar_swap_parent (OsScrollbar *scrollbar, GtkWidget *parent);
@@ -398,6 +404,20 @@
398}404}
399405
400static void406static void
407os_scrollbar_move_thumb (OsScrollbar *scrollbar,
408 gint x,
409 gint y)
410{
411 OsScrollbarPrivate *priv;
412
413 priv = OS_SCROLLBAR_GET_PRIVATE (scrollbar);
414
415 gtk_window_move (GTK_WINDOW (priv->thumb),
416 os_scrollbar_sanitize_x (scrollbar, x),
417 os_scrollbar_sanitize_y (scrollbar, y));
418}
419
420static void
401os_scrollbar_notify_adjustment_cb (GObject *object,421os_scrollbar_notify_adjustment_cb (GObject *object,
402 gpointer user_data)422 gpointer user_data)
403{423{
@@ -421,6 +441,50 @@
421 os_scrollbar_swap_thumb (OS_SCROLLBAR (object), os_thumb_new (priv->orientation));441 os_scrollbar_swap_thumb (OS_SCROLLBAR (object), os_thumb_new (priv->orientation));
422}442}
423443
444static gint
445os_scrollbar_sanitize_x (OsScrollbar *scrollbar,
446 gint x)
447{
448 OsScrollbarPrivate *priv;
449 gint screen_width;
450
451 priv = OS_SCROLLBAR_GET_PRIVATE (scrollbar);
452
453 /* FIXME we could store screen_width in priv
454 * and change it at screen-changed signal */
455 screen_width = gdk_screen_get_width (gtk_widget_get_screen (GTK_WIDGET (scrollbar)));
456
457 /* FIXME we could apply a static offest we
458 * set in size-allocate and configure-event */
459 if (priv->orientation == GTK_ORIENTATION_VERTICAL &&
460 (x + priv->slider.width > screen_width))
461 return x - DEFAULT_PAGER_WIDTH - priv->slider.width;
462
463 return x;
464}
465
466static gint
467os_scrollbar_sanitize_y (OsScrollbar *scrollbar,
468 gint y)
469{
470 OsScrollbarPrivate *priv;
471 gint screen_height;
472
473 priv = OS_SCROLLBAR_GET_PRIVATE (scrollbar);
474
475 /* FIXME we could store screen_height in priv
476 * and change it at screen-changed signal */
477 screen_height = gdk_screen_get_height (gtk_widget_get_screen (GTK_WIDGET (scrollbar)));
478
479 /* FIXME we could apply a static offest we
480 * set in size-allocate and configure-event */
481 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
482 (y + priv->slider.height > screen_height))
483 return y - DEFAULT_PAGER_WIDTH - priv->slider.height;
484
485 return y;
486}
487
424/* Store scrollbar window position. */488/* Store scrollbar window position. */
425static void489static void
426os_scrollbar_store_window_position (OsScrollbar *scrollbar)490os_scrollbar_store_window_position (OsScrollbar *scrollbar)
@@ -567,7 +631,7 @@
567631
568 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);632 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
569633
570 gtk_window_move (GTK_WINDOW (priv->thumb), x_pos + priv->thumb_all.x, y_pos + priv->thumb_all.y);634 os_scrollbar_move_thumb (scrollbar, x_pos + priv->thumb_all.x, y_pos + priv->thumb_all.y);
571635
572 if (priv->pager != NULL)636 if (priv->pager != NULL)
573 {637 {
@@ -802,7 +866,7 @@
802 }866 }
803 }867 }
804868
805 gtk_window_move (GTK_WINDOW (widget), x, y);869 os_scrollbar_move_thumb (scrollbar, x, y);
806 }870 }
807871
808 return TRUE;872 return TRUE;
@@ -821,7 +885,7 @@
821 {885 {
822 mask.x = 0;886 mask.x = 0;
823 mask.y = priv->overlay.y;887 mask.y = priv->overlay.y;
824 mask.width = 3;888 mask.width = DEFAULT_PAGER_WIDTH;
825 mask.height = priv->overlay.height;889 mask.height = priv->overlay.height;
826890
827 if (priv->proximity == TRUE891 if (priv->proximity == TRUE
@@ -842,7 +906,7 @@
842 mask.x = priv->overlay.x;906 mask.x = priv->overlay.x;
843 mask.y = 0;907 mask.y = 0;
844 mask.width = priv->overlay.width;908 mask.width = priv->overlay.width;
845 mask.height = 3;909 mask.height = DEFAULT_PAGER_WIDTH;
846910
847 if (priv->proximity == TRUE911 if (priv->proximity == TRUE
848 && priv->overlay.width >= priv->overlay_all.width - 2)912 && priv->overlay.width >= priv->overlay_all.width - 2)
@@ -874,7 +938,7 @@
874 {938 {
875 rect.x = priv->overlay_all.x;939 rect.x = priv->overlay_all.x;
876 rect.y = priv->overlay_all.y + 1;940 rect.y = priv->overlay_all.y + 1;
877 rect.width = 3;941 rect.width = DEFAULT_PAGER_WIDTH;
878 rect.height = priv->overlay_all.height - 2;942 rect.height = priv->overlay_all.height - 2;
879 }943 }
880 else944 else
@@ -882,7 +946,7 @@
882 rect.x = priv->overlay_all.x + 1;946 rect.x = priv->overlay_all.x + 1;
883 rect.y = priv->overlay_all.y;947 rect.y = priv->overlay_all.y;
884 rect.width = priv->overlay_all.width - 2;948 rect.width = priv->overlay_all.width - 2;
885 rect.height = 3;949 rect.height = DEFAULT_PAGER_WIDTH;
886 }950 }
887951
888 os_pager_size_allocate (OS_PAGER (priv->pager), rect);952 os_pager_size_allocate (OS_PAGER (priv->pager), rect);
@@ -949,14 +1013,14 @@
949 {1013 {
950 priv->slider.width = DEFAULT_SCROLLBAR_WIDTH;1014 priv->slider.width = DEFAULT_SCROLLBAR_WIDTH;
951 priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;1015 priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;
952 priv->overlay_all.x = allocation->x + allocation->width - 3;1016 priv->overlay_all.x = allocation->x + allocation->width - DEFAULT_PAGER_WIDTH;
953 priv->thumb_all.x = allocation->x + allocation->width;1017 priv->thumb_all.x = allocation->x + allocation->width;
954 }1018 }
955 else1019 else
956 {1020 {
957 priv->slider.width = DEFAULT_SCROLLBAR_HEIGHT;1021 priv->slider.width = DEFAULT_SCROLLBAR_HEIGHT;
958 priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;1022 priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;
959 priv->overlay_all.y = allocation->y + allocation->height - 3;1023 priv->overlay_all.y = allocation->y + allocation->height - DEFAULT_PAGER_WIDTH;
960 priv->thumb_all.y = allocation->y + allocation->height;1024 priv->thumb_all.y = allocation->y + allocation->height;
961 }1025 }
9621026
@@ -984,9 +1048,9 @@
9841048
985 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);1049 os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
986 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);1050 os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
987 gtk_window_move (GTK_WINDOW (priv->thumb),1051 os_scrollbar_move_thumb (scrollbar,
988 event->x + priv->thumb_all.x + priv->slider.x,1052 event->x + priv->thumb_all.x + priv->slider.x,
989 event->y + priv->thumb_all.y + priv->slider.y);1053 event->y + priv->thumb_all.y + priv->slider.y);
9901054
991 os_scrollbar_store_window_position (scrollbar);1055 os_scrollbar_store_window_position (scrollbar);
9921056
@@ -1047,11 +1111,11 @@
1047 priv->thumb_all.y + priv->overlay.y,1111 priv->thumb_all.y + priv->overlay.y,
1048 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);1112 priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
10491113
1050 gtk_window_move (GTK_WINDOW (priv->thumb), x_pos + x, y_pos + y);1114 os_scrollbar_move_thumb (scrollbar, x_pos + x, y_pos + y);
1051 }1115 }
1052 else1116 else
1053 {1117 {
1054 gtk_window_move (GTK_WINDOW (priv->thumb), priv->win_x, priv->win_y + priv->slider.y);1118 os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1055 }1119 }
10561120
1057 gtk_widget_show (GTK_WIDGET (priv->thumb));1121 gtk_widget_show (GTK_WIDGET (priv->thumb));
@@ -1083,11 +1147,11 @@
1083 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);1147 priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
1084 y = priv->thumb_all.y;1148 y = priv->thumb_all.y;
10851149
1086 gtk_window_move (GTK_WINDOW (priv->thumb), x_pos + x, y_pos + y);1150 os_scrollbar_move_thumb (scrollbar, x_pos + x, y_pos + y);
1087 }1151 }
1088 else1152 else
1089 {1153 {
1090 gtk_window_move (GTK_WINDOW (priv->thumb), priv->win_x, priv->win_y + priv->slider.y);1154 os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1091 }1155 }
10921156
1093 gtk_widget_show (GTK_WIDGET (priv->thumb));1157 gtk_widget_show (GTK_WIDGET (priv->thumb));

Subscribers

People subscribed via source and target branches