Reputation: 1299
It can be done with this code in python:
topw = window.get_toplevel().window
topw.property_change("_NET_WM_STRUT","CARDINAL",32,gtk.gdk.PROP_MODE_REPLACE, [0, 0, bar_size, 0])
topw.property_change("_NET_WM_STRUT_PARTIAL","CARDINAL",32,gtk.gdk.PROP_MODE_REPLACE, [0, 0, bar_size, 0, 0, 0, 0, 0, x, x+width, 0, 0])
But is there property_change
binding in GJS?
Upvotes: 2
Views: 744
Reputation: 9953
Here is how to do it in Gtk3:
display = Display()
topw = display.create_resource_object('window',
window.get_toplevel().get_window().get_xid())
topw.change_property(display.intern_atom('_NET_WM_STRUT'),
display.intern_atom('CARDINAL'), 32,
[0, 0, bar_size, 0 ],
X.PropModeReplace)
topw.change_property(display.intern_atom('_NET_WM_STRUT_PARTIAL'),
display.intern_atom('CARDINAL'), 32,
[0, 0, bar_size, 0, 0, 0, 0, 0, x, x+width-1, 0, 0],
X.PropModeReplace)
You need the following imports:
import gi
gi.require_version('Gtk','3.0')
from gi.repository import Gtk, Gdk
import Xlib
from Xlib.display import Display
from Xlib import X
I confirmed via the mailing list that, as @ptomato stated, the function is non-introspectable which means that it isn't available in introspected bindings such as Python.
Additional Information
You can do this in Ruby (either gtk2 or gtk3 bindings). You need to require 'xlib-objects'
and then, from an instance of (a subclass of) Gtk::Window
:
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)
Alternatively you can use xprop
to do it via system
subshell:
xid = toplevel.window.xid
system %Q{xprop -id #{xid} -format _NET_WM_STRUT 32c \
-set _NET_WM_STRUT \
"0, 0, #{self.height}, 0"}
system %Q{xprop -id #{xid} -format _NET_WM_STRUT_PARTIAL 32c \
-set _NET_WM_STRUT_PARTIAL \
"0, 0, #{self.height}, 0, 0, 0, 0, 0, #{x}, #{x+width-1}, 0, 0"}
Finally, to do it from the command-line:
$ xprop -id 44040195 -format _NET_WM_STRUT_PARTIAL 32c -set _NET_WM_STRUT_PARTIAL "0, 0, 15, 0, 0, 0, 0, 0, 1600, 3519, 0, 0"
(where -id 44040195
specifies the window it; omit to select window with mouse)
To view the settings from the command-line:
$ xprop _NET_WM_STRUT_PARTIAL _NET_WM_STRUT
Upvotes: 3
Reputation: 57890
Alas, gdk_property_change()
is marked non-introspectable so there is no binding in GJS, PyGObject, etc.
As you show, PyGTK did support it, but that's old and you can't use GTK 3 with it.
Upvotes: 1