예제 #1
0
        public bool TryGetText(out string text)
        {
            lock (selectionConversionLock)
            {
                selectionConvertedEvent.Reset();

                // todo: review usage of XLib under lock

                LibX11.XConvertSelection
                (
                    display,
                    XA_CLIPBOARD,
                    XA_UTF8_STRING,
                    XA_NWINDOWS_CONVERTED_CLIPBOARD,
                    windowId,
                    0 /* CurrentTime */
                );

                LibX11.XFlush(display);
            }

            if (!selectionConvertedEvent.WaitOne(OperationTimeout))
            {
                text = null;
                return(false);
            }

            lock (selectionConversionLock)
            {
                if (convertedText == null)
                {
                    text = null;
                    return(false);
                }

                text          = convertedText;
                convertedText = null;
                return(true);
            }
        }