![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
System clipboard: full X11 selection support on Linux, Win32 clipboard on Windows/MinGW. More...
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | N_CLIPBOARD_CLIPBOARD 0 |
| the Ctrl+C / Ctrl+V clipboard selection | |
| #define | N_CLIPBOARD_PRIMARY 1 |
| the X11 PRIMARY selection (mouse select-to-copy / middle-click paste); a no-op on Windows, which has no PRIMARY selection | |
Functions | |
| int | n_clipboard_available (void) |
| Whether a real clipboard backend (X11 or Win32) is active on this platform. | |
| void | n_clipboard_destroy (void) |
| Stop the backend thread and release the display connection. | |
| char * | n_clipboard_get (int which) |
Fetch the current text of which selection from its owner. | |
| int | n_clipboard_init (void) |
| Start the clipboard backend (idempotent; also started lazily on first use). | |
| int | n_clipboard_set (int which, const char *text) |
Own which selection and serve text to any app that requests it. | |
System clipboard: full X11 selection support on Linux, Win32 clipboard on Windows/MinGW.
On Linux/X11 a small backend owns the X11 CLIPBOARD and PRIMARY selections itself and answers SelectionRequest with the full target set (UTF8_STRING, STRING, TEXT, text/plain, text/plain;charset=utf-8, and TARGETS), so strict consumers such as Chromium (which query TARGETS and want text/plain;charset= utf-8) can paste text this process copies - which a UTF8_STRING-only backend fails to satisfy. It also exposes the X11 PRIMARY selection (select-to-copy / middle-click paste) that the ordinary clipboard API cannot reach. A background thread on a dedicated X display connection serves requests promptly even while the GUI is idle.
On Windows (MinGW) N_CLIPBOARD_CLIPBOARD maps to the Win32 system clipboard (CF_UNICODETEXT, UTF-8 <-> UTF-16 internally); Windows has no PRIMARY selection, so N_CLIPBOARD_PRIMARY is a graceful no-op there (set does nothing, get returns NULL). Text always crosses this API as UTF-8.
On any other platform the backend is unavailable (n_clipboard_available() returns 0) and the caller should fall back to its toolkit's own clipboard.
Definition in file n_clipboard.h.
| #define N_CLIPBOARD_CLIPBOARD 0 |
the Ctrl+C / Ctrl+V clipboard selection
Definition at line 56 of file n_clipboard.h.
| #define N_CLIPBOARD_PRIMARY 1 |
the X11 PRIMARY selection (mouse select-to-copy / middle-click paste); a no-op on Windows, which has no PRIMARY selection
Definition at line 59 of file n_clipboard.h.
| int n_clipboard_available | ( | void | ) |
Whether a real clipboard backend (X11 or Win32) is active on this platform.
Definition at line 436 of file n_clipboard.c.
Referenced by _ngui_clip_get(), _ngui_clip_set(), _ngui_publish_primary_selection(), main(), and main().
Here is the caller graph for this function:| void n_clipboard_destroy | ( | void | ) |
Stop the backend thread and release the display connection.
Definition at line 448 of file n_clipboard.c.
Referenced by main(), and n_gui_destroy_ctx().
Here is the caller graph for this function:| char * n_clipboard_get | ( | int | which | ) |
Fetch the current text of which selection from its owner.
| which | N_CLIPBOARD_CLIPBOARD or N_CLIPBOARD_PRIMARY. |
Definition at line 444 of file n_clipboard.c.
Referenced by _ngui_clip_get(), main(), and main().
Here is the caller graph for this function:| int n_clipboard_init | ( | void | ) |
Start the clipboard backend (idempotent; also started lazily on first use).
Definition at line 433 of file n_clipboard.c.
Referenced by main().
Here is the caller graph for this function:| int n_clipboard_set | ( | int | which, |
| const char * | text | ||
| ) |
Own which selection and serve text to any app that requests it.
| which | N_CLIPBOARD_CLIPBOARD or N_CLIPBOARD_PRIMARY. |
| text | The UTF-8 text to publish (copied). NULL/empty relinquishes it. |
Definition at line 439 of file n_clipboard.c.
Referenced by _ngui_clip_set(), and main().
Here is the caller graph for this function: