如何在Linux上将光标锁定到窗口的内部? [英] How can I lock the cursor to the inside of a window on Linux?

查看:278
本文介绍了如何在Linux上将光标锁定到窗口的内部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把一个Linux的游戏,涉及到很多快速动作和徘徊的鼠标光标。如果用户想要在窗口模式下播放,我很想锁定光标到窗口的内部,以避免在战斗的热量意外更改程序(显然,如果用户更改程序或命中逃脱暂停菜单。)



在Windows上,使用 ClipCursor()。我在Linux上找不到等效的。是否有一个?



我计划在纯X代码中这样做,但显然如果任何人都知道在任何Linux窗口库中这样做,我可以只读源代码并找出如何在X中复制它。

解决方案


int XGrabPointer (显示* 显示,窗口 grab_window
Bool owner_events ,unsigned int event_mask ,int pointer_mode ,int keyboard_mode ,Window confine_to ,Cursor cursor ,Time time);



confine_to

       指定将指针限制在中的窗口。



I'm trying to put together a game for Linux which involves a lot of fast action and flinging around of the mouse cursor. If the user wants to play in windowed mode, I'd quite like to lock the cursor to the inside of the window to avoid accidentally changing programs in the heat of battle (obviously this will cancel itself if the user changes programs or hits escape for the pause menu.)

On Windows, this can be accomplished easily with ClipCursor(). I can't find an equivalent on Linux. Is there one?

I plan to do this in pure X code, but obviously if anyone knows of a way to do this in any Linux windowing library then I can just read the source code and figure out how to duplicate it in X.

解决方案

int XGrabPointer(Display *display, Window grab_window, Bool owner_events, unsigned int event_mask, int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor, Time time);

confine_to
        Specifies the window to confine the pointer in or None.

这篇关于如何在Linux上将光标锁定到窗口的内部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