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

Side by Side Diff: ui/views/widget/native_widget_win.h

Issue 10827454: Move more methods from NWW to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | « ui/views/widget/native_widget_private.h ('k') | ui/views/widget/native_widget_win.cc » ('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) 2012 The Chromium Authors. All rights reserved. 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 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 UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ 5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ 6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlapp.h> 9 #include <atlapp.h>
10 #include <atlcrack.h> 10 #include <atlcrack.h>
(...skipping 24 matching lines...) Expand all
35 namespace gfx { 35 namespace gfx {
36 class Canvas; 36 class Canvas;
37 class Font; 37 class Font;
38 class Rect; 38 class Rect;
39 } 39 }
40 40
41 namespace views { 41 namespace views {
42 42
43 class DropTargetWin; 43 class DropTargetWin;
44 class HWNDMessageHandler; 44 class HWNDMessageHandler;
45 class InputMethodDelegate;
45 class RootView; 46 class RootView;
46 class TooltipManagerWin; 47 class TooltipManagerWin;
47 48
48 // These two messages aren't defined in winuser.h, but they are sent to windows 49 // These two messages aren't defined in winuser.h, but they are sent to windows
49 // with captions. They appear to paint the window caption and frame. 50 // with captions. They appear to paint the window caption and frame.
50 // Unfortunately if you override the standard non-client rendering as we do 51 // Unfortunately if you override the standard non-client rendering as we do
51 // with CustomFrameWindow, sometimes Windows (not deterministically 52 // with CustomFrameWindow, sometimes Windows (not deterministically
52 // reproducibly but definitely frequently) will send these messages to the 53 // reproducibly but definitely frequently) will send these messages to the
53 // window and paint the standard caption/title over the top of the custom one. 54 // window and paint the standard caption/title over the top of the custom one.
54 // So we need to handle these messages in CustomFrameWindow to prevent this 55 // So we need to handle these messages in CustomFrameWindow to prevent this
(...skipping 15 matching lines...) Expand all
70 // 71 //
71 /////////////////////////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////////////////////////
72 class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, 73 class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
73 public MessageLoopForUI::Observer, 74 public MessageLoopForUI::Observer,
74 public internal::NativeWidgetPrivate, 75 public internal::NativeWidgetPrivate,
75 public HWNDMessageHandlerDelegate { 76 public HWNDMessageHandlerDelegate {
76 public: 77 public:
77 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); 78 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate);
78 virtual ~NativeWidgetWin(); 79 virtual ~NativeWidgetWin();
79 80
80 // Returns true if we are on Windows Vista or greater and composition is
81 // enabled.
82 static bool IsAeroGlassEnabled();
83
84 // Returns the system set window title font. 81 // Returns the system set window title font.
85 static gfx::Font GetWindowTitleFont(); 82 static gfx::Font GetWindowTitleFont();
86 83
87 // Show the window with the specified show command. 84 // Show the window with the specified show command.
88 void Show(int show_state); 85 void Show(int show_state);
89 86
90 // Disable Layered Window updates by setting to false. 87 // Disable Layered Window updates by setting to false.
91 void set_can_update_layered_window(bool can_update_layered_window) { 88 void set_can_update_layered_window(bool can_update_layered_window) {
92 can_update_layered_window_ = can_update_layered_window; 89 can_update_layered_window_ = can_update_layered_window;
93 } 90 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; 198 virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE;
202 virtual TooltipManager* GetTooltipManager() const OVERRIDE; 199 virtual TooltipManager* GetTooltipManager() const OVERRIDE;
203 virtual bool IsScreenReaderActive() const OVERRIDE; 200 virtual bool IsScreenReaderActive() const OVERRIDE;
204 virtual void SendNativeAccessibilityEvent( 201 virtual void SendNativeAccessibilityEvent(
205 View* view, 202 View* view,
206 ui::AccessibilityTypes::Event event_type) OVERRIDE; 203 ui::AccessibilityTypes::Event event_type) OVERRIDE;
207 virtual void SetCapture() OVERRIDE; 204 virtual void SetCapture() OVERRIDE;
208 virtual void ReleaseCapture() OVERRIDE; 205 virtual void ReleaseCapture() OVERRIDE;
209 virtual bool HasCapture() const OVERRIDE; 206 virtual bool HasCapture() const OVERRIDE;
210 virtual InputMethod* CreateInputMethod() OVERRIDE; 207 virtual InputMethod* CreateInputMethod() OVERRIDE;
208 virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE;
211 virtual void CenterWindow(const gfx::Size& size) OVERRIDE; 209 virtual void CenterWindow(const gfx::Size& size) OVERRIDE;
212 virtual void GetWindowPlacement( 210 virtual void GetWindowPlacement(
213 gfx::Rect* bounds, 211 gfx::Rect* bounds,
214 ui::WindowShowState* show_state) const OVERRIDE; 212 ui::WindowShowState* show_state) const OVERRIDE;
215 virtual void SetWindowTitle(const string16& title) OVERRIDE; 213 virtual void SetWindowTitle(const string16& title) OVERRIDE;
216 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, 214 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
217 const gfx::ImageSkia& app_icon) OVERRIDE; 215 const gfx::ImageSkia& app_icon) OVERRIDE;
218 virtual void SetAccessibleName(const string16& name) OVERRIDE; 216 virtual void SetAccessibleName(const string16& name) OVERRIDE;
219 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; 217 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE;
220 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; 218 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // to SW_SHOWNORMAL, however windows (e.g. the main window) can override this 450 // to SW_SHOWNORMAL, however windows (e.g. the main window) can override this
453 // method to provide different values (e.g. retrieve the user's specified 451 // method to provide different values (e.g. retrieve the user's specified
454 // show state from the shortcut starutp info). 452 // show state from the shortcut starutp info).
455 virtual int GetShowState() const; 453 virtual int GetShowState() const;
456 454
457 // Returns the insets of the client area relative to the non-client area of 455 // Returns the insets of the client area relative to the non-client area of
458 // the window. Override this function instead of OnNCCalcSize, which is 456 // the window. Override this function instead of OnNCCalcSize, which is
459 // crazily complicated. 457 // crazily complicated.
460 virtual gfx::Insets GetClientAreaInsets() const; 458 virtual gfx::Insets GetClientAreaInsets() const;
461 459
462 // Start tracking all mouse events so that this window gets sent mouse leave
463 // messages too.
464 void TrackMouseEvents(DWORD mouse_tracking_flags);
465
466 // Called when a MSAA screen reader client is detected. 460 // Called when a MSAA screen reader client is detected.
467 virtual void OnScreenReaderDetected(); 461 virtual void OnScreenReaderDetected();
468 462
469 // Executes the specified SC_command. 463 // Executes the specified SC_command.
470 void ExecuteSystemMenuCommand(int command); 464 void ExecuteSystemMenuCommand(int command);
471 465
472 // The TooltipManager. This is NULL if there is a problem creating the 466 // The TooltipManager. This is NULL if there is a problem creating the
473 // underlying tooltip window. 467 // underlying tooltip window.
474 // WARNING: RootView's destructor calls into the TooltipManager. As such, this 468 // WARNING: RootView's destructor calls into the TooltipManager. As such, this
475 // must be destroyed AFTER root_view_. 469 // must be destroyed AFTER root_view_.
476 scoped_ptr<TooltipManagerWin> tooltip_manager_; 470 scoped_ptr<TooltipManagerWin> tooltip_manager_;
477 471
478 scoped_refptr<DropTargetWin> drop_target_; 472 scoped_refptr<DropTargetWin> drop_target_;
479 473
480 const gfx::Rect& invalid_rect() const { return invalid_rect_; } 474 const gfx::Rect& invalid_rect() const { return invalid_rect_; }
481 475
482 // Saved window information from before entering fullscreen mode. 476 // Saved window information from before entering fullscreen mode.
483 // TODO(beng): move to private once GetRestoredBounds() moves onto Widget. 477 // TODO(beng): move to private once GetRestoredBounds() moves onto Widget.
484 SavedWindowInfo saved_window_info_; 478 SavedWindowInfo saved_window_info_;
485 479
486 private: 480 private:
487 typedef ScopedVector<ui::ViewProp> ViewProps; 481 typedef ScopedVector<ui::ViewProp> ViewProps;
488 typedef std::set<DWORD> TouchIDs;
489 482
490 // TODO(beng): This friendship can be removed once all methods relating to 483 // TODO(beng): This friendship can be removed once all methods relating to
491 // this object being a WindowImpl are moved to HWNDMessageHandler. 484 // this object being a WindowImpl are moved to HWNDMessageHandler.
492 friend HWNDMessageHandler; 485 friend HWNDMessageHandler;
493 486
494 // Overridden from HWNDMessageHandlerDelegate: 487 // Overridden from HWNDMessageHandlerDelegate:
495 virtual bool IsWidgetWindow() const OVERRIDE; 488 virtual bool IsWidgetWindow() const OVERRIDE;
496 virtual bool IsUsingCustomFrame() const OVERRIDE; 489 virtual bool IsUsingCustomFrame() const OVERRIDE;
497 virtual void SchedulePaint() OVERRIDE; 490 virtual void SchedulePaint() OVERRIDE;
498 virtual void EnableInactiveRendering() OVERRIDE; 491 virtual void EnableInactiveRendering() OVERRIDE;
(...skipping 15 matching lines...) Expand all
514 virtual void HandleClose() OVERRIDE; 507 virtual void HandleClose() OVERRIDE;
515 virtual bool HandleCommand(int command) OVERRIDE; 508 virtual bool HandleCommand(int command) OVERRIDE;
516 virtual void HandleCreate() OVERRIDE; 509 virtual void HandleCreate() OVERRIDE;
517 virtual void HandleDestroy() OVERRIDE; 510 virtual void HandleDestroy() OVERRIDE;
518 virtual void HandleDisplayChange() OVERRIDE; 511 virtual void HandleDisplayChange() OVERRIDE;
519 virtual void HandleGlassModeChange() OVERRIDE; 512 virtual void HandleGlassModeChange() OVERRIDE;
520 virtual void HandleBeginWMSizeMove() OVERRIDE; 513 virtual void HandleBeginWMSizeMove() OVERRIDE;
521 virtual void HandleEndWMSizeMove() OVERRIDE; 514 virtual void HandleEndWMSizeMove() OVERRIDE;
522 virtual void HandleMove() OVERRIDE; 515 virtual void HandleMove() OVERRIDE;
523 virtual void HandleWorkAreaChanged() OVERRIDE; 516 virtual void HandleWorkAreaChanged() OVERRIDE;
517 virtual void HandleVisibilityChanged(bool visible) OVERRIDE;
518 virtual void HandleClientSizeChanged(const gfx::Size& new_size) OVERRIDE;
524 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE; 519 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE;
525 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE; 520 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE;
521 virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE;
522 virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE;
526 virtual void HandleScreenReaderDetected() OVERRIDE; 523 virtual void HandleScreenReaderDetected() OVERRIDE;
527 virtual bool HandleTooltipNotify(int w_param, 524 virtual bool HandleTooltipNotify(int w_param,
528 NMHDR* l_param, 525 NMHDR* l_param,
529 LRESULT* l_result) OVERRIDE; 526 LRESULT* l_result) OVERRIDE;
527 virtual void HandleTooltipMouseMove(UINT message,
528 WPARAM w_param,
529 LPARAM l_param) OVERRIDE;
530 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; 530 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE;
531 531
532 // Called after the WM_ACTIVATE message has been processed by the default 532 // Called after the WM_ACTIVATE message has been processed by the default
533 // windows procedure. 533 // windows procedure.
534 static void PostProcessActivateMessage(NativeWidgetWin* widget, 534 static void PostProcessActivateMessage(NativeWidgetWin* widget,
535 int activation_state); 535 int activation_state);
536 536
537 void SetInitParams(const Widget::InitParams& params); 537 void SetInitParams(const Widget::InitParams& params);
538 538
539 // Synchronously paints the invalid contents of the Widget. 539 // Synchronously paints the invalid contents of the Widget.
540 void RedrawInvalidRect(); 540 void RedrawInvalidRect();
541 541
542 // Synchronously updates the invalid contents of the Widget. Valid for 542 // Synchronously updates the invalid contents of the Widget. Valid for
543 // layered windows only. 543 // layered windows only.
544 void RedrawLayeredWindowContents(); 544 void RedrawLayeredWindowContents();
545 545
546 // Lock or unlock the window from being able to redraw itself in response to
547 // updates to its invalid region.
548 class ScopedRedrawLock;
549 void LockUpdates(bool force);
550 void UnlockUpdates(bool force);
551
552 // Determines whether the delegate expects the client size or the window size. 546 // Determines whether the delegate expects the client size or the window size.
553 bool WidgetSizeIsClientSize() const; 547 bool WidgetSizeIsClientSize() const;
554 548
555 // Responds to the client area changing size, either at window creation time
556 // or subsequently.
557 void ClientAreaSizeChanged();
558
559 // When removing the standard frame, tells the DWM how much glass we want on
560 // the edges. Currently hardcoded to 10px on all sides.
561 void UpdateDWMFrame();
562
563 // Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to
564 // prevent frame flicker. DefWindowProc handling can otherwise render the
565 // classic-look window title bar directly.
566 LRESULT DefWindowProcWithRedrawLock(UINT message,
567 WPARAM w_param,
568 LPARAM l_param);
569
570 // Stops ignoring SetWindowPos() requests (see below). 549 // Stops ignoring SetWindowPos() requests (see below).
571 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } 550 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
572 551
573 void RestoreEnabledIfNecessary(); 552 void RestoreEnabledIfNecessary();
574 553
575 void SetInitialFocus(); 554 void SetInitialFocus();
576 555
577 // Notifies any owned windows that we're closing. 556 // Notifies any owned windows that we're closing.
578 void NotifyOwnedWindowsParentClosing(); 557 void NotifyOwnedWindowsParentClosing();
579 558
580 // Overridden from internal::InputMethodDelegate
581 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
582
583 // Common implementation of fullscreen-related code. This method handles 559 // Common implementation of fullscreen-related code. This method handles
584 // changing from windowed mode to a display mode (dubbed fullscreen mode) 560 // changing from windowed mode to a display mode (dubbed fullscreen mode)
585 // where the window occupies a fixed portion (possibly 100%) of the screen. 561 // where the window occupies a fixed portion (possibly 100%) of the screen.
586 // |fullscreen| specifies whether we are entering or leaving fullscreen mode. 562 // |fullscreen| specifies whether we are entering or leaving fullscreen mode.
587 // |for_metro| specifies whether we are doing this at the behest of a metro 563 // |for_metro| specifies whether we are doing this at the behest of a metro
588 // snap transition. 564 // snap transition.
589 void SetFullscreenInternal(bool fullscreen, bool for_metro); 565 void SetFullscreenInternal(bool fullscreen, bool for_metro);
590 566
591 // A delegate implementation that handles events received here. 567 // A delegate implementation that handles events received here.
592 // See class documentation for Widget in widget.h for a note about ownership. 568 // See class documentation for Widget in widget.h for a note about ownership.
593 internal::NativeWidgetDelegate* delegate_; 569 internal::NativeWidgetDelegate* delegate_;
594 570
595 // The following factory is used for calls to close the NativeWidgetWin 571 // The following factory is used for calls to close the NativeWidgetWin
596 // instance. 572 // instance.
597 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_; 573 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_;
598 574
599 // The flags currently being used with TrackMouseEvent to track mouse
600 // messages. 0 if there is no active tracking. The value of this member is
601 // used when tracking is canceled.
602 DWORD active_mouse_tracking_flags_;
603
604 // Should we keep an off-screen buffer? This is false by default, set to true 575 // Should we keep an off-screen buffer? This is false by default, set to true
605 // when WS_EX_LAYERED is specified before the native window is created. 576 // when WS_EX_LAYERED is specified before the native window is created.
606 // 577 //
607 // NOTE: this is intended to be used with a layered window (a window with an 578 // NOTE: this is intended to be used with a layered window (a window with an
608 // extended window style of WS_EX_LAYERED). If you are using a layered window 579 // extended window style of WS_EX_LAYERED). If you are using a layered window
609 // and NOT changing the layered alpha or anything else, then leave this value 580 // and NOT changing the layered alpha or anything else, then leave this value
610 // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll 581 // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
611 // most likely want to set this to false, or after changing the alpha toggle 582 // most likely want to set this to false, or after changing the alpha toggle
612 // the extended style bit to false than back to true. See MSDN for more 583 // the extended style bit to false than back to true. See MSDN for more
613 // details. 584 // details.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // If this is greater than zero, we should prevent attempts to make the window 646 // If this is greater than zero, we should prevent attempts to make the window
676 // visible when we handle WM_WINDOWPOSCHANGING. Some calls like 647 // visible when we handle WM_WINDOWPOSCHANGING. Some calls like
677 // ShowWindow(SW_RESTORE) make the window visible in addition to restoring it, 648 // ShowWindow(SW_RESTORE) make the window visible in addition to restoring it,
678 // when all we want to do is restore it. 649 // when all we want to do is restore it.
679 int force_hidden_count_; 650 int force_hidden_count_;
680 651
681 // The window styles before we modified them for the drag frame appearance. 652 // The window styles before we modified them for the drag frame appearance.
682 DWORD drag_frame_saved_window_style_; 653 DWORD drag_frame_saved_window_style_;
683 DWORD drag_frame_saved_window_ex_style_; 654 DWORD drag_frame_saved_window_ex_style_;
684 655
685 // Represents the number of ScopedRedrawLocks active against this widget.
686 // If this is greater than zero, the widget should be locked against updates.
687 int lock_updates_count_;
688
689 // When true, this flag makes us discard incoming SetWindowPos() requests that 656 // When true, this flag makes us discard incoming SetWindowPos() requests that
690 // only change our position/size. (We still allow changes to Z-order, 657 // only change our position/size. (We still allow changes to Z-order,
691 // activation, etc.) 658 // activation, etc.)
692 bool ignore_window_pos_changes_; 659 bool ignore_window_pos_changes_;
693 660
694 // The following factory is used to ignore SetWindowPos() calls for short time 661 // The following factory is used to ignore SetWindowPos() calls for short time
695 // periods. 662 // periods.
696 base::WeakPtrFactory<NativeWidgetWin> ignore_pos_changes_factory_; 663 base::WeakPtrFactory<NativeWidgetWin> ignore_pos_changes_factory_;
697 664
698 // The last-seen monitor containing us, and its rect and work area. These are 665 // The last-seen monitor containing us, and its rect and work area. These are
699 // used to catch updates to the rect and work area and react accordingly. 666 // used to catch updates to the rect and work area and react accordingly.
700 HMONITOR last_monitor_; 667 HMONITOR last_monitor_;
701 gfx::Rect last_monitor_rect_, last_work_area_; 668 gfx::Rect last_monitor_rect_, last_work_area_;
702 669
703 // Set to true when the user presses the right mouse button on the caption
704 // area. We need this so we can correctly show the context menu on mouse-up.
705 bool is_right_mouse_pressed_on_caption_;
706
707 // Whether all ancestors have been enabled. This is only used if is_modal_ is 670 // Whether all ancestors have been enabled. This is only used if is_modal_ is
708 // true. 671 // true.
709 bool restored_enabled_; 672 bool restored_enabled_;
710 673
711 // This flag can be initialized and checked after certain operations (such as
712 // DefWindowProc) to avoid stack-controlled NativeWidgetWin operations (such
713 // as unlocking the Window with a ScopedRedrawLock) after Widget destruction.
714 bool* destroyed_;
715
716 // True if the widget is going to have a non_client_view. We cache this value 674 // True if the widget is going to have a non_client_view. We cache this value
717 // rather than asking the Widget for the non_client_view so that we know at 675 // rather than asking the Widget for the non_client_view so that we know at
718 // Init time, before the Widget has created the NonClientView. 676 // Init time, before the Widget has created the NonClientView.
719 bool has_non_client_view_; 677 bool has_non_client_view_;
720 678
721 // The set of touch devices currently down.
722 TouchIDs touch_ids_;
723
724 scoped_ptr<HWNDMessageHandler> message_handler_; 679 scoped_ptr<HWNDMessageHandler> message_handler_;
725 680
726 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); 681 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin);
727 }; 682 };
728 683
729 } // namespace views 684 } // namespace views
730 685
731 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ 686 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_private.h ('k') | ui/views/widget/native_widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698