summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2009-06-19 21:14:10 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2009-10-15 18:34:08 +0100
commit334a7fa6a7bce3b08c2f5f14a18aa4f2f333fbb8 (patch)
tree73607411e2f5095d73f366746548c090aef6a1b6
parentaff5b5b9262071e581456b8d680415ddff9495ba (diff)
Cache the CLIPBOARD Atom lookups in winClipboardWindowProc() Cache the Atom lookups in winClipboardFlushXEvents()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r--hw/xwin/winclipboardwndproc.c21
-rw-r--r--hw/xwin/winclipboardxevents.c27
2 files changed, 27 insertions, 21 deletions
diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
index 802a74035..e552decdc 100644
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -34,6 +34,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include "winclipboard.h"
+#include "misc.h"
extern void winFixClipboardChain();
@@ -259,6 +260,8 @@ winClipboardWindowProc (HWND hwnd, UINT message,
case WM_DRAWCLIPBOARD:
{
+ static Atom atomClipboard;
+ static int generation;
static Bool s_fProcessingDrawClipboard = FALSE;
Display *pDisplay = g_pClipboardDisplay;
Window iWindow = g_iClipboardWindow;
@@ -266,6 +269,12 @@ winClipboardWindowProc (HWND hwnd, UINT message,
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
+ if (generation != serverGeneration)
+ {
+ generation = serverGeneration;
+ atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
+ }
+
/*
* We've occasionally seen a loop in the clipboard chain.
* Try and fix it on the first hint of recursion.
@@ -353,17 +362,13 @@ winClipboardWindowProc (HWND hwnd, UINT message,
/* Release CLIPBOARD selection if owned */
iReturn = XGetSelectionOwner (pDisplay,
- XInternAtom (pDisplay,
- "CLIPBOARD",
- False));
+ atomClipboard);
if (iReturn == g_iClipboardWindow)
{
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
"CLIPBOARD selection is owned by us.\n");
XSetSelectionOwner (pDisplay,
- XInternAtom (pDisplay,
- "CLIPBOARD",
- False),
+ atomClipboard,
None,
CurrentTime);
}
@@ -396,9 +401,7 @@ winClipboardWindowProc (HWND hwnd, UINT message,
/* Reassert ownership of the CLIPBOARD */
iReturn = XSetSelectionOwner (pDisplay,
- XInternAtom (pDisplay,
- "CLIPBOARD",
- False),
+ atomClipboard,
iWindow,
CurrentTime);
if (iReturn == BadAtom || iReturn == BadWindow)
diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index d4c617bec..194d2834d 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -32,6 +32,7 @@
#include <xwin-config.h>
#endif
#include "winclipboard.h"
+#include "misc.h"
/*
@@ -51,18 +52,20 @@ winClipboardFlushXEvents (HWND hwnd,
Display *pDisplay,
Bool fUseUnicode)
{
- Atom atomLocalProperty = XInternAtom (pDisplay,
- WIN_LOCAL_PROPERTY,
- False);
- Atom atomUTF8String = XInternAtom (pDisplay,
- "UTF8_STRING",
- False);
- Atom atomCompoundText = XInternAtom (pDisplay,
- "COMPOUND_TEXT",
- False);
- Atom atomTargets = XInternAtom (pDisplay,
- "TARGETS",
- False);
+ static Atom atomLocalProperty;
+ static Atom atomCompoundText;
+ static Atom atomUTF8String;
+ static Atom atomTargets;
+ static int generation;
+
+ if (generation != serverGeneration)
+ {
+ generation = serverGeneration;
+ atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
+ atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
+ atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
+ atomTargets = XInternAtom (pDisplay, "TARGETS", False);
+ }
/* Process all pending events */
while (XPending (pDisplay))