aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11.c
AgeCommit message (Collapse)AuthorFilesLines
2023-01-02X11: Factor out getCurrentConfigurationDavid Robillard1-11/+18
2023-01-02Factor out common realize checks and initializationDavid Robillard1-14/+4
2023-01-02Fix PUGL_NUM_CURSORSDavid Robillard1-3/+1
2022-12-27Fix inconsistent initial window positioning across platformsDavid Robillard1-1/+1
2022-12-27Set transient parent when views are realized if necessaryDavid Robillard1-1/+1
2022-12-27Fail to set transient parent of views with a parent windowDavid Robillard1-0/+4
2022-12-24Fix weird/inconsistent control flow in puglSetSize()David Robillard1-3/+2
I'm not really sure about directly updating the frame like this - or whether these fields should even exist in the first place (it's questionable whether the view is "really" the new size until the configure process is complete) - but regardless, the same pattern should probably be used for both size and position. "Probably", because touching anything like this tends to break some situation or another somewhere, but such is life.
2022-12-24Add diagonal cursorsfalkTX1-2/+4
2022-10-07Use uppercase integer literal suffixesDavid Robillard1-10/+10
2022-07-16Fix missing field initializers when building as C++falkTX1-3/+3
2022-06-17Call XrmInitialize()David Robillard1-0/+1
This must be called before any other Xrm functions are used.
2022-06-08Use consistent terminology for native viewsDavid Robillard1-1/+1
On MacOS in particular, views and windows are entirely different concepts, so confusing them... confuses things. This was the last holdover in the API that used the old "native window".
2022-06-08Separate platform.h from internal.hDavid Robillard1-0/+1
This makes the internal header structure match the "kinds" of definition inside Pugl: common implementations of public API, things available internally to platform implementations, and things the platform must define.
2022-06-08Separate private and public function implementationsDavid Robillard1-1/+1
2022-06-08Fix potential null pointer dereferenceDavid Robillard1-5/+5
According to clang-tidy anyway, I'm not seeing it.
2022-06-07Remove unnecessary forward-compatibility codeDavid Robillard1-4/+0
2022-06-07X11: Simplify dispatchX11Events()David Robillard1-31/+44
2022-06-07X11: Flush before returning from puglRealize()David Robillard1-0/+8
This avoids bugs in plugins, because otherwise it's possible that size hints are not available when the host embeds the UI.
2022-06-03X11: Fix crash when input context is unavailable due to localesPace Willisson1-11/+17
Calling X*ICFocus on NULL segfaults. This can happen if XCreateIC failed, for example due to missing locales on minimal Docker images.
2022-05-28Omit cursor_names if XCursor is not availableDavid Robillard1-0/+2
This avoids a Wunused-const-variable warning with GCC.
2022-05-23Add rich clipboard supportDavid Robillard1-84/+286
This implements a more powerful protocol for working with clipboards, which supports datatype negotiation, and fixes various issues by mapping more directly to how things work on X11.
2022-05-21Add puglGetScaleFactor()David Robillard1-1/+36
2022-05-21Add puglSetPosition() and puglSetSize()David Robillard1-5/+48
These are redundant with puglSetFrame in a sense, but allow setting the size of a view without the position, or vice-versa. This API also maps more nicely to Wayland, where applications can not position themselves (but can resize).
2022-05-21Use consistent integer types for view positions and sizesDavid Robillard1-25/+25
Actual window sizes and positions fit easily in a 16-bit integer. So, we use that in "representation contexts" like events. This makes structures smaller, and allows the values to be converted to float, double, or integer without casting (since any int16_t or uint16_t value can fit in them without loss). Setter APIs use native integers for convenience, to avoid casting hassles when doing arithmetic. Ranges are checked at runtime.
2022-05-21Add a uniform API for setting size hintsDavid Robillard1-49/+42
This collapses many functions into one, which makes the API more easily extensible and reduces code size.
2022-05-21X11: Remove redundant display memberDavid Robillard1-33/+38
2022-05-21Rename PUGL_UNSUPPORTED_TYPE to be more genericDavid Robillard1-1/+1
2022-05-21X11: Use cursor themesDavid Robillard1-26/+41
This changes to getting cursors by name from the cursor theme, which makes the cursor match the ones used in modern desktop environments. As far as I can tell, there is no real standard for names, these ones seem to work for me in GNOME, KDE, and Xfce. I am not sure about the compatibility concerns here, but X11 without Xcursor themes strikes me as either too esoteric or too ancient to worry about, especially since cursor switching isn't critical functionality anyway.
2022-05-21Avoid setting cursor on realizationDavid Robillard1-4/+0
This avoids issues when the default X11 cursor isn't the expected "default" of the environment, for example with Plasma. A real application that changes the cursor needs to do so consistently on mouse enter and leave events anyway.
2022-04-23Fix IWYU warningsDavid Robillard1-1/+0
I suspect that using the same configuration across both C and C++ is starting to wear a bit thin, but this will do for now.
2022-04-23Move reserved platform defines from code to build systemDavid Robillard1-4/+0
Numerous things warn about this, and it's generally a bad idea to put these in the code since it can result in incompatibly compiled code being linked together. Unfortunately this makes building manually (without the build system) more fiddly, but such is life.
2022-04-21Improve error handlingDavid Robillard1-38/+55
2021-12-17Reduce variable scopeDavid Robillard1-2/+2
2021-12-17Adopt REUSE machine-readable licensing standardDavid Robillard1-17/+4
See https://reuse.software/ for details.
2021-12-17Make button numbers consistent across platformsDavid Robillard1-1/+8
There's no universal consensus on how buttons are numbered. Left, right, middle as 0, 1, 2 seems to be the most common convention on modern vaguely similar libraries, so I've gone with that. The switch to zero-based indices will obviously break all current client code. Particularly since now is the time to finish any breaking changes before a stable release, I think that is better than only changing the middle and right numbers, which would likely go unnoticed.
2021-12-16Rename puglSetTransientFor to puglSetTransientParentDavid Robillard1-1/+1
2021-12-16X11: Fix potential crash in puglGrabFocus()David Robillard1-1/+10
This is really a mistake in user code, but things shouldn't crash in general. So, this commit fixes the crash and adds some documentation so that developers hopefully don't try to grab focus before it makes sense. The case that was previously a crash will now gracefully fail, that is, the focus will not be (and can not be) grabbed.
2021-08-28X11: Check for XRandR extension before usagefalkTX1-6/+9
It happens in practice that XRandR is enabled in the build but is not available at runtime, particularly with X11 forwarding over SSH. This properly queries the extension first to avoid crashing in such situations.
2021-05-28Fix questionable float equality comparisonDavid Robillard1-3/+3
This avoids a warning, and makes more sense in this situation anyway because negatives are also a bad configuration.
2021-05-27Make code build cleanly as C++David Robillard1-3/+13
2021-05-27Fix missing function sentinelDavid Robillard1-1/+1
2021-05-27Avoid confusing fallthrough structureDavid Robillard1-6/+4
2021-05-25Rename event structs in a more readable styleDavid Robillard1-2/+2
Aside from reading more naturally, this avoids clashes with types that are not events, like PuglEventFlags. This is also more consistent with the C++ bindings, where "EventExpose" would be quite strange, for example. Apologies for the noise. Aliases to the old names will be preserved in the deprecated API like other things for a short while.
2021-05-25X11: Do not override _POSIX_C_SOURCE if already definedfalkTX1-1/+3
2021-05-24Separate stub backends from other backendsDavid Robillard1-0/+20
Stub backends were a dependency of other backends to allow some code reuse. However, that can cause conflicting symbols if multiple backends are linked into the same binary, which should be possible. To avoid this, move the shared code into the platform implementation, and export those symbols so that backends can use them. This adds some semi-public platform-specific API that can only be used by backends included with pugl. They are undocumented, subject to change at any time without a corresponding version change, and may not be used by third parties (for example by custom backends in an application).
2021-05-14Remove redundant conditionalRichard Gill1-5/+1
2021-05-08Send unmap/map events when the view is minimized/restoredDavid Robillard1-8/+92
X11 Window managers set WM_STATE to notify about minimization, often without sending core X visibility events (which seems odd to me, but that's what Gnome does anyway). So, implement this protocol and send map/unmap events to the view, and adjust the Windows implementation to do the same for consistency across all platforms.
2021-05-08X11: Always send an initial configure before mapDavid Robillard1-1/+1
I think the conditional here was because this is typical when the view is embedded, but window manager behaviour is all over the place and this is something we want to always guarantee.
2021-05-08X11: Factor out translateClientMessage()David Robillard1-12/+21
2021-05-06Clean up X11 implementationDavid Robillard1-152/+113