LMMS
Loading...
Searching...
No Matches
win.c File Reference
#include "win.h"
#include "internal.h"
#include "platform.h"
#include "pugl/pugl.h"
#include <windows.h>
#include <windowsx.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <wctype.h>

Macros

#define WM_MOUSEWHEEL   0x020A
#define WM_MOUSEHWHEEL   0x020E
#define WHEEL_DELTA   120
#define GWLP_USERDATA   (-21)
#define PUGL_LOCAL_CLOSE_MSG   (WM_USER + 50)
#define PUGL_LOCAL_MARK_MSG   (WM_USER + 51)
#define PUGL_LOCAL_CLIENT_MSG   (WM_USER + 52)
#define PUGL_USER_TIMER_MIN   9470

Typedefs

typedef BOOL(WINAPIPFN_SetProcessDPIAware) (void)
typedef HRESULT(WINAPIPFN_GetProcessDpiAwareness) (HANDLE, DWORD *)
typedef HRESULT(WINAPIPFN_GetScaleFactorForMonitor) (HMONITOR, DWORD *)

Functions

LRESULT CALLBACK wndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
static wchar_t * puglUtf8ToWideChar (const char *const utf8)
static char * puglWideCharToUtf8 (const wchar_t *const wstr, size_t *len)
static bool puglRegisterWindowClass (const char *name)
static unsigned puglWinGetWindowFlags (const PuglView *const view)
static unsigned puglWinGetWindowExFlags (const PuglView *const view)
static double puglWinGetViewScaleFactor (HWND hwnd)
PuglWorldInternalspuglInitWorldInternals (PuglWorldType type, PuglWorldFlags PUGL_UNUSED(flags))
voidpuglGetNativeWorld (PuglWorld *PUGL_UNUSED(world))
PuglInternalspuglInitViewInternals (PuglWorld *PUGL_UNUSED(world))
static PuglStatus puglPollWinEvents (PuglWorld *world, const double timeout)
PuglStatus puglRealize (PuglView *view)
PuglStatus puglShow (PuglView *view)
PuglStatus puglHide (PuglView *view)
 Hide the current window.
void puglFreeViewInternals (PuglView *view)
 Destroy and free view internals (implemented once per platform).
void puglFreeWorldInternals (PuglWorld *world)
 Destroy and free world internals (implemented once per platform).
static PuglKey keySymToSpecial (WPARAM sym)
static uint32_t getModifiers (void)
static void initMouseEvent (PuglEvent *event, PuglView *view, int button, bool press, LPARAM lParam)
static void initScrollEvent (PuglEvent *event, PuglView *view, LPARAM lParam)
static uint32_t puglDecodeUTF16 (const wchar_t *buf, const int len)
 Return the code point for buf, or the replacement character on error.
static void initKeyEvent (PuglKeyEvent *event, PuglView *view, bool press, WPARAM wParam, LPARAM lParam)
static void initCharEvent (PuglEvent *event, PuglView *view, WPARAM wParam, LPARAM lParam)
static bool ignoreKeyEvent (PuglView *view, LPARAM lParam)
static RECT handleConfigure (PuglView *view, PuglEvent *event)
static void handleCrossing (PuglView *view, const PuglEventType type, POINT pos)
static void constrainAspect (const PuglView *const view, RECT *const size, const WPARAM wParam)
static LRESULT handleMessage (PuglView *view, UINT message, WPARAM wParam, LPARAM lParam)
PuglStatus puglGrabFocus (PuglView *view)
bool puglHasFocus (const PuglView *view)
 Return whether View has the keyboard input focus.
PuglStatus puglRequestAttention (PuglView *view)
PuglStatus puglStartTimer (PuglView *view, uintptr_t id, double timeout)
PuglStatus puglStopTimer (PuglView *view, uintptr_t id)
PuglStatus puglSendEvent (PuglView *view, const PuglEvent *event)
PuglStatus puglWaitForEvent (PuglView *PUGL_UNUSED(view))
static PuglStatus puglDispatchViewEvents (PuglView *view)
static PuglStatus puglDispatchWinEvents (PuglWorld *world)
PuglStatus puglUpdate (PuglWorld *world, double timeout)
PuglStatus puglProcessEvents (PuglView *view)
double puglGetTime (const PuglWorld *world)
PuglStatus puglPostRedisplay (PuglView *view)
PuglStatus puglPostRedisplayRect (PuglView *view, const PuglRect rect)
PuglNativeView puglGetNativeView (PuglView *view)
 Return the native window handle.
