From: Axel <a99.googlegroups.a99 / dfgh.net>
Subject: TK: Get the "usable" screensize"?
Date: Tue, 2 Feb 2010 03:55:24 +0900
Message-ID: <371e3d52-02e8-4d9a-8b2b-61aa440e3e65 / v25g2000yqk.googlegroups.com>
> how can I get the "usable" screensize in Ruby/TK?
> I mean, the total screensize minus taskbar (on Windows).
> 
> I tried:
> 
>   require 'tk'
>   root = TkRoot.new
>   root.state('zoomed')
>   Tk.update
>   p TkWinfo.x(root)
>   p TkWinfo.y(root)
>   p TkWinfo.width(root)
>   p TkWinfo.height(root)
>   p TkWinfo.geometry(root)
> 
> but this gives me only
>   total_screensize - (taskbar + window_decoration)

Hmmm.... Well, does this work?
-------------------------------------------------------------------------
root = Tk.root
root.state(:zoomed)
Tk.update
root.geometry =~ /(\d+)x(\d+)\+([+-]?\d+)\+([+-]?\d)/
w = $1.to_i
h = $2.to_i
x = $3.to_i
y = $4.to_i
sw = root.winfo_screenwidth
sh = root.winfo_screenheight
rx = root.winfo_rootx
ry = root.winfo_rooty  # maybe, taskbar height
usable_screenwidth  = w + rx * 2  # maybe, x_border * 2
usable_screenheight = h + ry
taskbar_height = sh - usable_screenheight
-------------------------------------------------------------------------
-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)