Xming: Cache atom lookups in clipboard integration code
Cache the CLIPBOARD atom lookups in winClipboardWindowProc() Cache atom lookups in winClipboardFlushXEvents() Recache on server regeneration Copyright (C) Colin Harrison 2005-2008 http://www.straightrunning.com/XmingNotes/ http://sourceforge.net/projects/xming/ Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
This commit is contained in:
parent
4ec110327b
commit
71ba9856a4
|
@ -36,6 +36,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "winclipboard.h"
|
#include "winclipboard.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
extern void winFixClipboardChain();
|
extern void winFixClipboardChain();
|
||||||
|
|
||||||
|
@ -261,6 +262,8 @@ winClipboardWindowProc (HWND hwnd, UINT message,
|
||||||
|
|
||||||
case WM_DRAWCLIPBOARD:
|
case WM_DRAWCLIPBOARD:
|
||||||
{
|
{
|
||||||
|
static Atom atomClipboard;
|
||||||
|
static int generation;
|
||||||
static Bool s_fProcessingDrawClipboard = FALSE;
|
static Bool s_fProcessingDrawClipboard = FALSE;
|
||||||
Display *pDisplay = g_pClipboardDisplay;
|
Display *pDisplay = g_pClipboardDisplay;
|
||||||
Window iWindow = g_iClipboardWindow;
|
Window iWindow = g_iClipboardWindow;
|
||||||
|
@ -268,6 +271,12 @@ winClipboardWindowProc (HWND hwnd, UINT message,
|
||||||
|
|
||||||
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
|
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.
|
* We've occasionally seen a loop in the clipboard chain.
|
||||||
* Try and fix it on the first hint of recursion.
|
* Try and fix it on the first hint of recursion.
|
||||||
|
@ -355,17 +364,13 @@ winClipboardWindowProc (HWND hwnd, UINT message,
|
||||||
|
|
||||||
/* Release CLIPBOARD selection if owned */
|
/* Release CLIPBOARD selection if owned */
|
||||||
iReturn = XGetSelectionOwner (pDisplay,
|
iReturn = XGetSelectionOwner (pDisplay,
|
||||||
XInternAtom (pDisplay,
|
atomClipboard);
|
||||||
"CLIPBOARD",
|
|
||||||
False));
|
|
||||||
if (iReturn == g_iClipboardWindow)
|
if (iReturn == g_iClipboardWindow)
|
||||||
{
|
{
|
||||||
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
||||||
"CLIPBOARD selection is owned by us.\n");
|
"CLIPBOARD selection is owned by us.\n");
|
||||||
XSetSelectionOwner (pDisplay,
|
XSetSelectionOwner (pDisplay,
|
||||||
XInternAtom (pDisplay,
|
atomClipboard,
|
||||||
"CLIPBOARD",
|
|
||||||
False),
|
|
||||||
None,
|
None,
|
||||||
CurrentTime);
|
CurrentTime);
|
||||||
}
|
}
|
||||||
|
@ -399,17 +404,12 @@ winClipboardWindowProc (HWND hwnd, UINT message,
|
||||||
|
|
||||||
/* Reassert ownership of the CLIPBOARD */
|
/* Reassert ownership of the CLIPBOARD */
|
||||||
iReturn = XSetSelectionOwner (pDisplay,
|
iReturn = XSetSelectionOwner (pDisplay,
|
||||||
XInternAtom (pDisplay,
|
atomClipboard,
|
||||||
"CLIPBOARD",
|
|
||||||
False),
|
|
||||||
iWindow,
|
iWindow,
|
||||||
CurrentTime);
|
CurrentTime);
|
||||||
|
|
||||||
if (iReturn == BadAtom || iReturn == BadWindow ||
|
if (iReturn == BadAtom || iReturn == BadWindow ||
|
||||||
XGetSelectionOwner (pDisplay,
|
XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
|
||||||
XInternAtom (pDisplay,
|
|
||||||
"CLIPBOARD",
|
|
||||||
False)) != iWindow)
|
|
||||||
{
|
{
|
||||||
winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
|
||||||
"Could not reassert ownership of CLIPBOARD\n");
|
"Could not reassert ownership of CLIPBOARD\n");
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <xwin-config.h>
|
#include <xwin-config.h>
|
||||||
#endif
|
#endif
|
||||||
#include "winclipboard.h"
|
#include "winclipboard.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -53,18 +54,20 @@ winClipboardFlushXEvents (HWND hwnd,
|
||||||
Display *pDisplay,
|
Display *pDisplay,
|
||||||
Bool fUseUnicode)
|
Bool fUseUnicode)
|
||||||
{
|
{
|
||||||
Atom atomLocalProperty = XInternAtom (pDisplay,
|
static Atom atomLocalProperty;
|
||||||
WIN_LOCAL_PROPERTY,
|
static Atom atomCompoundText;
|
||||||
False);
|
static Atom atomUTF8String;
|
||||||
Atom atomUTF8String = XInternAtom (pDisplay,
|
static Atom atomTargets;
|
||||||
"UTF8_STRING",
|
static int generation;
|
||||||
False);
|
|
||||||
Atom atomCompoundText = XInternAtom (pDisplay,
|
if (generation != serverGeneration)
|
||||||
"COMPOUND_TEXT",
|
{
|
||||||
False);
|
generation = serverGeneration;
|
||||||
Atom atomTargets = XInternAtom (pDisplay,
|
atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
|
||||||
"TARGETS",
|
atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
|
||||||
False);
|
atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
|
||||||
|
atomTargets = XInternAtom (pDisplay, "TARGETS", False);
|
||||||
|
}
|
||||||
|
|
||||||
/* Process all pending events */
|
/* Process all pending events */
|
||||||
while (XPending (pDisplay))
|
while (XPending (pDisplay))
|
||||||
|
|
Loading…
Reference in New Issue