finally fix that Windows 32-bit crash
This commit is contained in:
parent
f69917010a
commit
8746d36eac
|
@ -24,7 +24,8 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
typedef HRESULT (*GDFM)(HMONITOR,int,UINT*,UINT*);
|
||||
#include "shellScalingStub.h"
|
||||
typedef HRESULT (WINAPI *GDFM)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
@ -71,9 +72,9 @@ double getScaleFactor(const char* driverHint) {
|
|||
return 1.0;
|
||||
}
|
||||
|
||||
unsigned int dpiX=96;
|
||||
unsigned int dpiY=96;
|
||||
HRESULT result=ta_GetDpiForMonitor(disp,0,&dpiX,&dpiY);
|
||||
UINT dpiX=96;
|
||||
UINT dpiY=96;
|
||||
HRESULT result=ta_GetDpiForMonitor(disp,MDT_EFFECTIVE_DPI,&dpiX,&dpiY);
|
||||
if (result!=S_OK) {
|
||||
logW("GetDpiForMonitor failure (%.8x) - no scaling detection available!",result);
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2016 Sebastian Lackner
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_SHELLSCALINGAPI_H
|
||||
|
||||
typedef enum MONITOR_DPI_TYPE
|
||||
{
|
||||
MDT_EFFECTIVE_DPI = 0,
|
||||
MDT_ANGULAR_DPI = 1,
|
||||
MDT_RAW_DPI = 2,
|
||||
MDT_DEFAULT = MDT_EFFECTIVE_DPI,
|
||||
} MONITOR_DPI_TYPE;
|
||||
|
||||
typedef enum PROCESS_DPI_AWARENESS
|
||||
{
|
||||
PROCESS_DPI_UNAWARE,
|
||||
PROCESS_SYSTEM_DPI_AWARE,
|
||||
PROCESS_PER_MONITOR_DPI_AWARE
|
||||
} PROCESS_DPI_AWARENESS;
|
||||
|
||||
#endif /* __WINE_SHELLSCALINGAPI_H */
|
20
src/main.cpp
20
src/main.cpp
|
@ -32,6 +32,10 @@
|
|||
#include <windows.h>
|
||||
#include <combaseapi.h>
|
||||
#include <shellapi.h>
|
||||
|
||||
#include "gui/shellScalingStub.h"
|
||||
|
||||
typedef HRESULT (WINAPI *SPDA)(PROCESS_DPI_AWARENESS);
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -339,6 +343,22 @@ void reportError(String what) {
|
|||
int main(int argc, char** argv) {
|
||||
initLog();
|
||||
#ifdef _WIN32
|
||||
// set DPI awareness
|
||||
HMODULE shcore=LoadLibraryW(L"shcore.dll");
|
||||
if (shcore!=NULL) {
|
||||
SPDA ta_SetProcessDpiAwareness=(SPDA)GetProcAddress(shcore,"SetProcessDpiAwareness");
|
||||
if (ta_SetProcessDpiAwareness!=NULL) {
|
||||
HRESULT result=ta_SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||
if (result!=S_OK) {
|
||||
// ???
|
||||
}
|
||||
}
|
||||
if (!FreeLibrary(shcore)) {
|
||||
// ???
|
||||
}
|
||||
}
|
||||
|
||||
// co initialize ex
|
||||
HRESULT coResult=CoInitializeEx(NULL,COINIT_MULTITHREADED);
|
||||
if (coResult!=S_OK) {
|
||||
logE("CoInitializeEx failed!");
|
||||
|
|
Loading…
Reference in New Issue