christopheraue / ruby-xlib-objects Goto Github PK
View Code? Open in Web Editor NEWX11 bindings for ruby
License: MIT License
X11 bindings for ruby
License: MIT License
I was trying to query and reposition the pointer but I could not find any implementation in the xlib-objects
gem. Did I miss it?
What I want to do, I achieved using xlib
but I'd prefer to use the cleaner object layer if support exists:
class IntPtr < FFI::Struct
layout :value, :int
end
display = XlibObj::Display.new(':0')
root_window = Xlib.XRootWindow(display.to_native,0)
Xlib.XQueryPointer(display.to_native,
root_window,
IntPtr.new,
IntPtr.new,
mx = IntPtr.new,
my = IntPtr.new,
IntPtr.new,
IntPtr.new,
IntPtr.new)
Xlib.XWarpPointer(display.to_native,
Xlib::None,
root_window,
0, 0,
0, 0,
x, 10)
display.flush
Also, I want to submit a mouse click. I want to implement this Python code in Ruby:
from Xlib.ext.xtest import fake_input
fake_input(display,X.ButtonPress,1, X.CurrentTime, X.NONE, x, 10)
which uses the XTest extension. I don't think you have support for that but I thought I'd ask. I am working around the problem by using xdotool
but I'd prefer to do it directly.
%x(xdotool click 1)
I've spent a few hours today (well, all day really!), first trying to write native Xlib code and then looking for libraries and trying to fix up a FFI binding to libxtst
and libxdo
. However, it's messy and I've fallen back to the above one-liner for the time being.
The gem claims to be compatible with any version of Ruby but is actually only compatible with Ruby >=2.1, due to use of "required keyword arguments":
require "xlib-objects"
SyntaxError: /usr/local/share/gems/gems/xlib-objects-0.7.6/lib/event/selection_notify.rb:12: syntax error, unexpected ','
def initialize(type:, target:, property:)
Hi, Thanks for this great library, It really was a godsend today!
This is just some feedback for you because what I wanted to do ended up being a little obscure. I wanted to set a property on a window in a Gtk application. I tried this:
topw.property('_NET_WM_STRUT').set([0, 0, self.height, 0 ], :CARDINAL)
However that didn't work because topw.property
returns nil
if the property isn't set. I ended up doing the work of XlibObj::WIndow::Property
myself:
XlibObj::Window::Property.new(topw, '_NET_WM_STRUT').set(
[0, 0, self.height, 0 ],
:CARDINAL)
My full code snippet, for the benefit of others,
topw = XlibObj::Window.new(XlibObj::Display.new(':0'), toplevel.window.xid)
XlibObj::Window::Property.new(topw, '_NET_WM_STRUT').set(
[0, 0, self.height, 0 ],
:CARDINAL)
XlibObj::Window::Property.new(topw, '_NET_WM_STRUT_PARTIAL').set(
[0, 0, self.height, 0, 0, 0, 0, 0, x, x+width-1, 0, 0],
:CARDINAL)
That first line gives me a Xlib window object for a Gtk window object. I don't know if there's a cleaner way to achieve that!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.