- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / gtk / gtk_window_util.h
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.
4
5 #ifndef CHROME_BROWSER_UI_GTK_GTK_WINDOW_UTIL_H_
6 #define CHROME_BROWSER_UI_GTK_GTK_WINDOW_UTIL_H_
7
8 #include <gtk/gtk.h>
9 #include <gdk/gdk.h>
10 #include "ui/gfx/rect.h"
11
12 namespace content {
13 class WebContents;
14 }
15
16 namespace ui{
17 class BaseWindow;
18 }
19
20 namespace gtk_window_util {
21
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;
28
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);
33
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);
38
39 // Returns the resize cursor corresponding to the window |edge|.
40 GdkCursorType GdkWindowEdgeToGdkCursorType(GdkWindowEdge edge);
41
42 // Returns |true| if the window bounds match the monitor size.
43 bool BoundsMatchMonitorSize(GtkWindow* window, gfx::Rect bounds);
44
45 bool HandleTitleBarLeftMousePress(GtkWindow* window,
46                                   const gfx::Rect& bounds,
47                                   GdkEventButton* event);
48
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);
54
55 // Set a custom WM_CLASS for a window.
56 void SetWindowCustomClass(GtkWindow* window, const std::string& wmclass);
57
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);
63
64 // Update the origin of |bounds| and |restored_bounds| with values gotten
65 // from GTK.
66 void UpdateWindowPosition(ui::BaseWindow* window,
67                           gfx::Rect* bounds,
68                           gfx::Rect* restored_bounds);
69
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,
77                    int top_edge_inset,
78                    int x,
79                    int y,
80                    GdkWindowEdge* edge);
81
82 }  // namespace gtk_window_util
83
84 #endif  // CHROME_BROWSER_UI_GTK_GTK_WINDOW_UTIL_H_
85