PuglStatus puglSetWindowTitle (PuglView *view, const char *title)
static RECT adjustedWindowRect (PuglView *const view, const long x, const long y, const long width, const long height)
double puglGetScaleFactor (const PuglView *const view)
PuglStatus puglSetFrame (PuglView *view, const PuglRect frame)
PuglStatus puglSetPosition (PuglView *const view, const int x, const int y)
PuglStatus puglSetSize (PuglView *const view, const unsigned width, const unsigned height)
PuglStatus puglSetSizeHint (PuglView *const view, const PuglSizeHint hint, const PuglSpan width, const PuglSpan height)
PuglStatus puglSetTransientParent (PuglView *view, PuglNativeView parent)
uint32_t puglGetNumClipboardTypes (const PuglView *const PUGL_UNUSED(view))
const char * puglGetClipboardType (const PuglView *const PUGL_UNUSED(view), const uint32_t typeIndex)
PuglStatus puglAcceptOffer (PuglView *const view, const PuglDataOfferEvent *const PUGL_UNUSED(offer), const uint32_t typeIndex)
const voidpuglGetClipboard (PuglView *const view, const uint32_t typeIndex, size_t *const len)
PuglStatus puglSetClipboard (PuglView *const view, const char *const type, const void *const data, const size_t len)
PuglStatus puglPaste (PuglView *const view)
PuglStatus puglSetCursor (PuglView *view, PuglCursor cursor)
PuglWinPFD puglWinGetPixelFormatDescriptor (const PuglHints hints)
PuglStatus puglWinCreateWindow (PuglView *const view, const char *const title, HWND *const hwnd, HDC *const hdc)
PuglStatus puglWinConfigure (PuglView *view)
PuglStatus puglWinEnter (PuglView *view, const PuglExposeEvent *expose)
PuglStatus puglWinLeave (PuglView *view, const PuglExposeEvent *expose)

Variables

static const char *const cursor_ids []

Macro Definition Documentation

◆ GWLP_USERDATA

#define GWLP_USERDATA   (-21)

◆ PUGL_LOCAL_CLIENT_MSG

#define PUGL_LOCAL_CLIENT_MSG   (WM_USER + 52)

◆ PUGL_LOCAL_CLOSE_MSG

#define PUGL_LOCAL_CLOSE_MSG   (WM_USER + 50)

◆ PUGL_LOCAL_MARK_MSG

#define PUGL_LOCAL_MARK_MSG   (WM_USER + 51)

◆ PUGL_USER_TIMER_MIN

#define PUGL_USER_TIMER_MIN   9470

◆ WHEEL_DELTA

#define WHEEL_DELTA   120

◆ WM_MOUSEHWHEEL

#define WM_MOUSEHWHEEL   0x020E

◆ WM_MOUSEWHEEL

#define WM_MOUSEWHEEL   0x020A

Typedef Documentation

◆ PFN_GetProcessDpiAwareness

typedef HRESULT(WINAPI * PFN_GetProcessDpiAwareness) (HANDLE, DWORD *)

◆ PFN_GetScaleFactorForMonitor

typedef HRESULT(WINAPI * PFN_GetScaleFactorForMonitor) (HMONITOR, DWORD *)

◆ PFN_SetProcessDPIAware

typedef BOOL(WINAPI * PFN_SetProcessDPIAware) (void)

Function Documentation

◆ adjustedWindowRect()

RECT adjustedWindowRect ( PuglView *const view,
const long x,
const long y,
const long width,
const long height )
static

◆ constrainAspect()

void constrainAspect ( const PuglView *const view,
RECT *const size,
const WPARAM wParam )
static

◆ getModifiers()

uint32_t getModifiers ( void )
static

◆ handleConfigure()

RECT handleConfigure ( PuglView * view,
PuglEvent * event )
static

◆ handleCrossing()

void handleCrossing ( PuglView * view,
const PuglEventType type,
POINT pos )
static

◆ handleMessage()

LRESULT handleMessage ( PuglView * view,
UINT message,
WPARAM wParam,
LPARAM lParam )
static

◆ ignoreKeyEvent()

bool ignoreKeyEvent ( PuglView * view,
LPARAM lParam )
static

◆ initCharEvent()

