⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 querypointer.c

📁 Nxlib,一个模拟xlib的程序。使用microwindows的库来运行需要xlib支持的程序。
💻 C
字号:
#include "nxlib.h"BoolXQueryPointer(Display * display, Window w, Window *root, Window *child,	int *root_x, int *root_y, int *win_x, int *win_y, unsigned int *mask){	int x, y;	GR_WINDOW_INFO winfo;	*root = GR_ROOT_WINDOW_ID;	/* FIXME: child should be None if not descendant of pointer window*/	GrQueryPointer((GR_WINDOW_ID *) child, root_x, root_y, mask);	/* convert window coords to absolute*/	GrGetWindowInfo(w, &winfo);	x = winfo.x;	y = winfo.y;	while (winfo.parent != 0) {		GrGetWindowInfo(winfo.parent, &winfo);		x += winfo.x;		y += winfo.y;	}	/* return pointer as window relative coords*/	*win_x = *root_x - x;	*win_y = *root_y - y;	return True;}static GR_WINDOW_ID_checkWindowCoords(GR_WINDOW_ID win, int x, int y){	GR_WINDOW_ID cwin;	GR_WINDOW_INFO winfo;	/* Go through each of the children and compare them */	GrGetWindowInfo(win, &winfo);	if (!winfo.child)		return (win);	cwin = winfo.child;	do {		GR_WINDOW_ID ret;		GrGetWindowInfo(cwin, &winfo);		if (x >= winfo.x && x <= winfo.x + winfo.width &&		    y >= winfo.y && y <= winfo.x + winfo.height		    && winfo.mapped) {			ret = _checkWindowCoords(cwin, x - winfo.x,						 y - winfo.y);			if (ret)				return (ret);		}		cwin = winfo.sibling;	} while (cwin);	return win;}BoolXTranslateCoordinates(Display * display, Window src_w, Window dest_w,		      int src_x, int src_y, int *dest_x_return,		      int *dest_y_return, Window * child_return){	int rx = src_x, ry = src_y;	int dx = 0, dy = 0;	GR_WINDOW_ID parent = (GR_WINDOW_ID) src_w;	/* Get the root x and y of the src values */	do {		GR_WINDOW_INFO winfo;		GrGetWindowInfo(parent, &winfo);		rx += winfo.x;		ry += winfo.y;		if (parent == GR_ROOT_WINDOW_ID)			break;		parent = winfo.parent;	} while (1);	/* Now find the destination window absolute coordinates */	parent = (GR_WINDOW_ID) dest_w;	do {		GR_WINDOW_INFO winfo;		GrGetWindowInfo(parent, &winfo);		dx += winfo.x;		dy += winfo.y;		if (parent == GR_ROOT_WINDOW_ID)			break;		parent = winfo.parent;	} while (1);	*dest_x_return = rx - dx;	*dest_y_return = ry - dy;	/* Now, see if this window is actually within any of our children */	*child_return = _checkWindowCoords((GR_WINDOW_ID) dest_w,				*dest_x_return, *dest_y_return);	if (*child_return == dest_w)		*child_return = None;	return True;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -