1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Use dynamic_cast to convert QWindow m_target to gs_frame

Used to access get_mouse_lock_state rather than going through the QWindow property tables.

Modify mouse hide and lock to default OFF when entering Windowed mode, and to default ON when entering Fullscreen unless 'show cursor in fullscreen' is configured
This commit is contained in:
Bevan Weiss 2020-08-31 00:09:38 +10:00 committed by Megamouse
parent ca3ee019cc
commit ae0e454fc2
5 changed files with 22 additions and 25 deletions

View File

@ -91,13 +91,8 @@ void basic_mouse_handler::MouseScroll(QWheelEvent* event)
bool basic_mouse_handler::get_mouse_lock_state()
{
if (m_target)
{
auto mouse_locked = m_target->property("mouse_locked");
if (mouse_locked.isValid())
return mouse_locked.toBool();
return false;
}
if (auto game_frame = dynamic_cast<gs_frame*>(m_target))
return game_frame->get_mouse_lock_state();
return false;
}

View File

@ -2,6 +2,7 @@
#include "stdafx.h"
#include "Emu/Io/MouseHandler.h"
#include "rpcs3qt/gs_frame.h"
#include <QWindow>
#include <QMouseEvent>

View File

@ -2,6 +2,7 @@
#include "pad_thread.h"
#include "Emu/Io/pad_config.h"
#include "Input/product_info.h"
#include "rpcs3qt/gs_frame.h"
#include <QApplication>
@ -315,13 +316,8 @@ void keyboard_pad_handler::mouseReleaseEvent(QMouseEvent* event)
bool keyboard_pad_handler::get_mouse_lock_state()
{
if (m_target)
{
auto mouse_locked = m_target->property("mouse_locked");
if (mouse_locked.isValid())
return mouse_locked.toBool();
return false;
}
if (auto game_frame = dynamic_cast<gs_frame*>(m_target))
return game_frame->get_mouse_lock_state();
return false;
}

View File

@ -78,8 +78,6 @@ gs_frame::gs_frame(const QRect& geometry, const QIcon& appIcon, const std::share
// We default the mouse lock to being off
m_mouse_hide_and_lock = false;
// and we 'publish' this to the property values of this window
setProperty("mouse_locked", m_mouse_hide_and_lock);
#ifdef _WIN32
m_tb_button = new QWinTaskbarButton();
@ -211,10 +209,15 @@ void gs_frame::toggle_fullscreen()
if (visibility() == FullScreen)
{
setVisibility(Windowed);
// in windowed mode we default to not hiding / locking the mouse
m_mouse_hide_and_lock = false;
}
else
{
setVisibility(FullScreen);
// in fullscreen (unless we want to show mouse) then we default to hiding and locking
if (!m_show_mouse_in_fullscreen)
m_mouse_hide_and_lock = true;
}
});
}
@ -224,12 +227,15 @@ void gs_frame::toggle_mouselock()
// first we toggle the value
m_mouse_hide_and_lock = !m_mouse_hide_and_lock;
// and then we publish it to the window properties
setProperty("mouse_locked", m_mouse_hide_and_lock);
// and update the cursor
HandleCursor(this->visibility());
}
bool gs_frame::get_mouse_lock_state()
{
return m_mouse_hide_and_lock;
}
void gs_frame::close()
{
Emu.Stop();
@ -484,19 +490,16 @@ void gs_frame::mouseDoubleClickEvent(QMouseEvent* ev)
}
}
void gs_frame::HandleCursor(QWindow::Visibility visibility)
void gs_frame::HandleCursor(QWindow::Visibility /*visibility*/)
{
if (m_mouse_hide_and_lock || (visibility == QWindow::Visibility::FullScreen && !m_show_mouse_in_fullscreen))
if (m_mouse_hide_and_lock)
{
setCursor(Qt::BlankCursor);
m_mousehide_timer.stop();
}
else
{
if (!m_mouse_hide_and_lock)
{
setCursor(Qt::ArrowCursor);
}
setCursor(Qt::ArrowCursor);
if (m_hide_mouse_after_idletime)
{

View File

@ -55,6 +55,8 @@ public:
void progress_increment(int delta);
void progress_set_limit(int limit);
bool get_mouse_lock_state();
void take_screenshot(const std::vector<u8> sshot_data, const u32 sshot_width, const u32 sshot_height, bool is_bgra) override;
protected: