Bug 1205

Summary: NEWT Security: Clear onscreen Window content after creation and before visibility
Product: [JogAmp] Newt Reporter: Sven Gothel <sgothel>
Component: coreAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: enhancement CC: xerxes, xerxes
Priority: ---    
Version: 2.3.2   
Hardware: All   
OS: all   
Type: FEATURE SCM Refs:
ee2fea13b20644e45c77f12a8b6d6f55941c27c8 f607c0148736fa198fb91b60123824e53366022e f60bc2eb827a89d5d26d7348761da268306c0623
Workaround: ---
Bug Depends on:    
Bug Blocks: 1178, 1206    

Description Sven Gothel 2015-08-28 00:36:03 CEST
NEWT windows shall clear their framebuffer,
read: window content, after creation and before visibility.

This shall ensure that no NEWT user or any 3rd party utility
will be enabled to read uninitialized memory.
The latter could be content of previous windows
or even any arbitrary memory region, depending of the 
underlying driver.

NEWT WindowImpl shall either 
  - (1) clear the memory itself using the underlying driver, or 
  - (2) clear the memory itself using via CPU memset
  - (3) clear the memory by a hooked SPI, i.e. GLWindow
        using its method, e.g. OpenGL.
Comment 1 Sven Gothel 2015-08-31 08:53:34 CEST
ee2fea13b20644e45c77f12a8b6d6f55941c27c8

    X11Window.c:
    
    Adding CWBackPixel BlackPixel(..) resulting in an initial black window (zero).
    
    com.jogamp.opengl.test.junit.newt.TestWindows02NEWT shows the content
    w/ opaque background and transparent one.
    Note: To be able to receive a transparent background,
    one needs to utilize a compositor WM (e.g. KWin w/ effects enabled).
    
    Due to commit cf9e2f2cb8ead7efd7751dcbfaecb36ed06cf9d6 (Bug 1210)
    this works in pure NEWT mode w/o utilizing GLX.
Comment 2 Xerxes RĂ„nby 2015-09-02 13:07:48 CEST
(In reply to comment #1)
> ee2fea13b20644e45c77f12a8b6d6f55941c27c8
> 
>     X11Window.c:
>     
>     Adding CWBackPixel BlackPixel(..) resulting in an initial black window
> (zero).
>     
>     com.jogamp.opengl.test.junit.newt.TestWindows02NEWT shows the content
>     w/ opaque background and transparent one.
>     Note: To be able to receive a transparent background,
>     one needs to utilize a compositor WM (e.g. KWin w/ effects enabled).
>     
>     Due to commit cf9e2f2cb8ead7efd7751dcbfaecb36ed06cf9d6 (Bug 1210)
>     this works in pure NEWT mode w/o utilizing GLX.

This commit have un-blocked 1178, thank you!
https://jogamp.org/bugzilla/show_bug.cgi?id=1178#c12
Comment 3 Sven Gothel 2015-09-29 11:27:07 CEST
commit f607c0148736fa198fb91b60123824e53366022e

NEWT Windows Onscreen
    
WindowsWindow.c:
  - WindowUserData.isInCreation set while window at initizalization,
    i.e. before final size/pos/visibility.
    
    Also no visibility until final NewtWindow_setVisiblePosSize(..) call.
    This is possible since even w/o ShowWindow upfront,
    UpdateInsets(..) is able to gather accurate values.
    
  - Suppress any Java callback while WindowUserData.isInCreation,
    issue one callback when window is final.
    Use newly accumulated callback WindowImpl.sizePosInsetsFocusVisibleChanged(..)
    
  - While WindowUserData.isInCreation, WM_PAINT triggers WM_ERASEBKGND
    and WM_ERASEBKGND actually erases background w/ window background color.
Comment 4 Sven Gothel 2015-09-29 12:09:38 CEST
OSX does clean the content of the initial framebuffer (NSView),
hence no change required here.
Comment 5 Sven Gothel 2015-09-29 12:33:31 CEST
The proprietary BCM VC IV seems to have cleared all allocated layers,
as reported by Xerxes.
Comment 6 Sven Gothel 2015-10-02 00:04:26 CEST
(In reply to Sven Gothel from comment #3)
> commit f607c0148736fa198fb91b60123824e53366022e
> 
> NEWT Windows Onscreen
>     
> WindowsWindow.c:
>   - WindowUserData.isInCreation set while window at initizalization,
>     i.e. before final size/pos/visibility.
>     
>     Also no visibility until final NewtWindow_setVisiblePosSize(..) call.
>     This is possible since even w/o ShowWindow upfront,
>     UpdateInsets(..) is able to gather accurate values.
>     
>   - Suppress any Java callback while WindowUserData.isInCreation,
>     issue one callback when window is final.
>     Use newly accumulated callback
> WindowImpl.sizePosInsetsFocusVisibleChanged(..)
>     
>   - While WindowUserData.isInCreation, WM_PAINT triggers WM_ERASEBKGND
>     and WM_ERASEBKGND actually erases background w/ window background color.

commit f60bc2eb827a89d5d26d7348761da268306c0623

Revert clear background to support fix for Bug 1232: 
NEWT Translucency Windows >= 8
    
Reverting 'clear backrgound' portion of commit f607c0148736fa198fb91b60123824e53366022e.
It has been identified, that Windows does initialize 
onscreen windows (i.e. w/ white/DESKTOP color).
    
This is also required for allowing translucent windows,
since clearing the background intefers on Windows >= 8 (undecorated windows).