Example #1
0
        public void SetTitle(string title)
        {
            byte[] windowTitleASCII = Encoding.ASCII.GetBytes(title);
            LibX11.XChangeProperty(
                display,
                windowId,
                LibX11.XInternAtom(display, "WM_NAME", 0),
                LibX11.XInternAtom(display, "STRING", 0),
                XChangePropertyFormat.Byte,
                XChangePropertyMode.PropModeReplace,
                windowTitleASCII,
                windowTitleASCII.Length
                );

            byte[] windowTitleUTF8 = Encoding.UTF8.GetBytes(title);
            LibX11.XChangeProperty(
                display,
                windowId,
                LibX11.XInternAtom(display, "_NET_WM_NAME", 0),
                LibX11.XInternAtom(display, "UTF8_STRING", 0),
                XChangePropertyFormat.Byte,
                XChangePropertyMode.PropModeReplace,
                windowTitleUTF8,
                windowTitleUTF8.Length
                );
        }
Example #2
0
        private bool ConvertOwnSelection(ulong requestor, ulong selection, ulong targetType, ulong targetProperty)
        {
            if (selection != XA_CLIPBOARD)
            {
                return(false);
            }

            string textToConvert;

            lock (selectionConversionLock)
            {
                textToConvert = bufferText;
                if (textToConvert == null)
                {
                    return(false);
                }
            }

            if (targetType == XA_TARGETS)
            {
                ulong[] targets = { XA_TARGETS, XA_UTF8_STRING };

                LibX11.XChangeProperty
                (
                    display,
                    requestor,
                    targetProperty,
                    XA_ATOM,
                    XChangePropertyFormat.Atom,
                    XChangePropertyMode.PropModeReplace,
                    targets,
                    targets.Length
                );

                return(true);
            }

            if (targetType == XA_UTF8_STRING)
            {
                byte[] text = Encoding.UTF8.GetBytes(textToConvert);
                LibX11.XChangeProperty
                (
                    display,
                    requestor,
                    targetProperty,
                    XA_UTF8_STRING,
                    XChangePropertyFormat.Byte,
                    XChangePropertyMode.PropModeReplace,
                    text,
                    text.Length
                );

                return(true);
            }

            return(false);
        }