X11 restrict mouse to visible area - mouse

I am currently running Linux Mint 17.2 with Cinnamon. I have 2 monitors.
When I set monitors to be adjacent in Cinnamon settings, mouse freely moves through border shared between monitors but cannot escape visible area.
That is, if I set monitors to share only corner, mouse is effectively locked to current monitor and can escape to another only through corner.
However, setting monitors to be non-adjacent allows mouse to roam freely all over virtual framebuffer, including invisible areas.
I thought that Cinnamon sets some flag that controls this behavior, but changing monitor position using xrandr has the same effect.
Also, it is the same when I start plain Xorg with nothing but xterm, even without a window manager, and configure monitors using xrandr.
What exactly stops mouse from leaving visible area when all monitors are adjacent? Is there a way to override this behavior?
Being able to control this might be useful e.g. to stop mouse from leaving monitor every time you try to click something near border, without running a busy loop that monitors mouse and moves it back if needed (and without doubling framebuffer size by making monitors be adjacent by corner).
With more control it can be used to e.g. make mouse "reluctant" to leave current window, and maybe do other fun stuff. At least it will make it possible to reimplement this thing so that it can actually lock mouse to window for apps like Chrome browser or OpenGL games and not just xterm and the like.
Now that I think of it, I may even try to implement it, if it is not yet and if I find relevant code.

Okay, I have found the relevant code.
This behavior is hardcoded in Xorg X server, in RandR extension, including visible area continuity check.
Definitely nothing configurable. Well, unless you agree with creator of dwm on what the word "configuration" means :)
I do agree. Right now relevant code locations are randr/rrpointer.c and
randr/rrcrtc.c:332,1685.
Would be nice though if someone created a proper X srver extension for that.

As you already figured out: if your monitor areas are non-continuous, it seems that xrandr will allow the entire x11-screen to be used by the pointer. I just purposefully moved the position of one by 1 pixel (option --pos with xrandr) to free the mouse.
Once the mouse can go everywhere, it should be possible to fence it in with pointer barriers:
http://who-t.blogspot.com/2012/12/whats-new-in-xi-23-pointer-barrier.html
That requires the XFixes extention version 5+ and gets enhanced with XInput as described in the link with events and temporary barrier lifts... which is probably not required here.

Related

Remove ui square when many touches

I am coding a game on a Touchscreen with many players at the same time. The issue is, when there are 2 or more touches, a little square is appearing on the screen. It seems to be a unity built-in feature as it is still present in an empty project.
Is there a way to prevent this annoying little square to appear ? I already disabled magic touch shortcuts in windows. And this doesn't appear on the desktop home screen.
I am able to listen to the touches. It seems to be only a visual thing.
Even when I disable multitouch with Input.multiTouchEnabled = false; It still appears.
I also tried to remove the 18 default Axes in the Input Manager.
My goal is to handle every touch separately, without listening to pinch, long press, or scroll interactions. Each player has only to tap somewhere on the screen.
Thanks for you time
Solved it by myself. I completely disabled Touch feedback in the windows parameters. I don't think it is the only way to do that but it works.
Configuration Panel > Pen and Touch
Unmark "Show visual feedback when touching the screen"

How can I set size and location of the app window within a ui-test?

A bit of background: I recently implemented a Drag and Drop Behavior to my app, where I can drag items from e.g. the Finder inside my NSTableView. Now I wanted to write a few ui-tests for this new functionality.
The general idea was to move the finder window to the left side of the screen and my application window to the right side of the screen and then execute the drag and drop. The drag and drop itself is not the problem, the problem is the setup of the mentioned window layout. I cannot find a convenient way to resize and move the two windows. Coming from .net, I expected something like app.window.setSize(..) or app.window.moveTo(...).
What I tried so far:
As I have Magnet installed on my Mac, I tried the easy way out and sent key-events (control + option + arrow) to the window. This did not work, sending the keystrokes results in an error beep. Doing this manually during the tests works, so I don't know what exactly stops Magnet from rearranging the windows, but I guess it has something to do with the Testing Framework. I did not dig deeper into this, as it would have been a cheap solution anyway.
Drag the app window corners based on screen dimensions, e.g. for the window on the left I drag the corners to the top left, bottom left, top middle and bottom middle of the screen. This requires that all four corners are visible on screen, but that's a problem for another day. The solution would normally work, but the problem is that the y-coordinates I get from the frame of my app window are not what I was expecting. I do receive the location of the app window with app.windows.firstMatch.frame.origin. The x-coordinates look alright, but the y-coordinates are totally off (from what I expected).
I can't find many resources regarding the origin or frame members. Any idea on how to face this problem or where to find a documentation about the XCUITest-Framework and the basic concepts behind it? The official documentation doesn't help in this case. I only found this short explanation in the apple documentation archive about the coordinate system of macOS (or OS X back then) applications.

How to tell capslock from tab and shift at blind typing?

I swapped ctrl with caps lock.
Since caps lock is in between tab and shift, it is hard to tell them apart without looking.
Mis-type often happens.
Is there a good solution for this?
I am using laptop.
Doesn't this sound more like a Programmers question than a StackOverflow question?
"Getting used to it" will obviously depend on your hand size and practice, basically. Eventually your mind will just train itself with muscle memory.
Start with your left hand on home row (index on f, pinky on a) then move your hand slightly to the left naturally. Arch your hand slightly upwards and use your ring finger to hit tab, and your pinky to hit shift.
Anyways if your hand size is similar to mine, which is somewhere between a small~medium sized lab glove - you'll find the distance between the tip of your ring and pinky finger is enough to not hit caps lock in the middle if you arch your pinky a bit, which happens naturally.
Obviously don't try to move UP the keyboard with your pinky, and don't try to move DOWN the keyboard with your ring when trying to hit shift and tab respectively.
Alternatively you could almost always use right-shift :), or pull out your caps lock keycap entirely.
Reference: TyprX contest winner?
I think depends a lot on the type of keyboard that you have. You said you're using a laptop, which obviously has the same keyboard all of the time, so adding a bump (via a burn or gluing a little half-sphere of plastic) will likely do the trick, but I'm not usually one to mark up an expensive device like that.
For me, I use an external keyboard via my desktop (and use synergy or ssh) and my Caps Lock key has an indentation (hard to describe, so I'll post an image below) so I use that to determine if my pinky finger is on the Caps Lock key or one of the other ones.
Like I said, this will depend heavily on your particular keyboard. Some of the more expensive external keyboards will allow you to replace the keys easily, so you could order one that's got the little raised bump on it.

What application has mouse control?

One way users can cheat with games (desktop or web) is by having "robots" monitor the screen and move the mouse for them. Is there a way (of course with transparency and user permission) to monitor if an application is controlling the mouse? I am primarily interested in a windows app, but if there is a way for other OS's that would be useful to know as well.
Thanks!
There shouldn't be. Any sensibly designed UI layer will only pass events to the applications, about inputs such as mouse, keyboard etc. Those events will typically not include information about how the event was generated (you're not supposed to care, so why pay for that overhead).
One way might be to scan the system for processes having names of known "event-fakers", much like some anti-virus programs blacklist applications by name.
On Windows you can add a hook to monitor for injected keyboard or mouse messages,
and remove them if you like.
But I'm not sure if you can find the source of the messages.
Just an idea:
Get the current mouse position and check for fast position changes.
Like from (10,15) to (1000, 400).
Most robots just set a new position and don't imitate the human mouse movement.

Things to consider when writing for touch screen?

