1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/renderer_host/render_widget_host.h"
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include "base/synchronization/lock.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/x11/WebScreenInfoFactory.h"
#include "ui/gfx/gtk_native_view_id_manager.h"
#include "ui/gfx/rect.h"
using WebKit::WebScreenInfo;
using WebKit::WebScreenInfoFactory;
// We get a null |view| passed into this function please see
// http://crbug.com/9060 for more details.
void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view,
WebScreenInfo* results) {
GtkWidget* widget = NULL;
GdkWindow* gdk_window = NULL;
if (GtkNativeViewManager::GetInstance()->GetNativeViewForId(
&widget, view) && widget) {
gdk_window = widget->window;
} else {
GdkDisplay* display = gdk_display_get_default();
gdk_window = gdk_display_get_default_group(display);
}
if (!gdk_window)
return;
GdkScreen* screen = gdk_drawable_get_screen(gdk_window);
*results = WebScreenInfoFactory::screenInfo(
gdk_x11_drawable_get_xdisplay(gdk_window),
gdk_x11_screen_get_screen_number(screen));
// TODO(tony): We should move this code into WebScreenInfoFactory.
int monitor_number = gdk_screen_get_monitor_at_window(screen, gdk_window);
GdkRectangle monitor_rect;
gdk_screen_get_monitor_geometry(screen, monitor_number, &monitor_rect);
results->rect = WebKit::WebRect(monitor_rect.x, monitor_rect.y,
monitor_rect.width, monitor_rect.height);
// TODO(tony): Should we query _NET_WORKAREA to get the workarea?
results->availableRect = results->rect;
}
// We get null window_ids passed into this function please see
// http://crbug.com/9060 for more details.
void RenderWidgetHost::OnMsgGetWindowRect(gfx::NativeViewId window_id,
gfx::Rect* results) {
GtkWidget* widget = NULL;
if (!GtkNativeViewManager::GetInstance()->GetNativeViewForId(
&widget, window_id) || !widget) {
return;
}
GdkWindow* gdk_window = widget->window;
if (!gdk_window)
return;
GdkRectangle window_rect;
gdk_window_get_origin(gdk_window, &window_rect.x, &window_rect.y);
gdk_drawable_get_size(gdk_window, &window_rect.width, &window_rect.height);
*results = window_rect;
}
// We get null window_ids passed into this function please see
// http://crbug.com/9060 for more details.
void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id,
gfx::Rect* results) {
GtkWidget* widget = NULL;
if (!GtkNativeViewManager::GetInstance()->GetNativeViewForId(
&widget, window_id) || !widget) {
return;
}
GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
if (!toplevel)
return;
GdkRectangle frame_extents;
GdkWindow* gdk_window = toplevel->window;
if (!gdk_window)
return;
gdk_window_get_frame_extents(gdk_window, &frame_extents);
*results = gfx::Rect(frame_extents.x, frame_extents.y,
frame_extents.width, frame_extents.height);
}
void RenderWidgetHost::OnMsgCreatePluginContainer(gfx::PluginWindowHandle id) {
// TODO(piman): view_ can only be NULL with delayed view creation in
// extensions (see ExtensionHost::CreateRenderViewSoon). Figure out how to
// support plugins in that case.
if (view_) {
view_->CreatePluginContainer(id);
} else {
deferred_plugin_handles_.push_back(id);
}
}
void RenderWidgetHost::OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id) {
if (view_) {
view_->DestroyPluginContainer(id);
} else {
for (int i = 0;
i < static_cast<int>(deferred_plugin_handles_.size());
i++) {
if (deferred_plugin_handles_[i] == id) {
deferred_plugin_handles_.erase(deferred_plugin_handles_.begin() + i);
i--;
}
}
}
}
|