Bugfixes and improvements
This commit is contained in:
parent
f9c2f8f543
commit
8c2d752780
@ -6,6 +6,11 @@ use NoccyLabs\X11\WindowSelector;
|
|||||||
|
|
||||||
$selector = new WindowSelector();
|
$selector = new WindowSelector();
|
||||||
|
|
||||||
|
// Select window
|
||||||
printf("Click a window to select it...\n");
|
printf("Click a window to select it...\n");
|
||||||
$window = $selector->select();
|
$window = $selector->select();
|
||||||
$window->dump();
|
$window->dump();
|
||||||
|
|
||||||
|
// Grow the window by 10 pixels
|
||||||
|
$size = $window->getWindowSize();
|
||||||
|
$window->setWindowSize($size->width + 10, $size->height + 10);
|
@ -86,12 +86,34 @@ class Window
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWindowSize()
|
||||||
|
{
|
||||||
|
exec("xdotool getwindowgeometry {$this->windowId}", $output, $status);
|
||||||
|
$str = join("\n",$output);
|
||||||
|
|
||||||
|
if (preg_match('/Geometry: ([0-9]+?)x([0-9]+?)$/i', $str, $match)) {
|
||||||
|
return (object)[
|
||||||
|
'width' => intval($match[1]),
|
||||||
|
'height' => intval($match[2])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setWindowSize($width, $height)
|
||||||
|
{
|
||||||
|
exec("xdotool windowsize {$this->windowId} {$width} {$height}");
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function dump()
|
public function dump()
|
||||||
{
|
{
|
||||||
printf("Window: (id=0x%08x)\n Title: %s\n Visible: %s\n",
|
$size = $this->getWindowSize();
|
||||||
|
printf("Window: (id=0x%08x)\n Title: %s\n Visible: %s\n Size: %dx%d\n",
|
||||||
$this->windowId,
|
$this->windowId,
|
||||||
$this->windowTitle,
|
$this->windowTitle,
|
||||||
$this->isVisible?'true':'false'
|
$this->isVisible?'true':'false',
|
||||||
|
$size->width, $size->height
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user