aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11.c
AgeCommit message (Collapse)AuthorFilesLines
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
2021-05-06Add test for copy/pasteDavid Robillard1-5/+4
2021-05-03Fix questionable event castsDavid Robillard1-4/+8
I don't think there is any UB actually happening here, but some of these were casting to a pointer of a larger type, which is problematic. Unfortunately, it makes for quite a bit of tedious verbosity, but I don't see a decent way around that in C99.
2021-01-28Fix size hints on X11David Robillard1-3/+6
2021-01-28Fix puglSetMaxSize() on X11David Robillard1-2/+2
2021-01-25Fix warnings when compiling for X11 as C++David Robillard1-2/+6
2021-01-02Avoid "else" after "return"David Robillard1-3/+5
2021-01-02Simplify clang-format configuration and format all codeDavid Robillard1-974/+1009
2020-11-26Remove file documentationDavid Robillard1-5/+0
These will not be used in the Sphinx documentation, and most were self-explanatory and only there to make the Doxygen index look nice anyway. Where there was actually useful information, it has been preserved as regular comments.
2020-11-25Rename puglShowWindow and puglHideWindow to puglShow an puglHideDavid Robillard1-2/+2
These names were confusing because a view is not necessarily a window. Since there's no room for ambiguity here, simply drop the superfluous word.
2020-11-22X11: Fix position of child windows and clean up window creation codeDavid Robillard1-50/+68
This fixes an issue where the default frame position would be set based on the screen size for child windows. This went unnoticed so far because most plugins, like pugl_embed_demo, explicitly set the frame and so avoided this code path. Also generally tidy up puglRealize() along the way to make it a bit more readable.
2020-11-10Fix asan errors on X11David Robillard1-12/+10
Fun with union punning. The different sizes mean that stuff on the stack could be copied to the destination event. I don't think this would cause a concrete issue (the contents of the event past the expose are irrelevant) but asan quite reasonably has a problem with it.
2020-10-30Remove logging APIDavid Robillard1-9/+5
This was missing from the C++ bindings and barely used anyway, so just remove it for now in the interests of simplicity and finalizing a stable API. The information previously logged in the X11 GL backend is now available programatically, so applications can print the same information portably if they like.
2020-10-30Move implementation source files to a conventional src directoryDavid Robillard1-0/+1349
I think this attempt to be optionally header-only was misguided, particularly installing source code to the system include path. Typically anyone vendoring code just includes the repository and builds from there anyway. This commit moves all the implementation code to a typical src directory (Don't Be Weird). I still think there is some value in simple "inline" deployment, but that would be better achieved another way, like producing a single-file amalgamation that builds anywhere, ala sqlite.