Skip to content

Commit

Permalink
Added Fullscreen WM Hit to the X11 window
Browse files Browse the repository at this point in the history
when true the request is send after configuring the window
otherwize before decoration. needs tweeking to ensure that the fullscreen is on-off
  • Loading branch information
rsantina committed Oct 11, 2010
1 parent 231f9fe commit fa30494
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
Expand Up @@ -105,7 +105,7 @@ protected void setPositionImpl(int x, int y) {

protected void reconfigureWindowImpl(int x, int y, int width, int height) {
reconfigureWindow0(fullscreen?0:getParentWindowHandle(), getDisplayHandle(), getScreenIndex(), getWindowHandle(),
x, y, width, height, isUndecorated(fullscreen), isVisible());
x, y, width, height, isUndecorated(fullscreen), isVisible(),isFullscreen());
}

protected boolean reparentWindowImpl() {
Expand Down Expand Up @@ -136,7 +136,7 @@ private native long CreateWindow0(long parentWindowHandle, long display,
private native void setVisible0(long display, long windowHandle, boolean visible);
private native void setSize0(long display, long windowHandle, int width, int height);
private native void reconfigureWindow0(long parentWindowHandle, long display, int screen_index, long windowHandle,
int x, int y, int width, int height, boolean undecorated, boolean isVisible);
int x, int y, int width, int height, boolean undecorated, boolean isVisible, boolean fullscreen);
private native void setTitle0(long display, long windowHandle, String title);
private native void requestFocus0(long display, long windowHandle, boolean reparented);
private native void setPosition0(long parentWindowHandle, long display, long windowHandle, int x, int y);
Expand Down
60 changes: 56 additions & 4 deletions src/newt/native/X11Window.c
Expand Up @@ -463,6 +463,47 @@ static void NewtWindows_setDecorations (Display *dpy, Window w, Bool decorated)
XChangeProperty( dpy, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, ntypes);
}

static void NewtWindows_setFullscreen (Display *dpy, Window w, Bool fullscreen) {
Atom _NET_WM_STATE = XInternAtom( dpy, "_NET_WM_STATE", False );
Atom _NET_WM_STATE_ABOVE = XInternAtom( dpy, "_NET_WM_STATE_ABOVE", False );
Atom _NET_WM_STATE_FULLSCREEN = XInternAtom( dpy, "_NET_WM_STATE_FULLSCREEN", False );

Atom types[2]={0};
int ntypes=0;

XEvent xev;
memset ( &xev, 0, sizeof(xev) );

if(True==fullscreen) {
types[ntypes++] = _NET_WM_STATE_FULLSCREEN;
types[ntypes++] = _NET_WM_STATE_ABOVE;

xev.type = ClientMessage;
xev.xclient.window = w;
xev.xclient.message_type = _NET_WM_STATE;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
xev.xclient.data.l[2] = _NET_WM_STATE_ABOVE;

} else {
types[ntypes++] = _NET_WM_STATE_FULLSCREEN;
types[ntypes++] = _NET_WM_STATE_ABOVE;

xev.type = ClientMessage;
xev.xclient.window = w;
xev.xclient.message_type = _NET_WM_STATE;
xev.xclient.format = 32;
xev.xclient.data.l[0] = 0;
xev.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN;
xev.xclient.data.l[2] = _NET_WM_STATE_ABOVE;
}

XChangeProperty( dpy, w, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, ntypes);

XSendEvent (dpy, w, False, SubstructureNotifyMask, &xev );
}

/*
* Class: com_jogamp_newt_impl_x11_X11Display
* Method: DispatchMessages
Expand Down Expand Up @@ -1037,7 +1078,7 @@ static void NewtWindows_reparentWindow
*/
JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reconfigureWindow0
(JNIEnv *env, jobject obj, jlong jparent, jlong display, jint screen_index, jlong window,
jint x, jint y, jint width, jint height, jboolean undecorated, jboolean isVisible)
jint x, jint y, jint width, jint height, jboolean undecorated, jboolean isVisible, jboolean isFullscreen)
{
Display * dpy = (Display *) (intptr_t) display;
Window w = (Window)window;
Expand All @@ -1046,16 +1087,22 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reconfigureWindow
XWindowChanges xwc;
XWindowAttributes xwa;

DBG_PRINT( "X11: reconfigureWindow0 dpy %p, parent %p, win %p, %d/%d %dx%d undec %d, visible %d\n",
(void*)dpy, (void*) jparent, (void*)w, x, y, width, height, undecorated, isVisible);
DBG_PRINT( "X11: reconfigureWindow0 dpy %p, parent %p, win %p, %d/%d %dx%d undec %d, visible %d, fullscreen %d\n",
(void*)dpy, (void*) jparent, (void*)w, x, y, width, height, undecorated, isVisible,isFullscreen);

if(dpy==NULL) {
_FatalError(env, "invalid display connection..");
}


XSync(dpy, False);
XGetWindowAttributes(dpy, w, &xwa);


if(JNI_FALSE == isFullscreen ) {
NewtWindows_setFullscreen(dpy, w, False );
XSync(dpy, False);
}

NewtWindows_reparentWindow(env, obj, dpy, scrn, w, &xwa, jparent, x, y, undecorated, isVisible);
XSync(dpy, False);

Expand All @@ -1066,6 +1113,11 @@ JNIEXPORT void JNICALL Java_com_jogamp_newt_impl_x11_X11Window_reconfigureWindow
xwc.height=height;
XConfigureWindow(dpy, w, CWX|CWY|CWWidth|CWHeight, &xwc);
XSync(dpy, False);

if(JNI_TRUE == isFullscreen ) {
NewtWindows_setFullscreen(dpy, w, True );
XSync(dpy, False);
}
}

/*
Expand Down

0 comments on commit fa30494

Please sign in to comment.