OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/window/native_window_gtk.h" | 5 #include "views/window/native_window_gtk.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "ui/gfx/gtk_util.h" | 9 #include "ui/gfx/gtk_util.h" |
10 #include "ui/gfx/path.h" | 10 #include "ui/gfx/path.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 SaveWindowPosition(); | 180 SaveWindowPosition(); |
181 } | 181 } |
182 | 182 |
183 gboolean NativeWindowGtk::OnLeaveNotify(GtkWidget* widget, | 183 gboolean NativeWindowGtk::OnLeaveNotify(GtkWidget* widget, |
184 GdkEventCrossing* event) { | 184 GdkEventCrossing* event) { |
185 gdk_window_set_cursor(widget->window, gfx::GetCursor(GDK_LEFT_PTR)); | 185 gdk_window_set_cursor(widget->window, gfx::GetCursor(GDK_LEFT_PTR)); |
186 | 186 |
187 return NativeWidgetGtk::OnLeaveNotify(widget, event); | 187 return NativeWidgetGtk::OnLeaveNotify(widget, event); |
188 } | 188 } |
189 | 189 |
190 void NativeWindowGtk::IsActiveChanged() { | |
191 NativeWidgetGtk::IsActiveChanged(); | |
192 delegate_->OnNativeWindowActivationChanged(IsActive()); | |
193 } | |
194 | |
195 void NativeWindowGtk::InitNativeWidget(const Widget::InitParams& params) { | 190 void NativeWindowGtk::InitNativeWidget(const Widget::InitParams& params) { |
196 NativeWidgetGtk::InitNativeWidget(params); | 191 NativeWidgetGtk::InitNativeWidget(params); |
197 | 192 |
198 g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event", | 193 g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event", |
199 G_CALLBACK(CallConfigureEvent), this); | 194 G_CALLBACK(CallConfigureEvent), this); |
200 } | 195 } |
201 | 196 |
202 //////////////////////////////////////////////////////////////////////////////// | 197 //////////////////////////////////////////////////////////////////////////////// |
203 // NativeWindowGtk, NativeWindow implementation: | 198 // NativeWindowGtk, NativeWindow implementation: |
204 | 199 |
205 NativeWidget* NativeWindowGtk::AsNativeWidget() { | 200 NativeWidget* NativeWindowGtk::AsNativeWidget() { |
206 return this; | 201 return this; |
207 } | 202 } |
208 | 203 |
209 const NativeWidget* NativeWindowGtk::AsNativeWidget() const { | 204 const NativeWidget* NativeWindowGtk::AsNativeWidget() const { |
210 return this; | 205 return this; |
211 } | 206 } |
212 | 207 |
213 gfx::Rect NativeWindowGtk::GetRestoredBounds() const { | |
214 // We currently don't support tiling, so this doesn't matter. | |
215 return GetWindowScreenBounds(); | |
216 } | |
217 | |
218 void NativeWindowGtk::ShowNativeWindow(ShowState state) { | |
219 // No concept of maximization (yet) on ChromeOS. | |
220 if (state == NativeWindow::SHOW_INACTIVE) | |
221 gtk_window_set_focus_on_map(GetNativeWindow(), false); | |
222 gtk_widget_show(GetNativeView()); | |
223 } | |
224 | |
225 void NativeWindowGtk::BecomeModal() { | 208 void NativeWindowGtk::BecomeModal() { |
226 gtk_window_set_modal(GetNativeWindow(), true); | 209 gtk_window_set_modal(GetNativeWindow(), true); |
227 } | 210 } |
228 | 211 |
229 void NativeWindowGtk::EnableClose(bool enable) { | |
230 gtk_window_set_deletable(GetNativeWindow(), enable); | |
231 } | |
232 | |
233 Window* NativeWindowGtk::GetWindow() { | 212 Window* NativeWindowGtk::GetWindow() { |
234 return delegate_->AsWindow(); | 213 return delegate_->AsWindow(); |
235 } | 214 } |
236 | 215 |
237 const Window* NativeWindowGtk::GetWindow() const { | 216 const Window* NativeWindowGtk::GetWindow() const { |
238 return delegate_->AsWindow(); | 217 return delegate_->AsWindow(); |
239 } | 218 } |
240 | 219 |
241 //////////////////////////////////////////////////////////////////////////////// | 220 //////////////////////////////////////////////////////////////////////////////// |
242 // NativeWindowGtk, NativeWidgetGtk overrides: | 221 // NativeWindowGtk, NativeWidgetGtk overrides: |
243 | 222 |
244 void NativeWindowGtk::Restore() { | |
245 if (IsFullscreen()) | |
246 SetFullscreen(false); | |
247 else | |
248 NativeWidgetGtk::Restore(); | |
249 } | |
250 | |
251 gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget, | 223 gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget, |
252 GdkEventWindowState* event) { | 224 GdkEventWindowState* event) { |
253 if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) | 225 if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN)) |
254 SaveWindowPosition(); | 226 SaveWindowPosition(); |
255 return NativeWidgetGtk::OnWindowStateEvent(widget, event); | 227 return NativeWidgetGtk::OnWindowStateEvent(widget, event); |
256 } | 228 } |
257 | 229 |
258 //////////////////////////////////////////////////////////////////////////////// | 230 //////////////////////////////////////////////////////////////////////////////// |
259 // NativeWindowGtk, private: | 231 // NativeWindowGtk, private: |
260 | 232 |
261 // static | 233 // static |
262 gboolean NativeWindowGtk::CallConfigureEvent(GtkWidget* widget, | 234 gboolean NativeWindowGtk::CallConfigureEvent(GtkWidget* widget, |
263 GdkEventConfigure* event, | 235 GdkEventConfigure* event, |
264 NativeWindowGtk* window_gtk) { | 236 NativeWindowGtk* window_gtk) { |
265 return window_gtk->OnConfigureEvent(widget, event); | 237 return window_gtk->OnConfigureEvent(widget, event); |
266 } | 238 } |
267 | 239 |
268 void NativeWindowGtk::SaveWindowPosition() { | 240 void NativeWindowGtk::SaveWindowPosition() { |
269 // The delegate may have gone away on us. | 241 // The delegate may have gone away on us. |
270 if (!GetWindow()->window_delegate()) | 242 if (!GetWindow()->window_delegate()) |
271 return; | 243 return; |
272 | 244 |
273 bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED; | 245 bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED; |
274 GetWindow()->window_delegate()->SaveWindowPlacement( | 246 GetWindow()->window_delegate()->SaveWindowPlacement( |
275 GetWidget()->GetWindowScreenBounds(), | 247 GetWidget()->GetWindowScreenBounds(), |
276 maximized); | 248 maximized); |
277 } | 249 } |
278 | 250 |
279 void NativeWindowGtk::OnDestroy(GtkWidget* widget) { | |
280 delegate_->OnNativeWindowDestroying(); | |
281 NativeWidgetGtk::OnDestroy(widget); | |
282 } | |
283 | |
284 //////////////////////////////////////////////////////////////////////////////// | 251 //////////////////////////////////////////////////////////////////////////////// |
285 // NativeWindow, public: | 252 // NativeWindow, public: |
286 | 253 |
287 // static | 254 // static |
288 NativeWindow* NativeWindow::CreateNativeWindow( | 255 NativeWindow* NativeWindow::CreateNativeWindow( |
289 internal::NativeWindowDelegate* delegate) { | 256 internal::NativeWindowDelegate* delegate) { |
290 return new NativeWindowGtk(delegate); | 257 return new NativeWindowGtk(delegate); |
291 } | 258 } |
292 | 259 |
293 } // namespace views | 260 } // namespace views |
OLD | NEW |