UI: Hide the cursor after 3 seconds in fullscreen-mode.

This commit is contained in:
Dr. Chat
2016-08-06 17:00:12 -05:00
parent 1a5d4b99fc
commit 1de47e0d17
4 changed files with 44 additions and 4 deletions

View File

@@ -57,7 +57,7 @@ bool Win32Window::OnCreate() {
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, L"MAINICON");
wcex.hIconSm = LoadIcon(hInstance, L"MAINICON");
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hCursor = nullptr;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = nullptr;
wcex.lpszClassName = L"XeniaWindowClass";
@@ -105,6 +105,8 @@ bool Win32Window::OnCreate() {
ShowWindow(hwnd_, SW_SHOWNORMAL);
UpdateWindow(hwnd_);
arrow_cursor_ = LoadCursor(nullptr, IDC_ARROW);
// Initial state.
if (!is_cursor_visible_) {
ShowCursor(FALSE);
@@ -254,9 +256,10 @@ void Win32Window::set_cursor_visible(bool value) {
if (is_cursor_visible_ == value) {
return;
}
is_cursor_visible_ = value;
if (value) {
ShowCursor(TRUE);
SetCursor(nullptr);
} else {
ShowCursor(FALSE);
}
@@ -483,8 +486,8 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) {
}
MouseEvent::Button button = MouseEvent::Button::kNone;
int32_t dx = 0;
int32_t dy = 0;
int32_t dx = x - last_mouse_pos_.x;
int32_t dy = y - last_mouse_pos_.y;
switch (message) {
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
@@ -524,6 +527,8 @@ bool Win32Window::HandleMouse(UINT message, WPARAM wParam, LPARAM lParam) {
return true;
}
last_mouse_pos_ = {x, y};
auto e = MouseEvent(this, button, x, y, dx, dy);
switch (message) {
case WM_LBUTTONDOWN:

View File

@@ -73,8 +73,10 @@ class Win32Window : public Window {
HICON icon_ = nullptr;
bool closing_ = false;
bool fullscreen_ = false;
HCURSOR arrow_cursor_ = nullptr;
WINDOWPLACEMENT windowed_pos_ = {0};
POINT last_mouse_pos_ = {0};
};
class Win32MenuItem : public MenuItem {