mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 06:04:34 +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
|
## 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
|
- Added `glfwGetError` function for querying the last error code and its
|
||||||
description (#970)
|
description (#970)
|
||||||
- Added `glfwUpdateGamepadMappings` function for importing gamepad mappings in
|
- 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
|
- Added `glfwGetJoystickHats` function for querying joystick hats
|
||||||
(#889,#906,#934)
|
(#889,#906,#934)
|
||||||
- Added `glfwInitHint` and `glfwInitHintString` for setting initialization hints
|
- 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 headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
|
||||||
- Added definition of `GLAPIENTRY` to public header
|
- Added definition of `GLAPIENTRY` to public header
|
||||||
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
|
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
|
||||||
@ -333,6 +332,7 @@ skills.
|
|||||||
- Jon Morton
|
- Jon Morton
|
||||||
- Pierre Moulon
|
- Pierre Moulon
|
||||||
- Julian Møller
|
- Julian Møller
|
||||||
|
- Kristian Nielsen
|
||||||
- Kamil Nowakowski
|
- Kamil Nowakowski
|
||||||
- Ozzy
|
- Ozzy
|
||||||
- Andri Pálsson
|
- Andri Pálsson
|
||||||
|
@ -5,15 +5,6 @@
|
|||||||
@section news_33 Release notes for 3.3
|
@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
|
@subsection news_33_geterror Error query
|
||||||
|
|
||||||
GLFW now supports querying the last error code for the calling thread and its
|
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.
|
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
|
@section news_32 Release notes for 3.2
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,12 +671,16 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
char* selectionString = NULL;
|
||||||
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||||
_glfw.x11.COMPOUND_STRING,
|
_glfw.x11.COMPOUND_STRING,
|
||||||
XA_STRING };
|
XA_STRING };
|
||||||
const int formatCount = sizeof(formats) / sizeof(formats[0]);
|
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)
|
if (request->property == None)
|
||||||
{
|
{
|
||||||
@ -803,13 +807,12 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||||||
|
|
||||||
static void handleSelectionClear(XEvent* event)
|
static void handleSelectionClear(XEvent* event)
|
||||||
{
|
{
|
||||||
const XSelectionClearEvent* request = &event->xselectionclear;
|
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
||||||
if (request->selection == _glfw.x11.PRIMARY)
|
|
||||||
{
|
{
|
||||||
free(_glfw.x11.primarySelectionString);
|
free(_glfw.x11.primarySelectionString);
|
||||||
_glfw.x11.primarySelectionString = NULL;
|
_glfw.x11.primarySelectionString = NULL;
|
||||||
}
|
}
|
||||||
else if (request->selection == _glfw.x11.CLIPBOARD)
|
else
|
||||||
{
|
{
|
||||||
free(_glfw.x11.clipboardString);
|
free(_glfw.x11.clipboardString);
|
||||||
_glfw.x11.clipboardString = NULL;
|
_glfw.x11.clipboardString = NULL;
|
||||||
@ -834,24 +837,30 @@ static void handleSelectionRequest(XEvent* event)
|
|||||||
XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
|
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;
|
size_t i;
|
||||||
|
char** selectionString = NULL;
|
||||||
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
const Atom formats[] = { _glfw.x11.UTF8_STRING,
|
||||||
_glfw.x11.COMPOUND_STRING,
|
_glfw.x11.COMPOUND_STRING,
|
||||||
XA_STRING };
|
XA_STRING };
|
||||||
const size_t formatCount = sizeof(formats) / sizeof(formats[0]);
|
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) ==
|
if (XGetSelectionOwner(_glfw.x11.display, selection) ==
|
||||||
_glfw.x11.helperWindowHandle)
|
_glfw.x11.helperWindowHandle)
|
||||||
{
|
{
|
||||||
// Instead of doing a large number of X round-trips just to put this
|
// 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
|
// string into a window property and then read it back, just return it
|
||||||
return *ptr;
|
return *selectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(*ptr);
|
free(*selectionString);
|
||||||
*ptr = NULL;
|
*selectionString = NULL;
|
||||||
|
|
||||||
for (i = 0; i < formatCount; i++)
|
for (i = 0; i < formatCount; i++)
|
||||||
{
|
{
|
||||||
@ -881,7 +890,7 @@ static const char *getSelection(Atom selection, char **ptr)
|
|||||||
event.xselection.target,
|
event.xselection.target,
|
||||||
(unsigned char**) &data))
|
(unsigned char**) &data))
|
||||||
{
|
{
|
||||||
*ptr = strdup(data);
|
*selectionString = strdup(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
@ -891,17 +900,17 @@ static const char *getSelection(Atom selection, char **ptr)
|
|||||||
event.xselection.requestor,
|
event.xselection.requestor,
|
||||||
event.xselection.property);
|
event.xselection.property);
|
||||||
|
|
||||||
if (*ptr)
|
if (*selectionString)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ptr == NULL)
|
if (!*selectionString)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
||||||
"X11: Failed to convert clipboard to string");
|
"X11: Failed to convert clipboard to string");
|
||||||
}
|
}
|
||||||
|
|
||||||
return *ptr;
|
return *selectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the specified window and its video mode active on its monitor
|
// 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)
|
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return getSelection(_glfw.x11.CLIPBOARD, &_glfw.x11.clipboardString);
|
return getSelectionString(_glfw.x11.CLIPBOARD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||||
@ -2846,5 +2855,6 @@ GLFWAPI void glfwSetX11SelectionString(const char* string)
|
|||||||
GLFWAPI const char* glfwGetX11SelectionString(void)
|
GLFWAPI const char* glfwGetX11SelectionString(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_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