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

Side by Side Diff: views/widget/widget_win.h

Issue 6756043: Consolidate Widget Event code, other cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Additional code consolidation, move base defs, nix MakeMSG, TooltipManager cleanup, etc. Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ 5 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_
6 #define VIEWS_WIDGET_WIDGET_WIN_H_ 6 #define VIEWS_WIDGET_WIDGET_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <atlbase.h> 9 #include <atlbase.h>
10 #include <atlapp.h> 10 #include <atlapp.h>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void ResetLastMouseMoveFlag() { 199 void ResetLastMouseMoveFlag() {
200 last_mouse_event_was_move_ = false; 200 last_mouse_event_was_move_ = false;
201 } 201 }
202 202
203 // Overridden from NativeWidget: 203 // Overridden from NativeWidget:
204 virtual Widget* GetWidget() OVERRIDE; 204 virtual Widget* GetWidget() OVERRIDE;
205 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; 205 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
206 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; 206 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
207 virtual TooltipManager* GetTooltipManager() const OVERRIDE; 207 virtual TooltipManager* GetTooltipManager() const OVERRIDE;
208 virtual bool IsScreenReaderActive() const OVERRIDE; 208 virtual bool IsScreenReaderActive() const OVERRIDE;
209 virtual void SetNativeCapture() OVERRIDE; 209 virtual void SetMouseCapture() OVERRIDE;
210 virtual void ReleaseNativeCapture() OVERRIDE; 210 virtual void ReleaseMouseCapture() OVERRIDE;
211 virtual bool HasNativeCapture() const OVERRIDE; 211 virtual bool HasMouseCapture() const OVERRIDE;
212 virtual bool ShouldReleaseCaptureOnMouseReleased() const OVERRIDE;
212 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; 213 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
213 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; 214 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
214 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 215 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
215 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; 216 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE;
216 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; 217 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
217 virtual void Close() OVERRIDE; 218 virtual void Close() OVERRIDE;
218 virtual void CloseNow() OVERRIDE; 219 virtual void CloseNow() OVERRIDE;
219 virtual void Show() OVERRIDE; 220 virtual void Show() OVERRIDE;
220 virtual void Hide() OVERRIDE; 221 virtual void Hide() OVERRIDE;
221 virtual void SetOpacity(unsigned char opacity) OVERRIDE; 222 virtual void SetOpacity(unsigned char opacity) OVERRIDE;
(...skipping 17 matching lines...) Expand all
239 virtual HICON GetDefaultWindowIcon() const OVERRIDE; 240 virtual HICON GetDefaultWindowIcon() const OVERRIDE;
240 virtual LRESULT OnWndProc(UINT message, 241 virtual LRESULT OnWndProc(UINT message,
241 WPARAM w_param, 242 WPARAM w_param,
242 LPARAM l_param) OVERRIDE; 243 LPARAM l_param) OVERRIDE;
243 244
244 // Message Handlers ---------------------------------------------------------- 245 // Message Handlers ----------------------------------------------------------
245 246
246 BEGIN_MSG_MAP_EX(WidgetWin) 247 BEGIN_MSG_MAP_EX(WidgetWin)
247 // Range handlers must go first! 248 // Range handlers must go first!
248 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) 249 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
249 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnNCMouseRange) 250 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnMouseRange)
250 251
251 // Reflected message handler 252 // Reflected message handler
252 MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) 253 MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage)
253 254
254 // CustomFrameWindow hacks 255 // CustomFrameWindow hacks
255 MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption) 256 MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption)
256 MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame) 257 MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame)
257 258
258 // Vista and newer 259 // Vista and newer
259 MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged) 260 MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged)
260 261
261 // Non-atlcrack.h handlers 262 // Non-atlcrack.h handlers
262 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) 263 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
263 264
264 // Mouse events. 265 // Mouse events.
265 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate) 266 MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate)
266 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) 267 MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseRange)
267 MESSAGE_HANDLER_EX(WM_MOUSEMOVE, OnMouseMove)
268 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel) 268 MESSAGE_HANDLER_EX(WM_MOUSEWHEEL, OnMouseWheel)
269 MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnNCMouseLeave) 269 MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnMouseRange)
270 MESSAGE_HANDLER_EX(WM_NCMOUSEMOVE, OnNCMouseMove)
271 270
272 // Key events. 271 // Key events.
273 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyDown) 272 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyDown)
274 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyUp) 273 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyUp)
275 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyDown); 274 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyDown);
276 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyUp); 275 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyUp);
277 276
278 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. 277 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU.
279 MSG_WM_ACTIVATE(OnActivate) 278 MSG_WM_ACTIVATE(OnActivate)
280 MSG_WM_ACTIVATEAPP(OnActivateApp) 279 MSG_WM_ACTIVATEAPP(OnActivateApp)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 virtual void OnExitSizeMove(); 347 virtual void OnExitSizeMove();
349 virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); 348 virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param);
350 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info); 349 virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info);
351 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); 350 virtual void OnHScroll(int scroll_type, short position, HWND scrollbar);
352 virtual void OnInitMenu(HMENU menu); 351 virtual void OnInitMenu(HMENU menu);
353 virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); 352 virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu);
354 virtual LRESULT OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param); 353 virtual LRESULT OnKeyDown(UINT message, WPARAM w_param, LPARAM l_param);
355 virtual LRESULT OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param); 354 virtual LRESULT OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param);
356 virtual void OnKillFocus(HWND focused_window); 355 virtual void OnKillFocus(HWND focused_window);
357 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); 356 virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
358 virtual LRESULT OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param);
359 virtual LRESULT OnMouseMove(UINT message, WPARAM w_param, LPARAM l_param);
360 virtual LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); 357 virtual LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
361 virtual LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param); 358 virtual LRESULT OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param);
362 virtual void OnMove(const CPoint& point); 359 virtual void OnMove(const CPoint& point);
363 virtual void OnMoving(UINT param, LPRECT new_bounds); 360 virtual void OnMoving(UINT param, LPRECT new_bounds);
364 virtual LRESULT OnNCActivate(BOOL active); 361 virtual LRESULT OnNCActivate(BOOL active);
365 virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param); 362 virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param);
366 virtual LRESULT OnNCHitTest(const CPoint& pt); 363 virtual LRESULT OnNCHitTest(const CPoint& pt);
367 virtual LRESULT OnNCMouseLeave(UINT message, WPARAM w_param, LPARAM l_param);
368 virtual LRESULT OnNCMouseMove(UINT message, WPARAM w_param, LPARAM l_param);
369 virtual LRESULT OnNCMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
370 virtual void OnNCPaint(HRGN rgn); 364 virtual void OnNCPaint(HRGN rgn);
371 virtual LRESULT OnNCUAHDrawCaption(UINT msg, 365 virtual LRESULT OnNCUAHDrawCaption(UINT msg,
372 WPARAM w_param, 366 WPARAM w_param,
373 LPARAM l_param); 367 LPARAM l_param);
374 virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param); 368 virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param);
375 virtual LRESULT OnNotify(int w_param, NMHDR* l_param); 369 virtual LRESULT OnNotify(int w_param, NMHDR* l_param);
376 virtual void OnPaint(HDC dc); 370 virtual void OnPaint(HDC dc);
377 virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data); 371 virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data);
378 virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param); 372 virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param);
379 virtual void OnSetFocus(HWND focused_window); 373 virtual void OnSetFocus(HWND focused_window);
380 virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon); 374 virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon);
381 virtual LRESULT OnSetText(const wchar_t* text); 375 virtual LRESULT OnSetText(const wchar_t* text);
382 virtual void OnSettingChange(UINT flags, const wchar_t* section); 376 virtual void OnSettingChange(UINT flags, const wchar_t* section);
383 virtual void OnSize(UINT param, const CSize& size); 377 virtual void OnSize(UINT param, const CSize& size);
384 virtual void OnSysCommand(UINT notification_code, CPoint click); 378 virtual void OnSysCommand(UINT notification_code, CPoint click);
385 virtual void OnThemeChanged(); 379 virtual void OnThemeChanged();
386 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar); 380 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar);
387 virtual void OnWindowPosChanging(WINDOWPOS* window_pos); 381 virtual void OnWindowPosChanging(WINDOWPOS* window_pos);
388 virtual void OnWindowPosChanged(WINDOWPOS* window_pos); 382 virtual void OnWindowPosChanged(WINDOWPOS* window_pos);
389 383
390 // Deletes this window as it is destroyed, override to provide different 384 // Deletes this window as it is destroyed, override to provide different
391 // behavior. 385 // behavior.
392 virtual void OnFinalMessage(HWND window); 386 virtual void OnFinalMessage(HWND window);
393 387
394 // Start tracking all mouse events so that this window gets sent mouse leave 388 // Start tracking all mouse events so that this window gets sent mouse leave
395 // messages too. 389 // messages too.
396 void TrackMouseEvents(DWORD mouse_tracking_flags); 390 void TrackMouseEvents(DWORD mouse_tracking_flags);
397 391
398 // Actually handle mouse events. These functions are called by subclasses who
399 // override the message handlers above to do the actual real work of handling
400 // the event in the View system.
401 bool ProcessMousePressed(UINT message, WPARAM w_param, LPARAM l_param);
402 bool ProcessMouseReleased(UINT message, WPARAM w_param, LPARAM l_param);
403 bool ProcessMouseMoved(UINT message, WPARAM w_param, LPARAM l_param);
404 void ProcessMouseExited(UINT message, WPARAM w_param, LPARAM l_param);
405
406 // Called when a MSAA screen reader client is detected. 392 // Called when a MSAA screen reader client is detected.
407 virtual void OnScreenReaderDetected(); 393 virtual void OnScreenReaderDetected();
408 394
409 // Returns whether capture should be released on mouse release. The default
410 // is true.
411 virtual bool ReleaseCaptureOnMouseReleased();
412
413 // The TooltipManager. 395 // The TooltipManager.
414 // WARNING: RootView's destructor calls into the TooltipManager. As such, this 396 // WARNING: RootView's destructor calls into the TooltipManager. As such, this
415 // must be destroyed AFTER root_view_. 397 // must be destroyed AFTER root_view_.
416 scoped_ptr<TooltipManagerWin> tooltip_manager_; 398 scoped_ptr<TooltipManagerWin> tooltip_manager_;
417 399
418 scoped_refptr<DropTargetWin> drop_target_; 400 scoped_refptr<DropTargetWin> drop_target_;
419 401
420 // If true, the mouse is currently down.
421 bool is_mouse_down_;
422
423 // Are a subclass of WindowWin? 402 // Are a subclass of WindowWin?
424 bool is_window_; 403 bool is_window_;
425 404
426 private: 405 private:
427 typedef ScopedVector<ui::ViewProp> ViewProps; 406 typedef ScopedVector<ui::ViewProp> ViewProps;
428 407
429 // Implementation of GetWindow. Ascends the parents of |hwnd| returning the 408 // Implementation of GetWindow. Ascends the parents of |hwnd| returning the
430 // first ancestor that is a Window. 409 // first ancestor that is a Window.
431 static Window* GetWindowImpl(HWND hwnd); 410 static Window* GetWindowImpl(HWND hwnd);
432 411
433 // Returns the RootView that contains the focused view, or NULL if there is no 412 // Returns the RootView that contains the focused view, or NULL if there is no
434 // focused view. 413 // focused view.
435 RootView* GetFocusedViewRootView(); 414 RootView* GetFocusedViewRootView();
436 415
437 // Called after the WM_ACTIVATE message has been processed by the default 416 // Called after the WM_ACTIVATE message has been processed by the default
438 // windows procedure. 417 // windows procedure.
439 static void PostProcessActivateMessage(WidgetWin* widget, 418 static void PostProcessActivateMessage(WidgetWin* widget,
440 int activation_state); 419 int activation_state);
441 420
442 // Fills out a MSG struct with the supplied values.
443 void MakeMSG(MSG* msg, UINT message, WPARAM w_param, LPARAM l_param,
444 DWORD time = 0, LONG x = 0, LONG y = 0) const;
445
446 // Synchronously paints the invalid contents of the Widget. 421 // Synchronously paints the invalid contents of the Widget.
447 void RedrawInvalidRect(); 422 void RedrawInvalidRect();
448 423
449 // Synchronously updates the invalid contents of the Widget. Valid for 424 // Synchronously updates the invalid contents of the Widget. Valid for
450 // layered windows only. 425 // layered windows only.
451 void RedrawLayeredWindowContents(); 426 void RedrawLayeredWindowContents();
452 427
453 // Responds to the client area changing size, either at window creation time 428 // Responds to the client area changing size, either at window creation time
454 // or subsequently. 429 // or subsequently.
455 void ClientAreaSizeChanged(); 430 void ClientAreaSizeChanged();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_; 472 ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_;
498 473
499 // Whether or not the window should delete itself when it is destroyed. 474 // Whether or not the window should delete itself when it is destroyed.
500 // Set this to false via its setter for stack allocated instances. 475 // Set this to false via its setter for stack allocated instances.
501 bool delete_on_destroy_; 476 bool delete_on_destroy_;
502 477
503 // True if we are allowed to update the layered window from the DIB backing 478 // True if we are allowed to update the layered window from the DIB backing
504 // store if necessary. 479 // store if necessary.
505 bool can_update_layered_window_; 480 bool can_update_layered_window_;
506 481
507 // The following are used to detect duplicate mouse move events and not
508 // deliver them. Displaying a window may result in the system generating
509 // duplicate move events even though the mouse hasn't moved.
510
511 // If true, the last event was a mouse move event.
512 bool last_mouse_event_was_move_;
513
514 // Coordinates of the last mouse move event.
515 int last_mouse_move_x_;
516 int last_mouse_move_y_;
517
518 // Whether the focus should be restored next time we get enabled. Needed to 482 // Whether the focus should be restored next time we get enabled. Needed to
519 // restore focus correctly when Windows modal dialogs are displayed. 483 // restore focus correctly when Windows modal dialogs are displayed.
520 bool restore_focus_when_enabled_; 484 bool restore_focus_when_enabled_;
521 485
522 // Instance of accessibility information and handling for MSAA root 486 // Instance of accessibility information and handling for MSAA root
523 base::win::ScopedComPtr<IAccessible> accessibility_root_; 487 base::win::ScopedComPtr<IAccessible> accessibility_root_;
524 488
525 // Value determines whether the Widget is customized for accessibility. 489 // Value determines whether the Widget is customized for accessibility.
526 static bool screen_reader_active_; 490 static bool screen_reader_active_;
527 491
(...skipping 13 matching lines...) Expand all
541 gfx::NativeCursor previous_cursor_; 505 gfx::NativeCursor previous_cursor_;
542 506
543 ViewProps props_; 507 ViewProps props_;
544 508
545 DISALLOW_COPY_AND_ASSIGN(WidgetWin); 509 DISALLOW_COPY_AND_ASSIGN(WidgetWin);
546 }; 510 };
547 511
548 } // namespace views 512 } // namespace views
549 513
550 #endif // VIEWS_WIDGET_WIDGET_WIN_H_ 514 #endif // VIEWS_WIDGET_WIDGET_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698