aboutsummaryrefslogtreecommitdiffstats
path: root/src/win.c
AgeCommit message (Collapse)AuthorFilesLines
2025-01-31Windows: Improve clipboard reliabilityDavid Robillard1-2/+15
2025-01-31Windows: Actually use impl variablesDavid Robillard1-14/+13
2025-01-31Windows: Ignore return value of SetForegroundWindowDavid Robillard1-1/+1
It turns out that this is flaky for reasons that aren't terribly clear from the documentation. So, just ignore it, it's not the end of the world if raising doesn't happen anyway.
2025-01-31Windows: Improve error handlingDavid Robillard1-46/+30
2025-01-31Windows: Simplify message pollingDavid Robillard1-21/+6
The internal puglPollWinEvents() abstraction was doing more harm than good.
2025-01-31Windows: Avoid using a floating point loop counterDavid Robillard1-1/+3
2025-01-23Replace puglPostRedisplayRect() with puglObscureRegion()David Robillard1-5/+15
2025-01-23Rename puglPostRedisplay() to puglObscureView()David Robillard1-2/+2
For consistency with event types (since "obscure" is opposite "expose") and the upcoming puglObscureRegion().
2025-01-22Simplify initial position code and place children at the originDavid Robillard1-42/+19
The code to find the initial size and position for a view had a lot of duplication, and was inconsistent between platforms. Flaky positioning and attempting to center embedded children has historically caused a bunch of problems in general, particularly since windows can be resized. So, factor out all the initial size and position code so that the logic is in one centralized place used by all platforms, and always position embedded children within their parent at the top/left origin. For top-level windows, the view is centered on its transient parent or the screen (as before). A new platform function puglGetAncestorCenter() is used to do this in general code. Also towards a total separation of position and size, towards support for Wayland, where applications don't dictate their own positions.
2025-01-22Factor out puglIsValidSize()David Robillard1-1/+1
2025-01-22Factor out puglIsValidPosition()David Robillard1-2/+2
2025-01-22Rename PuglViewSize to PuglAreaDavid Robillard1-5/+5
2025-01-22Make puglSetSizeHint() consistent with puglSetSize()David Robillard1-9/+3
In general, it's more convenient to have full-width integers as parameters, since C will promote any arithmetic on smaller types to them anyway. Using narrow types here, then, doesn't really make anything stricter, just forces an annoying cast when lots of warnings are enabled, which is likely unchecked. Better to handle it here, since it's more convenient, and the integer range checks the compiler can do aren't correct anyway (the max width/height is intentionally smaller than the max PuglSpan, so it can fit in a signed 16-bit integer).
2025-01-22Windows: Avoid waiting less than a millisecondDavid Robillard1-2/+4
There is API to access the minimum timer resolution, but it seems to always be 1 millisecond, which is also the unit of the MsgWaitForMultipleObjects parameter, so just avoid the fuss and hardcode this as the minimum. This should slightly reduce overhead when the main loop is running without much of a margin until the frame needs to be drawn.
2025-01-21Support building for Windows with or without UNICODEDavid Robillard1-40/+63
2025-01-21Add PUGL_KEY_NONEDavid Robillard1-3/+3
This isn't a strict enumeration anyway, so a sentinel value does no harm, and using it avoids warnings about testing an enum with no zero value.
2025-01-21Fix whitespaceDavid Robillard1-4/+1
2025-01-21Fix warnings in clang build on WindowsDavid Robillard1-12/+15
2024-07-12Windows: Support building with UNICODEDavid Robillard1-18/+35
2023-11-11Add support for Num, Scroll, and Caps LockDavid Robillard1-5/+9
2023-10-21Filter out corresponding modifiers from key eventsDavid Robillard1-1/+2
Platforms differ here, but it's meaningless to ask about the state of a modifier that's currently being pressed or released, so simply mask this out in general so it's easy for platform implementations to clean events up before dispatching them.
2023-10-21Windows: Fix left and right key distinctionDavid Robillard1-6/+6
2023-05-29Add support for numeric keypad and simplify keyboard handlingDavid Robillard1-37/+49
2023-05-29Deprecate redundant key symbolsDavid Robillard1-5/+5
2023-05-12Factor out return code to status conversionDavid Robillard1-32/+30
2023-05-12Factor out puglIsValidSize() and use consistent rules everywhereDavid Robillard1-3/+3
2023-05-12Windows: Pass the struct from BeginPaint() to EndPaint()David Robillard1-4/+2
The documentation explains that the PAINTSTRUCT returned by BeginPaint() should be passed to the corresponding call to EndPaint(). I'm not sure what real-world effects not doing this had, but this commit fixes things to use the API as intended.
2023-05-12Remove redundant castsDavid Robillard1-3/+3
2023-05-03Add missing field initializerDavid Robillard1-1/+1
2023-05-03Avoid double equality comparisonDavid Robillard1-2/+2
2023-05-03Fix mismatched types in ternary expressionsDavid Robillard1-11/+12
2023-05-03Fix implicit sign conversionsDavid Robillard1-2/+2
2023-01-14Windows: Fix potentially insecure library loadingDavid Robillard1-2/+4
2023-01-14Windows: Add PUGL_DARK_FRAME hintDavid Robillard1-0/+20
This allows dark applications to visually integrate more nicely in Windows 10. A little thing, but it really goes a long way to make programs not look out of place and half-baked.
2023-01-14Add general string hint interfaceDavid Robillard1-15/+19
This replaces the window title and class name APIs with a more general one that can be easily extended to other things, like icon names, more detailed application hints, and so on.
2023-01-11Clean up puglRealize() implementationsDavid Robillard1-7/+3
2023-01-11Remove cached frame from viewDavid Robillard1-58/+91
This was just a source of ambiguity and bugs, since it represented different things at different times and could become stale. Redundant data is always trouble, so eliminate it, leaving just two positions/sizes: the defaults (used when the view is not yet realized), and the last configuration.
2023-01-11Fix checks for invalid view positionsDavid Robillard1-1/+1
2023-01-11Center windows on their transient parent where possibleDavid Robillard1-10/+18
This is only really relevant in practice on MacOS and Windows. On X11, the window manager places new windows where it pleases.
2023-01-10Add PUGL_CURSOR_ALL_SCROLLDavid Robillard1-0/+1
2023-01-10Windows: Make puglGetScaleFactor always return a reasonable valueDavid Robillard1-4/+24
This guesses the likely scale factor when the view hasn't been realized (and so there's no real window to get information for). It may still be wrong for multiple display systems, but will always return some scale factor that "exists" on the system, and should always be correct when there's only one display.
2023-01-08Use ensureHint pattern everywhereDavid Robillard1-12/+4
2023-01-08Add support for raising windowsDavid Robillard1-3/+15
2023-01-07Replace map/unmap events with more expressive configure eventsDavid Robillard1-6/+4
2023-01-07Add support for special view types and stylesDavid Robillard1-23/+109
2023-01-07Support closing views by sending a close eventDavid Robillard1-0/+5
2023-01-07Rename create/destroy events to realize/unrealizeDavid Robillard1-18/+17
As evidence that this was confusing, the documentation for these was an outright lie, and I've burned quite a bit of time in the past few days trying to rework things based around that flawed understanding. These names make it clear what these events actually are. If we need actual create/destroy events with a broader scope, they'll have to be added, but I suspect those aren't actually useful anyway.
2023-01-04Add puglUnrealize()David Robillard1-1/+25
2023-01-02Factor out common realize checks and initializationDavid Robillard1-16/+8
2022-12-27Fix inconsistent initial window positioning across platformsDavid Robillard1-4/+8