XQueryPointer 函数中的 root_x_return 和 root_y_return 代表什么值?
What values do root_x_return and root_y_return in XQueryPointer function represent?
这只是一个虚拟的确认问题,但我真的想确保我通过调用函数 XQueryPointer
收到的值在 X 和 Y 的 像素 中屏幕坐标。
extern Bool XQueryPointer(
Display* /* display */,
Window /* w */,
Window* /* root_return */,
Window* /* child_return */,
int* /* root_x_return */,
int* /* root_y_return */,
int* /* win_x_return */,
int* /* win_y_return */,
unsigned int* /* mask_return */
);
这是因为一旦我使用以下函数获得屏幕的整个分辨率,我将需要执行一些操作,即我将从整个屏幕中过滤掉一些像素,但需要知道 XQueryPointer
也是像素。
xVal = DisplayWidth(display, screen_number);
yVal = DisplayHeight(display, screen_number);
我假设 root_x_return
和 root_y_return
以像素为单位。我说得对吗?
是的。来自 Xlib documentation:
Each window and pixmap has its own coordinate system. The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. For a window, the origin is inside the border at the inside, upper-left corner.
这只是一个虚拟的确认问题,但我真的想确保我通过调用函数 XQueryPointer
收到的值在 X 和 Y 的 像素 中屏幕坐标。
extern Bool XQueryPointer(
Display* /* display */,
Window /* w */,
Window* /* root_return */,
Window* /* child_return */,
int* /* root_x_return */,
int* /* root_y_return */,
int* /* win_x_return */,
int* /* win_y_return */,
unsigned int* /* mask_return */
);
这是因为一旦我使用以下函数获得屏幕的整个分辨率,我将需要执行一些操作,即我将从整个屏幕中过滤掉一些像素,但需要知道 XQueryPointer
也是像素。
xVal = DisplayWidth(display, screen_number);
yVal = DisplayHeight(display, screen_number);
我假设 root_x_return
和 root_y_return
以像素为单位。我说得对吗?
是的。来自 Xlib documentation:
Each window and pixmap has its own coordinate system. The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. For a window, the origin is inside the border at the inside, upper-left corner.