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

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

Issue 202050: Disallow popup windows from setting the window size to the exact (Closed)
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/browser_window_gtk.h" 5 #include "chrome/browser/gtk/browser_window_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <X11/XF86keysym.h> 8 #include <X11/XF86keysym.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 default: 510 default:
511 NOTREACHED(); 511 NOTREACHED();
512 } 512 }
513 return GDK_LAST_CURSOR; 513 return GDK_LAST_CURSOR;
514 } 514 }
515 515
516 GdkColor SkColorToGdkColor(const SkColor& color) { 516 GdkColor SkColorToGdkColor(const SkColor& color) {
517 return skia::SkColorToGdkColor(color); 517 return skia::SkColorToGdkColor(color);
518 } 518 }
519 519
520 // A helper method for setting the GtkWindow size that should be used in place
521 // of calling gtk_window_resize directly. This is done to avoid a WM "feature"
522 // where setting the window size to the screen size causes the WM to set the
523 // EWMH for full screen mode.
524 void SetWindowSize(GtkWindow* window, int width, int height) {
525 GdkScreen* screen = gdk_screen_get_default();
526 if (width == gdk_screen_get_width(screen) &&
527 height == gdk_screen_get_height(screen)) {
528 // Adjust the height so we don't trigger the WM feature.
529 gtk_window_resize(window, width, height - 1);
530 } else {
531 gtk_window_resize(window, width, height);
532 }
533 }
534
520 } // namespace 535 } // namespace
521 536
522 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_; 537 std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_;
523 538
524 #if defined(OS_CHROMEOS) 539 #if defined(OS_CHROMEOS)
525 // Default to using the regular window style. 540 // Default to using the regular window style.
526 bool BrowserWindowGtk::next_window_should_use_compact_nav_ = false; 541 bool BrowserWindowGtk::next_window_should_use_compact_nav_ = false;
527 #endif 542 #endif
528 543
529 BrowserWindowGtk::BrowserWindowGtk(Browser* browser) 544 BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 808 }
794 } 809 }
795 810
796 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { 811 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) {
797 gint x = static_cast<gint>(bounds.x()); 812 gint x = static_cast<gint>(bounds.x());
798 gint y = static_cast<gint>(bounds.y()); 813 gint y = static_cast<gint>(bounds.y());
799 gint width = static_cast<gint>(bounds.width()); 814 gint width = static_cast<gint>(bounds.width());
800 gint height = static_cast<gint>(bounds.height()); 815 gint height = static_cast<gint>(bounds.height());
801 816
802 gtk_window_move(window_, x, y); 817 gtk_window_move(window_, x, y);
803 gtk_window_resize(window_, width, height); 818 SetWindowSize(window_, width, height);
804 } 819 }
805 820
806 void BrowserWindowGtk::Close() { 821 void BrowserWindowGtk::Close() {
807 // We're already closing. Do nothing. 822 // We're already closing. Do nothing.
808 if (!window_) 823 if (!window_)
809 return; 824 return;
810 825
811 if (!CanClose()) 826 if (!CanClose())
812 return; 827 return;
813 828
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 // on the window and we intentionally *don't* do that for normal 1450 // on the window and we intentionally *don't* do that for normal
1436 // windows. We tested many programs and none of them restored their 1451 // windows. We tested many programs and none of them restored their
1437 // position on Linux. 1452 // position on Linux.
1438 // 1453 //
1439 // However, in cases like dropping a tab where the bounds are 1454 // However, in cases like dropping a tab where the bounds are
1440 // specifically set, we do want to position explicitly. 1455 // specifically set, we do want to position explicitly.
1441 if (browser_->bounds_overridden()) { 1456 if (browser_->bounds_overridden()) {
1442 SetBounds(bounds); 1457 SetBounds(bounds);
1443 } else { 1458 } else {
1444 // Ignore the position but obey the size. 1459 // Ignore the position but obey the size.
1445 GdkScreen* screen = gdk_screen_get_default(); 1460 SetWindowSize(window_, bounds.width(), bounds.height());
1446 if (bounds.width() == gdk_screen_get_width(screen) &&
1447 bounds.height() == gdk_screen_get_height(screen)) {
1448 // Work around a WM "feature" where if we set the window to the exact
1449 // size of the monitor, the WM automatically puts us in full screen mode.
1450 // Instead, adjust the height so we don't trigger this WM work around.
1451 gtk_window_resize(window_, bounds.width(), bounds.height() - 1);
1452 } else {
1453 gtk_window_resize(window_, bounds.width(), bounds.height());
1454 }
1455 } 1461 }
1456 } 1462 }
1457 1463
1458 void BrowserWindowGtk::ConnectHandlersToSignals() { 1464 void BrowserWindowGtk::ConnectHandlersToSignals() {
1459 g_signal_connect(window_, "delete-event", 1465 g_signal_connect(window_, "delete-event",
1460 G_CALLBACK(MainWindowDeleteEvent), this); 1466 G_CALLBACK(MainWindowDeleteEvent), this);
1461 g_signal_connect(window_, "destroy", 1467 g_signal_connect(window_, "destroy",
1462 G_CALLBACK(MainWindowDestroy), this); 1468 G_CALLBACK(MainWindowDestroy), this);
1463 g_signal_connect(window_, "configure-event", 1469 g_signal_connect(window_, "configure-event",
1464 G_CALLBACK(MainWindowConfigured), this); 1470 G_CALLBACK(MainWindowConfigured), this);
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 // special-case the ones where the custom frame should be used. These names 2159 // special-case the ones where the custom frame should be used. These names
2154 // are taken from the WMs' source code. 2160 // are taken from the WMs' source code.
2155 return (wm_name == "Blackbox" || 2161 return (wm_name == "Blackbox" ||
2156 wm_name == "compiz" || 2162 wm_name == "compiz" ||
2157 wm_name == "e16" || // Enlightenment DR16 2163 wm_name == "e16" || // Enlightenment DR16
2158 wm_name == "KWin" || 2164 wm_name == "KWin" ||
2159 wm_name == "Metacity" || 2165 wm_name == "Metacity" ||
2160 wm_name == "Openbox" || 2166 wm_name == "Openbox" ||
2161 wm_name == "Xfwm4"); 2167 wm_name == "Xfwm4");
2162 } 2168 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698