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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 gint parent_h = 0; | 1021 gint parent_h = 0; |
1022 gtk_window_get_size(parent, &parent_w, &parent_h); | 1022 gtk_window_get_size(parent, &parent_w, &parent_h); |
1023 center_rect = gfx::Rect(parent_x, parent_y, parent_w, parent_h); | 1023 center_rect = gfx::Rect(parent_x, parent_y, parent_w, parent_h); |
1024 } else { | 1024 } else { |
1025 // We have no parent window, center over the screen. | 1025 // We have no parent window, center over the screen. |
1026 center_rect = gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); | 1026 center_rect = gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); |
1027 } | 1027 } |
1028 gfx::Rect bounds(center_rect.x() + (center_rect.width() - size.width()) / 2, | 1028 gfx::Rect bounds(center_rect.x() + (center_rect.width() - size.width()) / 2, |
1029 center_rect.y() + (center_rect.height() - size.height()) / 2, | 1029 center_rect.y() + (center_rect.height() - size.height()) / 2, |
1030 size.width(), size.height()); | 1030 size.width(), size.height()); |
1031 SetBoundsConstrained(bounds, NULL); | 1031 widget_->SetBoundsConstrained(bounds); |
1032 } | 1032 } |
1033 | 1033 |
1034 void NativeWidgetGtk::GetWindowPlacement( | 1034 void NativeWidgetGtk::GetWindowPlacement( |
1035 gfx::Rect* bounds, | 1035 gfx::Rect* bounds, |
1036 ui::WindowShowState* show_state) const { | 1036 ui::WindowShowState* show_state) const { |
1037 // Do nothing for now. ChromeOS isn't yet saving window placement. | 1037 // Do nothing for now. ChromeOS isn't yet saving window placement. |
1038 } | 1038 } |
1039 | 1039 |
1040 void NativeWidgetGtk::SetWindowTitle(const string16& title) { | 1040 void NativeWidgetGtk::SetWindowTitle(const string16& title) { |
1041 // We don't have a window title on ChromeOS (right now). | 1041 // We don't have a window title on ChromeOS (right now). |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 } | 1137 } |
1138 } else { | 1138 } else { |
1139 if (GTK_WIDGET_MAPPED(widget_)) | 1139 if (GTK_WIDGET_MAPPED(widget_)) |
1140 gdk_window_resize(widget_->window, size.width(), size.height()); | 1140 gdk_window_resize(widget_->window, size.width(), size.height()); |
1141 GtkWindow* gtk_window = GTK_WINDOW(widget_); | 1141 GtkWindow* gtk_window = GTK_WINDOW(widget_); |
1142 if (!size.IsEmpty()) | 1142 if (!size.IsEmpty()) |
1143 gtk_window_resize(gtk_window, size.width(), size.height()); | 1143 gtk_window_resize(gtk_window, size.width(), size.height()); |
1144 } | 1144 } |
1145 } | 1145 } |
1146 | 1146 |
1147 void NativeWidgetGtk::SetBoundsConstrained(const gfx::Rect& bounds, | |
1148 Widget* other_widget) { | |
1149 // We apparently don't care about |other_widget|. | |
1150 SetBounds(bounds); | |
1151 } | |
1152 | |
1153 void NativeWidgetGtk::MoveAbove(gfx::NativeView native_view) { | 1147 void NativeWidgetGtk::MoveAbove(gfx::NativeView native_view) { |
1154 ui::StackPopupWindow(GetNativeView(), native_view); | 1148 ui::StackPopupWindow(GetNativeView(), native_view); |
1155 } | 1149 } |
1156 | 1150 |
1157 void NativeWidgetGtk::MoveToTop() { | 1151 void NativeWidgetGtk::MoveToTop() { |
1158 DCHECK(GTK_IS_WINDOW(GetNativeView())); | 1152 DCHECK(GTK_IS_WINDOW(GetNativeView())); |
1159 gtk_window_present(GTK_WINDOW(GetNativeView())); | 1153 gtk_window_present(GTK_WINDOW(GetNativeView())); |
1160 } | 1154 } |
1161 | 1155 |
1162 void NativeWidgetGtk::SetShape(gfx::NativeRegion region) { | 1156 void NativeWidgetGtk::SetShape(gfx::NativeRegion region) { |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 button_pressed = event->type == GDK_BUTTON_PRESS || | 2301 button_pressed = event->type == GDK_BUTTON_PRESS || |
2308 event->type == GDK_2BUTTON_PRESS || | 2302 event->type == GDK_2BUTTON_PRESS || |
2309 event->type == GDK_3BUTTON_PRESS; | 2303 event->type == GDK_3BUTTON_PRESS; |
2310 gdk_event_free(event); | 2304 gdk_event_free(event); |
2311 } | 2305 } |
2312 return button_pressed; | 2306 return button_pressed; |
2313 } | 2307 } |
2314 | 2308 |
2315 } // namespace internal | 2309 } // namespace internal |
2316 } // namespace views | 2310 } // namespace views |
OLD | NEW |