aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorRami Santina <[email protected]>2010-10-11 05:36:23 +0300
committerRami Santina <[email protected]>2010-10-11 05:36:23 +0300
commitfa304942297fcb94c16d8f734570243cf324cb37 (patch)
tree55dc613ce5ddd6482562c0a30477ea6349985cd5 /src/newt
parent231f9fe67c55ece5ee013cf1183f15200b602cd8 (diff)
Added Fullscreen WM Hit to the X11 window
when true the request is send after configuring the window otherwize before decoration. needs tweeking to ensure that the fullscreen is on-off
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java4
-rw-r--r--src/newt/native/X11Window.c60
2 files changed, 58 insertions, 6 deletions
diff --git a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
index f9fce6fc1..8251fdeae 100644
--- a/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
+++ b/src/newt/classes/com/jogamp/newt/impl/x11/X11Window.java
@@ -105,7 +105,7 @@ public class X11Window extends WindowImpl {
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() {
@@ -136,7 +136,7 @@ public class X11Window extends WindowImpl {
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);
diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c
index 8a07067b7..0799190b4 100644
--- a/src/newt/native/X11Window.c
+++ b/src/newt/native/X11Window.c
@@ -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
@@ -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;
@@ -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);
@@ -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);
+ }
}
/*
id='n422' href='#n422'>422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
/**
 * OpenAL cross platform audio library
 * Copyright (C) 1999-2000 by authors.
 * This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA  02111-1307, USA.
 * Or go to http://www.gnu.org/copyleft/lgpl.html
 */

#include "config.h"

#include <stdlib.h>
#include "alMain.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "alError.h"
#include "alSource.h"
#include "alState.h"

static const ALchar alVendor[] = "OpenAL Community";
static const ALchar alVersion[] = "1.1 ALSOFT "ALSOFT_VERSION;
static const ALchar alRenderer[] = "OpenAL Soft";

// Error Messages
static const ALchar alNoError[] = "No Error";
static const ALchar alErrInvalidName[] = "Invalid Name";
static const ALchar alErrInvalidEnum[] = "Invalid Enum";
static const ALchar alErrInvalidValue[] = "Invalid Value";
static const ALchar alErrInvalidOp[] = "Invalid Operation";
static const ALchar alErrOutOfMemory[] = "Out of Memory";

AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
{
    ALCcontext *Context;

    Context = GetLockedContext();
    if(!Context) return;

    switch(capability)
    {
        case AL_SOURCE_DISTANCE_MODEL:
            Context->SourceDistanceModel = AL_TRUE;
            Context->UpdateSources = AL_TRUE;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);
}

AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
{
    ALCcontext *Context;

    Context = GetLockedContext();
    if(!Context) return;

    switch(capability)
    {
        case AL_SOURCE_DISTANCE_MODEL:
            Context->SourceDistanceModel = AL_FALSE;
            Context->UpdateSources = AL_TRUE;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);
}

AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
{
    ALCcontext *Context;
    ALboolean value=AL_FALSE;

    Context = GetLockedContext();
    if(!Context) return AL_FALSE;

    switch(capability)
    {
        case AL_SOURCE_DISTANCE_MODEL:
            value = Context->SourceDistanceModel;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);

    return value;
}

AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
{
    ALCcontext *Context;
    ALboolean value=AL_FALSE;

    Context = GetLockedContext();
    if(!Context) return AL_FALSE;

    switch(pname)
    {
        case AL_DOPPLER_FACTOR:
            if(Context->DopplerFactor != 0.0f)
                value = AL_TRUE;
            break;

        case AL_DOPPLER_VELOCITY:
            if(Context->DopplerVelocity != 0.0f)
                value = AL_TRUE;
            break;

        case AL_DISTANCE_MODEL:
            if(Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED)
                value = AL_TRUE;
            break;

        case AL_SPEED_OF_SOUND:
            if(Context->flSpeedOfSound != 0.0f)
                value = AL_TRUE;
            break;

        case AL_DEFERRED_UPDATES_SOFT:
            value = Context->DeferUpdates;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);

    return value;
}

AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
{
    ALCcontext *Context;
    ALdouble value = 0.0;

    Context = GetLockedContext();
    if(!Context) return 0.0;

    switch(pname)
    {
        case AL_DOPPLER_FACTOR:
            value = (double)Context->DopplerFactor;
            break;

        case AL_DOPPLER_VELOCITY:
            value = (double)Context->DopplerVelocity;
            break;

        case AL_DISTANCE_MODEL:
            value = (double)Context->DistanceModel;
            break;

        case AL_SPEED_OF_SOUND:
            value = (double)Context->flSpeedOfSound;
            break;

        case AL_DEFERRED_UPDATES_SOFT:
            value = (ALdouble)Context->DeferUpdates;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);

    return value;
}

AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
{
    ALCcontext *Context;
    ALfloat value = 0.0f;

    Context = GetLockedContext();
    if(!Context) return 0.0f;

    switch(pname)
    {
        case AL_DOPPLER_FACTOR:
            value = Context->DopplerFactor;
            break;

        case AL_DOPPLER_VELOCITY:
            value = Context->DopplerVelocity;
            break;

        case AL_DISTANCE_MODEL:
            value = (float)Context->DistanceModel;
            break;

        case AL_SPEED_OF_SOUND:
            value = Context->flSpeedOfSound;
            break;

        case AL_DEFERRED_UPDATES_SOFT:
            value = (ALfloat)Context->DeferUpdates;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);

    return value;
}

AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
{
    ALCcontext *Context;
    ALint value = 0;

    Context = GetLockedContext();
    if(!Context) return 0;

    switch(pname)
    {
        case AL_DOPPLER_FACTOR:
            value = (ALint)Context->DopplerFactor;
            break;

        case AL_DOPPLER_VELOCITY:
            value = (ALint)Context->DopplerVelocity;
            break;

        case AL_DISTANCE_MODEL:
            value = (ALint)Context->DistanceModel;
            break;

        case AL_SPEED_OF_SOUND:
            value = (ALint)Context->flSpeedOfSound;
            break;

        case AL_DEFERRED_UPDATES_SOFT:
            value = (ALint)Context->DeferUpdates;
            break;

        default:
            alSetError(Context, AL_INVALID_ENUM);
            break;
    }

    UnlockContext(Context);

    return value;
}

AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname,ALboolean *data)
{
    ALCcontext *Context;

    if(data)
    {
        switch(pname)
        {
            case AL_DOPPLER_FACTOR:
            case AL_DOPPLER_VELOCITY:
            case AL_DISTANCE_MODEL:
            case AL_SPEED_OF_SOUND:
            case AL_DEFERRED_UPDATES_SOFT:
                *data = alGetBoolean(pname);
                return;
        }
    }

    Context = GetLockedContext();
    if(!Context) return;

    if(data)
    {
        switch(pname)
        {
            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
    {
        // data is a NULL pointer
        alSetError(Context, AL_INVALID_VALUE);
    }

    UnlockContext(Context);
}

AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname,ALdouble *data)
{
    ALCcontext *Context;

    if(data)
    {
        switch(pname)
        {
            case AL_DOPPLER_FACTOR:
            case AL_DOPPLER_VELOCITY:
            case AL_DISTANCE_MODEL:
            case AL_SPEED_OF_SOUND:
            case AL_DEFERRED_UPDATES_SOFT:
                *data = alGetDouble(pname);
                return;
        }
    }

    Context = GetLockedContext();
    if(!Context) return;

    if(data)
    {
        switch(pname)
        {
            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
    {
        // data is a NULL pointer
        alSetError(Context, AL_INVALID_VALUE);
    }

    UnlockContext(Context);
}

AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname,ALfloat *data)
{
    ALCcontext *Context;

    if(data)
    {
        switch(pname)
        {
            case AL_DOPPLER_FACTOR:
            case AL_DOPPLER_VELOCITY:
            case AL_DISTANCE_MODEL:
            case AL_SPEED_OF_SOUND:
            case AL_DEFERRED_UPDATES_SOFT:
                *data = alGetFloat(pname);
                return;
        }
    }

    Context = GetLockedContext();
    if(!Context) return;

    if(data)
    {
        switch(pname)
        {
            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
    {
        // data is a NULL pointer
        alSetError(Context, AL_INVALID_VALUE);
    }

    UnlockContext(Context);
}

AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname,ALint *data)
{
    ALCcontext *Context;

    if(data)
    {
        switch(pname)
        {
            case AL_DOPPLER_FACTOR:
            case AL_DOPPLER_VELOCITY:
            case AL_DISTANCE_MODEL:
            case AL_SPEED_OF_SOUND:
            case AL_DEFERRED_UPDATES_SOFT:
                *data = alGetInteger(pname);
                return;
        }
    }

    Context = GetLockedContext();
    if(!Context) return;

    if(data)
    {
        switch(pname)
        {
            default:
                alSetError(Context, AL_INVALID_ENUM);
                break;
        }
    }
    else
    {
        // data is a NULL pointer
        alSetError(Context, AL_INVALID_VALUE);
    }

    UnlockContext(Context);
}

AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
{
    const ALchar *value;
    ALCcontext *pContext;

    pContext = GetLockedContext();
    if(!pContext) return NULL;

    switch(pname)
    {
        case AL_VENDOR: