libsdl: add initial window position support

* fix window size
This commit is contained in:
Gerasim Troeglazov
2020-05-21 20:05:11 +10:00
parent 1fc89269bc
commit 46eab79a7b
2 changed files with 136 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ joystick, and graphics via OpenGL."
HOMEPAGE="http://www.libsdl.org/"
COPYRIGHT="1997-2012 Sam Lantinga"
LICENSE="GNU LGPL v2.1"
REVISION="16"
REVISION="17"
SOURCE_URI="http://www.libsdl.org/release/SDL-1.2.15.tar.gz"
CHECKSUM_SHA256="d6d316a793e5e348155f0dd93b979798933fb98aa1edebcc108829d6474aad00"
SOURCE_DIR="SDL-$portVersion"

View File

@@ -1,4 +1,4 @@
From 52028fa20c3c87e7e320a0665cf94c84de09d7c2 Mon Sep 17 00:00:00 2001
From 50011b87890b57435eeacfe718627b491619abbc Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Nov 2013 23:38:56 +0100
Subject: Remove Alsa and ESD detection
@@ -36,7 +36,7 @@ index 08c8e1e..84d9a55 100644
2.26.0
From 19601bfe8a61929dc5e5bffc0ce791032d24d13d Mon Sep 17 00:00:00 2001
From ccb8d617d98f5f138838327da70be061237a655f Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Nov 2013 23:39:26 +0100
Subject: Fix samples vs bytes issues
@@ -67,7 +67,7 @@ index de635f8..7faf571 100644
2.26.0
From f35babd06d0232d31a377f6e05557e2fc0166ee2 Mon Sep 17 00:00:00 2001
From f4bb5a49719622a970e91f0bf1bf499cdde3079c Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Nov 2013 23:40:12 +0100
Subject: Various fixes to the video code
@@ -147,7 +147,7 @@ index c32b661..a26f18b 100644
2.26.0
From 3a8e071ebd848afd5b1e185b74384cbcb37d7c5a Mon Sep 17 00:00:00 2001
From 413345646cc0d5d69b65370fa7e2f453826f0444 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 23 Nov 2013 11:59:00 +0100
Subject: Actually fix the sample vs bytes problem in audio driver.
@@ -201,7 +201,7 @@ index 7faf571..300bf03 100644
2.26.0
From 0b4e43c371de5699b410021caa74c9690da479d9 Mon Sep 17 00:00:00 2001
From 58bb99d3d7ffa2ff5670943b2a9288bc6e524b7a Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Sun, 22 Dec 2013 18:37:30 -0700
Subject: Remove Haiku from specialized DECLSPEC definition
@@ -224,7 +224,7 @@ index 27e2f7b..d5e2f1f 100644
2.26.0
From 87cfecc3ee01ea4843f77fff1d328936cdd6d0ec Mon Sep 17 00:00:00 2001
From 6352a72a663b848cca09d9e8c480e789b50c9c3b Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 5 Jan 2014 17:22:10 +0100
Subject: Change prefix from "be" to "os" for OpenGL includes
@@ -248,7 +248,7 @@ index f2b19a2..2cb94ee 100644
2.26.0
From 32bd8f08e15ab34abfa8dfdb4e050653e0493fcb Mon Sep 17 00:00:00 2001
From 1852e933b85aef624e46092f004db05c0d089a2a Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Fri, 28 Mar 2014 18:04:12 +0100
Subject: Fix compilation on x86_64
@@ -383,7 +383,7 @@ index 7c71b00..f2fef10 100644
2.26.0
From 361e8774494b8ce68e609adca55917c19b35c548 Mon Sep 17 00:00:00 2001
From 1cf66d3efc3a60fb11ad5181b4f5d73d8a14f945 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Mon, 20 Oct 2014 13:33:55 +0200
Subject: Fix problem with GL viewport
@@ -411,7 +411,7 @@ index 5d4077f..7e1bd38 100644
2.26.0
From b8b9a74dbf782f65065da035789fddfc919222c5 Mon Sep 17 00:00:00 2001
From f3607ec1423ff4eb4b15ea89e956b608b1cbfe23 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Tue, 27 Oct 2015 21:39:24 +0000
Subject: Avoid crashing on quit when SDL_Win was never initialized.
@@ -440,7 +440,7 @@ index 7e1bd38..818d1a0 100644
2.26.0
From 45fd89b3f39103aa48bc4c899bb259ceee016d3d Mon Sep 17 00:00:00 2001
From f6184d24a887cc0bfcd638bd6afd8e25a64a19af Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Tue, 27 Oct 2015 21:40:36 +0000
Subject: Add 24 bit color spaces to ColorSpaceToBitsPerPixel().
@@ -467,7 +467,7 @@ index 818d1a0..0100f3b 100644
2.26.0
From 1819548d78a438eda8cfb07c5c839e4e366a9c41 Mon Sep 17 00:00:00 2001
From 5623298d212e0f2a8750a8db062413061e5b7f84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Mon, 11 Jul 2016 15:08:06 +0200
Subject: Try to find correct application signature from app resources
@@ -519,7 +519,7 @@ index 8b79377..65a6dbf 100644
2.26.0
From b2cb262190e7f10809d6fdfde382d0f28e25bcfb Mon Sep 17 00:00:00 2001
From 1a6af96dd5a4bb67128d49a1de660f94ae8ef7a2 Mon Sep 17 00:00:00 2001
From: Peter Kosyh <p.kosyh@gmail.com>
Date: Fri, 5 Oct 2018 17:39:06 +0300
Subject: fix black box in top-left corner while win lost mouse focus
@@ -553,7 +553,7 @@ index 9e12750..63afded 100644
2.26.0
From 89bab4cb82d25d2ea02e3f849a23b711a2219313 Mon Sep 17 00:00:00 2001
From e467a7710ab2ce5dbb2a83154114f37bb005edf2 Mon Sep 17 00:00:00 2001
From: Peter Kosyh <p.kosyh@gmail.com>
Date: Sat, 6 Oct 2018 14:17:22 +0300
Subject: libsdl: mouse wheel inverted
@@ -582,7 +582,7 @@ index 63afded..225e882 100644
2.26.0
From 45835affbca3b752da33aae35eea331fba0e0327 Mon Sep 17 00:00:00 2001
From ef0037b49fd0359c7d5288978c1d484d1197db53 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 19 May 2020 18:10:45 +1000
Subject: Disable direct mode for BGLView
@@ -657,3 +657,124 @@ index 225e882..38ce3c9 100644
--
2.26.0
From 3d47666a1eed13f76c230b68dd957f65e1a3b573 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 21 May 2020 13:11:45 +1000
Subject: Add window positon support
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index 0100f3b..07f16b5 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -578,6 +578,30 @@ SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,
/* Set the correct fullscreen mode */
BE_SetFullScreen(_this, current, flags & SDL_FULLSCREEN ? 1 : 0);
+ if (!(flags & SDL_FULLSCREEN)) {
+ int x, y;
+ BPoint pos;
+ const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS");
+ const char *center = SDL_getenv("SDL_VIDEO_CENTERED");
+
+ if ( window ) {
+ if ( SDL_sscanf(window, "%d,%d", x, y) == 2 ) {
+ pos.x = x;
+ pos.y = y;
+ SDL_Win->MoveTo(pos);
+ return(current);
+ }
+ if ( SDL_strcmp(window, "center") == 0 ) {
+ center = window;
+ }
+ }
+ if ( center ) {
+ pos.x = (bscreen.Frame().Width() - width) / 2;
+ pos.y = (bscreen.Frame().Height() - height) / 2;
+ SDL_Win->MoveTo(pos);
+ }
+ }
+
/* We're done */
return(current);
}
--
2.26.0
From b6d516bb5cdd05ecb58c77649a1607acf0fde95d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 21 May 2020 19:57:35 +1000
Subject: Fix window size
diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h
index d6b6b3c..3eb4c55 100644
--- a/src/video/bwindow/SDL_BWin.h
+++ b/src/video/bwindow/SDL_BWin.h
@@ -102,8 +102,8 @@ public:
virtual void FrameResized(float width, float height) {
if(inhibit_resize)
inhibit_resize = false;
- else
- SDL_PrivateResize((int)width, (int)height);
+ else
+ SDL_PrivateResize((int)width+1, (int)height+1);
}
virtual int CreateView(Uint32 flags, Uint32 gl_flags) {
int retval;
@@ -178,6 +178,9 @@ public:
#endif
SDL_View->GetXYOffset(x, y);
}
+ virtual void ResizeWindow(int width, int height) {
+ ResizeTo(width-1, height-1);
+ }
virtual bool BeginDraw(void) {
return(Lock());
}
diff --git a/src/video/bwindow/SDL_sysevents.cc b/src/video/bwindow/SDL_sysevents.cc
index 38ce3c9..549af1c 100644
--- a/src/video/bwindow/SDL_sysevents.cc
+++ b/src/video/bwindow/SDL_sysevents.cc
@@ -398,10 +398,10 @@ void SDL_BWin::DirectConnected(direct_buffer_info *info) {
case B_DIRECT_START:
case B_DIRECT_MODIFY:
{
- int32 width = info->window_bounds.right -
- info->window_bounds.left;
- int32 height = info->window_bounds.bottom -
- info->window_bounds.top;
+ int32 width = (info->window_bounds.right -
+ info->window_bounds.left) + 1;
+ int32 height = (info->window_bounds.bottom -
+ info->window_bounds.top) + 1;
SDL_PrivateResize(width, height);
break;
}
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index 07f16b5..163b0a6 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -468,7 +468,7 @@ static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
// printf("Doing not fullscreen stuff.\n");
// We are not in full screen mode, so we want to change the window
// size to match the resolution in SDL.
- SDL_Win->ResizeTo(width, height);
+ SDL_Win->ResizeWindow(width, height);
// And also center the window and reset the drawing offset.
if(firstTime || wasFullScreen) {
@@ -511,7 +511,7 @@ SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,
BRect bounds;
Uint32 gl_flags = 0;
- SDL_Win->ResizeTo(width, height);
+ SDL_Win->ResizeWindow(width, height);
/* Only RGB works on r5 currently */
gl_flags = BGL_RGB;
--
2.26.0