I'm starting a new project which involves developing an interface for a machine that measures wedge and roundness of lenses and stores the information in a database and reports on it. There's a decent chance we're going to be putting a touch screen on this machine so that it doesn't need to have a mouse or keyboard...
I don't have any experience developing for full size touch screens, so I'm looking for advice/tips/info from you guys...
I can imagine you want to make the elements a little larger than normal... space buttons out a bit more.... things like that... anyone have anything else to add?
A few things to consider:
You need to account for parallax error when touching controls. Basically, the user may touch the screen above or below your actual control and therefore miss the control. This is a combination of the size of the control (eg you can have the active area larger than visual control to allow the user to miss and still activate the control), the viewing angle of the user (which you may or may not be able to predict/control) and the type of touch screen you're using. If you know where the user will be placed relative to the screen when using it, you can usually accommodate this with appropriate calibration.
Depending on the type of touch screen, you may need to ensure that your users aren't wearing gloves or using an implement other than their fingers (eg the end of a pen) to touch the screen. Some screens (eg those depending on conductance) don't respond well to anything other than flesh and blood.
Avoid using double clicks because it can be very hard for users to reliably double click a control. This can be partly mitigated if you've got experienced/trained users working in a fairly controlled environment where they're used to the screens.
Linked to the above, if you are using double clicks, you may find the double click activated when the user only wants to single click. This is because it's very easy for the user's finger to bounce slightly on touching the screen and, depending on how sensitive the double click settings are, trigger a double rather than a single click. For this and the previous reason, we always disable double clicks and only use single clicks (or similar single activation controls).
However big you think you need to make the controls to allow for touch activation, they almost certainly need to be bigger still. Make sure you test the interface with real users in the real deployment environment (or as close to it as you can get). For example, we deployed some screens with nice big buttons you couldn't miss only to find that the control room was unheated and that the users were wearing thick gloves in the middle of winter, making their fingers way bigger than we had allowed for.
Don't put any controls near the edges of the screen - it's very hard to get your finger into the edges (particularly if the screen has a deep bezel) and a slight calibration problem can easily shift the control too close to the edge to use. Standard menus and scroll bars are a good example of controls that can be very tricky to use on a touch screen and you should either avoid them (which is preferable - they're not good for touch screens) or replicate them with jumbo equivalents.
Remember that the user's hand will be over the screen, obscuring some of the screen and controls (typically those below where the user is touching, but it depends on the position of the user relative to the screen). Don't put instructions or indicators where the user's hand or arm will obscure them when trying to use the control they relate to (eg typically put them above rather than below the control).
Depending on the environment, make sure your touch screen is suitably proofed against dust, damp, grease etc and make sure it's easy to clean without damaging it. You wouldn't believe the slime that can quickly accumulate on a touch screen in an industrial or public setting.
The other obvious one is that there's no equivalent of pointer 'hover'. Not that that affects many apps though.
If you decide to put in analog controls (scrollbars, rotation widgets, etc) be sure to put in a digital control also. Some companies think that a touch screen means perfect control over something with your fingers. In real life, this translates to minutes of frustration trying to fix a number that's just a little off.
The most obvious thing is that everything on the GUI needs to be big enough for a fingertip to hit, which is sometimes bigger than you think.
As has been mentioned, there's really no way for a right-click action to happen. Also, double-clicking can be tricky with a fingertip on a touch screen.
The other major thing is that you'll want to create a on-screen keyboard that pops up for text entry and an on-screen numpad for number only fields.
I wrote my own set of controls for a POS application designed specifically to be touchscreen friendly.
Remember to allow enough real estate for stubby fingers and talons. In our application the users can have these manicures that necessitate them to use the pad of their finger instead of the tip. This means that you need to allow more space for activation areas than you would normally consider in any other type of application.
I would also recommend that you accommodate yourself as a programmer from a testing standpoint and from the point of view that things change and there may need to be a keyboard/mouse attached to a non-touch workstation. I cannot tell you how many times I went to touch my flat panel LCD expecting something to happen, before remembering that I had to use the mouse.
Make sure to read your basic UI principles like Fitz law (The time to acquire a target is a function of the distance to and size of the target).
Also consider whether or not the device is stationary or not when it is in use (e.g., like a palmpilot or iphone), research shows that you must accomodate that into your design.
The larger gui elements is the major thing. But it applies to all elements, scroll bars, tabs and even text fields.
The other major thing that I can think of, it's hard for the user to right click. So things that require a right click should be avoided, context menus are the only thing that comes to mind at the moment.
The other responses are pretty good, but are you totally sure that a touch screen would actually be easier to use? There are a lot of devices where a touch screen actually makes them much harder to use, not easier. The main problem is that you can't use the device when you're not looking at it. If users are going to be doing a lot of repetitive actions, a keyboard could be a lot more efficient.
Also, a touch screen might be a lot harder to use by someone with a disability, if you think there's even a small chance that could happen.
Even though this is quite old now, I found it to still be useful, as a starting point for design considerations.
http://www.sapdesignguild.org/resources/tsdesigngl/index.htm
If you've not already done so, have a look at some of the documentation available for developers on mobile platforms, eg Windows Mobile, iPhone.