| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ | |
| 6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ | |
| 7 | |
| 8 #include <gtk/gtk.h> | |
| 9 | |
| 10 #include "base/timer.h" | |
| 11 #include "chrome/browser/ui/extensions/native_shell_window.h" | |
| 12 #include "chrome/browser/ui/extensions/shell_window.h" | |
| 13 #include "chrome/browser/ui/gtk/extensions/extension_view_gtk.h" | |
| 14 #include "third_party/skia/include/core/SkRegion.h" | |
| 15 #include "ui/base/gtk/gtk_signal.h" | |
| 16 #include "ui/base/x/active_window_watcher_x_observer.h" | |
| 17 #include "ui/gfx/rect.h" | |
| 18 | |
| 19 class ExtensionKeybindingRegistryGtk; | |
| 20 class Profile; | |
| 21 | |
| 22 namespace extensions { | |
| 23 class Extension; | |
| 24 } | |
| 25 | |
| 26 class ShellWindowGtk : public NativeShellWindow, | |
| 27 public ExtensionViewGtk::Container, | |
| 28 public ui::ActiveWindowWatcherXObserver { | |
| 29 public: | |
| 30 ShellWindowGtk(ShellWindow* shell_window, | |
| 31 const ShellWindow::CreateParams& params); | |
| 32 | |
| 33 // BaseWindow implementation. | |
| 34 virtual bool IsActive() const OVERRIDE; | |
| 35 virtual bool IsMaximized() const OVERRIDE; | |
| 36 virtual bool IsMinimized() const OVERRIDE; | |
| 37 virtual bool IsFullscreen() const OVERRIDE; | |
| 38 virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; | |
| 39 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
| 40 virtual gfx::Rect GetBounds() const OVERRIDE; | |
| 41 virtual void Show() OVERRIDE; | |
| 42 virtual void ShowInactive() OVERRIDE; | |
| 43 virtual void Hide() OVERRIDE; | |
| 44 virtual void Close() OVERRIDE; | |
| 45 virtual void Activate() OVERRIDE; | |
| 46 virtual void Deactivate() OVERRIDE; | |
| 47 virtual void Maximize() OVERRIDE; | |
| 48 virtual void Minimize() OVERRIDE; | |
| 49 virtual void Restore() OVERRIDE; | |
| 50 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 51 virtual void FlashFrame(bool flash) OVERRIDE; | |
| 52 virtual bool IsAlwaysOnTop() const OVERRIDE; | |
| 53 | |
| 54 // ActiveWindowWatcherXObserver implementation. | |
| 55 virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE; | |
| 56 | |
| 57 private: | |
| 58 // NativeShellWindow implementation. | |
| 59 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | |
| 60 virtual bool IsFullscreenOrPending() const OVERRIDE; | |
| 61 virtual void UpdateWindowIcon() OVERRIDE; | |
| 62 virtual void UpdateWindowTitle() OVERRIDE; | |
| 63 virtual void HandleKeyboardEvent( | |
| 64 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
| 65 virtual void UpdateDraggableRegions( | |
| 66 const std::vector<extensions::DraggableRegion>& regions) OVERRIDE; | |
| 67 virtual void RenderViewHostChanged() OVERRIDE {} | |
| 68 | |
| 69 content::WebContents* web_contents() const { | |
| 70 return shell_window_->web_contents(); | |
| 71 } | |
| 72 const extensions::Extension* extension() const { | |
| 73 return shell_window_->extension(); | |
| 74 } | |
| 75 | |
| 76 virtual ~ShellWindowGtk(); | |
| 77 | |
| 78 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnMainWindowDeleteEvent, | |
| 79 GdkEvent*); | |
| 80 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnConfigure, | |
| 81 GdkEventConfigure*); | |
| 82 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnWindowState, | |
| 83 GdkEventWindowState*); | |
| 84 CHROMEGTK_CALLBACK_1(ShellWindowGtk, gboolean, OnButtonPress, | |
| 85 GdkEventButton*); | |
| 86 | |
| 87 void OnDebouncedBoundsChanged(); | |
| 88 | |
| 89 ShellWindow* shell_window_; // weak - ShellWindow owns NativeShellWindow. | |
| 90 | |
| 91 GtkWindow* window_; | |
| 92 GdkWindowState state_; | |
| 93 | |
| 94 // True if the window manager thinks the window is active. Not all window | |
| 95 // managers keep track of this state (_NET_ACTIVE_WINDOW), in which case | |
| 96 // this will always be true. | |
| 97 bool is_active_; | |
| 98 | |
| 99 // The position and size of the current window. | |
| 100 gfx::Rect bounds_; | |
| 101 | |
| 102 // The position and size of the non-maximized, non-fullscreen window. | |
| 103 gfx::Rect restored_bounds_; | |
| 104 | |
| 105 // True if the RVH is in fullscreen mode. The window may not actually be in | |
| 106 // fullscreen, however: some WMs don't support fullscreen. | |
| 107 bool content_thinks_its_fullscreen_; | |
| 108 | |
| 109 // The region is treated as title bar, can be dragged to move | |
| 110 // and double clicked to maximize. | |
| 111 scoped_ptr<SkRegion> draggable_region_; | |
| 112 | |
| 113 // If true, don't call gdk_window_raise() when we get a click in the title | |
| 114 // bar or window border. This is to work around a compiz bug. | |
| 115 bool suppress_window_raise_; | |
| 116 | |
| 117 // True if the window shows without frame. | |
| 118 bool frameless_; | |
| 119 | |
| 120 // The timer used to save the window position for session restore. | |
| 121 base::OneShotTimer<ShellWindowGtk> window_configure_debounce_timer_; | |
| 122 | |
| 123 // The Extension Keybinding Registry responsible for registering listeners for | |
| 124 // accelerators that are sent to the window, that are destined to be turned | |
| 125 // into events and sent to the extension. | |
| 126 scoped_ptr<ExtensionKeybindingRegistryGtk> extension_keybinding_registry_; | |
| 127 | |
| 128 DISALLOW_COPY_AND_ASSIGN(ShellWindowGtk); | |
| 129 }; | |
| 130 | |
| 131 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_SHELL_WINDOW_GTK_H_ | |
| OLD | NEW |