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

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

Issue 10834205: Draggable region support for frameless app window on GTK. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: refactor the patch. Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 } 2315 }
2316 } 2316 }
2317 2317
2318 return FALSE; // Continue to propagate the event. 2318 return FALSE; // Continue to propagate the event.
2319 } 2319 }
2320 2320
2321 bool BrowserWindowGtk::HandleTitleBarLeftMousePress( 2321 bool BrowserWindowGtk::HandleTitleBarLeftMousePress(
2322 GdkEventButton* event, 2322 GdkEventButton* event,
2323 guint32 last_click_time, 2323 guint32 last_click_time,
2324 gfx::Point last_click_position) { 2324 gfx::Point last_click_position) {
2325 // We want to start a move when the user single clicks, but not start a 2325 return gtk_window_util::HandleTitleBarLeftMousePress(window_, bounds_,
2326 // move when the user double clicks. However, a double click sends the 2326 event, last_click_time, last_click_position);
2327 // following GDK events: GDK_BUTTON_PRESS, GDK_BUTTON_RELEASE,
2328 // GDK_BUTTON_PRESS, GDK_2BUTTON_PRESS, GDK_BUTTON_RELEASE. If we
2329 // start a gtk_window_begin_move_drag on the second GDK_BUTTON_PRESS,
2330 // the call to gtk_window_maximize fails. To work around this, we
2331 // keep track of the last click and if it's going to be a double click,
2332 // we don't call gtk_window_begin_move_drag.
2333 static GtkSettings* settings = gtk_settings_get_default();
2334 gint double_click_time = 250;
2335 gint double_click_distance = 5;
2336 g_object_get(G_OBJECT(settings),
2337 "gtk-double-click-time", &double_click_time,
2338 "gtk-double-click-distance", &double_click_distance,
2339 NULL);
2340
2341 guint32 click_time = event->time - last_click_time;
2342 int click_move_x = abs(event->x - last_click_position.x());
2343 int click_move_y = abs(event->y - last_click_position.y());
2344
2345 if (click_time > static_cast<guint32>(double_click_time) ||
2346 click_move_x > double_click_distance ||
2347 click_move_y > double_click_distance) {
2348 // Ignore drag requests if the window is the size of the screen.
2349 // We do this to avoid triggering fullscreen mode in metacity
2350 // (without the --no-force-fullscreen flag) and in compiz (with
2351 // Legacy Fullscreen Mode enabled).
2352 if (!BoundsMatchMonitorSize()) {
2353 gtk_window_begin_move_drag(window_, event->button,
2354 static_cast<gint>(event->x_root),
2355 static_cast<gint>(event->y_root),
2356 event->time);
2357 }
2358 return TRUE;
2359 }
2360 return FALSE;
2361 } 2327 }
2362 2328
2363 bool BrowserWindowGtk::HandleWindowEdgeLeftMousePress( 2329 bool BrowserWindowGtk::HandleWindowEdgeLeftMousePress(
2364 GtkWindow* window, 2330 GtkWindow* window,
2365 GdkWindowEdge edge, 2331 GdkWindowEdge edge,
2366 GdkEventButton* event) { 2332 GdkEventButton* event) {
2367 gtk_window_begin_resize_drag(window, edge, event->button, 2333 gtk_window_begin_resize_drag(window, edge, event->button,
2368 static_cast<gint>(event->x_root), 2334 static_cast<gint>(event->x_root),
2369 static_cast<gint>(event->y_root), 2335 static_cast<gint>(event->y_root),
2370 event->time); 2336 event->time);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 2455
2490 NOTREACHED(); 2456 NOTREACHED();
2491 return false; 2457 return false;
2492 } 2458 }
2493 2459
2494 bool BrowserWindowGtk::UseCustomFrame() const { 2460 bool BrowserWindowGtk::UseCustomFrame() const {
2495 // We don't use the custom frame for app mode windows or app window popups. 2461 // We don't use the custom frame for app mode windows or app window popups.
2496 return use_custom_frame_pref_.GetValue() && !browser_->is_app(); 2462 return use_custom_frame_pref_.GetValue() && !browser_->is_app();
2497 } 2463 }
2498 2464
2499 bool BrowserWindowGtk::BoundsMatchMonitorSize() {
2500 // A screen can be composed of multiple monitors.
2501 GdkScreen* screen = gtk_window_get_screen(window_);
2502 gint monitor_num = gdk_screen_get_monitor_at_window(screen,
2503 gtk_widget_get_window(GTK_WIDGET(window_)));
2504
2505 GdkRectangle monitor_size;
2506 gdk_screen_get_monitor_geometry(screen, monitor_num, &monitor_size);
2507 return bounds_.size() == gfx::Size(monitor_size.width, monitor_size.height);
2508 }
2509
2510 void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) { 2465 void BrowserWindowGtk::PlaceBookmarkBar(bool is_floating) {
2511 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::PlaceBookmarkBar"); 2466 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::PlaceBookmarkBar");
2512 2467
2513 GtkWidget* target_parent = NULL; 2468 GtkWidget* target_parent = NULL;
2514 if (!is_floating) { 2469 if (!is_floating) {
2515 // Place the bookmark bar at the end of |window_vbox_|; this happens after 2470 // Place the bookmark bar at the end of |window_vbox_|; this happens after
2516 // we have placed the render area at the end of |window_vbox_| so we will 2471 // we have placed the render area at the end of |window_vbox_| so we will
2517 // be above the render area. 2472 // be above the render area.
2518 target_parent = window_vbox_; 2473 target_parent = window_vbox_;
2519 } else { 2474 } else {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 wm_type == ui::WM_OPENBOX || 2507 wm_type == ui::WM_OPENBOX ||
2553 wm_type == ui::WM_XFWM4); 2508 wm_type == ui::WM_XFWM4);
2554 } 2509 }
2555 2510
2556 // static 2511 // static
2557 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2512 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2558 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2513 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2559 browser_window_gtk->Init(); 2514 browser_window_gtk->Init();
2560 return browser_window_gtk; 2515 return browser_window_gtk;
2561 } 2516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698