-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop files from TUI into GUI #21
Comments
"mimic drag and drop behavior of: GUI file-managers, like nautilus" |
Ok, i think i found a solution for linux: |
meh |
I think it's possible without dragon by using xdtools to get the window and pid of proccess and then invoking somehow the events of DND or something? |
So there's something called XDND (X Drag-and-Drop) protocol for x11, I've no idea how it works but I asked chat-GPT for help and it gave me plenty of intresting but unusefull example using the xpybutil module.... |
It also gave me this example (that obviously is completly wrong) that has some interesting elements ... from Xlib import X, display
from Xlib.protocol.event import ClientMessage
from Xlib import Xatom
# Connect to the X server
d = display.Display()
# Get the root window
root = d.screen().root
# Create a window for the drag source
source_window = root.create_window(
100, 100, 100, 100, # x, y, width, height
1, # border width
X.CopyFromParent, # depth
X.InputOutput, # class
X.CopyFromParent, # visual
background_pixel=d.screen().black_pixel
)
# Create a window for the drop target
target_window = root.create_window(
200, 200, 200, 200, # x, y, width, height
1, # border width
X.CopyFromParent, # depth
X.InputOutput, # class
X.CopyFromParent, # visual
background_pixel=d.screen().white_pixel
)
# Map the windows
source_window.map()
target_window.map()
# Simulate the drag and drop action
text_to_send = "Hello, world!" # Modify this line to change the text to be sent
source_data = [
d.intern_atom('XdndSelection'), # selection atom
Xatom.STRING, # target atom
0, # timestamp
source_window.id, # source window
X.CurrentTime # time
]
source_event = ClientMessage(
display=d,
window=target_window.id,
client_type=d.intern_atom('XdndEnter'),
data=(32, source_data) # 32 is the data format
)
source_window.send_event(source_event)
target_data = [
source_window.id, # source window
target_window.id, # target window
X.CurrentTime # time
]
target_event = ClientMessage(
display=d,
window=target_window.id,
client_type=d.intern_atom('XdndDrop'),
data=(32, source_data) # 32 is the data format
)
target_window.send_event(target_event)
# Flush the event queue and wait for events
d.flush()
while True:
event = d.next_event()
if event.type == X.ClientMessage:
message_type = d.get_atom_name(event.client_type)
print(f"Received message of type: {message_type}")
print(event)
# break
# Close the display connection
d.close() PS. use |
(Ok at least there's some progress) I think that something along those steps would work for X11:
|
We need to figure out, how to drop a file from terminal into GUIs (especially browsers) [...]
The text was updated successfully, but these errors were encountered: