Commit f8ead841 authored by Ionel Popescu's avatar Ionel Popescu Committed by Commit Bot

Add drop shadow support for popups on Windows.

This CL adds drop shadow support for popups on Windows when
the FormControlsRefresh feature is enabled.

In order to add the drop shadow, the Window used for popups (TYPE_MENU)
is decorated with the WS_THICKFRAME style. Since WS_THICKFRAME also
provides a frame, the remove_standard_frame flag is set as we are interested
in keeping just the drop shadow.

Since drop shadow is not supported on Windows versions without DWM composition,
then the drop shadow is replaced by a thin-line border by using the
WS_BORDER style.

Bug: 1000898
Change-Id: I04588d8d1703cb98f4b7a239f9cf46d742324a1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786247Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#695655}
parent 62193179
......@@ -25,6 +25,7 @@
#include "ui/base/class_property.h"
#include "ui/base/hit_test.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ui_base_features.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point_conversions.h"
......@@ -98,6 +99,13 @@ class DesktopNativeWidgetTopLevelHandler : public aura::WindowObserver {
init_params.type = full_screen ? Widget::InitParams::TYPE_WINDOW
: is_menu ? Widget::InitParams::TYPE_MENU
: Widget::InitParams::TYPE_POPUP;
#if defined(OS_WIN)
// For menus, on Windows versions that support drop shadow remove
// the standard frame in order to keep just the shadow.
if (features::IsFormControlsRefreshEnabled() &&
init_params.type == Widget::InitParams::TYPE_MENU)
init_params.remove_standard_frame = true;
#endif
init_params.bounds = bounds;
init_params.ownership = Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET;
init_params.layer_type = ui::LAYER_NOT_DRAWN;
......
......@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "build/build_config.h"
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/ui_base_switches.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/win/hwnd_message_handler.h"
......@@ -108,6 +109,15 @@ void CalculateWindowStylesFromInitParams(
break;
case Widget::InitParams::TYPE_MENU:
*style |= WS_POPUP;
if (features::IsFormControlsRefreshEnabled() &&
params.remove_standard_frame) {
// If the platform doesn't support drop shadow, decorate the Window
// with just a border.
if (ui::win::IsAeroGlassEnabled())
*style |= WS_THICKFRAME;
else
*style |= WS_BORDER;
}
break;
case Widget::InitParams::TYPE_TOOLTIP:
*style |= WS_POPUP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment