#include "ui/base/win/touch_input.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
-#include "ui/events/gestures/gesture_sequence.h"
#include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia_paint.h"
in_size_loop_(false),
touch_down_contexts_(0),
last_mouse_hwheel_time_(0),
- msg_handled_(FALSE) {
+ msg_handled_(FALSE),
+ dwm_transition_desired_(false) {
}
HWNDMessageHandler::~HWNDMessageHandler() {
}
void HWNDMessageHandler::FrameTypeChanged() {
- // Called when the frame type could possibly be changing (theme change or
- // DWM composition change).
- UpdateDwmNcRenderingPolicy();
-
- // Don't redraw the window here, because we need to hide and show the window
- // which will also trigger a redraw.
- ResetWindowRegion(true, false);
-
- // The non-client view needs to update too.
- delegate_->HandleFrameChanged();
-
- if (IsVisible() && !delegate_->IsUsingCustomFrame()) {
- // For some reason, we need to hide the window after we change from a custom
- // frame to a native frame. If we don't, the client area will be filled
- // with black. This seems to be related to an interaction between DWM and
- // SetWindowRgn, but the details aren't clear. Additionally, we need to
- // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows
- // open they will re-appear with a non-deterministic Z-order.
- UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
- SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
- SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
+ if (base::win::GetVersion() < base::win::VERSION_VISTA) {
+ // Don't redraw the window here, because we invalidate the window later.
+ ResetWindowRegion(true, false);
+ // The non-client view needs to update too.
+ delegate_->HandleFrameChanged();
+ InvalidateRect(hwnd(), NULL, FALSE);
+ } else {
+ if (!custom_window_region_ && !delegate_->IsUsingCustomFrame())
+ dwm_transition_desired_ = true;
+ if (!dwm_transition_desired_ || !fullscreen_handler_->fullscreen())
+ PerformDwmTransition();
}
-
- // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
- // to notify our children too, since we can have MDI child windows who need to
- // update their appearance.
- EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
}
void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) {
}
}
+void HWNDMessageHandler::SetFullscreen(bool fullscreen) {
+ fullscreen_handler()->SetFullscreen(fullscreen);
+ // If we are out of fullscreen and there was a pending DWM transition for the
+ // window, then go ahead and do it now.
+ if (!fullscreen && dwm_transition_desired_)
+ PerformDwmTransition();
+}
+
+void HWNDMessageHandler::SizeConstraintsChanged() {
+ LONG style = GetWindowLong(hwnd(), GWL_STYLE);
+ // Ignore if this is not a standard window.
+ if (!(style & WS_OVERLAPPED))
+ return;
+
+ if (delegate_->CanResize()) {
+ style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
+ if (!delegate_->CanMaximize())
+ style &= ~WS_MAXIMIZEBOX;
+ } else {
+ style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
+ }
+ if (delegate_->CanMinimize()) {
+ style |= WS_MINIMIZEBOX;
+ } else {
+ style &= ~WS_MINIMIZEBOX;
+ }
+ SetWindowLong(hwnd(), GWL_STYLE, style);
+}
+
////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, InputMethodDelegate implementation:
if (base::win::GetVersion() < base::win::VERSION_VISTA)
return;
+ if (fullscreen_handler_->fullscreen())
+ return;
+
DWMNCRENDERINGPOLICY policy =
custom_window_region_ || delegate_->IsUsingCustomFrame() ?
DWMNCRP_DISABLED : DWMNCRP_ENABLED;
gfx::Size min_window_size;
gfx::Size max_window_size;
delegate_->GetMinMaxSize(&min_window_size, &max_window_size);
+ min_window_size = gfx::win::DIPToScreenSize(min_window_size);
+ max_window_size = gfx::win::DIPToScreenSize(max_window_size);
+
// Add the native frame border size to the minimum and maximum size if the
// view reports its size as the client size.
WPARAM w_param,
LPARAM l_param) {
LRESULT result = 0;
- SetMsgHandled(delegate_->HandleIMEMessage(
- message, w_param, l_param, &result));
+ base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
+ const bool msg_handled =
+ delegate_->HandleIMEMessage(message, w_param, l_param, &result);
+ if (ref.get())
+ SetMsgHandled(msg_handled);
return result;
}
EnableMenuItemByCommand(menu, SC_SIZE, delegate_->CanResize() && is_restored);
EnableMenuItemByCommand(menu, SC_MAXIMIZE, delegate_->CanMaximize() &&
!is_fullscreen && !is_maximized);
- // TODO: unfortunately, WidgetDelegate does not declare CanMinimize() and some
- // code depends on this check, see http://crbug.com/341010.
- EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMaximize() &&
+ EnableMenuItemByCommand(menu, SC_MINIMIZE, delegate_->CanMinimize() &&
!is_minimized);
if (is_maximized && delegate_->CanResize())
return false;
}
+void HWNDMessageHandler::PerformDwmTransition() {
+ dwm_transition_desired_ = false;
+
+ UpdateDwmNcRenderingPolicy();
+ // Don't redraw the window here, because we need to hide and show the window
+ // which will also trigger a redraw.
+ ResetWindowRegion(true, false);
+ // The non-client view needs to update too.
+ delegate_->HandleFrameChanged();
+
+ if (IsVisible() && !delegate_->IsUsingCustomFrame()) {
+ // For some reason, we need to hide the window after we change from a custom
+ // frame to a native frame. If we don't, the client area will be filled
+ // with black. This seems to be related to an interaction between DWM and
+ // SetWindowRgn, but the details aren't clear. Additionally, we need to
+ // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows
+ // open they will re-appear with a non-deterministic Z-order.
+ UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER;
+ SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
+ SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
+ }
+ // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
+ // to notify our children too, since we can have MDI child windows who need to
+ // update their appearance.
+ EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
+}
+
} // namespace views