1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-30 05:58:52 -05:00

Cleanup of clipboard and string atoms.

This commit is contained in:
Camilla Berglund 2013-01-29 02:45:08 +01:00
parent 82b8dd5040
commit f3e39ce680
4 changed files with 22 additions and 18 deletions

View File

@ -88,7 +88,7 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
if (property == None)
property = _glfw.x11.selection.property;
if (request->target == _glfw.x11.selection.targets)
if (request->target == _glfw.x11.TARGETS)
{
// The list of supported targets was requested
@ -139,7 +139,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
// Set the specified window as owner of the selection
XSetSelectionOwner(_glfw.x11.display,
_glfw.x11.selection.atom,
_glfw.x11.CLIPBOARD,
window->x11.handle, CurrentTime);
}
@ -155,7 +155,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
_glfw.x11.selection.target = _glfw.x11.selection.formats[i];
XConvertSelection(_glfw.x11.display,
_glfw.x11.selection.atom,
_glfw.x11.CLIPBOARD,
_glfw.x11.selection.target,
_glfw.x11.selection.property,
window->x11.handle, CurrentTime);

View File

@ -518,26 +518,28 @@ static GLboolean initDisplay(void)
// Detect whether an EWMH-conformant window manager is running
detectEWMH();
// Find or create string format atoms
_glfw.x11.UTF8_STRING =
XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
_glfw.x11.COMPOUND_STRING =
XInternAtom(_glfw.x11.display, "COMPOUND_STRING", False);
// Find or create selection property atom
_glfw.x11.selection.property =
XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
// Find or create clipboard atom
_glfw.x11.selection.atom =
XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
// Find or create standard clipboard atoms
_glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
_glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
// Find or create selection target atoms
_glfw.x11.selection.formats[_GLFW_CLIPBOARD_FORMAT_UTF8] =
XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
_glfw.x11.UTF8_STRING;
_glfw.x11.selection.formats[_GLFW_CLIPBOARD_FORMAT_COMPOUND] =
XInternAtom(_glfw.x11.display, "COMPOUND_STRING", False);
_glfw.x11.COMPOUND_STRING;
_glfw.x11.selection.formats[_GLFW_CLIPBOARD_FORMAT_STRING] =
XA_STRING;
_glfw.x11.selection.targets = XInternAtom(_glfw.x11.display,
"TARGETS",
False);
return GL_TRUE;
}

View File

@ -132,6 +132,12 @@ typedef struct _GLFWlibraryX11
Atom NET_WM_STATE_FULLSCREEN;
Atom NET_ACTIVE_WINDOW;
// Selection atoms
Atom TARGETS;
Atom CLIPBOARD;
Atom UTF8_STRING;
Atom COMPOUND_STRING;
// True if window manager supports EWMH
GLboolean hasEWMH;
@ -176,11 +182,9 @@ typedef struct _GLFWlibraryX11
} timer;
struct {
Atom atom;
Atom formats[_GLFW_CLIPBOARD_FORMAT_COUNT];
char* string;
Atom target;
Atom targets;
Atom property;
int status;
} selection;

View File

@ -872,8 +872,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{
Atom type = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
#if defined(X_HAVE_UTF8_STRING)
Xutf8SetWMProperties(_glfw.x11.display,
window->x11.handle,
@ -893,7 +891,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
if (_glfw.x11.NET_WM_NAME != None)
{
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_NAME, type, 8,
_glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
PropModeReplace,
(unsigned char*) title, strlen(title));
}
@ -901,7 +899,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
if (_glfw.x11.NET_WM_ICON_NAME != None)
{
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_ICON_NAME, type, 8,
_glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
PropModeReplace,
(unsigned char*) title, strlen(title));
}