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

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

Issue 10871077: Move more code from NWW to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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/ui/views/tabs/dragged_tab_view.cc ('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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 public: 77 public:
78 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate); 78 explicit NativeWidgetWin(internal::NativeWidgetDelegate* delegate);
79 virtual ~NativeWidgetWin(); 79 virtual ~NativeWidgetWin();
80 80
81 // Returns the system set window title font. 81 // Returns the system set window title font.
82 static gfx::Font GetWindowTitleFont(); 82 static gfx::Font GetWindowTitleFont();
83 83
84 // Show the window with the specified show command. 84 // Show the window with the specified show command.
85 void Show(int show_state); 85 void Show(int show_state);
86 86
87 // Disable Layered Window updates by setting to false.
88 void set_can_update_layered_window(bool can_update_layered_window) {
89 can_update_layered_window_ = can_update_layered_window;
90 }
91
92 // Obtain the view event with the given MSAA child id. Used in 87 // Obtain the view event with the given MSAA child id. Used in
93 // NativeViewAccessibilityWin::get_accChild to support requests for 88 // NativeViewAccessibilityWin::get_accChild to support requests for
94 // children of windowless controls. May return NULL 89 // children of windowless controls. May return NULL
95 // (see ViewHierarchyChanged). 90 // (see ViewHierarchyChanged).
96 View* GetAccessibilityViewEventAt(int id); 91 View* GetAccessibilityViewEventAt(int id);
97 92
98 // Add a view that has recently fired an accessibility event. Returns a MSAA 93 // Add a view that has recently fired an accessibility event. Returns a MSAA
99 // child id which is generated by: -(index of view in vector + 1) which 94 // child id which is generated by: -(index of view in vector + 1) which
100 // guarantees a negative child id. This distinguishes the view from 95 // guarantees a negative child id. This distinguishes the view from
101 // positive MSAA child id's which are direct leaf children of views that have 96 // positive MSAA child id's which are direct leaf children of views that have
102 // associated hWnd's (e.g. NativeWidgetWin). 97 // associated hWnd's (e.g. NativeWidgetWin).
103 int AddAccessibilityViewEvent(View* view); 98 int AddAccessibilityViewEvent(View* view);
104 99
105 // Clear a view that has recently been removed on a hierarchy change. 100 // Clear a view that has recently been removed on a hierarchy change.
106 void ClearAccessibilityViewEvent(View* view); 101 void ClearAccessibilityViewEvent(View* view);
107 102
108 // Places the window in a pseudo-fullscreen mode where it looks and acts as 103 // Places the window in a pseudo-fullscreen mode where it looks and acts as
109 // like a fullscreen window except that it remains within the boundaries 104 // like a fullscreen window except that it remains within the boundaries
110 // of the metro snap divider. 105 // of the metro snap divider.
111 void SetMetroSnapFullscreen(bool metro_snap); 106 void SetMetroSnapFullscreen(bool metro_snap);
112 107
113 bool IsInMetroSnapMode() const; 108 bool IsInMetroSnapMode() const;
114 109
110 void SetCanUpdateLayeredWindow(bool can_update);
111
115 BOOL IsWindow() const { 112 BOOL IsWindow() const {
116 return ::IsWindow(GetNativeView()); 113 return ::IsWindow(GetNativeView());
117 } 114 }
118 115
119 BOOL ShowWindow(int command) { 116 BOOL ShowWindow(int command) {
120 DCHECK(::IsWindow(GetNativeView())); 117 DCHECK(::IsWindow(GetNativeView()));
121 return ::ShowWindow(GetNativeView(), command); 118 return ::ShowWindow(GetNativeView(), command);
122 } 119 }
123 120
124 HWND GetParent() const { 121 HWND GetParent() const {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 virtual void OnScreenReaderDetected(); 435 virtual void OnScreenReaderDetected();
439 436
440 // The TooltipManager. This is NULL if there is a problem creating the 437 // The TooltipManager. This is NULL if there is a problem creating the
441 // underlying tooltip window. 438 // underlying tooltip window.
442 // WARNING: RootView's destructor calls into the TooltipManager. As such, this 439 // WARNING: RootView's destructor calls into the TooltipManager. As such, this
443 // must be destroyed AFTER root_view_. 440 // must be destroyed AFTER root_view_.
444 scoped_ptr<TooltipManagerWin> tooltip_manager_; 441 scoped_ptr<TooltipManagerWin> tooltip_manager_;
445 442
446 scoped_refptr<DropTargetWin> drop_target_; 443 scoped_refptr<DropTargetWin> drop_target_;
447 444
448 const gfx::Rect& invalid_rect() const { return invalid_rect_; }
449
450 // Overridden from HWNDMessageHandlerDelegate: 445 // Overridden from HWNDMessageHandlerDelegate:
451 virtual bool IsWidgetWindow() const OVERRIDE; 446 virtual bool IsWidgetWindow() const OVERRIDE;
452 virtual bool IsUsingCustomFrame() const OVERRIDE; 447 virtual bool IsUsingCustomFrame() const OVERRIDE;
453 virtual void SchedulePaint() OVERRIDE; 448 virtual void SchedulePaint() OVERRIDE;
454 virtual void EnableInactiveRendering() OVERRIDE; 449 virtual void EnableInactiveRendering() OVERRIDE;
455 virtual bool IsInactiveRenderingDisabled() OVERRIDE; 450 virtual bool IsInactiveRenderingDisabled() OVERRIDE;
456 virtual bool CanResize() const OVERRIDE; 451 virtual bool CanResize() const OVERRIDE;
457 virtual bool CanMaximize() const OVERRIDE; 452 virtual bool CanMaximize() const OVERRIDE;
458 virtual bool CanActivate() const OVERRIDE; 453 virtual bool CanActivate() const OVERRIDE;
459 virtual bool WillProcessWorkAreaChange() const OVERRIDE; 454 virtual bool WillProcessWorkAreaChange() const OVERRIDE;
460 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; 455 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE;
461 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE; 456 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE;
462 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE; 457 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE;
463 virtual void GetMinMaxSize(gfx::Size* min_size, 458 virtual void GetMinMaxSize(gfx::Size* min_size,
464 gfx::Size* max_size) const OVERRIDE; 459 gfx::Size* max_size) const OVERRIDE;
460 virtual gfx::Size GetRootViewSize() const OVERRIDE;
465 virtual void ResetWindowControls() OVERRIDE; 461 virtual void ResetWindowControls() OVERRIDE;
462 virtual void UpdateFrame() OVERRIDE;
463 virtual void PaintLayeredWindow(gfx::Canvas* canvas) OVERRIDE;
466 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; 464 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
467 virtual InputMethod* GetInputMethod() OVERRIDE; 465 virtual InputMethod* GetInputMethod() OVERRIDE;
468 virtual void HandleAppDeactivated() OVERRIDE; 466 virtual void HandleAppDeactivated() OVERRIDE;
469 virtual void HandleActivationChanged(bool active) OVERRIDE; 467 virtual void HandleActivationChanged(bool active) OVERRIDE;
470 virtual bool HandleAppCommand(short command) OVERRIDE; 468 virtual bool HandleAppCommand(short command) OVERRIDE;
471 virtual void HandleCaptureLost() OVERRIDE; 469 virtual void HandleCaptureLost() OVERRIDE;
472 virtual void HandleClose() OVERRIDE; 470 virtual void HandleClose() OVERRIDE;
473 virtual bool HandleCommand(int command) OVERRIDE; 471 virtual bool HandleCommand(int command) OVERRIDE;
474 virtual void HandleAccelerator(const ui::Accelerator& accelerator) OVERRIDE; 472 virtual void HandleAccelerator(const ui::Accelerator& accelerator) OVERRIDE;
475 virtual void HandleCreate() OVERRIDE; 473 virtual void HandleCreate() OVERRIDE;
476 virtual void HandleDestroy() OVERRIDE; 474 virtual void HandleDestroy() OVERRIDE;
477 virtual void HandleDisplayChange() OVERRIDE; 475 virtual void HandleDisplayChange() OVERRIDE;
478 virtual void HandleGlassModeChange() OVERRIDE; 476 virtual void HandleGlassModeChange() OVERRIDE;
479 virtual void HandleBeginWMSizeMove() OVERRIDE; 477 virtual void HandleBeginWMSizeMove() OVERRIDE;
480 virtual void HandleEndWMSizeMove() OVERRIDE; 478 virtual void HandleEndWMSizeMove() OVERRIDE;
481 virtual void HandleMove() OVERRIDE; 479 virtual void HandleMove() OVERRIDE;
482 virtual void HandleWorkAreaChanged() OVERRIDE; 480 virtual void HandleWorkAreaChanged() OVERRIDE;
483 virtual void HandleVisibilityChanged(bool visible) OVERRIDE; 481 virtual void HandleVisibilityChanged(bool visible) OVERRIDE;
484 virtual void HandleClientSizeChanged(const gfx::Size& new_size) OVERRIDE; 482 virtual void HandleClientSizeChanged(const gfx::Size& new_size) OVERRIDE;
485 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE; 483 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE;
486 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE; 484 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE;
487 virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; 485 virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE;
488 virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; 486 virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE;
487 virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE;
488 virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE;
489 virtual void HandleScreenReaderDetected() OVERRIDE; 489 virtual void HandleScreenReaderDetected() OVERRIDE;
490 virtual bool HandleTooltipNotify(int w_param, 490 virtual bool HandleTooltipNotify(int w_param,
491 NMHDR* l_param, 491 NMHDR* l_param,
492 LRESULT* l_result) OVERRIDE; 492 LRESULT* l_result) OVERRIDE;
493 virtual void HandleTooltipMouseMove(UINT message, 493 virtual void HandleTooltipMouseMove(UINT message,
494 WPARAM w_param, 494 WPARAM w_param,
495 LPARAM l_param) OVERRIDE; 495 LPARAM l_param) OVERRIDE;
496 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; 496 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE;
497 497
498 private: 498 private:
499 typedef ScopedVector<ui::ViewProp> ViewProps; 499 typedef ScopedVector<ui::ViewProp> ViewProps;
500 500
501 // TODO(beng): This friendship can be removed once all methods relating to 501 // TODO(beng): This friendship can be removed once all methods relating to
502 // this object being a WindowImpl are moved to HWNDMessageHandler. 502 // this object being a WindowImpl are moved to HWNDMessageHandler.
503 friend HWNDMessageHandler; 503 friend HWNDMessageHandler;
504 504
505 // Called after the WM_ACTIVATE message has been processed by the default 505 // Called after the WM_ACTIVATE message has been processed by the default
506 // windows procedure. 506 // windows procedure.
507 static void PostProcessActivateMessage(NativeWidgetWin* widget, 507 static void PostProcessActivateMessage(NativeWidgetWin* widget,
508 int activation_state); 508 int activation_state);
509 509
510 void SetInitParams(const Widget::InitParams& params); 510 void SetInitParams(const Widget::InitParams& params);
511 511
512 // Synchronously paints the invalid contents of the Widget.
513 void RedrawInvalidRect();
514
515 // Synchronously updates the invalid contents of the Widget. Valid for
516 // layered windows only.
517 void RedrawLayeredWindowContents();
518
519 // Determines whether the delegate expects the client size or the window size. 512 // Determines whether the delegate expects the client size or the window size.
520 bool WidgetSizeIsClientSize() const; 513 bool WidgetSizeIsClientSize() const;
521 514
522 void RestoreEnabledIfNecessary(); 515 void RestoreEnabledIfNecessary();
523 516
524 void SetInitialFocus(); 517 void SetInitialFocus();
525 518
526 // A delegate implementation that handles events received here. 519 // A delegate implementation that handles events received here.
527 // See class documentation for Widget in widget.h for a note about ownership. 520 // See class documentation for Widget in widget.h for a note about ownership.
528 internal::NativeWidgetDelegate* delegate_; 521 internal::NativeWidgetDelegate* delegate_;
529 522
530 // The following factory is used for calls to close the NativeWidgetWin 523 // The following factory is used for calls to close the NativeWidgetWin
531 // instance. 524 // instance.
532 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_; 525 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_;
533 526
534 // Should we keep an off-screen buffer? This is false by default, set to true
535 // when WS_EX_LAYERED is specified before the native window is created.
536 //
537 // NOTE: this is intended to be used with a layered window (a window with an
538 // extended window style of WS_EX_LAYERED). If you are using a layered window
539 // and NOT changing the layered alpha or anything else, then leave this value
540 // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
541 // most likely want to set this to false, or after changing the alpha toggle
542 // the extended style bit to false than back to true. See MSDN for more
543 // details.
544 bool use_layered_buffer_;
545
546 // The default alpha to be applied to the layered window.
547 BYTE layered_alpha_;
548
549 // A canvas that contains the window contents in the case of a layered
550 // window.
551 scoped_ptr<gfx::Canvas> layered_window_contents_;
552
553 // We must track the invalid rect ourselves, for two reasons:
554 // For layered windows, Windows will not do this properly with
555 // InvalidateRect()/GetUpdateRect(). (In fact, it'll return misleading
556 // information from GetUpdateRect()).
557 // We also need to keep track of the invalid rectangle for the RootView should
558 // we need to paint the non-client area. The data supplied to WM_NCPAINT seems
559 // to be insufficient.
560 gfx::Rect invalid_rect_;
561
562 // A factory that allows us to schedule a redraw for layered windows.
563 base::WeakPtrFactory<NativeWidgetWin> paint_layered_window_factory_;
564
565 // See class documentation for Widget in widget.h for a note about ownership. 527 // See class documentation for Widget in widget.h for a note about ownership.
566 Widget::InitParams::Ownership ownership_; 528 Widget::InitParams::Ownership ownership_;
567 529
568 // True if we are allowed to update the layered window from the DIB backing
569 // store if necessary.
570 bool can_update_layered_window_;
571
572 // Whether the focus should be restored next time we get enabled. Needed to 530 // Whether the focus should be restored next time we get enabled. Needed to
573 // restore focus correctly when Windows modal dialogs are displayed. 531 // restore focus correctly when Windows modal dialogs are displayed.
574 bool restore_focus_when_enabled_; 532 bool restore_focus_when_enabled_;
575 533
576 // Instance of accessibility information and handling for MSAA root 534 // Instance of accessibility information and handling for MSAA root
577 base::win::ScopedComPtr<IAccessible> accessibility_root_; 535 base::win::ScopedComPtr<IAccessible> accessibility_root_;
578 536
579 // Value determines whether the Widget is customized for accessibility. 537 // Value determines whether the Widget is customized for accessibility.
580 static bool screen_reader_active_; 538 static bool screen_reader_active_;
581 539
582 // The maximum number of view events in our vector below. 540 // The maximum number of view events in our vector below.
583 static const int kMaxAccessibilityViewEvents = 20; 541 static const int kMaxAccessibilityViewEvents = 20;
584 542
585 // A vector used to access views for which we have sent notifications to 543 // A vector used to access views for which we have sent notifications to
586 // accessibility clients. It is used as a circular queue. 544 // accessibility clients. It is used as a circular queue.
587 std::vector<View*> accessibility_view_events_; 545 std::vector<View*> accessibility_view_events_;
588 546
589 // The current position of the view events vector. When incrementing, 547 // The current position of the view events vector. When incrementing,
590 // we always mod this value with the max view events above . 548 // we always mod this value with the max view events above .
591 int accessibility_view_events_index_; 549 int accessibility_view_events_index_;
592 550
593 // The last cursor that was active before the current one was selected. Saved
594 // so that we can restore it.
595 gfx::NativeCursor previous_cursor_;
596
597 ViewProps props_; 551 ViewProps props_;
598 552
599 // The window styles before we modified them for the drag frame appearance. 553 // The window styles before we modified them for the drag frame appearance.
600 DWORD drag_frame_saved_window_style_; 554 DWORD drag_frame_saved_window_style_;
601 DWORD drag_frame_saved_window_ex_style_; 555 DWORD drag_frame_saved_window_ex_style_;
602 556
603 // Whether all ancestors have been enabled. This is only used if is_modal_ is 557 // Whether all ancestors have been enabled. This is only used if is_modal_ is
604 // true. 558 // true.
605 bool restored_enabled_; 559 bool restored_enabled_;
606 560
607 // True if the widget is going to have a non_client_view. We cache this value 561 // True if the widget is going to have a non_client_view. We cache this value
608 // rather than asking the Widget for the non_client_view so that we know at 562 // rather than asking the Widget for the non_client_view so that we know at
609 // Init time, before the Widget has created the NonClientView. 563 // Init time, before the Widget has created the NonClientView.
610 bool has_non_client_view_; 564 bool has_non_client_view_;
611 565
612 scoped_ptr<HWNDMessageHandler> message_handler_; 566 scoped_ptr<HWNDMessageHandler> message_handler_;
613 567
614 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); 568 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin);
615 }; 569 };
616 570
617 } // namespace views 571 } // namespace views
618 572
619 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ 573 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/dragged_tab_view.cc ('k') | ui/views/widget/native_widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698