From 57427620704c707fa5d50eb6f01a5c4654708c4c Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 1 Aug 2019 17:22:17 +0100 Subject: split browser and browser_window operations --- frontends/windows/main.c | 23 +++++++++++++++++++++++ frontends/windows/window.c | 25 ------------------------- 2 files changed, 23 insertions(+), 25 deletions(-) (limited to 'frontends/windows') diff --git a/frontends/windows/main.c b/frontends/windows/main.c index b021751c9..6592e1626 100644 --- a/frontends/windows/main.c +++ b/frontends/windows/main.c @@ -34,6 +34,7 @@ #include "utils/nsoption.h" #include "netsurf/url_db.h" #include "netsurf/cookie_db.h" +#include "netsurf/browser.h" #include "netsurf/browser_window.h" #include "netsurf/fetch.h" #include "netsurf/misc.h" @@ -61,6 +62,26 @@ char **respaths; /** exported global defined in windows/gui.h */ char *nsw32_config_home; /* exported global defined in windows/gui.h */ +/** + * Obtain the DPI of the display. + * + * \return The DPI of the device the window is displayed on. + */ +static int get_screen_dpi(void) +{ + HDC screendc = GetDC(0); + int dpi = GetDeviceCaps(screendc, LOGPIXELSY); + ReleaseDC(0, screendc); + + if (dpi <= 10) { + dpi = 96; /* 96DPI is the default */ + } + + NSLOG(netsurf, INFO, "FIX DPI %d", dpi); + + return dpi; +} + /** * Get the path to the config directory. * @@ -393,6 +414,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) return 1; } + browser_set_dpi(get_screen_dpi()); + urldb_load(nsoption_charp(url_file)); urldb_load_cookies(nsoption_charp(cookie_file)); hotlist_init(nsoption_charp(hotlist_path), diff --git a/frontends/windows/window.c b/frontends/windows/window.c index 575d089a3..689e78d8c 100644 --- a/frontends/windows/window.c +++ b/frontends/windows/window.c @@ -71,29 +71,6 @@ static const char windowclassname_main[] = "nswsmainwindow"; static int open_windows = 0; -/** - * Obtain the DPI of the display. - * - * \param hwnd A win32 window handle to get the DPI for - * \return The DPI of the device the window is displayed on. - */ -static int get_window_dpi(HWND hwnd) -{ - HDC hdc = GetDC(hwnd); - int dpi = GetDeviceCaps(hdc, LOGPIXELSY); - - if (dpi <= 10) { - dpi = 96; /* 96DPI is the default */ - } - - ReleaseDC(hwnd, hdc); - - NSLOG(netsurf, INFO, "FIX DPI %d", dpi); - - return dpi; -} - - /** * create and attach accelerator table to main window * @@ -190,8 +167,6 @@ static HWND nsws_window_create(HINSTANCE hInstance, struct gui_window *gw) /* set the gui window associated with this browser */ SetProp(hwnd, TEXT("GuiWnd"), (HANDLE)gw); - browser_set_dpi(get_window_dpi(hwnd)); - if ((nsoption_int(window_width) >= 100) && (nsoption_int(window_height) >= 100) && (nsoption_int(window_x) >= 0) && -- cgit v1.2.3