using pytyle2 without xinerama

31 views
Skip to first unread message

nihil

unread,
Oct 24, 2011, 12:49:53 PM10/24/11
to pytyle
I tried to use pytyle2 in an x2go session an failed.
The same problem should arise in an nx session too.
Both xserver implementations (in reality it is the same code) lack the
xinerama extension completely.
In my opinion this should not keep people from using pytyle2 and
because of this i wrote some code
to circumvent the problems. It is up to you to decide if the code is
good enough to be included or not.
I had to change xinerama_get_screens from connection.py. It looks like
this now:

def xinerama_get_screens():
global conn, setup

ret = []

try:
xinerama = conn(xcb.xinerama.key)
screens = xinerama.QueryScreens().reply().screen_info

for screen in screens:
ret.append({
'x': screen.x_org,
'y': screen.y_org,
'width': screen.width,
'height': screen.height
})
except:
# no xinerama, what a mess
# build a fake xinerama data structure
command = r'xdpyinfo|\grep dimensions'
p = subprocess.Popen(command, shell=True,
stdout=subprocess.PIPE).stdout
# I really have not found an uglier way
d = p.readline().split(' ')[6].split('x')
ret.append({
'x': 0,
'y': 0,
'width': int(d[0]),
'height': int(d[1])
})

# For the RandR extension...
# I'm using nVidia TwinView... need to test this
#randr = conn(xcb.randr.key)
#r_screens = randr.GetScreenResources(setup.roots[0].root).reply()
#for icrt in r_screens.crtcs:
#crt = randr.GetCrtcInfo(icrt, xcb.xcb.CurrentTime).reply()
#crt.x, crt.y, crt.width, crt.height

return ret

Also state.py needs to be changed.
def update_NET_DESKTOP_GEOMETRY(force=False):
global properties, xinerama

old_geom = properties['_NET_DESKTOP_GEOMETRY']
old_xinerama = xinerama

time.sleep(1)

properties['_NET_DESKTOP_GEOMETRY'] =
ptxcb.XROOT.get_desktop_geometry()
xinerama = ptxcb.connection.xinerama_get_screens()

if old_xinerama != xinerama or force:
if not force and len(old_xinerama) == len(xinerama):
for mon in Workspace.iter_all_monitors():
mon.refresh_bounds(
# where does mid come from?
# mid = monitor id?
#xinerama[mid]['x'],
#xinerama[mid]['y'],
#xinerama[mid]['width'],
#xinerama[mid]['height']
xinerama[0]['x'],
xinerama[0]['y'],
xinerama[0]['width'],
xinerama[0]['height']
)
mon.calculate_workarea()
else:
for mon in Workspace.iter_all_monitors():
for tiler in mon.tilers:
tiler.destroy()

for wid in Window.WINDOWS.keys():
Window.remove(wid)

for wsid in Workspace.WORKSPACES.keys():
Monitor.remove(wsid)
Workspace.remove(wsid)

reset_properties()
load_properties()


I admit that I do not understand what the changed lines do at all.
mid is not an global variable nor is it locally defined. Where does it
come from?
Best regards.











Reply all
Reply to author
Forward
0 new messages