OpenTTD Source 20260311-master-g511d3794ce
win32_v.cpp File Reference

Implementation of the Windows (GDI) video driver. More...

#include "../stdafx.h"
#include "../openttd.h"
#include "../error_func.h"
#include "../gfx_func.h"
#include "../os/windows/win32.h"
#include "../blitter/factory.hpp"
#include "../core/geometry_func.hpp"
#include "../core/math_func.hpp"
#include "../core/random_func.hpp"
#include "../texteff.hpp"
#include "../thread.h"
#include "../progress.h"
#include "../window_gui.h"
#include "../window_func.h"
#include "../framerate_type.h"
#include "../library_loader.h"
#include "../core/utf8.hpp"
#include "win32_v.h"
#include <windows.h>
#include <imm.h>
#include <versionhelpers.h>
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

struct  Win32VkMapping

Macros

#define MAPVK_VK_TO_CHAR   (2)
#define PM_QS_INPUT   0x20000
#define WM_DPICHANGED   0x02E0
#define AS(x, z)
#define AM(x, y, z, w)
#define WM_MOUSEWHEEL   0x020A
#define WM_MOUSEHWHEEL   0x020E
#define GET_WHEEL_DELTA_WPARAM(wparam)

Functions

static uint MapWindowsKey (uint sym)
static LRESULT HandleCharMsg (uint keycode, char32_t charcode)
 Forward key presses to the window system.
static bool DrawIMECompositionString ()
 Should we draw the composition string ourself, i.e is this a normal IME?
static void SetCompositionPos (HWND hwnd)
 Set position of the composition window to the caret position.
static void SetCandidatePos (HWND hwnd)
 Set the position of the candidate window.
static LRESULT HandleIMEComposition (HWND hwnd, WPARAM wParam, LPARAM lParam)
 Handle WM_IME_COMPOSITION messages.
static void CancelIMEComposition (HWND hwnd)
 Clear the current composition string.
static bool IsDarkModeEnabled ()
static void SetDarkModeForWindow (HWND hWnd, bool dark_mode)
LRESULT WndProcGdi (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
static void RegisterWndClass ()
static void FindResolutions (uint8_t bpp)
static BOOL MonitorEnumProc (HMONITOR hMonitor, HDC, LPRECT, LPARAM data)

Variables

bool _window_maximize
static Dimension _bck_resolution
DWORD _imm_props
static Palette _local_palette
 Current palette to use for drawing.
static const Win32VkMapping _vk_mapping []
static const Dimension default_resolutions []
static FVideoDriver_Win32GDI iFVideoDriver_Win32GDI

Detailed Description

Implementation of the Windows (GDI) video driver.

Definition in file win32_v.cpp.

Macro Definition Documentation

◆ AM

#define AM ( x,
y,
z,
w )
Value:
{x, y - x + 1, z}

Definition at line 75 of file win32_v.cpp.

◆ AS

#define AS ( x,
z )
Value:
{x, 1, z}

Definition at line 74 of file win32_v.cpp.

◆ GET_WHEEL_DELTA_WPARAM

#define GET_WHEEL_DELTA_WPARAM ( wparam)
Value:
((short)HIWORD(wparam))

◆ MAPVK_VK_TO_CHAR

#define MAPVK_VK_TO_CHAR   (2)

Definition at line 46 of file win32_v.cpp.

◆ PM_QS_INPUT

#define PM_QS_INPUT   0x20000

Definition at line 50 of file win32_v.cpp.

◆ WM_DPICHANGED

#define WM_DPICHANGED   0x02E0

Definition at line 54 of file win32_v.cpp.

Function Documentation

◆ CancelIMEComposition()

void CancelIMEComposition ( HWND hwnd)
static

Clear the current composition string.

Parameters
hwndHandle to the window to cancel the composition for.

Definition at line 427 of file win32_v.cpp.

References HandleTextInput().

Referenced by VideoDriver_Win32Base::EditBoxLostFocus().

◆ DrawIMECompositionString()

bool DrawIMECompositionString ( )
static

Should we draw the composition string ourself, i.e is this a normal IME?

Returns
true when the window is at the caret and does not a non-standard UI.

Definition at line 288 of file win32_v.cpp.

Referenced by HandleIMEComposition().

