Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-11-10 13:14:27

tehkos
Member
Registered: 2021-07-12
Posts: 10

Emulate ctrl+v (pasting a text) without freezing on xfce.

Hi.
I'm trying to create a script that inserts some text in different editors. I'm using xdotool, but after the text is pasted, the screen freezes for a second. That happens when the default xfce compositor is on.

For example: copy any text and then launch the next code in the terminal:

sleep 4 && xdotool key ctrl+v 

Then quickly start to type something in any editor or erase the text.

With the compositor off, typing is smooth without freezing.

Maybe somebody knows another tool for emulating key pressing that feels more native for pasting (or typing) with the xfce compositor on?

I tried autokey. It works fine. The only thing I don't like is the process that always in the background consuming memory.

Offline

#2 2021-11-10 23:42:40

Misko_2083
Member
Registered: 2015-10-13
Posts: 211
Website

Re: Emulate ctrl+v (pasting a text) without freezing on xfce.

What if you write your own app?
You will need Xlib and XTest extension
In Debian these dev libraries are needed to compile: libx11-dev libxt-dev libxext-dev
Will also need gcc.

Save next as tehkopaste.c and comile in the same folder with:

gcc tehkopaste.c -o tehkopaste -lX11 -lXtst -lXext
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/extensions/XTest.h>

static void SimKey (Display * disp,
                    KeySym keysym,
                    KeySym modsym){
 KeyCode keycode = 0, modcode = 0;
 keycode = XKeysymToKeycode (disp, keysym);
 modcode = XKeysymToKeycode(disp, modsym);
 XTestGrabControl (disp, True);
 XTestFakeKeyEvent (disp, modcode, True, 0);
 XTestFakeKeyEvent (disp, keycode, True, 0);
 XTestFakeKeyEvent (disp, keycode, False, 0); 
 XTestFakeKeyEvent (disp, modcode, False, 0);
 XSync (disp, False);
 XTestGrabControl (disp, False);
}
 
int main (){
 Display *disp = XOpenDisplay (NULL);
 SimKey (disp, XK_V, XK_Control_L);
 XCloseDisplay(disp);
}

When a binary is created up run:

sleep 4 && tehkopaste

And then, if you wish so, drop by to tell us how tehkopasting goes. big_smile

Last edited by Misko_2083 (2021-11-11 00:47:25)


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#3 2021-11-11 02:46:56

KBar
Member
Registered: 2021-11-05
Posts: 689

Re: Emulate ctrl+v (pasting a text) without freezing on xfce.

Misko_2083 wrote:

Save next as tehkopaste.c and comile in the same folder with:

And then, if you wish so, drop by to tell us how tehkopasting goes. big_smile

Cool name but it's got nothing on "ganknkill.c". tongue


Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please! tongue

Offline

#4 2021-11-11 20:43:12

tehkos
Member
Registered: 2021-07-12
Posts: 10

Re: Emulate ctrl+v (pasting a text) without freezing on xfce.

Misko_2083, I tried your solution. It feels the same like xdotool script. I mean when text is pasted and I start to erase it, the screen' freezing. It's not the same when I physically press ctrl+v.

Autokey somehow solved it.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 530.02 KiB (Peak: 530.87 KiB) ]