[win] Use WinTab/tablet pressure only for certain windows (#3358)

Windows that need tablet information are the MainWindow, DynamicsPopup,
and scripts Dialog.
This commit is contained in:
David Capello 2024-11-21 17:23:50 -03:00
parent dbccf71622
commit 84f3101681
7 changed files with 22 additions and 2 deletions

2
laf

@ -1 +1 @@
Subproject commit 631bc339fa7a4b5adb9c4caee5b07dac18f2219a
Subproject commit 7af127f4785ac0fb0e50fa32e68e572719477f2a

View File

@ -66,6 +66,8 @@ public:
: WindowWithHand(type, text)
, m_handTool(false)
{
// As scripts can receive the "pressure" information.
setNeedsTabletPressure(true);
}
// Enables the Hand tool in the active editor.

View File

@ -222,6 +222,8 @@ DynamicsPopup::DynamicsPopup(Delegate* delegate)
, m_ditheringSel(new DitheringSelector(DitheringSelector::SelectMatrix))
, m_fromTo(tools::ColorFromTo::BgToFg)
{
setNeedsTabletPressure(true);
m_dynamics->stabilizer()->Click.connect(
[this](){
if (m_dynamics->stabilizer()->isSelected()) {

View File

@ -95,6 +95,7 @@ MainWindow::MainWindow()
#endif
{
enableFlags(ALLOW_DROP);
setNeedsTabletPressure(true);
}
// This 'initialize' function is a way to split the creation of the

View File

@ -1394,6 +1394,11 @@ void Manager::_openWindow(Window* window, bool center)
spec.parent(parentDisplay->nativeWindow());
}
#if LAF_WINDOWS
// Just in case we'll try to avoid using WinTab at all costs.
spec.useTabletOptions(window->needsTabletPressure());
#endif
os::WindowRef newNativeWindow = os::System::instance()->makeWindow(spec);
ui::Display* newDisplay = new ui::Display(parentDisplay, newNativeWindow, window);

View File

@ -122,6 +122,8 @@ Window::Window(Type type, const std::string& text)
, m_isWantFocus(true)
, m_isForeground(false)
, m_isAutoRemap(true)
, m_isResizing(false)
, m_needsTabletPressure(false)
{
setVisible(false);
setAlign(LEFT | MIDDLE);

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
@ -66,6 +66,13 @@ namespace ui {
bool isSizeable() const { return m_isSizeable; }
bool isMoveable() const { return m_isMoveable; }
// Use to inhibit buggy WinTab implementations that might crash
// the whole program just calling WTOpen(). This must be called
// before creating the native window (before
// Manager::_openWindow()).
void setNeedsTabletPressure(const bool s) { m_needsTabletPressure = s; }
bool needsTabletPressure() const { return m_needsTabletPressure; }
// Returns true only inside onWindowResize() when the window size
// changed.
bool isResizing() const { return m_isResizing; }
@ -136,6 +143,7 @@ namespace ui {
bool m_isForeground : 1;
bool m_isAutoRemap : 1;
bool m_isResizing : 1;
bool m_needsTabletPressure : 1;
int m_hitTest;
gfx::Rect m_lastFrame;
};