summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-10-02 15:19:58 -0700
committerSven Gothel <[email protected]>2009-10-02 15:19:58 -0700
commit52c3caf07ad07fcb029ea584d7e5f4c5031f84c2 (patch)
tree5ea67263408af6db6cb594c6fee6746d228723a5
parent56cc5d5058f352d0a46679b67d4f6650e457cbb9 (diff)
NEWT Intel GDL: Proper Pos/Size/Fullscreen
-rw-r--r--src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java70
-rw-r--r--src/newt/native/IntelGDL.c65
2 files changed, 112 insertions, 23 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java
index 3e4b5b90e..0332f442a 100644
--- a/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/intel/gdl/Window.java
@@ -89,28 +89,65 @@ public class Window extends com.sun.javafx.newt.Window {
}
public void setSize(int width, int height) {
+ Screen screen = (Screen) getScreen();
+ if((x+width)>screen.getWidth()) {
+ width=screen.getWidth()-x;
+ }
+ if((y+height)>screen.getHeight()) {
+ height=screen.getHeight()-y;
+ }
+ this.width = width;
+ this.height = height;
+ if(!fullscreen) {
+ nfs_width=width;
+ nfs_height=height;
+ }
if(0!=surfaceHandle) {
- System.err.println("setSize "+width+"x"+height+" n/a in IntelGDL _after_ surface established");
- } else {
- Screen screen = (Screen) getScreen();
- if(width>screen.getWidth() || height>screen.getHeight()) {
- width=screen.getWidth();
- height=screen.getHeight();
- }
- this.width = width;
- this.height = height;
+ SetBounds0(surfaceHandle, screen.getWidth(), screen.getHeight(), x, y, width, height);
}
}
public void setPosition(int x, int y) {
- // n/a in IntelGDL
- System.err.println("setPosition n/a in IntelGDL");
+ Screen screen = (Screen) getScreen();
+ if((x+width)>screen.getWidth()) {
+ x=screen.getWidth()-width;
+ }
+ if((y+height)>screen.getHeight()) {
+ y=screen.getHeight()-height;
+ }
+ this.x = x;
+ this.y = y;
+ if(!fullscreen) {
+ nfs_x=x;
+ nfs_y=y;
+ }
+ if(0!=surfaceHandle) {
+ SetBounds0(surfaceHandle, screen.getWidth(), screen.getHeight(), x, y, width, height);
+ }
}
public boolean setFullscreen(boolean fullscreen) {
- // n/a in IntelGDL
- System.err.println("setFullscreen n/a in IntelGDL");
- return false;
+ if(this.fullscreen!=fullscreen) {
+ int x,y,w,h;
+ this.fullscreen=fullscreen;
+ if(fullscreen) {
+ x = 0; y = 0;
+ w = screen.getWidth();
+ h = screen.getHeight();
+ } else {
+ x = nfs_x;
+ y = nfs_y;
+ w = nfs_width;
+ h = nfs_height;
+ }
+ if(DEBUG_IMPLEMENTATION || DEBUG_WINDOW_EVENT) {
+ System.err.println("IntelGDL Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h);
+ }
+ if(0!=surfaceHandle) {
+ SetBounds0(surfaceHandle, screen.getWidth(), screen.getHeight(), x, y, w, h);
+ }
+ }
+ return fullscreen;
}
public void requestFocus() {
@@ -126,9 +163,9 @@ public class Window extends com.sun.javafx.newt.Window {
//
protected static native boolean initIDs();
- private native long CreateSurface(long displayHandle, int width, int height);
+ private native long CreateSurface(long displayHandle, int scrn_width, int scrn_height, int x, int y, int width, int height);
private native void CloseSurface(long displayHandle, long surfaceHandle);
-
+ private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height);
private void updateBounds(int x, int y, int width, int height) {
this.x = x;
@@ -138,4 +175,5 @@ public class Window extends com.sun.javafx.newt.Window {
}
private long surfaceHandle;
+ private int nfs_width, nfs_height, nfs_x, nfs_y;
}
diff --git a/src/newt/native/IntelGDL.c b/src/newt/native/IntelGDL.c
index 1ea576297..1bc43cd0e 100644
--- a/src/newt/native/IntelGDL.c
+++ b/src/newt/native/IntelGDL.c
@@ -267,16 +267,16 @@ JNIEXPORT jlong JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CreateSurface
DBG_PRINT("[CreateSurface: screen %dx%d, win %d/%d %dx%d plane %d]\n",
scr_width, scr_height, x, y, width, height, plane);
- srcRect.origin.x = 0;
- srcRect.origin.y = 0;
- srcRect.width = scr_width;
- srcRect.height = scr_height;
-
- /** Overwrite - TEST - Check semantics of dstRect! */
+ /** Overwrite - TEST - Check semantics of dstRect!
x = 0;
y = 0;
width = scr_width;
- height = scr_height;
+ height = scr_height; */
+
+ srcRect.origin.x = x;
+ srcRect.origin.y = y;
+ srcRect.width = width;
+ srcRect.height = height;
dstRect.origin.x = x;
dstRect.origin.y = y;
@@ -348,4 +348,55 @@ JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_CloseSurface
DBG_PRINT("[CloseSurface] plane %d\n", plane);
}
+JNIEXPORT void JNICALL Java_com_sun_javafx_newt_intel_gdl_Window_SetBounds0
+ (JNIEnv *env, jobject obj, jlong surface, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) {
+
+ gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ;
+ gdl_ret_t retval;
+ gdl_rectangle_t srcRect, dstRect;
+
+ (void) env;
+ (void) obj;
+
+ DBG_PRINT("[SetBounds0: screen %dx%d, win %d/%d %dx%d plane %d]\n",
+ scr_width, scr_height, x, y, width, height, plane);
+
+ srcRect.origin.x = x;
+ srcRect.origin.y = y;
+ srcRect.width = width;
+ srcRect.height = height;
+
+ dstRect.origin.x = x;
+ dstRect.origin.y = y;
+ dstRect.width = width;
+ dstRect.height = height;
+
+ retval = gdl_plane_config_begin(plane);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_config_begin");
+ return;
+ }
+
+ retval = gdl_plane_set_attr(GDL_PLANE_DST_RECT, &dstRect);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_set_attr dstRect");
+ return;
+ }
+
+ retval = gdl_plane_set_attr(GDL_PLANE_SRC_RECT, &srcRect);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_set_attr srcRect");
+ return;
+ }
+
+ retval = gdl_plane_config_end(GDL_FALSE);
+ if (retval != GDL_SUCCESS) {
+ JNI_ThrowNew(env, "java/lang/IllegalStateException", "gdl_plane_config_end");
+ return;
+ }
+
+ (*env)->CallVoidMethod(env, obj, updateBoundsID, (jint)x, (jint)y, (jint)width, (jint)height);
+
+ DBG_PRINT("[SetBounds0] returning plane %d\n", plane);
+}