Skip to content

Commit

Permalink
[win] Add option to disable WinTab for certain windows (aseprite/asep…
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Nov 21, 2024
1 parent 631bc33 commit 7af127f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions os/win/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ WindowWin::WindowWin(const WindowSpec& spec)
, m_lastPointerDownButton(Event::NoneButton)
, m_pointerDownCount(0)
#endif
, m_allowWintab(spec.useTabletOptions())
, m_hpenctx(nullptr)
, m_fullscreen(false)
, m_titled(spec.titled())
Expand Down Expand Up @@ -2485,6 +2486,9 @@ void WindowWin::checkDarkModeChange()

void WindowWin::openWintabCtx()
{
if (!m_allowWintab)
return;

auto sys = system();
TabletOptions options = sys->tabletOptions();
if (options.api == TabletAPI::Wintab ||
Expand Down
1 change: 1 addition & 0 deletions os/win/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ namespace os {
// packets queue are shared between all windows, because it's
// information from the device that doesn't depend on the active
// window.
bool m_allowWintab;
HCTX m_hpenctx;
static PointerType m_pointerType;
static float m_pressure;
Expand Down
12 changes: 11 additions & 1 deletion os/window_spec.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// LAF OS Library
// Copyright (C) 2019-2021 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
Expand Down Expand Up @@ -58,6 +58,13 @@ namespace os {
void transparent(const bool s) { m_transparent = s; }
void parent(Window* p) { m_parent = p; }

// Option to ignore tablet options and avoid calling WTOpen() for
// each single window (e.g. tooltips don't need the tablet).
#if LAF_WINDOWS
bool useTabletOptions() const { return m_useTabletOptions; }
void useTabletOptions(const bool s) { m_useTabletOptions = s; }
#endif

const gfx::Rect& frame() const { return m_frame; }
const gfx::Rect& contentRect() const { return m_contentRect; }
int scale() const { return m_scale; }
Expand All @@ -83,6 +90,9 @@ namespace os {
int m_scale = 1;
ScreenRef m_screen;
Window* m_parent = nullptr;
#if LAF_WINDOWS
bool m_useTabletOptions = true;
#endif
};

} // namespace os
Expand Down

0 comments on commit 7af127f

Please sign in to comment.