Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / notifications / balloon_collection_gtk.cc
blobc07bdbd2eae263f268bfcb1585b7aa1eb852ec9b
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/notifications/balloon_collection_impl.h"
7 #include "chrome/browser/notifications/balloon.h"
8 #include "chrome/browser/ui/gtk/notifications/balloon_view_gtk.h"
9 #include "ui/gfx/size.h"
11 Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification,
12 Profile* profile) {
13 Balloon* balloon = new Balloon(notification, profile, this);
15 balloon->set_view(new BalloonViewImpl(this));
16 gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height());
17 balloon->set_content_size(size);
18 return balloon;
21 int BalloonCollectionImpl::Layout::InterBalloonMargin() const {
22 return 5;
25 int BalloonCollectionImpl::Layout::HorizontalEdgeMargin() const {
26 return 5;
29 int BalloonCollectionImpl::Layout::VerticalEdgeMargin() const {
30 return 5;
33 bool BalloonCollectionImpl::Layout::NeedToMoveAboveLeftSidePanels() const {
34 return placement_ == VERTICALLY_FROM_BOTTOM_LEFT;
37 bool BalloonCollectionImpl::Layout::NeedToMoveAboveRightSidePanels() const {
38 return placement_ == VERTICALLY_FROM_BOTTOM_RIGHT;
41 void BalloonCollectionImpl::PositionBalloons(bool reposition) {
42 PositionBalloonsInternal(reposition);
45 void BalloonCollectionImpl::WillProcessEvent(GdkEvent* event) {
48 void BalloonCollectionImpl::DidProcessEvent(GdkEvent* event) {
49 switch (event->type) {
50 case GDK_MOTION_NOTIFY:
51 case GDK_LEAVE_NOTIFY:
52 HandleMouseMoveEvent();
53 break;
54 default:
55 break;
59 bool BalloonCollectionImpl::IsCursorInBalloonCollection() const {
60 GdkScreen* screen = gdk_screen_get_default();
61 GdkDisplay* display = gdk_screen_get_display(screen);
62 gint x, y;
63 gdk_display_get_pointer(display, NULL, &x, &y, NULL);
65 return GetBalloonsBoundingBox().Contains(gfx::Point(x, y));
68 void BalloonCollectionImpl::SetPositionPreference(
69 PositionPreference position) {
70 if (position == DEFAULT_POSITION)
71 position = LOWER_RIGHT;
73 // All positioning schemes are vertical, and linux
74 // uses the normal screen orientation.
75 if (position == UPPER_RIGHT)
76 layout_.set_placement(Layout::VERTICALLY_FROM_TOP_RIGHT);
77 else if (position == UPPER_LEFT)
78 layout_.set_placement(Layout::VERTICALLY_FROM_TOP_LEFT);
79 else if (position == LOWER_LEFT)
80 layout_.set_placement(Layout::VERTICALLY_FROM_BOTTOM_LEFT);
81 else if (position == LOWER_RIGHT)
82 layout_.set_placement(Layout::VERTICALLY_FROM_BOTTOM_RIGHT);
83 else
84 NOTREACHED();
86 layout_.ComputeOffsetToMoveAbovePanels();
87 PositionBalloons(true);
90 // static
91 BalloonCollection* BalloonCollection::Create() {
92 return new BalloonCollectionImpl();