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

Side by Side Diff: ui/views/win/hwnd_message_handler.h

Issue 1976923004: Reduce the size of the fullscreen window on activation loss only if the window being activated is … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix include order Created 4 years, 7 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
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_WIN_HWND_MESSAGE_HANDLER_H_ 5 #ifndef UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ 6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <map>
11 #include <memory> 12 #include <memory>
12 #include <set> 13 #include <set>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
18 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
19 #include "base/win/scoped_gdi_object.h" 20 #include "base/win/scoped_gdi_object.h"
20 #include "base/win/win_util.h" 21 #include "base/win/win_util.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 BOOL bHandled = TRUE; \ 99 BOOL bHandled = TRUE; \
99 hWnd; \ 100 hWnd; \
100 uMsg; \ 101 uMsg; \
101 wParam; \ 102 wParam; \
102 lParam; \ 103 lParam; \
103 lResult; \ 104 lResult; \
104 bHandled; \ 105 bHandled; \
105 switch(dwMsgMapID) { \ 106 switch(dwMsgMapID) { \
106 case 0: 107 case 0:
107 108
109 // This message is posted when our window is activated on the monitor
110 // where there is a fullscreen window owned by us. The handler for
111 // this message reduces the size of the fullscreen window by 1 px. This is
112 // to workaround a bug in the taskbar where it treats all windows owned by
113 // a thread on a monitor as fullscreen windows if one of the windows in there
114 // is a full screen window. The bug does not occur across monitors.
115 const int WM_CUSTOM_MESSAGE_HANDLE_BACKGROUND_FULLSCREEN = WM_USER + 1;
116
108 // An object that handles messages for a HWND that implements the views 117 // An object that handles messages for a HWND that implements the views
109 // "Custom Frame" look. The purpose of this class is to isolate the windows- 118 // "Custom Frame" look. The purpose of this class is to isolate the windows-
110 // specific message handling from the code that wraps it. It is intended to be 119 // specific message handling from the code that wraps it. It is intended to be
111 // used by both a views::NativeWidget and an aura::WindowTreeHost 120 // used by both a views::NativeWidget and an aura::WindowTreeHost
112 // implementation. 121 // implementation.
113 // TODO(beng): This object should eventually *become* the WindowImpl. 122 // TODO(beng): This object should eventually *become* the WindowImpl.
114 class VIEWS_EXPORT HWNDMessageHandler : 123 class VIEWS_EXPORT HWNDMessageHandler :
115 public gfx::WindowImpl, 124 public gfx::WindowImpl,
116 public ui::WindowEventTarget { 125 public ui::WindowEventTarget {
117 public: 126 public:
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 CR_MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage) 370 CR_MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage)
362 371
363 // Touch Events. 372 // Touch Events.
364 CR_MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent) 373 CR_MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent)
365 374
366 // Uses the general handler macro since the specific handler macro 375 // Uses the general handler macro since the specific handler macro
367 // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high 376 // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high
368 // word of WPARAM could be set when the window is minimized or restored. 377 // word of WPARAM could be set when the window is minimized or restored.
369 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate) 378 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
370 379
380 CR_MESSAGE_HANDLER_EX(WM_CUSTOM_MESSAGE_HANDLE_BACKGROUND_FULLSCREEN,
381 OnBackgroundFullscreen)
382
371 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. 383 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU.
372 CR_MSG_WM_ACTIVATEAPP(OnActivateApp) 384 CR_MSG_WM_ACTIVATEAPP(OnActivateApp)
373 CR_MSG_WM_APPCOMMAND(OnAppCommand) 385 CR_MSG_WM_APPCOMMAND(OnAppCommand)
374 CR_MSG_WM_CANCELMODE(OnCancelMode) 386 CR_MSG_WM_CANCELMODE(OnCancelMode)
375 CR_MSG_WM_CAPTURECHANGED(OnCaptureChanged) 387 CR_MSG_WM_CAPTURECHANGED(OnCaptureChanged)
376 CR_MSG_WM_CLOSE(OnClose) 388 CR_MSG_WM_CLOSE(OnClose)
377 CR_MSG_WM_COMMAND(OnCommand) 389 CR_MSG_WM_COMMAND(OnCommand)
378 CR_MSG_WM_CREATE(OnCreate) 390 CR_MSG_WM_CREATE(OnCreate)
379 CR_MSG_WM_DESTROY(OnDestroy) 391 CR_MSG_WM_DESTROY(OnDestroy)
380 CR_MSG_WM_DISPLAYCHANGE(OnDisplayChange) 392 CR_MSG_WM_DISPLAYCHANGE(OnDisplayChange)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 void OnSetFocus(HWND last_focused_window); 464 void OnSetFocus(HWND last_focused_window);
453 LRESULT OnSetIcon(UINT size_type, HICON new_icon); 465 LRESULT OnSetIcon(UINT size_type, HICON new_icon);
454 LRESULT OnSetText(const wchar_t* text); 466 LRESULT OnSetText(const wchar_t* text);
455 void OnSettingChange(UINT flags, const wchar_t* section); 467 void OnSettingChange(UINT flags, const wchar_t* section);
456 void OnSize(UINT param, const gfx::Size& size); 468 void OnSize(UINT param, const gfx::Size& size);
457 void OnSysCommand(UINT notification_code, const gfx::Point& point); 469 void OnSysCommand(UINT notification_code, const gfx::Point& point);
458 void OnThemeChanged(); 470 void OnThemeChanged();
459 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param); 471 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param);
460 void OnWindowPosChanging(WINDOWPOS* window_pos); 472 void OnWindowPosChanging(WINDOWPOS* window_pos);
461 void OnWindowPosChanged(WINDOWPOS* window_pos); 473 void OnWindowPosChanged(WINDOWPOS* window_pos);
474 LRESULT OnBackgroundFullscreen(UINT message, WPARAM w_param, LPARAM l_param);
462 475
463 // Receives Windows Session Change notifications. 476 // Receives Windows Session Change notifications.
464 void OnSessionChange(WPARAM status_code); 477 void OnSessionChange(WPARAM status_code);
465 478
466 typedef std::vector<ui::TouchEvent> TouchEvents; 479 typedef std::vector<ui::TouchEvent> TouchEvents;
467 // Helper to handle the list of touch events passed in. We need this because 480 // Helper to handle the list of touch events passed in. We need this because
468 // touch events on windows don't fire if we enter a modal loop in the context 481 // touch events on windows don't fire if we enter a modal loop in the context
469 // of a touch event. 482 // of a touch event.
470 void HandleTouchEvents(const TouchEvents& touch_events); 483 void HandleTouchEvents(const TouchEvents& touch_events);
471 484
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // Returns true if the message was handled. 523 // Returns true if the message was handled.
511 bool HandleMouseInputForCaption(unsigned int message, 524 bool HandleMouseInputForCaption(unsigned int message,
512 WPARAM w_param, 525 WPARAM w_param,
513 LPARAM l_param); 526 LPARAM l_param);
514 527
515 // Helper function for setting the bounds of the HWND. For more information 528 // Helper function for setting the bounds of the HWND. For more information
516 // please refer to the SetBounds() function. 529 // please refer to the SetBounds() function.
517 void SetBoundsInternal(const gfx::Rect& bounds_in_pixels, 530 void SetBoundsInternal(const gfx::Rect& bounds_in_pixels,
518 bool force_size_changed); 531 bool force_size_changed);
519 532
533 // Checks if there is a full screen window on the same monitor as the
534 // |window| which is becoming active. If yes then we reduce the size of the
535 // fullscreen window by 1 px to ensure that maximized windows on the same
536 // monitor don't draw over the taskbar.
537 void CheckAndHandleBackgroundFullscreenOnMonitor(HWND window);
538
520 HWNDMessageHandlerDelegate* delegate_; 539 HWNDMessageHandlerDelegate* delegate_;
521 540
522 std::unique_ptr<FullscreenHandler> fullscreen_handler_; 541 std::unique_ptr<FullscreenHandler> fullscreen_handler_;
523 542
524 // Set to true in Close() and false is CloseNow(). 543 // Set to true in Close() and false is CloseNow().
525 bool waiting_for_close_now_; 544 bool waiting_for_close_now_;
526 545
527 bool use_system_default_icon_; 546 bool use_system_default_icon_;
528 547
529 // Whether all ancestors have been enabled. This is only used if is_modal_ is 548 // Whether all ancestors have been enabled. This is only used if is_modal_ is
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 672
654 // The WeakPtrFactories below must occur last in the class definition so they 673 // The WeakPtrFactories below must occur last in the class definition so they
655 // get destroyed last. 674 // get destroyed last.
656 675
657 // The factory used to lookup appbar autohide edges. 676 // The factory used to lookup appbar autohide edges.
658 base::WeakPtrFactory<HWNDMessageHandler> autohide_factory_; 677 base::WeakPtrFactory<HWNDMessageHandler> autohide_factory_;
659 678
660 // The factory used with BEGIN_SAFE_MSG_MAP_EX. 679 // The factory used with BEGIN_SAFE_MSG_MAP_EX.
661 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; 680 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_;
662 681
682 // This is a map of the HMONITOR to full screeen window handle.
683 typedef std::map<HMONITOR, HWND> FullscreenWindowMonitorMap;
684 static FullscreenWindowMonitorMap* fullscreen_monitor_map_;
685 // This holds the number of HWNDMessageHandler instances currently active.
686 static int32_t instance_count_;
687
663 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); 688 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
664 }; 689 };
665 690
666 } // namespace views 691 } // namespace views
667 692
668 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ 693 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/win/hwnd_message_handler.cc » ('j') | ui/views/win/hwnd_message_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698