Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: views/window/native_window_gtk.cc

Issue 6976040: Revert 86914 - Move a bunch of functions from Window onto Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/window/native_window_gtk.h ('k') | views/window/native_window_views.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return GDK_LEFT_PTR; 73 return GDK_LEFT_PTR;
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 namespace views { 78 namespace views {
79 79
80 NativeWindowGtk::NativeWindowGtk(internal::NativeWindowDelegate* delegate) 80 NativeWindowGtk::NativeWindowGtk(internal::NativeWindowDelegate* delegate)
81 : NativeWidgetGtk(delegate->AsNativeWidgetDelegate()), 81 : NativeWidgetGtk(delegate->AsNativeWidgetDelegate()),
82 delegate_(delegate), 82 delegate_(delegate),
83 window_state_(GDK_WINDOW_STATE_WITHDRAWN),
83 window_closed_(false) { 84 window_closed_(false) {
84 is_window_ = true; 85 is_window_ = true;
85 } 86 }
86 87
87 NativeWindowGtk::~NativeWindowGtk() { 88 NativeWindowGtk::~NativeWindowGtk() {
88 } 89 }
89 90
90 //////////////////////////////////////////////////////////////////////////////// 91 ////////////////////////////////////////////////////////////////////////////////
91 // NativeWindowGtk, NativeWidgetGtk overrides: 92 // NativeWindowGtk, NativeWidgetGtk overrides:
92 93
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 allocation->height), 175 allocation->height),
175 &window_mask); 176 &window_mask);
176 GdkRegion* mask_region = window_mask.CreateNativeRegion(); 177 GdkRegion* mask_region = window_mask.CreateNativeRegion();
177 gdk_window_shape_combine_region(GetNativeView()->window, mask_region, 0, 0); 178 gdk_window_shape_combine_region(GetNativeView()->window, mask_region, 0, 0);
178 if (mask_region) 179 if (mask_region)
179 gdk_region_destroy(mask_region); 180 gdk_region_destroy(mask_region);
180 181
181 SaveWindowPosition(); 182 SaveWindowPosition();
182 } 183 }
183 184
185 gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget,
186 GdkEventWindowState* event) {
187 window_state_ = event->new_window_state;
188 if (!(window_state_ & GDK_WINDOW_STATE_WITHDRAWN))
189 SaveWindowPosition();
190 return FALSE;
191 }
192
184 gboolean NativeWindowGtk::OnLeaveNotify(GtkWidget* widget, 193 gboolean NativeWindowGtk::OnLeaveNotify(GtkWidget* widget,
185 GdkEventCrossing* event) { 194 GdkEventCrossing* event) {
186 gdk_window_set_cursor(widget->window, gfx::GetCursor(GDK_LEFT_PTR)); 195 gdk_window_set_cursor(widget->window, gfx::GetCursor(GDK_LEFT_PTR));
187 196
188 return NativeWidgetGtk::OnLeaveNotify(widget, event); 197 return NativeWidgetGtk::OnLeaveNotify(widget, event);
189 } 198 }
190 199
191 void NativeWindowGtk::IsActiveChanged() { 200 void NativeWindowGtk::IsActiveChanged() {
192 NativeWidgetGtk::IsActiveChanged(); 201 NativeWidgetGtk::IsActiveChanged();
193 delegate_->OnNativeWindowActivationChanged(IsActive()); 202 delegate_->OnNativeWindowActivationChanged(IsActive());
194 } 203 }
195 204
196 void NativeWindowGtk::InitNativeWidget(const Widget::InitParams& params) { 205 void NativeWindowGtk::InitNativeWidget(const Widget::InitParams& params) {
197 NativeWidgetGtk::InitNativeWidget(params); 206 NativeWidgetGtk::InitNativeWidget(params);
198 207
199 g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event", 208 g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event",
200 G_CALLBACK(CallConfigureEvent), this); 209 G_CALLBACK(CallConfigureEvent), this);
210 g_signal_connect(G_OBJECT(GetNativeWindow()), "window-state-event",
211 G_CALLBACK(CallWindowStateEvent), this);
201 } 212 }
202 213
203 //////////////////////////////////////////////////////////////////////////////// 214 ////////////////////////////////////////////////////////////////////////////////
204 // NativeWindowGtk, NativeWindow implementation: 215 // NativeWindowGtk, NativeWindow implementation:
205 216
206 NativeWidget* NativeWindowGtk::AsNativeWidget() { 217 NativeWidget* NativeWindowGtk::AsNativeWidget() {
207 return this; 218 return this;
208 } 219 }
209 220
210 const NativeWidget* NativeWindowGtk::AsNativeWidget() const { 221 const NativeWidget* NativeWindowGtk::AsNativeWidget() const {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 const Window* NativeWindowGtk::GetWindow() const { 295 const Window* NativeWindowGtk::GetWindow() const {
285 return delegate_->AsWindow(); 296 return delegate_->AsWindow();
286 } 297 }
287 298
288 void NativeWindowGtk::SetWindowBounds(const gfx::Rect& bounds, 299 void NativeWindowGtk::SetWindowBounds(const gfx::Rect& bounds,
289 gfx::NativeWindow other_window) { 300 gfx::NativeWindow other_window) {
290 // TODO: need to deal with other_window. 301 // TODO: need to deal with other_window.
291 NativeWidgetGtk::SetBounds(bounds); 302 NativeWidgetGtk::SetBounds(bounds);
292 } 303 }
293 304
305 void NativeWindowGtk::HideWindow() {
306 GetWindow()->Hide();
307 }
308
309 void NativeWindowGtk::Activate() {
310 gtk_window_present(GTK_WINDOW(GetNativeView()));
311 }
312
313 void NativeWindowGtk::Deactivate() {
314 gdk_window_lower(GTK_WIDGET(GetNativeView())->window);
315 }
316
317 void NativeWindowGtk::Maximize() {
318 gtk_window_maximize(GetNativeWindow());
319 }
320
321 void NativeWindowGtk::Minimize() {
322 gtk_window_iconify(GetNativeWindow());
323 }
324
325 void NativeWindowGtk::Restore() {
326 if (IsMaximized())
327 gtk_window_unmaximize(GetNativeWindow());
328 else if (IsMinimized())
329 gtk_window_deiconify(GetNativeWindow());
330 else if (IsFullscreen())
331 SetFullscreen(false);
332 }
333
334 bool NativeWindowGtk::IsActive() const {
335 return NativeWidgetGtk::IsActive();
336 }
337
338 bool NativeWindowGtk::IsVisible() const {
339 return GTK_WIDGET_VISIBLE(GetNativeView());
340 }
341
342 bool NativeWindowGtk::IsMaximized() const {
343 return window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
344 }
345
346 bool NativeWindowGtk::IsMinimized() const {
347 return window_state_ & GDK_WINDOW_STATE_ICONIFIED;
348 }
349
294 void NativeWindowGtk::SetFullscreen(bool fullscreen) { 350 void NativeWindowGtk::SetFullscreen(bool fullscreen) {
295 if (fullscreen) 351 if (fullscreen)
296 gtk_window_fullscreen(GetNativeWindow()); 352 gtk_window_fullscreen(GetNativeWindow());
297 else 353 else
298 gtk_window_unfullscreen(GetNativeWindow()); 354 gtk_window_unfullscreen(GetNativeWindow());
299 } 355 }
300 356
301 bool NativeWindowGtk::IsFullscreen() const { 357 bool NativeWindowGtk::IsFullscreen() const {
302 return window_state_ & GDK_WINDOW_STATE_FULLSCREEN; 358 return window_state_ & GDK_WINDOW_STATE_FULLSCREEN;
303 } 359 }
304 360
305 void NativeWindowGtk::SetUseDragFrame(bool use_drag_frame) { 361 void NativeWindowGtk::SetUseDragFrame(bool use_drag_frame) {
306 NOTIMPLEMENTED(); 362 NOTIMPLEMENTED();
307 } 363 }
308 364
309 NonClientFrameView* NativeWindowGtk::CreateFrameViewForWindow() { 365 NonClientFrameView* NativeWindowGtk::CreateFrameViewForWindow() {
310 return NULL; 366 return NULL;
311 } 367 }
312 368
369 void NativeWindowGtk::SetAlwaysOnTop(bool always_on_top) {
370 gtk_window_set_keep_above(GetNativeWindow(), always_on_top);
371 }
372
313 void NativeWindowGtk::UpdateFrameAfterFrameChange() { 373 void NativeWindowGtk::UpdateFrameAfterFrameChange() {
314 // We currently don't support different frame types on Gtk, so we don't 374 // We currently don't support different frame types on Gtk, so we don't
315 // need to implement this. 375 // need to implement this.
316 NOTIMPLEMENTED(); 376 NOTIMPLEMENTED();
317 } 377 }
318 378
379 gfx::NativeWindow NativeWindowGtk::GetNativeWindow() const {
380 return GTK_WINDOW(GetNativeView());
381 }
382
319 bool NativeWindowGtk::ShouldUseNativeFrame() const { 383 bool NativeWindowGtk::ShouldUseNativeFrame() const {
320 return false; 384 return false;
321 } 385 }
322 386
323 void NativeWindowGtk::FrameTypeChanged() { 387 void NativeWindowGtk::FrameTypeChanged() {
324 // This is called when the Theme has changed, so forward the event to the root 388 // This is called when the Theme has changed, so forward the event to the root
325 // widget. 389 // widget.
326 GetWidget()->ThemeChanged(); 390 GetWidget()->ThemeChanged();
327 GetWidget()->GetRootView()->SchedulePaint(); 391 GetWidget()->GetRootView()->SchedulePaint();
328 } 392 }
329 393
330 //////////////////////////////////////////////////////////////////////////////// 394 ////////////////////////////////////////////////////////////////////////////////
331 // NativeWindowGtk, NativeWidgetGtk overrides:
332
333 void NativeWindowGtk::Restore() {
334 if (IsFullscreen())
335 SetFullscreen(false);
336 else
337 NativeWidgetGtk::Restore();
338 }
339
340 gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget,
341 GdkEventWindowState* event) {
342 if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN))
343 SaveWindowPosition();
344 return NativeWidgetGtk::OnWindowStateEvent(widget, event);
345 }
346
347 ////////////////////////////////////////////////////////////////////////////////
348 // NativeWindowGtk, private: 395 // NativeWindowGtk, private:
349 396
350 // static 397 // static
351 gboolean NativeWindowGtk::CallConfigureEvent(GtkWidget* widget, 398 gboolean NativeWindowGtk::CallConfigureEvent(GtkWidget* widget,
352 GdkEventConfigure* event, 399 GdkEventConfigure* event,
353 NativeWindowGtk* window_gtk) { 400 NativeWindowGtk* window_gtk) {
354 return window_gtk->OnConfigureEvent(widget, event); 401 return window_gtk->OnConfigureEvent(widget, event);
355 } 402 }
356 403
404 // static
405 gboolean NativeWindowGtk::CallWindowStateEvent(GtkWidget* widget,
406 GdkEventWindowState* event,
407 NativeWindowGtk* window_gtk) {
408 return window_gtk->OnWindowStateEvent(widget, event);
409 }
410
357 void NativeWindowGtk::SaveWindowPosition() { 411 void NativeWindowGtk::SaveWindowPosition() {
358 // The delegate may have gone away on us. 412 // The delegate may have gone away on us.
359 if (!GetWindow()->window_delegate()) 413 if (!GetWindow()->window_delegate())
360 return; 414 return;
361 415
362 bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED; 416 bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
363 GetWindow()->window_delegate()->SaveWindowPlacement( 417 GetWindow()->window_delegate()->SaveWindowPlacement(
364 GetWidget()->GetWindowScreenBounds(), 418 GetWidget()->GetWindowScreenBounds(),
365 maximized); 419 maximized);
366 } 420 }
367 421
368 void NativeWindowGtk::OnDestroy(GtkWidget* widget) { 422 void NativeWindowGtk::OnDestroy(GtkWidget* widget) {
369 delegate_->OnNativeWindowDestroying(); 423 delegate_->OnNativeWindowDestroying();
370 NativeWidgetGtk::OnDestroy(widget); 424 NativeWidgetGtk::OnDestroy(widget);
371 delegate_->OnNativeWindowDestroyed(); 425 delegate_->OnNativeWindowDestroyed();
372 } 426 }
373 427
374 //////////////////////////////////////////////////////////////////////////////// 428 ////////////////////////////////////////////////////////////////////////////////
375 // NativeWindow, public: 429 // NativeWindow, public:
376 430
377 // static 431 // static
378 NativeWindow* NativeWindow::CreateNativeWindow( 432 NativeWindow* NativeWindow::CreateNativeWindow(
379 internal::NativeWindowDelegate* delegate) { 433 internal::NativeWindowDelegate* delegate) {
380 return new NativeWindowGtk(delegate); 434 return new NativeWindowGtk(delegate);
381 } 435 }
382 436
383 } // namespace views 437 } // namespace views
384 438
OLDNEW
« no previous file with comments | « views/window/native_window_gtk.h ('k') | views/window/native_window_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698