OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/gtk/extensions/native_app_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/native_app_window_gtk.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" | 9 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" |
10 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 | 280 |
281 int left_inset = current_x - rect_with_decorations.x; | 281 int left_inset = current_x - rect_with_decorations.x; |
282 int top_inset = current_y - rect_with_decorations.y; | 282 int top_inset = current_y - rect_with_decorations.y; |
283 return gfx::Insets( | 283 return gfx::Insets( |
284 top_inset, | 284 top_inset, |
285 left_inset, | 285 left_inset, |
286 rect_with_decorations.height - current_height - top_inset, | 286 rect_with_decorations.height - current_height - top_inset, |
287 rect_with_decorations.width - current_width - left_inset); | 287 rect_with_decorations.width - current_width - left_inset); |
288 } | 288 } |
289 | 289 |
290 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { | |
291 gint current_width = 0; | |
292 gint current_height = 0; | |
293 gtk_window_get_size(window_, ¤t_width, ¤t_height); | |
294 return gfx::Point(current_width / 2 - size.width() / 2, | |
295 current_height / 2 - size.height() / 2); | |
296 } | |
297 | |
298 void NativeAppWindowGtk::AddObserver( | |
299 WebContentsModalDialogHostObserver* observer) { | |
300 observer_list_.AddObserver(observer); | |
301 } | |
302 | |
303 void NativeAppWindowGtk::RemoveObserver( | |
304 WebContentsModalDialogHostObserver* observer) { | |
305 observer_list_.RemoveObserver(observer); | |
306 } | |
307 | |
290 void NativeAppWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 308 void NativeAppWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
291 // Do nothing if we're in the process of closing the browser window. | 309 // Do nothing if we're in the process of closing the browser window. |
292 if (!window_) | 310 if (!window_) |
293 return; | 311 return; |
294 | 312 |
295 is_active_ = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; | 313 is_active_ = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; |
296 } | 314 } |
297 | 315 |
298 // Callback for the delete event. This event is fired when the user tries to | 316 // Callback for the delete event. This event is fired when the user tries to |
299 // close the window (e.g., clicking on the X in the window manager title bar). | 317 // close the window (e.g., clicking on the X in the window manager title bar). |
(...skipping 29 matching lines...) Expand all Loading... | |
329 window_configure_debounce_timer_.Start(FROM_HERE, | 347 window_configure_debounce_timer_.Start(FROM_HERE, |
330 base::TimeDelta::FromMilliseconds(kDebounceTimeoutMilliseconds), this, | 348 base::TimeDelta::FromMilliseconds(kDebounceTimeoutMilliseconds), this, |
331 &NativeAppWindowGtk::OnDebouncedBoundsChanged); | 349 &NativeAppWindowGtk::OnDebouncedBoundsChanged); |
332 | 350 |
333 return FALSE; | 351 return FALSE; |
334 } | 352 } |
335 | 353 |
336 void NativeAppWindowGtk::OnDebouncedBoundsChanged() { | 354 void NativeAppWindowGtk::OnDebouncedBoundsChanged() { |
337 gtk_window_util::UpdateWindowPosition(this, &bounds_, &restored_bounds_); | 355 gtk_window_util::UpdateWindowPosition(this, &bounds_, &restored_bounds_); |
338 shell_window_->OnNativeWindowChanged(); | 356 shell_window_->OnNativeWindowChanged(); |
357 | |
358 FOR_EACH_OBSERVER(WebContentsModalDialogHostObserver, | |
359 observer_list_, | |
360 OnPositionRequiresUpdate()); | |
jeremya
2013/04/04 19:59:17
This code could live in OnNativeWindowChanged(), I
Mike Wittman
2013/04/04 22:56:08
See comment in the .h file. Also, OnNativeWindowC
| |
339 } | 361 } |
340 | 362 |
341 gboolean NativeAppWindowGtk::OnWindowState(GtkWidget* sender, | 363 gboolean NativeAppWindowGtk::OnWindowState(GtkWidget* sender, |
342 GdkEventWindowState* event) { | 364 GdkEventWindowState* event) { |
343 state_ = event->new_window_state; | 365 state_ = event->new_window_state; |
344 | 366 |
345 if (content_thinks_its_fullscreen_ && | 367 if (content_thinks_its_fullscreen_ && |
346 !(state_ & GDK_WINDOW_STATE_FULLSCREEN)) { | 368 !(state_ & GDK_WINDOW_STATE_FULLSCREEN)) { |
347 content_thinks_its_fullscreen_ = false; | 369 content_thinks_its_fullscreen_ = false; |
348 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | 370 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 | 512 |
491 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 513 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
492 } | 514 } |
493 | 515 |
494 // static | 516 // static |
495 NativeAppWindow* NativeAppWindow::Create( | 517 NativeAppWindow* NativeAppWindow::Create( |
496 ShellWindow* shell_window, | 518 ShellWindow* shell_window, |
497 const ShellWindow::CreateParams& params) { | 519 const ShellWindow::CreateParams& params) { |
498 return new NativeAppWindowGtk(shell_window, params); | 520 return new NativeAppWindowGtk(shell_window, params); |
499 } | 521 } |
OLD | NEW |