Add --disable-wintab CLI option

This can be used to avoid loading wintab32.dll which sometimes locks
Aseprite loading.
This commit is contained in:
David Capello 2017-09-22 15:40:59 -03:00
parent db2e582f23
commit a96a9e9868
7 changed files with 61 additions and 8 deletions

View File

@ -146,6 +146,11 @@ App::App()
void App::initialize(const AppOptions& options)
{
#ifdef _WIN32
if (options.disableWintab())
she::instance()->useWintabAPI(false);
#endif
m_isGui = options.startUI() && !options.previewCLI();
m_isShell = options.startShell();
m_coreModules = new CoreModules;

View File

@ -70,6 +70,9 @@ AppOptions::AppOptions(int argc, const char* argv[])
, m_oneFrame(m_po.add("oneframe").description("Load just the first frame"))
, m_verbose(m_po.add("verbose").mnemonic('v').description("Explain what is being done"))
, m_debug(m_po.add("debug").description("Extreme verbose mode and\ncopy log to desktop"))
#ifdef _WIN32
, m_disableWintab(m_po.add("disable-wintab").description("Don't load wintab32.dll library"))
#endif
, m_help(m_po.add("help").mnemonic('?').description("Display this help and exits"))
, m_version(m_po.add("version").description("Output version information and exit"))
{
@ -109,4 +112,11 @@ bool AppOptions::hasExporterParams() const
m_po.enabled(m_sheet);
}
#ifdef _WIN32
bool AppOptions::disableWintab() const
{
return m_po.enabled(m_disableWintab);
}
#endif
}

View File

@ -84,6 +84,9 @@ public:
const Option& oneFrame() const { return m_oneFrame; }
bool hasExporterParams() const;
#ifdef _WIN32
bool disableWintab() const;
#endif
private:
std::string m_exeName;
@ -140,6 +143,9 @@ private:
Option& m_verbose;
Option& m_debug;
#ifdef _WIN32
Option& m_disableWintab;
#endif
Option& m_help;
Option& m_version;

View File

@ -37,6 +37,9 @@ public:
CommonSystem()
: m_nativeDialogs(nullptr)
, m_menus(nullptr) {
#ifdef _WIN32
m_useWintabAPI = true;
#endif
}
~CommonSystem() {
@ -48,6 +51,18 @@ public:
delete this;
}
void useWintabAPI(bool state) override {
#ifdef _WIN32
m_useWintabAPI = state;
#endif
}
#ifdef _WIN32
bool useWintabAPI() const {
return m_useWintabAPI;
}
#endif
Logger* logger() override {
#ifdef __APPLE__
return getOsxLogger();
@ -114,6 +129,9 @@ public:
}
private:
#ifdef _WIN32
bool m_useWintabAPI;
#endif
NativeDialogs* m_nativeDialogs;
Menus* m_menus;
base::UniquePtr<ft::Lib> m_ft;

View File

@ -37,6 +37,12 @@ namespace she {
virtual void activateApp() = 0;
virtual void finishLaunching() = 0;
virtual Capabilities capabilities() const = 0;
// Disables loading wintab32.dll (sometimes a program can be
// locked when we load the wintab32.dll, so we need a way to
// opt-out loading this library.)
virtual void useWintabAPI(bool enable) = 0;
virtual Logger* logger() = 0;
virtual Menus* menus() = 0;
virtual NativeDialogs* nativeDialogs() = 0;

View File

@ -372,10 +372,10 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
case WM_CREATE:
LOG("WIN: Creating window %p\n", m_hwnd);
// Attach Wacom context
m_hpenctx =
static_cast<WindowSystem*>(she::instance())
->penApi().open(m_hwnd);
if (system()->useWintabAPI()) {
// Attach Wacom context
m_hpenctx = system()->penApi().open(m_hwnd);
}
break;
case WM_DESTROY:
@ -383,8 +383,7 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
m_hwnd, m_hpenctx);
if (m_hpenctx) {
static_cast<WindowSystem*>(she::instance())
->penApi().close(m_hpenctx);
system()->penApi().close(m_hpenctx);
m_hpenctx = nullptr;
}
break;
@ -781,7 +780,7 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
}
case WT_CSRCHANGE: { // From Wintab 1.1
auto& api = static_cast<WindowSystem*>(she::instance())->penApi();
auto& api = system()->penApi();
UINT serial = wparam;
HCTX ctx = (HCTX)lparam;
PACKET packet;
@ -810,7 +809,7 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
}
case WT_PACKET: {
auto& api = static_cast<WindowSystem*>(she::instance())->penApi();
auto& api = system()->penApi();
UINT serial = wparam;
HCTX ctx = (HCTX)lparam;
PACKET packet;
@ -938,4 +937,10 @@ LRESULT CALLBACK WinWindow::staticWndProc(HWND hwnd, UINT msg, WPARAM wparam, LP
}
}
// static
WindowSystem* WinWindow::system()
{
return static_cast<WindowSystem*>(she::instance());
}
} // namespace she

View File

@ -19,6 +19,7 @@
namespace she {
class Event;
class Surface;
class WindowSystem;
class WinWindow {
public:
@ -62,6 +63,8 @@ namespace she {
static HWND createHwnd(WinWindow* self, int width, int height);
static LRESULT CALLBACK staticWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
static WindowSystem* system();
mutable HWND m_hwnd;
HCURSOR m_hcursor;
gfx::Size m_clientSize;