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

Side by Side Diff: chrome/browser/render_widget_host_view_win.cc

Issue 15088: Add support for custom cursors set by windowless plugins. Windowless plugins... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/render_widget_host_view_win.h ('k') | webkit/glue/chrome_client_impl.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/render_widget_host_view_win.h" 5 #include "chrome/browser/render_widget_host_view_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/gfx/gdi_util.h" 8 #include "base/gfx/gdi_util.h"
9 #include "base/gfx/rect.h" 9 #include "base/gfx/rect.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 60 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
61 RenderWidgetHost* widget) { 61 RenderWidgetHost* widget) {
62 return new RenderWidgetHostViewWin(widget); 62 return new RenderWidgetHostViewWin(widget);
63 } 63 }
64 64
65 /////////////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////////////
66 // RenderWidgetHostViewWin, public: 66 // RenderWidgetHostViewWin, public:
67 67
68 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) 68 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
69 : render_widget_host_(widget), 69 : render_widget_host_(widget),
70 cursor_(LoadCursor(NULL, IDC_ARROW)),
71 cursor_is_custom_(false),
72 track_mouse_leave_(false), 70 track_mouse_leave_(false),
73 ime_notification_(false), 71 ime_notification_(false),
74 is_hidden_(false), 72 is_hidden_(false),
75 close_on_deactivate_(false), 73 close_on_deactivate_(false),
76 tooltip_hwnd_(NULL), 74 tooltip_hwnd_(NULL),
77 tooltip_showing_(false), 75 tooltip_showing_(false),
78 shutdown_factory_(this), 76 shutdown_factory_(this),
79 parent_hwnd_(NULL), 77 parent_hwnd_(NULL),
80 is_loading_(false), 78 is_loading_(false),
81 focus_on_show_(true) { 79 focus_on_show_(true) {
82 render_widget_host_->set_view(this); 80 render_widget_host_->set_view(this);
83 renderer_accessible_ = 81 renderer_accessible_ =
84 CommandLine().HasSwitch(switches::kEnableRendererAccessibility); 82 CommandLine().HasSwitch(switches::kEnableRendererAccessibility);
85 } 83 }
86 84
87 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { 85 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() {
88 if (cursor_is_custom_)
89 DestroyIcon(cursor_);
90 ResetTooltip(); 86 ResetTooltip();
91 } 87 }
92 88
93 /////////////////////////////////////////////////////////////////////////////// 89 ///////////////////////////////////////////////////////////////////////////////
94 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: 90 // RenderWidgetHostViewWin, RenderWidgetHostView implementation:
95 91
96 RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { 92 RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const {
97 return render_widget_host_; 93 return render_widget_host_;
98 } 94 }
99 95
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 WasHidden(); 207 WasHidden();
212 } 208 }
213 209
214 gfx::Rect RenderWidgetHostViewWin::GetViewBounds() const { 210 gfx::Rect RenderWidgetHostViewWin::GetViewBounds() const {
215 CRect window_rect; 211 CRect window_rect;
216 GetWindowRect(&window_rect); 212 GetWindowRect(&window_rect);
217 return gfx::Rect(window_rect); 213 return gfx::Rect(window_rect);
218 } 214 }
219 215
220 void RenderWidgetHostViewWin::UpdateCursor(const WebCursor& cursor) { 216 void RenderWidgetHostViewWin::UpdateCursor(const WebCursor& cursor) {
221 static HINSTANCE module_handle = 217 current_cursor_ = cursor;
222 GetModuleHandle(chrome::kBrowserResourcesDll);
223
224 // If the last active cursor was a custom cursor, we need to destroy
225 // it before setting the new one.
226 if (cursor_is_custom_)
227 DestroyIcon(cursor_);
228
229 cursor_is_custom_ = cursor.IsCustom();
230 if (cursor_is_custom_) {
231 cursor_ = cursor.GetCustomCursor();
232 } else {
233 // We cannot pass in NULL as the module handle as this would only
234 // work for standard win32 cursors. We can also receive cursor
235 // types which are defined as webkit resources. We need to specify
236 // the module handle of chrome.dll while loading these cursors.
237 cursor_ = cursor.GetCursor(module_handle);
238 }
239
240 UpdateCursorIfOverSelf(); 218 UpdateCursorIfOverSelf();
241 } 219 }
242 220
243 void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() { 221 void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() {
244 static HCURSOR kCursorArrow = LoadCursor(NULL, IDC_ARROW); 222 static HCURSOR kCursorArrow = LoadCursor(NULL, IDC_ARROW);
245 static HCURSOR kCursorAppStarting = LoadCursor(NULL, IDC_APPSTARTING); 223 static HCURSOR kCursorAppStarting = LoadCursor(NULL, IDC_APPSTARTING);
224 static HINSTANCE module_handle =
225 GetModuleHandle(chrome::kBrowserResourcesDll);
246 226
247 HCURSOR display_cursor = cursor_; 227 // We cannot pass in NULL as the module handle as this would only work for
228 // standard win32 cursors. We can also receive cursor types which are defined
229 // as webkit resources. We need to specify the module handle of chrome.dll
230 // while loading these cursors.
231 HCURSOR display_cursor = current_cursor_.GetCursor(module_handle);
232
248 // If a page is in the loading state, we want to show the Arrow+Hourglass 233 // If a page is in the loading state, we want to show the Arrow+Hourglass
249 // cursor only when the current cursor is the ARROW cursor. In all other 234 // cursor only when the current cursor is the ARROW cursor. In all other
250 // cases we should continue to display the current cursor. 235 // cases we should continue to display the current cursor.
251 if (is_loading_ && display_cursor == kCursorArrow) 236 if (is_loading_ && display_cursor == kCursorArrow)
252 display_cursor = kCursorAppStarting; 237 display_cursor = kCursorAppStarting;
253 238
254 // If the mouse is over our HWND, then update the cursor state immediately. 239 // If the mouse is over our HWND, then update the cursor state immediately.
255 CPoint pt; 240 CPoint pt;
256 GetCursorPos(&pt); 241 GetCursorPos(&pt);
257 if (WindowFromPoint(pt) == m_hWnd) 242 if (WindowFromPoint(pt) == m_hWnd)
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 if (!handled_by_webcontents) { 758 if (!handled_by_webcontents) {
774 render_widget_host_->ForwardWheelEvent( 759 render_widget_host_->ForwardWheelEvent(
775 WebMouseWheelEvent(m_hWnd, message, wparam, lparam)); 760 WebMouseWheelEvent(m_hWnd, message, wparam, lparam));
776 } 761 }
777 handled = TRUE; 762 handled = TRUE;
778 return 0; 763 return 0;
779 } 764 }
780 765
781 LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM, 766 LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM,
782 BOOL& handled) { 767 BOOL& handled) {
768 if (!focus_on_show_)
769 return MA_NOACTIVATE;
770
783 HWND focus_window = GetFocus(); 771 HWND focus_window = GetFocus();
784 if (!::IsWindow(focus_window) || !IsChild(focus_window)) { 772 if (!::IsWindow(focus_window) || !IsChild(focus_window)) {
785 // We handle WM_MOUSEACTIVATE to set focus to the underlying plugin 773 // We handle WM_MOUSEACTIVATE to set focus to the underlying plugin
786 // child window. This is to ensure that keyboard events are received 774 // child window. This is to ensure that keyboard events are received
787 // by the plugin. The correct way to fix this would be send over 775 // by the plugin. The correct way to fix this would be send over
788 // an event to the renderer which would then eventually send over 776 // an event to the renderer which would then eventually send over
789 // a setFocus call to the plugin widget. This would ensure that 777 // a setFocus call to the plugin widget. This would ensure that
790 // the renderer (webkit) knows about the plugin widget receiving 778 // the renderer (webkit) knows about the plugin widget receiving
791 // focus. 779 // focus.
792 // TODO(iyengar) Do the right thing as per the above comment. 780 // TODO(iyengar) Do the right thing as per the above comment.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 if (::IsWindow(tooltip_hwnd_)) 897 if (::IsWindow(tooltip_hwnd_))
910 ::DestroyWindow(tooltip_hwnd_); 898 ::DestroyWindow(tooltip_hwnd_);
911 tooltip_hwnd_ = NULL; 899 tooltip_hwnd_ = NULL;
912 } 900 }
913 901
914 void RenderWidgetHostViewWin::ShutdownHost() { 902 void RenderWidgetHostViewWin::ShutdownHost() {
915 shutdown_factory_.RevokeAll(); 903 shutdown_factory_.RevokeAll();
916 render_widget_host_->Shutdown(); 904 render_widget_host_->Shutdown();
917 // Do not touch any members at this point, |this| has been deleted. 905 // Do not touch any members at this point, |this| has been deleted.
918 } 906 }
919
OLDNEW
« no previous file with comments | « chrome/browser/render_widget_host_view_win.h ('k') | webkit/glue/chrome_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698