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

Side by Side Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 8625001: GTK: Part 1 of removing GtkWidget->window to close up GSEALs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Ignore chromeos Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/gtk/browser_titlebar.cc ('k') | no next file » | 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 "chrome/browser/ui/gtk/browser_window_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <string> 10 #include <string>
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // of calling gtk_window_resize directly. This is done to avoid a WM "feature" 250 // of calling gtk_window_resize directly. This is done to avoid a WM "feature"
251 // where setting the window size to the monitor size causes the WM to set the 251 // where setting the window size to the monitor size causes the WM to set the
252 // EWMH for full screen mode. 252 // EWMH for full screen mode.
253 void SetWindowSize(GtkWindow* window, const gfx::Size& size) { 253 void SetWindowSize(GtkWindow* window, const gfx::Size& size) {
254 gfx::Size new_size = size; 254 gfx::Size new_size = size;
255 255
256 gint current_width = 0; 256 gint current_width = 0;
257 gint current_height = 0; 257 gint current_height = 0;
258 gtk_window_get_size(window, &current_width, &current_height); 258 gtk_window_get_size(window, &current_width, &current_height);
259 GdkRectangle size_with_decorations = {0}; 259 GdkRectangle size_with_decorations = {0};
260 if (GTK_WIDGET(window)->window) { 260 GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window));
261 gdk_window_get_frame_extents(GTK_WIDGET(window)->window, 261 if (gdk_window) {
262 gdk_window_get_frame_extents(gdk_window,
262 &size_with_decorations); 263 &size_with_decorations);
263 } 264 }
264 265
265 if (current_width == size_with_decorations.width && 266 if (current_width == size_with_decorations.width &&
266 current_height == size_with_decorations.height) { 267 current_height == size_with_decorations.height) {
267 // Make sure the window doesn't match any monitor size. We compare against 268 // Make sure the window doesn't match any monitor size. We compare against
268 // all monitors because we don't know which monitor the window is going to 269 // all monitors because we don't know which monitor the window is going to
269 // open on (the WM decides that). 270 // open on (the WM decides that).
270 GdkScreen* screen = gtk_window_get_screen(window); 271 GdkScreen* screen = gtk_window_get_screen(window);
271 gint num_monitors = gdk_screen_get_n_monitors(screen); 272 gint num_monitors = gdk_screen_get_n_monitors(screen);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 // the window is destroyed. 737 // the window is destroyed.
737 global_menu_bar_->Disable(); 738 global_menu_bar_->Disable();
738 gtk_widget_destroy(window); 739 gtk_widget_destroy(window);
739 } 740 }
740 741
741 void BrowserWindowGtk::Activate() { 742 void BrowserWindowGtk::Activate() {
742 gtk_window_present(window_); 743 gtk_window_present(window_);
743 } 744 }
744 745
745 void BrowserWindowGtk::Deactivate() { 746 void BrowserWindowGtk::Deactivate() {
746 gdk_window_lower(GTK_WIDGET(window_)->window); 747 gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(window_)));
747 } 748 }
748 749
749 bool BrowserWindowGtk::IsActive() const { 750 bool BrowserWindowGtk::IsActive() const {
750 return is_active_; 751 return is_active_;
751 } 752 }
752 753
753 void BrowserWindowGtk::FlashFrame() { 754 void BrowserWindowGtk::FlashFrame() {
754 // May not be respected by all window managers. 755 // May not be respected by all window managers.
755 gtk_window_set_urgency_hint(window_, TRUE); 756 gtk_window_set_urgency_hint(window_, TRUE);
756 } 757 }
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 // Update all the UI bits. 1255 // Update all the UI bits.
1255 UpdateTitleBar(); 1256 UpdateTitleBar();
1256 MaybeShowBookmarkBar(false); 1257 MaybeShowBookmarkBar(false);
1257 } 1258 }
1258 1259
1259 void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { 1260 void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) {
1260 // Do nothing if we're in the process of closing the browser window. 1261 // Do nothing if we're in the process of closing the browser window.
1261 if (!window_) 1262 if (!window_)
1262 return; 1263 return;
1263 1264
1264 bool is_active = (GTK_WIDGET(window_)->window == active_window); 1265 bool is_active = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window;
1265 bool changed = (is_active != is_active_); 1266 bool changed = (is_active != is_active_);
1266 1267
1267 if (is_active && changed) { 1268 if (is_active && changed) {
1268 // If there's an app modal dialog (e.g., JS alert), try to redirect 1269 // If there's an app modal dialog (e.g., JS alert), try to redirect
1269 // the user's attention to the window owning the dialog. 1270 // the user's attention to the window owning the dialog.
1270 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { 1271 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) {
1271 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 1272 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
1272 return; 1273 return;
1273 } 1274 }
1274 } 1275 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 gtk_floating_container_add_floating( 1551 gtk_floating_container_add_floating(
1551 GTK_FLOATING_CONTAINER(render_area_floating_container_), 1552 GTK_FLOATING_CONTAINER(render_area_floating_container_),
1552 findbar->widget()); 1553 findbar->widget());
1553 } 1554 }
1554 1555
1555 void BrowserWindowGtk::ResetCustomFrameCursor() { 1556 void BrowserWindowGtk::ResetCustomFrameCursor() {
1556 if (!frame_cursor_) 1557 if (!frame_cursor_)
1557 return; 1558 return;
1558 1559
1559 frame_cursor_ = NULL; 1560 frame_cursor_ = NULL;
1560 gdk_window_set_cursor(GTK_WIDGET(window_)->window, NULL); 1561 gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)), NULL);
1561 } 1562 }
1562 1563
1563 // static 1564 // static
1564 BrowserWindowGtk* BrowserWindowGtk::GetBrowserWindowForNativeWindow( 1565 BrowserWindowGtk* BrowserWindowGtk::GetBrowserWindowForNativeWindow(
1565 gfx::NativeWindow window) { 1566 gfx::NativeWindow window) {
1566 if (window) { 1567 if (window) {
1567 return static_cast<BrowserWindowGtk*>( 1568 return static_cast<BrowserWindowGtk*>(
1568 g_object_get_qdata(G_OBJECT(window), GetBrowserWindowQuarkKey())); 1569 g_object_get_qdata(G_OBJECT(window), GetBrowserWindowQuarkKey()));
1569 } 1570 }
1570 1571
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 gtk_widget_show(bookmark_bar_->widget()); 1767 gtk_widget_show(bookmark_bar_->widget());
1767 1768
1768 g_signal_connect_after(bookmark_bar_->widget(), "expose-event", 1769 g_signal_connect_after(bookmark_bar_->widget(), "expose-event",
1769 G_CALLBACK(OnBookmarkBarExposeThunk), this); 1770 G_CALLBACK(OnBookmarkBarExposeThunk), this);
1770 g_signal_connect(bookmark_bar_->widget(), "size-allocate", 1771 g_signal_connect(bookmark_bar_->widget(), "size-allocate",
1771 G_CALLBACK(OnBookmarkBarSizeAllocateThunk), this); 1772 G_CALLBACK(OnBookmarkBarSizeAllocateThunk), this);
1772 } 1773 }
1773 1774
1774 // We have to realize the window before we try to apply a window shape mask. 1775 // We have to realize the window before we try to apply a window shape mask.
1775 gtk_widget_realize(GTK_WIDGET(window_)); 1776 gtk_widget_realize(GTK_WIDGET(window_));
1776 state_ = gdk_window_get_state(GTK_WIDGET(window_)->window); 1777 state_ = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(window_)));
1777 // Note that calling this the first time is necessary to get the 1778 // Note that calling this the first time is necessary to get the
1778 // proper control layout. 1779 // proper control layout.
1779 UpdateCustomFrame(); 1780 UpdateCustomFrame();
1780 1781
1781 // We have to call this after the first window is created, but after that only 1782 // We have to call this after the first window is created, but after that only
1782 // when the theme changes. 1783 // when the theme changes.
1783 static bool default_icon_set = false; 1784 static bool default_icon_set = false;
1784 if (!default_icon_set) { 1785 if (!default_icon_set) {
1785 gtk_util::SetDefaultWindowIcon(window_); 1786 gtk_util::SetDefaultWindowIcon(window_);
1786 default_icon_set = true; 1787 default_icon_set = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 // The bottom two rects are mirror images of the top two rects. 1846 // The bottom two rects are mirror images of the top two rects.
1846 GdkRectangle bot_mid_rect = top_mid_rect; 1847 GdkRectangle bot_mid_rect = top_mid_rect;
1847 bot_mid_rect.y = height - 3; 1848 bot_mid_rect.y = height - 3;
1848 GdkRectangle bot_bot_rect = top_top_rect; 1849 GdkRectangle bot_bot_rect = top_top_rect;
1849 bot_bot_rect.y = height - 1; 1850 bot_bot_rect.y = height - 1;
1850 GdkRegion* mask = gdk_region_rectangle(&top_top_rect); 1851 GdkRegion* mask = gdk_region_rectangle(&top_top_rect);
1851 gdk_region_union_with_rect(mask, &top_mid_rect); 1852 gdk_region_union_with_rect(mask, &top_mid_rect);
1852 gdk_region_union_with_rect(mask, &mid_rect); 1853 gdk_region_union_with_rect(mask, &mid_rect);
1853 gdk_region_union_with_rect(mask, &bot_mid_rect); 1854 gdk_region_union_with_rect(mask, &bot_mid_rect);
1854 gdk_region_union_with_rect(mask, &bot_bot_rect); 1855 gdk_region_union_with_rect(mask, &bot_bot_rect);
1855 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); 1856 gdk_window_shape_combine_region(gtk_widget_get_window(GTK_WIDGET(window_)),
1857 mask, 0, 0);
1856 gdk_region_destroy(mask); 1858 gdk_region_destroy(mask);
1857 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1, 1859 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1,
1858 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness); 1860 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness);
1859 } else { 1861 } else {
1860 // XFCE disables the system decorations if there's an xshape set. 1862 // XFCE disables the system decorations if there's an xshape set.
1861 if (UseCustomFrame()) { 1863 if (UseCustomFrame()) {
1862 // Disable rounded corners. Simply passing in a NULL region doesn't 1864 // Disable rounded corners. Simply passing in a NULL region doesn't
1863 // seem to work on KWin, so manually set the shape to the whole window. 1865 // seem to work on KWin, so manually set the shape to the whole window.
1864 GdkRectangle rect = { 0, 0, width, height }; 1866 GdkRectangle rect = { 0, 0, width, height };
1865 GdkRegion* mask = gdk_region_rectangle(&rect); 1867 GdkRegion* mask = gdk_region_rectangle(&rect);
1866 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); 1868 gdk_window_shape_combine_region(
1869 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0);
1867 gdk_region_destroy(mask); 1870 gdk_region_destroy(mask);
1868 } else { 1871 } else {
1869 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); 1872 gdk_window_shape_combine_region(
1873 gtk_widget_get_window(GTK_WIDGET(window_)), NULL, 0, 0);
1870 } 1874 }
1871 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); 1875 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0);
1872 } 1876 }
1873 } 1877 }
1874 1878
1875 void BrowserWindowGtk::ConnectAccelerators() { 1879 void BrowserWindowGtk::ConnectAccelerators() {
1876 accel_group_ = gtk_accel_group_new(); 1880 accel_group_ = gtk_accel_group_new();
1877 gtk_window_add_accel_group(window_, accel_group_); 1881 gtk_window_add_accel_group(window_, accel_group_);
1878 1882
1879 AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance(); 1883 AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance();
(...skipping 16 matching lines...) Expand all
1896 } 1900 }
1897 1901
1898 gfx::Size BrowserWindowGtk::GetNonClientFrameSize() const { 1902 gfx::Size BrowserWindowGtk::GetNonClientFrameSize() const {
1899 return gfx::Size(window_container_->allocation.width - 1903 return gfx::Size(window_container_->allocation.width -
1900 render_area_floating_container_->allocation.width, 1904 render_area_floating_container_->allocation.width,
1901 window_container_->allocation.height - 1905 window_container_->allocation.height -
1902 render_area_floating_container_->allocation.height); 1906 render_area_floating_container_->allocation.height);
1903 } 1907 }
1904 1908
1905 void BrowserWindowGtk::InvalidateWindow() { 1909 void BrowserWindowGtk::InvalidateWindow() {
1906 gdk_window_invalidate_rect(GTK_WIDGET(window_)->window, 1910 gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(window_)),
1907 &GTK_WIDGET(window_)->allocation, TRUE); 1911 &GTK_WIDGET(window_)->allocation, TRUE);
1908 } 1912 }
1909 1913
1910 void BrowserWindowGtk::SaveWindowPosition() { 1914 void BrowserWindowGtk::SaveWindowPosition() {
1911 // Browser::SaveWindowPlacement is used for session restore. 1915 // Browser::SaveWindowPlacement is used for session restore.
1912 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; 1916 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
1913 if (IsMaximized()) 1917 if (IsMaximized())
1914 show_state = ui::SHOW_STATE_MAXIMIZED; 1918 show_state = ui::SHOW_STATE_MAXIMIZED;
1915 else if (IsMinimized()) 1919 else if (IsMinimized())
1916 show_state = ui::SHOW_STATE_MINIMIZED; 1920 show_state = ui::SHOW_STATE_MINIMIZED;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 2055
2052 // Prevents the default handler from handling this event. 2056 // Prevents the default handler from handling this event.
2053 return TRUE; 2057 return TRUE;
2054 } 2058 }
2055 2059
2056 gboolean BrowserWindowGtk::OnMouseMoveEvent(GtkWidget* widget, 2060 gboolean BrowserWindowGtk::OnMouseMoveEvent(GtkWidget* widget,
2057 GdkEventMotion* event) { 2061 GdkEventMotion* event) {
2058 // This method is used to update the mouse cursor when over the edge of the 2062 // This method is used to update the mouse cursor when over the edge of the
2059 // custom frame. If the custom frame is off or we're over some other widget, 2063 // custom frame. If the custom frame is off or we're over some other widget,
2060 // do nothing. 2064 // do nothing.
2061 if (!UseCustomFrame() || event->window != widget->window) { 2065 if (!UseCustomFrame() || event->window != gtk_widget_get_window(widget)) {
2062 // Reset the cursor. 2066 // Reset the cursor.
2063 if (frame_cursor_) { 2067 if (frame_cursor_) {
2064 frame_cursor_ = NULL; 2068 frame_cursor_ = NULL;
2065 gdk_window_set_cursor(GTK_WIDGET(window_)->window, NULL); 2069 gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)), NULL);
2066 } 2070 }
2067 return FALSE; 2071 return FALSE;
2068 } 2072 }
2069 2073
2070 // Update the cursor if we're on the custom frame border. 2074 // Update the cursor if we're on the custom frame border.
2071 GdkWindowEdge edge; 2075 GdkWindowEdge edge;
2072 bool has_hit_edge = GetWindowEdge(static_cast<int>(event->x), 2076 bool has_hit_edge = GetWindowEdge(static_cast<int>(event->x),
2073 static_cast<int>(event->y), &edge); 2077 static_cast<int>(event->y), &edge);
2074 GdkCursorType new_cursor = GDK_LAST_CURSOR; 2078 GdkCursorType new_cursor = GDK_LAST_CURSOR;
2075 if (has_hit_edge) 2079 if (has_hit_edge)
2076 new_cursor = GdkWindowEdgeToGdkCursorType(edge); 2080 new_cursor = GdkWindowEdgeToGdkCursorType(edge);
2077 2081
2078 GdkCursorType last_cursor = GDK_LAST_CURSOR; 2082 GdkCursorType last_cursor = GDK_LAST_CURSOR;
2079 if (frame_cursor_) 2083 if (frame_cursor_)
2080 last_cursor = frame_cursor_->type; 2084 last_cursor = frame_cursor_->type;
2081 2085
2082 if (last_cursor != new_cursor) { 2086 if (last_cursor != new_cursor) {
2083 if (has_hit_edge) { 2087 if (has_hit_edge) {
2084 frame_cursor_ = gfx::GetCursor(new_cursor); 2088 frame_cursor_ = gfx::GetCursor(new_cursor);
2085 } else { 2089 } else {
2086 frame_cursor_ = NULL; 2090 frame_cursor_ = NULL;
2087 } 2091 }
2088 gdk_window_set_cursor(GTK_WIDGET(window_)->window, frame_cursor_); 2092 gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(window_)),
2093 frame_cursor_);
2089 } 2094 }
2090 return FALSE; 2095 return FALSE;
2091 } 2096 }
2092 2097
2093 gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget, 2098 gboolean BrowserWindowGtk::OnButtonPressEvent(GtkWidget* widget,
2094 GdkEventButton* event) { 2099 GdkEventButton* event) {
2095 // Handle back/forward. 2100 // Handle back/forward.
2096 if (event->type == GDK_BUTTON_PRESS) { 2101 if (event->type == GDK_BUTTON_PRESS) {
2097 if (event->button == 8) { 2102 if (event->button == 8) {
2098 browser_->GoBack(CURRENT_TAB); 2103 browser_->GoBack(CURRENT_TAB);
2099 return TRUE; 2104 return TRUE;
2100 } else if (event->button == 9) { 2105 } else if (event->button == 9) {
2101 browser_->GoForward(CURRENT_TAB); 2106 browser_->GoForward(CURRENT_TAB);
2102 return TRUE; 2107 return TRUE;
2103 } 2108 }
2104 } 2109 }
2105 2110
2106 // Handle left, middle and right clicks. In particular, we care about clicks 2111 // Handle left, middle and right clicks. In particular, we care about clicks
2107 // in the custom frame border and clicks in the titlebar. 2112 // in the custom frame border and clicks in the titlebar.
2108 2113
2109 // Make the button press coordinate relative to the browser window. 2114 // Make the button press coordinate relative to the browser window.
2110 int win_x, win_y; 2115 int win_x, win_y;
2111 gdk_window_get_origin(GTK_WIDGET(window_)->window, &win_x, &win_y); 2116 GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window_));
2117 gdk_window_get_origin(gdk_window, &win_x, &win_y);
2112 2118
2113 GdkWindowEdge edge; 2119 GdkWindowEdge edge;
2114 gfx::Point point(static_cast<int>(event->x_root - win_x), 2120 gfx::Point point(static_cast<int>(event->x_root - win_x),
2115 static_cast<int>(event->y_root - win_y)); 2121 static_cast<int>(event->y_root - win_y));
2116 bool has_hit_edge = GetWindowEdge(point.x(), point.y(), &edge); 2122 bool has_hit_edge = GetWindowEdge(point.x(), point.y(), &edge);
2117 2123
2118 // Ignore clicks that are in/below the browser toolbar. 2124 // Ignore clicks that are in/below the browser toolbar.
2119 GtkWidget* toolbar = toolbar_->widget(); 2125 GtkWidget* toolbar = toolbar_->widget();
2120 if (!gtk_widget_get_visible(toolbar)) { 2126 if (!gtk_widget_get_visible(toolbar)) {
2121 // If the toolbar is not showing, use the location of web contents as the 2127 // If the toolbar is not showing, use the location of web contents as the
2122 // boundary of where to ignore clicks. 2128 // boundary of where to ignore clicks.
2123 toolbar = render_area_vbox_; 2129 toolbar = render_area_vbox_;
2124 } 2130 }
2125 gint toolbar_y; 2131 gint toolbar_y;
2126 gtk_widget_get_pointer(toolbar, NULL, &toolbar_y); 2132 gtk_widget_get_pointer(toolbar, NULL, &toolbar_y);
2127 bool has_hit_titlebar = !IsFullscreen() && (toolbar_y < 0) 2133 bool has_hit_titlebar = !IsFullscreen() && (toolbar_y < 0)
2128 && !has_hit_edge; 2134 && !has_hit_edge;
2129 if (event->button == 1) { 2135 if (event->button == 1) {
2130 if (GDK_BUTTON_PRESS == event->type) { 2136 if (GDK_BUTTON_PRESS == event->type) {
2131 guint32 last_click_time = last_click_time_; 2137 guint32 last_click_time = last_click_time_;
2132 gfx::Point last_click_position = last_click_position_; 2138 gfx::Point last_click_position = last_click_position_;
2133 last_click_time_ = event->time; 2139 last_click_time_ = event->time;
2134 last_click_position_ = gfx::Point(static_cast<int>(event->x), 2140 last_click_position_ = gfx::Point(static_cast<int>(event->x),
2135 static_cast<int>(event->y)); 2141 static_cast<int>(event->y));
2136 2142
2137 // Raise the window after a click on either the titlebar or the border to 2143 // Raise the window after a click on either the titlebar or the border to
2138 // match the behavior of most window managers, unless that behavior has 2144 // match the behavior of most window managers, unless that behavior has
2139 // been suppressed. 2145 // been suppressed.
2140 if ((has_hit_titlebar || has_hit_edge) && !suppress_window_raise_) 2146 if ((has_hit_titlebar || has_hit_edge) && !suppress_window_raise_)
2141 gdk_window_raise(GTK_WIDGET(window_)->window); 2147 gdk_window_raise(gdk_window);
2142 2148
2143 if (has_hit_titlebar) { 2149 if (has_hit_titlebar) {
2144 return HandleTitleBarLeftMousePress( 2150 return HandleTitleBarLeftMousePress(
2145 event, last_click_time, last_click_position); 2151 event, last_click_time, last_click_position);
2146 } else if (has_hit_edge) { 2152 } else if (has_hit_edge) {
2147 gtk_window_begin_resize_drag(window_, edge, event->button, 2153 gtk_window_begin_resize_drag(window_, edge, event->button,
2148 static_cast<gint>(event->x_root), 2154 static_cast<gint>(event->x_root),
2149 static_cast<gint>(event->y_root), 2155 static_cast<gint>(event->y_root),
2150 event->time); 2156 event->time);
2151 return TRUE; 2157 return TRUE;
2152 } 2158 }
2153 } else if (GDK_2BUTTON_PRESS == event->type) { 2159 } else if (GDK_2BUTTON_PRESS == event->type) {
2154 if (has_hit_titlebar) { 2160 if (has_hit_titlebar) {
2155 // Maximize/restore on double click. 2161 // Maximize/restore on double click.
2156 if (IsMaximized()) { 2162 if (IsMaximized()) {
2157 UnMaximize(); 2163 UnMaximize();
2158 } else { 2164 } else {
2159 gtk_window_maximize(window_); 2165 gtk_window_maximize(window_);
2160 } 2166 }
2161 return TRUE; 2167 return TRUE;
2162 } 2168 }
2163 } 2169 }
2164 } else if (event->button == 2) { 2170 } else if (event->button == 2) {
2165 if (has_hit_titlebar || has_hit_edge) { 2171 if (has_hit_titlebar || has_hit_edge) {
2166 gdk_window_lower(GTK_WIDGET(window_)->window); 2172 gdk_window_lower(gdk_window);
2167 } 2173 }
2168 return TRUE; 2174 return TRUE;
2169 } else if (event->button == 3) { 2175 } else if (event->button == 3) {
2170 if (has_hit_titlebar) { 2176 if (has_hit_titlebar) {
2171 titlebar_->ShowContextMenu(event); 2177 titlebar_->ShowContextMenu(event);
2172 return TRUE; 2178 return TRUE;
2173 } 2179 }
2174 } 2180 }
2175 2181
2176 return FALSE; // Continue to propagate the event. 2182 return FALSE; // Continue to propagate the event.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 return FALSE; 2240 return FALSE;
2235 } 2241 }
2236 2242
2237 void BrowserWindowGtk::ShowSupportedWindowFeatures() { 2243 void BrowserWindowGtk::ShowSupportedWindowFeatures() {
2238 if (IsTabStripSupported()) 2244 if (IsTabStripSupported())
2239 tabstrip_->Show(); 2245 tabstrip_->Show();
2240 2246
2241 if (IsToolbarSupported()) { 2247 if (IsToolbarSupported()) {
2242 toolbar_->Show(); 2248 toolbar_->Show();
2243 gtk_widget_show(toolbar_border_); 2249 gtk_widget_show(toolbar_border_);
2244 gdk_window_lower(toolbar_border_->window); 2250 gdk_window_lower(gtk_widget_get_window(toolbar_border_));
2245 } 2251 }
2246 2252
2247 if (IsBookmarkBarSupported()) 2253 if (IsBookmarkBarSupported())
2248 MaybeShowBookmarkBar(false); 2254 MaybeShowBookmarkBar(false);
2249 } 2255 }
2250 2256
2251 void BrowserWindowGtk::HideUnsupportedWindowFeatures() { 2257 void BrowserWindowGtk::HideUnsupportedWindowFeatures() {
2252 if (!IsTabStripSupported()) 2258 if (!IsTabStripSupported())
2253 tabstrip_->Hide(); 2259 tabstrip_->Hide();
2254 2260
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 2343
2338 bool BrowserWindowGtk::UseCustomFrame() { 2344 bool BrowserWindowGtk::UseCustomFrame() {
2339 // We don't use the custom frame for app mode windows or app window popups. 2345 // We don't use the custom frame for app mode windows or app window popups.
2340 return use_custom_frame_pref_.GetValue() && !browser_->is_app(); 2346 return use_custom_frame_pref_.GetValue() && !browser_->is_app();
2341 } 2347 }
2342 2348
2343 bool BrowserWindowGtk::BoundsMatchMonitorSize() { 2349 bool BrowserWindowGtk::BoundsMatchMonitorSize() {
2344 // A screen can be composed of multiple monitors. 2350 // A screen can be composed of multiple monitors.
2345 GdkScreen* screen = gtk_window_get_screen(window_); 2351 GdkScreen* screen = gtk_window_get_screen(window_);
2346 gint monitor_num = gdk_screen_get_monitor_at_window(screen, 2352 gint monitor_num = gdk_screen_get_monitor_at_window(screen,
2347 GTK_WIDGET(window_)->window); 2353 gtk_widget_get_window(GTK_WIDGET(window_)));
2348 2354
2349 GdkRectangle monitor_size; 2355 GdkRectangle monitor_size;
2350 gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor_size); 2356 gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor_size);
2351 return bounds_.size() == gfx::Size(monitor_size.width, monitor_size.height); 2357 return bounds_.size() == gfx::Size(monitor_size.width, monitor_size.height);
2352 } 2358 }
2353 2359
2354 void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) { 2360 void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) {
2355 GtkWidget* target_parent = NULL; 2361 GtkWidget* target_parent = NULL;
2356 if (!is_floating) { 2362 if (!is_floating) {
2357 // Place the bookmark bar at the end of |window_vbox_|; this happens after 2363 // Place the bookmark bar at the end of |window_vbox_|; this happens after
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 wm_type == ui::WM_OPENBOX || 2412 wm_type == ui::WM_OPENBOX ||
2407 wm_type == ui::WM_XFWM4); 2413 wm_type == ui::WM_XFWM4);
2408 } 2414 }
2409 2415
2410 // static 2416 // static
2411 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2417 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2412 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2418 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2413 browser_window_gtk->Init(); 2419 browser_window_gtk->Init();
2414 return browser_window_gtk; 2420 return browser_window_gtk;
2415 } 2421 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_titlebar.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698