GetMouse focus is always 0

Dear PTB community,

I am having trouble with the GetMouse function. This should return an argument called 'focus' that is 1 if the mouse cursor is over a specified screen or PTB window, and 0 otherwise. However, no matter what screen or window id I provide, focus is always zero.

I am using Ubuntu 14.04, Matlab R2015a, and PsychToolbox 3.0.14 on a system with two separate monitors such that Screen ( 'Screens' ) returns 0 and 1 ; note, X11 creates two xscreens and assigns one to each physical monitor. I have run PsychLinux. Opening and drawing to screen 1 works without issue. However, the following code fails to raise the focus flag:

WaitSecs ( 0.1 ) ;

while   ~ KbCheck

  [ x , y , ~ , focus ] = GetMouse ( 1 ) ;
  fprintf ( 'focus %d , x %0.2f , y %0.2f\n' , focus , x , y )

end


I always get output like this "focus 0 , x 1278.00 , y 547.00" no matter what screen the cursor is on. The result is the same if I run GetMouse ( 0 ) or if I open a PTB window and provide the window pointer instead.

Is there anything else I can do to identify which screen the mouse cursor is in?

Best wishes,
Jackson
That's not what the 'focus' return argument does. As the help text says, it tells you if the Psychtoolbox onscreen window has keyboard input focus. That usually means it receives keyboard input when you type, and usually when it is a GUI window it is somehow highlighted/visually marked as the one receiving input, e.g., by having solid instead of dimmed out text in the window title bar, or different border colors or shadows or whatever.

A window can have input focus without the mouse cursor being in it, and it can have no input focus even if the mouse cursor hovers above it.

If you wanted to know if the mouse pointer is in the window you'd have to match the returned x,y position of GetMouse(windowHandle) against the Screen('Rect', windowHandle) of the window, e.g., via IsInRect(x,y, Screen('Rect', windowHandle))

-mario