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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_GTK_WINDOW_UTIL_H_
6 #define CHROME_BROWSER_UI_GTK_GTK_WINDOW_UTIL_H_
10 #include "ui/gfx/rect.h"
20 namespace gtk_window_util
{
22 // The frame border is only visible in restored mode and is hardcoded to 4 px
23 // on each side regardless of the system window border size.
24 extern const int kFrameBorderThickness
;
25 // In the window corners, the resize areas don't actually expand bigger, but
26 // the 16 px at the end of each edge triggers diagonal resizing.
27 extern const int kResizeAreaCornerSize
;
29 // Performs Cut/Copy/Paste operation on the |window|'s |web_contents|.
30 void DoCut(GtkWindow
* window
, content::WebContents
* web_contents
);
31 void DoCopy(GtkWindow
* window
, content::WebContents
* web_contents
);
32 void DoPaste(GtkWindow
* window
, content::WebContents
* web_contents
);
34 // Ubuntu patches their version of GTK+ to that there is always a
35 // gripper in the bottom right corner of the window. We always need to
36 // disable this feature since we can't communicate this to WebKit easily.
37 void DisableResizeGrip(GtkWindow
* window
);
39 // Returns the resize cursor corresponding to the window |edge|.
40 GdkCursorType
GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge
);
42 // Returns |true| if the window bounds match the monitor size.
43 bool BoundsMatchMonitorSize(GtkWindow
* window
, gfx::Rect bounds
);
45 bool HandleTitleBarLeftMousePress(GtkWindow
* window
,
46 const gfx::Rect
& bounds
,
47 GdkEventButton
* event
);
49 // Request the underlying window to unmaximize. Also tries to work around
50 // a window manager "feature" that can prevent this in some edge cases.
51 void UnMaximize(GtkWindow
* window
,
52 const gfx::Rect
& bounds
,
53 const gfx::Rect
& restored_bounds
);
55 // Set a custom WM_CLASS for a window.
56 void SetWindowCustomClass(GtkWindow
* window
, const std::string
& wmclass
);
58 // A helper method for setting the GtkWindow size that should be used in place
59 // of calling gtk_window_resize directly. This is done to avoid a WM "feature"
60 // where setting the window size to the monitor size causes the WM to set the
61 // EWMH for full screen mode.
62 void SetWindowSize(GtkWindow
* window
, const gfx::Size
& size
);
64 // Update the origin of |bounds| and |restored_bounds| with values gotten
66 void UpdateWindowPosition(ui::BaseWindow
* window
,
68 gfx::Rect
* restored_bounds
);
70 // If the point (|x|, |y|) is within the resize border area of the window,
71 // returns true and sets |edge| to the appropriate GdkWindowEdge value.
72 // Otherwise, returns false.
73 // |top_edge_inset| specifies how much smaller (in px) than the default edge
74 // size the top edge should be, used by browser windows to make it easier to
75 // move the window since a lot of title bar space is taken by the tabs.
76 bool GetWindowEdge(const gfx::Size
& window_size
,
82 } // namespace gtk_window_util
84 #endif // CHROME_BROWSER_UI_GTK_GTK_WINDOW_UTIL_H_