| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/widget_gtk.h" | 5 #include "views/widget/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 | 10 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 gtk_widget_add_events(window_contents_, | 493 gtk_widget_add_events(window_contents_, |
| 494 GDK_ENTER_NOTIFY_MASK | | 494 GDK_ENTER_NOTIFY_MASK | |
| 495 GDK_LEAVE_NOTIFY_MASK | | 495 GDK_LEAVE_NOTIFY_MASK | |
| 496 GDK_BUTTON_PRESS_MASK | | 496 GDK_BUTTON_PRESS_MASK | |
| 497 GDK_BUTTON_RELEASE_MASK | | 497 GDK_BUTTON_RELEASE_MASK | |
| 498 GDK_POINTER_MOTION_MASK | | 498 GDK_POINTER_MOTION_MASK | |
| 499 GDK_KEY_PRESS_MASK | | 499 GDK_KEY_PRESS_MASK | |
| 500 GDK_KEY_RELEASE_MASK); | 500 GDK_KEY_RELEASE_MASK); |
| 501 SetRootViewForWidget(widget_, root_view_.get()); | 501 SetRootViewForWidget(widget_, root_view_.get()); |
| 502 | 502 |
| 503 g_signal_connect_after(G_OBJECT(window_contents_), "size_request", |
| 504 G_CALLBACK(&OnSizeRequestThunk), this); |
| 503 g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate", | 505 g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate", |
| 504 G_CALLBACK(&OnSizeAllocateThunk), this); | 506 G_CALLBACK(&OnSizeAllocateThunk), this); |
| 505 gtk_widget_set_app_paintable(window_contents_, true); | 507 gtk_widget_set_app_paintable(window_contents_, true); |
| 506 g_signal_connect(window_contents_, "expose_event", | 508 g_signal_connect(window_contents_, "expose_event", |
| 507 G_CALLBACK(&OnPaintThunk), this); | 509 G_CALLBACK(&OnPaintThunk), this); |
| 508 g_signal_connect(window_contents_, "enter_notify_event", | 510 g_signal_connect(window_contents_, "enter_notify_event", |
| 509 G_CALLBACK(&OnEnterNotifyThunk), this); | 511 G_CALLBACK(&OnEnterNotifyThunk), this); |
| 510 g_signal_connect(window_contents_, "leave_notify_event", | 512 g_signal_connect(window_contents_, "leave_notify_event", |
| 511 G_CALLBACK(&OnLeaveNotifyThunk), this); | 513 G_CALLBACK(&OnLeaveNotifyThunk), this); |
| 512 g_signal_connect(window_contents_, "motion_notify_event", | 514 g_signal_connect(window_contents_, "motion_notify_event", |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 break; | 878 break; |
| 877 default: | 879 default: |
| 878 // We only deal with 1-3. | 880 // We only deal with 1-3. |
| 879 break; | 881 break; |
| 880 } | 882 } |
| 881 if (event.type == GDK_2BUTTON_PRESS) | 883 if (event.type == GDK_2BUTTON_PRESS) |
| 882 flags |= MouseEvent::EF_IS_DOUBLE_CLICK; | 884 flags |= MouseEvent::EF_IS_DOUBLE_CLICK; |
| 883 return flags; | 885 return flags; |
| 884 } | 886 } |
| 885 | 887 |
| 888 void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) { |
| 889 // Do only return the preferred size for child windows. GtkWindow interprets |
| 890 // the requisition as a minimum size for top level windows, returning a |
| 891 // preferred size for these would prevents us from setting smaller window |
| 892 // sizes. |
| 893 if (type_ == TYPE_CHILD) { |
| 894 gfx::Size size(root_view_->GetPreferredSize()); |
| 895 requisition->width = size.width(); |
| 896 requisition->height = size.height(); |
| 897 } |
| 898 } |
| 899 |
| 886 void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { | 900 void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { |
| 887 // See comment next to size_ as to why we do this. Also note, it's tempting | 901 // See comment next to size_ as to why we do this. Also note, it's tempting |
| 888 // to put this in the static method so subclasses don't need to worry about | 902 // to put this in the static method so subclasses don't need to worry about |
| 889 // it, but if a subclasses needs to set a shape then they need to always | 903 // it, but if a subclasses needs to set a shape then they need to always |
| 890 // reset the shape in this method regardless of whether the size changed. | 904 // reset the shape in this method regardless of whether the size changed. |
| 891 gfx::Size new_size(allocation->width, allocation->height); | 905 gfx::Size new_size(allocation->width, allocation->height); |
| 892 if (new_size == size_) | 906 if (new_size == size_) |
| 893 return; | 907 return; |
| 894 size_ = new_size; | 908 size_ = new_size; |
| 895 root_view_->SetBounds(0, 0, allocation->width, allocation->height); | 909 root_view_->SetBounds(0, 0, allocation->width, allocation->height); |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 GtkWindow* window = GTK_WINDOW(element->data); | 1546 GtkWindow* window = GTK_WINDOW(element->data); |
| 1533 DCHECK(window); | 1547 DCHECK(window); |
| 1534 RootView *root_view = FindRootView(window); | 1548 RootView *root_view = FindRootView(window); |
| 1535 if (root_view) | 1549 if (root_view) |
| 1536 root_view->NotifyLocaleChanged(); | 1550 root_view->NotifyLocaleChanged(); |
| 1537 } | 1551 } |
| 1538 g_list_free(window_list); | 1552 g_list_free(window_list); |
| 1539 } | 1553 } |
| 1540 | 1554 |
| 1541 } // namespace views | 1555 } // namespace views |
| OLD | NEW |