void initCharEvent ( PuglEvent * event,
PuglView * view,
WPARAM wParam,
LPARAM lParam )
static

◆ initKeyEvent()

void initKeyEvent ( PuglKeyEvent * event,
PuglView * view,
bool press,
WPARAM wParam,
LPARAM lParam )
static

◆ initMouseEvent()

void initMouseEvent ( PuglEvent * event,
PuglView * view,
int button,
bool press,
LPARAM lParam )
static

◆ initScrollEvent()

void initScrollEvent ( PuglEvent * event,
PuglView * view,
LPARAM lParam )
static

◆ keySymToSpecial()

PuglKey keySymToSpecial ( WPARAM sym)
static

◆ puglAcceptOffer()

PuglStatus puglAcceptOffer ( PuglView *const view,
const PuglDataOfferEvent *const PUGL_UNUSEDoffer,
const uint32_t typeIndex )

◆ puglDecodeUTF16()

uint32_t puglDecodeUTF16 ( const wchar_t * buf,
const int len )
static

Return the code point for buf, or the replacement character on error.

◆ puglDispatchViewEvents()

PuglStatus puglDispatchViewEvents ( PuglView * view)
static

◆ puglDispatchWinEvents()

PuglStatus puglDispatchWinEvents ( PuglWorld * world)
static

◆ puglFreeViewInternals()

void puglFreeViewInternals ( PuglView * view)

Destroy and free view internals (implemented once per platform).

◆ puglFreeWorldInternals()

void puglFreeWorldInternals ( PuglWorld * world)

Destroy and free world internals (implemented once per platform).

◆ puglGetClipboardType()

const char * puglGetClipboardType ( const PuglView *const PUGL_UNUSEDview,
const uint32_t typeIndex )

◆ puglGetNativeWorld()

void * puglGetNativeWorld ( PuglWorld * PUGL_UNUSEDworld)

◆ puglGetNumClipboardTypes()

uint32_t puglGetNumClipboardTypes ( const PuglView *const PUGL_UNUSEDview)

◆ puglInitViewInternals()

PuglInternals * puglInitViewInternals ( PuglWorld * PUGL_UNUSEDworld)

◆ puglInitWorldInternals()

PuglWorldInternals * puglInitWorldInternals ( PuglWorldType type,
PuglWorldFlags PUGL_UNUSEDflags )

◆ puglPollWinEvents()

PuglStatus puglPollWinEvents ( PuglWorld * world,
const double timeout )
static

◆ puglRegisterWindowClass()

bool puglRegisterWindowClass ( const char * name)
static

◆ puglUtf8ToWideChar()

wchar_t * puglUtf8ToWideChar ( const char *const utf8)
static

◆ puglWaitForEvent()

PuglStatus puglWaitForEvent ( PuglView * PUGL_UNUSEDview)

◆ puglWideCharToUtf8()

char * puglWideCharToUtf8 ( const wchar_t *const wstr,
size_t * len )
static

◆ puglWinConfigure()

PuglStatus puglWinConfigure ( PuglView * view)

◆ puglWinCreateWindow()

PuglStatus puglWinCreateWindow ( PuglView *const view,
const char *const title,
HWND *const hwnd,
HDC *const hdc )

◆ puglWinEnter()

PuglStatus puglWinEnter ( PuglView * view,
const PuglExposeEvent * expose )

◆ puglWinGetPixelFormatDescriptor()

PuglWinPFD puglWinGetPixelFormatDescriptor ( const PuglHints hints)

◆ puglWinGetViewScaleFactor()

double puglWinGetViewScaleFactor ( HWND hwnd)
static

◆ puglWinGetWindowExFlags()

unsigned puglWinGetWindowExFlags ( const PuglView *const view)
static

◆ puglWinGetWindowFlags()

unsigned puglWinGetWindowFlags ( const PuglView *const view)
static

◆ puglWinLeave()

PuglStatus puglWinLeave ( PuglView * view,
const PuglExposeEvent * expose )

◆ wndProc()

LRESULT CALLBACK wndProc ( HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam )

Variable Documentation

◆ cursor_ids

const char* const cursor_ids[]
static
Initial value:
= {
IDC_CROSS,
}
#define IDC_SIZENESW
#define IDC_NO
#define IDC_ARROW
#define IDC_SIZENWSE
#define IDC_SIZENS
#define IDC_IBEAM
#define IDC_HAND
#define IDC_SIZEWE