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/widget/native_widget_gtk.h" | 5 #include "views/widget/native_widget_gtk.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <X11/extensions/shape.h> | 9 #include <X11/extensions/shape.h> |
10 #include <X11/Xatom.h> | 10 #include <X11/Xatom.h> |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 static bool installed_message_loop_observer = false; | 386 static bool installed_message_loop_observer = false; |
387 if (!installed_message_loop_observer) { | 387 if (!installed_message_loop_observer) { |
388 installed_message_loop_observer = true; | 388 installed_message_loop_observer = true; |
389 MessageLoopForUI* loop = MessageLoopForUI::current(); | 389 MessageLoopForUI* loop = MessageLoopForUI::current(); |
390 if (loop) | 390 if (loop) |
391 loop->AddObserver(DropObserver::GetInstance()); | 391 loop->AddObserver(DropObserver::GetInstance()); |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 NativeWidgetGtk::~NativeWidgetGtk() { | 395 NativeWidgetGtk::~NativeWidgetGtk() { |
396 DCHECK(widget_ == NULL); | |
397 // We need to delete the input method before calling DestroyRootView(), | 396 // We need to delete the input method before calling DestroyRootView(), |
398 // because it'll set focus_manager_ to NULL. | 397 // because it'll set focus_manager_ to NULL. |
399 input_method_.reset(); | 398 input_method_.reset(); |
400 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 399 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { |
| 400 DCHECK(widget_ == NULL); |
401 delete delegate_; | 401 delete delegate_; |
| 402 } else { |
| 403 CloseNow(); |
| 404 } |
402 } | 405 } |
403 | 406 |
404 GtkWindow* NativeWidgetGtk::GetTransientParent() const { | 407 GtkWindow* NativeWidgetGtk::GetTransientParent() const { |
405 return (!child_ && widget_) ? | 408 return (!child_ && widget_) ? |
406 gtk_window_get_transient_for(GTK_WINDOW(widget_)) : NULL; | 409 gtk_window_get_transient_for(GTK_WINDOW(widget_)) : NULL; |
407 } | 410 } |
408 | 411 |
409 bool NativeWidgetGtk::MakeTransparent() { | 412 bool NativeWidgetGtk::MakeTransparent() { |
410 // Transparency can only be enabled only if we haven't realized the widget. | 413 // Transparency can only be enabled only if we haven't realized the widget. |
411 DCHECK(!widget_); | 414 DCHECK(!widget_); |
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2158 button_pressed = event->type == GDK_BUTTON_PRESS || | 2161 button_pressed = event->type == GDK_BUTTON_PRESS || |
2159 event->type == GDK_2BUTTON_PRESS || | 2162 event->type == GDK_2BUTTON_PRESS || |
2160 event->type == GDK_3BUTTON_PRESS; | 2163 event->type == GDK_3BUTTON_PRESS; |
2161 gdk_event_free(event); | 2164 gdk_event_free(event); |
2162 } | 2165 } |
2163 return button_pressed; | 2166 return button_pressed; |
2164 } | 2167 } |
2165 | 2168 |
2166 } // namespace internal | 2169 } // namespace internal |
2167 } // namespace views | 2170 } // namespace views |
OLD | NEW |