~cimi/overlay-scrollbar/fix-unity-restore-from-maximized

« back to all changes in this revision

Viewing changes to os/os-scrollbar.c

  • Committer: Andrea Cimitan
  • Date: 2011-03-16 16:17:08 UTC
  • mfrom: (150.2.16 performance-tweaks)
  • Revision ID: andrea.cimitan@canonical.com-20110316161708-6frhsf647igfq6ab
Merged branch performance-tweaks

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
static gboolean thumb_leave_notify_event_cb (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
103
103
static gboolean thumb_motion_notify_event_cb (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
104
104
static void pager_move (OsScrollbar *scrollbar);
105
 
static void pager_set_allocation (OsScrollbar *scrollbar);
106
105
static void pager_set_state (OsScrollbar *scrollbar);
107
106
static void adjustment_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
108
107
static void adjustment_value_changed_cb (GtkAdjustment *adjustment, gpointer user_data);
657
656
 
658
657
          priv->pointer_x = event->x;
659
658
          priv->pointer_y = event->y;
660
 
 
661
 
          gtk_widget_queue_draw (widget);
662
659
        }
663
660
    }
664
661
 
704
701
 
705
702
          priv->button_press_event = FALSE;
706
703
          priv->motion_notify_event = FALSE;
707
 
 
708
 
          gtk_widget_queue_draw (widget);
709
704
        }
710
705
    }
711
706
 
783
778
          priv->value_changed_event = FALSE;
784
779
        }
785
780
 
786
 
      if (!priv->motion_notify_event)
787
 
        gtk_widget_queue_draw (widget);
788
 
 
789
781
      priv->motion_notify_event = TRUE;
790
782
 
791
783
      os_scrollbar_move (scrollbar, event->x_root, event->y_root);
876
868
  os_pager_move_resize (OS_PAGER (priv->pager), mask);
877
869
}
878
870
 
879
 
/* Resize the overlay window. */
880
 
static void
881
 
pager_set_allocation (OsScrollbar *scrollbar)
882
 
{
883
 
  GdkRectangle rect;
884
 
  OsScrollbarPrivate *priv;
885
 
  gint offset;
886
 
 
887
 
  priv = scrollbar->priv;
888
 
 
889
 
  if (GTK_IS_SCROLLED_WINDOW (priv->parent) &&
890
 
      gtk_scrolled_window_get_shadow_type (GTK_SCROLLED_WINDOW (priv->parent)) != GTK_SHADOW_NONE)
891
 
    offset = 1;
892
 
  else
893
 
    offset = 0;
894
 
 
895
 
  if (priv->orientation == GTK_ORIENTATION_VERTICAL)
896
 
    {
897
 
      rect.x = priv->overlay_all.x;
898
 
      rect.y = priv->overlay_all.y + offset;
899
 
      rect.width = DEFAULT_PAGER_WIDTH;
900
 
      rect.height = priv->overlay_all.height - offset * 2;
901
 
    }
902
 
  else
903
 
    {
904
 
      rect.x = priv->overlay_all.x + offset;
905
 
      rect.y = priv->overlay_all.y;
906
 
      rect.width = priv->overlay_all.width - offset * 2;
907
 
      rect.height = DEFAULT_PAGER_WIDTH;
908
 
    }
909
 
 
910
 
  os_pager_size_allocate (OS_PAGER (priv->pager), rect);
911
 
}
912
 
 
913
871
static void
914
872
pager_set_state (OsScrollbar *scrollbar)
915
873
{
1006
964
                         GtkAllocation *allocation,
1007
965
                         gpointer       user_data)
1008
966
{
 
967
  GdkRectangle rect;
1009
968
  OsScrollbar *scrollbar;
1010
969
  OsScrollbarPrivate *priv;
1011
970
  gint offset;
1033
992
      priv->slider.height = DEFAULT_SCROLLBAR_HEIGHT;
1034
993
      priv->overlay_all.x = allocation->x + allocation->width - DEFAULT_PAGER_WIDTH - offset;
1035
994
      priv->thumb_all.x = allocation->x + allocation->width - offset;
 
995
 
 
996
      rect.x = priv->overlay_all.x;
 
997
      rect.y = priv->overlay_all.y + offset;
 
998
      rect.width = DEFAULT_PAGER_WIDTH;
 
999
      rect.height = priv->overlay_all.height - offset * 2;
1036
1000
    }
1037
1001
  else
1038
1002
    {
1040
1004
      priv->slider.height = DEFAULT_SCROLLBAR_WIDTH;
1041
1005
      priv->overlay_all.y = allocation->y + allocation->height - DEFAULT_PAGER_WIDTH - offset;
1042
1006
      priv->thumb_all.y = allocation->y + allocation->height - offset;
 
1007
 
 
1008
      rect.x = priv->overlay_all.x + offset;
 
1009
      rect.y = priv->overlay_all.y;
 
1010
      rect.width = priv->overlay_all.width - offset * 2;
 
1011
      rect.height = DEFAULT_PAGER_WIDTH;
1043
1012
    }
1044
1013
 
1045
1014
  if (priv->adjustment != NULL)
1048
1017
      os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
1049
1018
    }
1050
1019
 
1051
 
  pager_set_allocation (scrollbar);
 
1020
  os_pager_size_allocate (OS_PAGER (priv->pager), rect);
 
1021
 
1052
1022
  pager_move (scrollbar);
1053
1023
 
1054
1024
  if (gtk_widget_get_realized (widget))
1095
1065
 
1096
1066
  os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
1097
1067
  os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
 
1068
 
1098
1069
  os_scrollbar_move_thumb (scrollbar,
1099
1070
                           event->x + priv->thumb_all.x + priv->slider.x,
1100
1071
                           event->y + priv->thumb_all.y + priv->slider.y);
1101
1072
 
1102
1073
  os_scrollbar_store_window_position (scrollbar);
1103
1074
 
1104
 
  pager_set_allocation (scrollbar);
1105
 
  pager_move (scrollbar);
1106
 
 
1107
1075
  return FALSE;
1108
1076
}
1109
1077
 
1133
1101
      /* get the motion_notify_event trough XEvent */
1134
1102
      if (xevent->type == MotionNotify)
1135
1103
        {
1136
 
          os_scrollbar_calc_layout_pager (scrollbar, priv->adjustment->value);
1137
 
          os_scrollbar_calc_layout_slider (scrollbar, priv->adjustment->value);
1138
 
 
1139
1104
          /* proximity area */
1140
1105
          if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1141
1106
            {