open web browser in screen

Hi there,

I am working on stimuli for an experiment where participants do some things in matlab, then answer survey questions online, then go back to doing more things in matlab. Is it possible to open a web browser window over the top of a fullscreen psychtoolbox presentation (in this case, a fullscreen white Rect). I've tried to use Matlab's built in web browser, but it always appears behind the Screen, and since I am running stimuli in full-screen, the web browser is inaccessible. Any help or ideas would be greatly appreciated.

Patrick Williams
--- In psychtoolbox@yahoogroups.com, Patrick Williams <patrick.b.williams@...> wrote:
>
> Hi there,
>
> I am working on stimuli for an experiment where participants do some things
> in matlab, then answer survey questions online, then go back to doing more
> things in matlab. Is it possible to open a web browser window over the top
> of a fullscreen psychtoolbox presentation (in this case, a fullscreen white
> Rect). I've tried to use Matlab's built in web browser, but it always
> appears behind the Screen, and since I am running stimuli in full-screen,
> the web browser is inaccessible. Any help or ideas would be greatly
> appreciated.
>
> Patrick Williams
>

Depends on the operating system and other factors. On current versions of OS/X you could do this:

% Enable transparency for Windows, but default to 100% opaque:
PsychDebugWindowConfiguration([], 1);

% Open a fullscreen window with white background color:
w=Screen('Openwindow', 0, 255);

% Poke a transparent hole into the window inside the
% rectangle [300 300 600 600], by filling with black
% pixels that have alpha value of zero for "fully transparent":
Screen('FillRect', w, [0 0 0 0], [300 300 600 600]);

% Show it:
Screen('Flip', w);

-> Wherever you draw with alpha value zero, the window becomes transparent and your webbrowser shines through.

Downside is a loss of timing precision: Stimulus presentation timing and the timestamps returned by Screen('Flip') can be off by multiple video refresh cycles / dozens of milliseconds. Also some loss of graphics performance. Also it is not guaranteed that this function will continue to work on future Apple operating systems, or with a future 64 bit Psychtoolbox on OS/X.

The same trick probably works on Windows Vista and Windows-7 with octave or Matlab R2007a and later, the same caveats as on OS/X apply.

I can't remember if i implemented full support for this on Linux, or only control of global transparency - that is, assign one transparency value to a whole window. If so, same caveats apply.

The whole transparency thing was just meant as a debugging aid on single display setups.

On Linux you could probably call "xdotool" from within Matlab to show or hide onscreen windows or change their relative order on the screen to temporarily hide/show the ptb onscreen window. xdotool can also be used to simulate keyboard/mouse input from subjects.

The most portable solution is to close and reopen the onscreen window to show/hide the webbrowser.

-mario

Hello,

I realize this post is quite old, but I am trying to achieve the same thing with Win 11 and OTB3. The code you sent produces a completely opaque black rectangle (i. e., not transparent). However, if I set the PsychDebugWindowConfiguraiton function to 0.5, the entire window becomes semi-transparent (i. e., the transparency in general works). Do you have an idea what could be wrong?

Thanks so much!
Dominik

The sample code works fine on Linux and macOS, as I just tested.

I don’t know if it works on current Windows, or if it ever worked since Windows Vista changed the display system radically. The transparency support is rather fragile on MS-Windows. E.g., especially with fullscreen windows, transparent window requests are often ignored by some driver like Intel graphics, possibly others.

Update: It doesn’t work on modern Windows with current PTB. However, I spent 67 minutes developing support for this feature on Windows, as tested on Windows-10 and Windows-11. On some graphics cards on Windows, one does need to open a window that is not a fullscreen window, but at least 1 pixel smaller, god knows why, otherwise transparency will not kick in. Also visual timing is always impaired in such a setup on Windows and macOS, as mentioned before. And only colors of the form [0,0,0,alpha] with alpha = 0 for fully transparent, or higher alphas for partial transparency make sense, as otherwise the MS-Windows DWM compositor will weirdly change colors of background pixels, as if multiplying the background pixel colors with the provided color values. These are limitations not present on macOS and Linux iirc., but for the basic “cut a hole into a window to see background content” it will be sufficient.

In the spirit of Christmas time, I’ll provide you with this if you post a paid support authentication token for up to 30 minutes of work time, ie. get 67 minutes of work for the price of 30 minutes. If your lab wasn’t wise enough to buy a support license in advance and would have to buy one first, this might not happen anymore this year though, probably not even before late January.

Otherwise I’ll simply hold this improvement back until somebody pays for it, or until I feel excessively generous.