OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 XSync(ui::GetXDisplay(), false /* don't discard events */); | 35 XSync(ui::GetXDisplay(), false /* don't discard events */); |
36 } | 36 } |
37 gfx::Rect scheduled_dirty_rect = GetScheduledPaintRectConstrainedToSize(); | 37 gfx::Rect scheduled_dirty_rect = GetScheduledPaintRectConstrainedToSize(); |
38 gfx::Rect expose_rect = gfx::Rect(event->area); | 38 gfx::Rect expose_rect = gfx::Rect(event->area); |
39 gfx::CanvasSkiaPaint canvas(event); | 39 gfx::CanvasSkiaPaint canvas(event); |
40 bool invoked_process_paint = false; | 40 bool invoked_process_paint = false; |
41 if (!canvas.is_empty()) { | 41 if (!canvas.is_empty()) { |
42 canvas.set_composite_alpha(widget->is_transparent()); | 42 canvas.set_composite_alpha(widget->is_transparent()); |
43 SchedulePaintInRect(gfx::Rect(canvas.rectangle()), false); | 43 SchedulePaintInRect(gfx::Rect(canvas.rectangle()), false); |
44 if (NeedsPainting(false)) { | 44 if (NeedsPainting(false)) { |
45 ProcessPaint(&canvas); | 45 Paint(&canvas); |
46 invoked_process_paint = true; | 46 invoked_process_paint = true; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 if (invoked_process_paint && !scheduled_dirty_rect.IsEmpty() && | 50 if (invoked_process_paint && !scheduled_dirty_rect.IsEmpty() && |
51 !expose_rect.Contains(scheduled_dirty_rect) && widget && | 51 !expose_rect.Contains(scheduled_dirty_rect) && widget && |
52 !widget->in_paint_now()) { | 52 !widget->in_paint_now()) { |
53 // We're painting as the result of Gtk wanting us to paint (not from views) | 53 // We're painting as the result of Gtk wanting us to paint (not from views) |
54 // and there was a region scheduled by views to be painted that is not | 54 // and there was a region scheduled by views to be painted that is not |
55 // contained in the region gtk wants us to paint. As a result of the | 55 // contained in the region gtk wants us to paint. As a result of the |
56 // ProcessPaint call above views no longer thinks it needs to be painted. | 56 // Paint() call above views no longer thinks it needs to be painted. |
57 // We have to invoke SchedulePaint here to be sure we end up painting the | 57 // We have to invoke SchedulePaint here to be sure we end up painting the |
58 // region views wants to paint, otherwise we'll drop the views paint region | 58 // region views wants to paint, otherwise we'll drop the views paint region |
59 // on the floor. | 59 // on the floor. |
60 // | 60 // |
61 // NOTE: We don't expand the region to paint to include | 61 // NOTE: We don't expand the region to paint to include |
62 // scheduled_dirty_rect as that results in us drawing on top of any GTK | 62 // scheduled_dirty_rect as that results in us drawing on top of any GTK |
63 // widgets that don't have a window. We have to schedule the paint through | 63 // widgets that don't have a window. We have to schedule the paint through |
64 // GTK so that such widgets are painted. | 64 // GTK so that such widgets are painted. |
65 SchedulePaintInRect(scheduled_dirty_rect, false); | 65 SchedulePaintInRect(scheduled_dirty_rect, false); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void RootView::StartDragForViewFromMouseEvent( | 69 void RootView::StartDragForViewFromMouseEvent( |
70 View* view, | 70 View* view, |
71 const OSExchangeData& data, | 71 const OSExchangeData& data, |
72 int operation) { | 72 int operation) { |
73 // NOTE: view may be null. | 73 // NOTE: view may be null. |
74 drag_view_ = view; | 74 drag_view_ = view; |
75 static_cast<WidgetGtk*>(GetWidget())->DoDrag(data, operation); | 75 static_cast<WidgetGtk*>(GetWidget())->DoDrag(data, operation); |
76 // If the view is removed during the drag operation, drag_view_ is set to | 76 // If the view is removed during the drag operation, drag_view_ is set to |
77 // NULL. | 77 // NULL. |
78 if (view && drag_view_ == view) { | 78 if (view && drag_view_ == view) { |
79 View* drag_view = drag_view_; | 79 View* drag_view = drag_view_; |
80 drag_view_ = NULL; | 80 drag_view_ = NULL; |
81 drag_view->OnDragDone(); | 81 drag_view->OnDragDone(); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 } | 85 } |
OLD | NEW |