| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/gtk/info_bubble_gtk.h" | 5 #include "chrome/browser/gtk/info_bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "app/gfx/gtk_util.h" | 10 #include "app/gfx/gtk_util.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 screen_x = toplevel_x + rect_.x() + (rect_.width() / 2) - kArrowX; | 253 screen_x = toplevel_x + rect_.x() + (rect_.width() / 2) - kArrowX; |
| 254 } | 254 } |
| 255 | 255 |
| 256 gint screen_y = toplevel_y + rect_.y() + rect_.height() + | 256 gint screen_y = toplevel_y + rect_.y() + rect_.height() + |
| 257 kArrowToContentPadding; | 257 kArrowToContentPadding; |
| 258 | 258 |
| 259 gtk_window_move(GTK_WINDOW(window_), screen_x, screen_y); | 259 gtk_window_move(GTK_WINDOW(window_), screen_x, screen_y); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void InfoBubbleGtk::StackWindow() { | 262 void InfoBubbleGtk::StackWindow() { |
| 263 // Stack our window directly above the toplevel window. Our window is a | 263 // Stack our window directly above the toplevel window. |
| 264 // direct child of the root window, so we need to find a similar ancestor | 264 gtk_util::StackPopupWindow(window_, GTK_WIDGET(toplevel_window_)); |
| 265 // for the toplevel window (which might have been reparented by a window | |
| 266 // manager). | |
| 267 XID toplevel_window_base = x11_util::GetHighestAncestorWindow( | |
| 268 x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(toplevel_window_)), | |
| 269 x11_util::GetX11RootWindow()); | |
| 270 if (toplevel_window_base) { | |
| 271 XID window_xid = x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(window_)); | |
| 272 XID window_parent = x11_util::GetParentWindow(window_xid); | |
| 273 if (window_parent == x11_util::GetX11RootWindow()) { | |
| 274 x11_util::RestackWindow(window_xid, toplevel_window_base, true); | |
| 275 } else { | |
| 276 // The window manager shouldn't reparent override-redirect windows. | |
| 277 DLOG(ERROR) << "override-redirect window " << window_xid | |
| 278 << "'s parent is " << window_parent | |
| 279 << ", rather than root window " | |
| 280 << x11_util::GetX11RootWindow(); | |
| 281 } | |
| 282 } | |
| 283 } | 265 } |
| 284 | 266 |
| 285 void InfoBubbleGtk::Observe(NotificationType type, | 267 void InfoBubbleGtk::Observe(NotificationType type, |
| 286 const NotificationSource& source, | 268 const NotificationSource& source, |
| 287 const NotificationDetails& details) { | 269 const NotificationDetails& details) { |
| 288 DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED); | 270 DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED); |
| 289 if (theme_provider_->UseGtkTheme()) { | 271 if (theme_provider_->UseGtkTheme()) { |
| 290 gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, NULL); | 272 gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, NULL); |
| 291 } else { | 273 } else { |
| 292 // Set the background color, so we don't need to paint it manually. | 274 // Set the background color, so we don't need to paint it manually. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 gboolean InfoBubbleGtk::HandleToplevelConfigure(GdkEventConfigure* event) { | 370 gboolean InfoBubbleGtk::HandleToplevelConfigure(GdkEventConfigure* event) { |
| 389 MoveWindow(); | 371 MoveWindow(); |
| 390 StackWindow(); | 372 StackWindow(); |
| 391 return FALSE; | 373 return FALSE; |
| 392 } | 374 } |
| 393 | 375 |
| 394 gboolean InfoBubbleGtk::HandleToplevelUnmap() { | 376 gboolean InfoBubbleGtk::HandleToplevelUnmap() { |
| 395 Close(); | 377 Close(); |
| 396 return FALSE; | 378 return FALSE; |
| 397 } | 379 } |
| OLD | NEW |