mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Cleanup
Don't advertise native functions in public API guides. Don't list primary selection access as most notable new feature. Don't have different levels of abstraction among selection helper functions. Don't forget to take credit. Related to #1056.
This commit is contained in:
parent
29a75ab09d
commit
b7a0f225ea
@ -124,9 +124,6 @@ information on what to include when reporting a bug.
|
||||
|
||||
## Changelog
|
||||
|
||||
- Added `glfwSetX11SelectionString` and `glfwGetX11SelectionString`
|
||||
native functions for accessing X11 primary selection as a supplement to
|
||||
the clipboard on the X11 platform (#894)
|
||||
- Added `glfwGetError` function for querying the last error code and its
|
||||
description (#970)
|
||||
- Added `glfwUpdateGamepadMappings` function for importing gamepad mappings in
|
||||
@ -149,6 +146,8 @@ information on what to include when reporting a bug.
|
||||
- Added `glfwGetJoystickHats` function for querying joystick hats
|
||||
(#889,#906,#934)
|
||||
- Added `glfwInitHint` and `glfwInitHintString` for setting initialization hints
|
||||
- Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString`
|
||||
functions for accessing X11 primary selection (#894,#1056)
|
||||
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
|
||||
- Added definition of `GLAPIENTRY` to public header
|
||||
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
|
||||
@ -333,6 +332,7 @@ skills.
|
||||
- Jon Morton
|
||||
- Pierre Moulon
|
||||
- Julian Møller
|
||||
- Kristian Nielsen
|
||||
- Kamil Nowakowski
|
||||
- Ozzy
|
||||
- Andri Pálsson
|
||||
|
@ -5,15 +5,6 @@
|
||||
@section news_33 Release notes for 3.3
|
||||
|
||||
|
||||
@subsection news_33_native_x11_selection X11 native Primary Selection access
|
||||
|
||||
GLFW now supports X11 platform specific native functions for accessing
|
||||
the X11 primary selection, as a supplement to the clipboard on this
|
||||
platform. See @ref clipboard.
|
||||
|
||||
@see @ref error_handling
|
||||
|
||||
|
||||
@subsection news_33_geterror Error query
|
||||
|
||||
GLFW now supports querying the last error code for the calling thread and its
|
||||
@ -127,6 +118,13 @@ creation API, intended for automated testing. This backend does not provide
|
||||
input.
|
||||
|
||||
|
||||
@subsection news_33_primary X11 primary selection access
|
||||
|
||||
GLFW now supports querying and setting the X11 primary selection via the native
|
||||
access functions @ref glfwGetX11SelectionString and @ref
|
||||
glfwSetX11SelectionString.
|
||||
|
||||
|
||||
@section news_32 Release notes for 3.2
|
||||
|
||||
|
||||
|
@ -671,12 +671,16 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
||||
{
|
||||
int i;
|
||||
char* selectionString = NULL;
|
||||
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||
_glfw.x11.COMPOUND_STRING,
|
||||
XA_STRING };
|
||||
const int formatCount = sizeof(formats) / sizeof(formats[0]);
|
||||
char *selectionString = request->selection == _glfw.x11.PRIMARY ?
|
||||
_glfw.x11.primarySelectionString : _glfw.x11.clipboardString;
|
||||
|
||||
if (request->selection == _glfw.x11.PRIMARY)
|
||||
selectionString = _glfw.x11.primarySelectionString;
|
||||
else
|
||||
selectionString = _glfw.x11.clipboardString;
|
||||
|
||||
if (request->property == None)
|
||||
{
|
||||
@ -803,13 +807,12 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
||||
|
||||
static void handleSelectionClear(XEvent* event)
|
||||
{
|
||||
const XSelectionClearEvent* request = &event->xselectionclear;
|
||||
if (request->selection == _glfw.x11.PRIMARY)
|
||||
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
||||
{
|
||||
free(_glfw.x11.primarySelectionString);
|
||||
_glfw.x11.primarySelectionString = NULL;
|
||||
}
|
||||
else if (request->selection == _glfw.x11.CLIPBOARD)
|
||||
else
|
||||
{
|
||||
free(_glfw.x11.clipboardString);
|
||||
_glfw.x11.clipboardString = NULL;
|
||||
@ -834,24 +837,30 @@ static void handleSelectionRequest(XEvent* event)
|
||||
XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
|
||||
}
|
||||
|
||||
static const char *getSelection(Atom selection, char **ptr)
|
||||
static const char* getSelectionString(Atom selection)
|
||||
{
|
||||
size_t i;
|
||||
char** selectionString = NULL;
|
||||
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||
_glfw.x11.COMPOUND_STRING,
|
||||
XA_STRING };
|
||||
const size_t formatCount = sizeof(formats) / sizeof(formats[0]);
|
||||
|
||||
if (selection == _glfw.x11.PRIMARY)
|
||||
selectionString = &_glfw.x11.primarySelectionString;
|
||||
else
|
||||
selectionString = &_glfw.x11.clipboardString;
|
||||
|
||||
if (XGetSelectionOwner(_glfw.x11.display, selection) ==
|
||||
_glfw.x11.helperWindowHandle)
|
||||
{
|
||||
// Instead of doing a large number of X round-trips just to put this
|
||||
// string into a window property and then read it back, just return it
|
||||
return *ptr;
|
||||
return *selectionString;
|
||||
}
|
||||
|
||||
free(*ptr);
|
||||
*ptr = NULL;
|
||||
free(*selectionString);
|
||||
*selectionString = NULL;
|
||||
|
||||
for (i = 0; i < formatCount; i++)
|
||||
{
|
||||
@ -881,7 +890,7 @@ static const char *getSelection(Atom selection, char **ptr)
|
||||
event.xselection.target,
|
||||
(unsigned char**) &data))
|
||||
{
|
||||
*ptr = strdup(data);
|
||||
*selectionString = strdup(data);
|
||||
}
|
||||
|
||||
if (data)
|
||||
@ -891,17 +900,17 @@ static const char *getSelection(Atom selection, char **ptr)
|
||||
event.xselection.requestor,
|
||||
event.xselection.property);
|
||||
|
||||
if (*ptr)
|
||||
if (*selectionString)
|
||||
break;
|
||||
}
|
||||
|
||||
if (*ptr == NULL)
|
||||
if (!*selectionString)
|
||||
{
|
||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
||||
"X11: Failed to convert clipboard to string");
|
||||
}
|
||||
|
||||
return *ptr;
|
||||
return *selectionString;
|
||||
}
|
||||
|
||||
// Make the specified window and its video mode active on its monitor
|
||||
@ -2653,7 +2662,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
||||
|
||||
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||
{
|
||||
return getSelection(_glfw.x11.CLIPBOARD, &_glfw.x11.clipboardString);
|
||||
return getSelectionString(_glfw.x11.CLIPBOARD);
|
||||
}
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
@ -2846,5 +2855,6 @@ GLFWAPI void glfwSetX11SelectionString(const char* string)
|
||||
GLFWAPI const char* glfwGetX11SelectionString(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return getSelection(_glfw.x11.PRIMARY, &_glfw.x11.primarySelectionString);
|
||||
return getSelectionString(_glfw.x11.PRIMARY);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user