◆ FindResolutions()

void FindResolutions ( uint8_t bpp)
static

Definition at line 944 of file win32_v.cpp.

◆ HandleCharMsg()

LRESULT HandleCharMsg ( uint keycode,
char32_t charcode )
static

Forward key presses to the window system.

Parameters
keycodeThe pressed key code.
charcodeThe pressed char code.
Returns
Always \0 to denote it was handled.

Definition at line 258 of file win32_v.cpp.

References Debug, HandleKeypress(), Utf16DecodeSurrogate(), Utf16IsLeadSurrogate(), and Utf16IsTrailSurrogate().

◆ HandleIMEComposition()

LRESULT HandleIMEComposition ( HWND hwnd,
WPARAM wParam,
LPARAM lParam )
static

Handle WM_IME_COMPOSITION messages.

Parameters
hwndThe handle to the window.
wParamThe latest change in the composition.
lParamHow the composition was changed.
Returns
Always \0 to denote it was handled.

Definition at line 362 of file win32_v.cpp.

References convert_from_fs(), DrawIMECompositionString(), FS2OTTD(), HandleTextInput(), SetCompositionPos(), and Utf16IsLeadSurrogate().

◆ IsDarkModeEnabled()

bool IsDarkModeEnabled ( )
static

Definition at line 470 of file win32_v.cpp.

◆ MapWindowsKey()

uint MapWindowsKey ( uint sym)
static

Definition at line 118 of file win32_v.cpp.

◆ MonitorEnumProc()

BOOL MonitorEnumProc ( HMONITOR hMonitor,
HDC ,
LPRECT ,
LPARAM data )
static

Definition at line 1091 of file win32_v.cpp.

◆ RegisterWndClass()

void RegisterWndClass ( )
static

Definition at line 906 of file win32_v.cpp.

◆ SetCandidatePos()

void SetCandidatePos ( HWND hwnd)
static

Set the position of the candidate window.

Parameters
hwndHandle to the window.

Definition at line 322 of file win32_v.cpp.

References _focused_window, EditBoxInGlobalFocus(), Point, WC_CONSOLE, Coord2D< T >::x, and Coord2D< T >::y.

Referenced by VideoDriver_Win32Base::EditBoxLostFocus().

◆ SetCompositionPos()

void SetCompositionPos ( HWND hwnd)
static

Set position of the composition window to the caret position.

Parameters
hwndHandle to the window.

Definition at line 297 of file win32_v.cpp.

References _focused_window, EditBoxInGlobalFocus(), Point, Coord2D< T >::x, and Coord2D< T >::y.

Referenced by VideoDriver_Win32Base::EditBoxLostFocus(), and HandleIMEComposition().

◆ SetDarkModeForWindow()

void SetDarkModeForWindow ( HWND hWnd,
bool dark_mode )
static

Definition at line 499 of file win32_v.cpp.

◆ WndProcGdi()

LRESULT WndProcGdi ( HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam )

Definition at line 523 of file win32_v.cpp.

Variable Documentation

◆ _bck_resolution

Dimension _bck_resolution
static

Definition at line 58 of file win32_v.cpp.

◆ _imm_props

DWORD _imm_props

Definition at line 59 of file win32_v.cpp.

◆ _local_palette

Palette _local_palette
static

Current palette to use for drawing.

Definition at line 61 of file win32_v.cpp.

◆ _vk_mapping

const Win32VkMapping _vk_mapping[]
static

Definition at line 77 of file win32_v.cpp.

◆ _window_maximize

bool _window_maximize

Definition at line 57 of file win32_v.cpp.

◆ default_resolutions

const Dimension default_resolutions[]
static
Initial value:
= {
{ 640, 480 },
{ 800, 600 },
{ 1024, 768 },
{ 1152, 864 },
{ 1280, 800 },
{ 1280, 960 },
{ 1280, 1024 },
{ 1400, 1050 },
{ 1600, 1200 },
{ 1680, 1050 },
{ 1920, 1200 }
}

Definition at line 930 of file win32_v.cpp.

◆ iFVideoDriver_Win32GDI

FVideoDriver_Win32GDI iFVideoDriver_Win32GDI
static

Definition at line 1144 of file win32_v.cpp.