Xserver: More font options

This commit is contained in:
pelya
2013-11-05 09:08:00 +02:00
parent cf7eaf9957
commit 7f6347c844
3 changed files with 39 additions and 13 deletions

View File

@@ -148,7 +148,7 @@ void XSDL_unpackFiles()
}
}
static void showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH)
void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH)
{
int x, y, i, ii;
SDL_Event event;
@@ -168,12 +168,14 @@ static void showConfigMenu(int * resolutionW, int * displayW, int * resolutionH,
const char * fontsStr[] = {
"x2.5", "x2", "x1.7", "x1.5",
"x1.3", "x1", "x0.9", "x0.8",
"x0.7", "x0.6", "x0.5", "x0.4"
"x0.7", "x0.6", "x0.5", "x0.4",
"x0.3", "x0.2", "x0.15", "x0.1"
};
const float fontsVal[] = {
2.5f, 2.0f, 1.7f, 1.5f,
1.3f, 1.0f, 0.9f, 0.8f,
0.7f, 0.6f, 0.5f, 0.4f
0.7f, 0.6f, 0.5f, 0.4f,
0.3f, 0.2f, 0.15f, 0.1f
};
sprintf(native, "%dx%d native", resVal[0][0], resVal[0][1]);
@@ -224,7 +226,7 @@ static void showConfigMenu(int * resolutionW, int * displayW, int * resolutionH,
case SDL_MOUSEBUTTONUP:
{
SDL_GetMouseState(&x, &y);
i = (y / (VID_Y/3));
i = (y / (VID_Y/4));
ii = (x / (VID_X/4));
dpi = i * 4 + ii;
}
@@ -232,10 +234,10 @@ static void showConfigMenu(int * resolutionW, int * displayW, int * resolutionH,
}
}
SDL_FillRect(SDL_GetVideoSurface(), NULL, 0);
renderString("Select font scale", VID_X/2, VID_Y/3);
for(i = 0; i < 3; i++)
renderString("Select font scale", VID_X/2, VID_Y/2);
for(i = 0; i < 4; i++)
for(ii = 0; ii < 4; ii++)
renderString(fontsStr[i*4+ii], VID_X/8 + (ii*VID_X/4), VID_Y/6 + (i*VID_Y/3));
renderString(fontsStr[i*4+ii], VID_X/8 + (ii*VID_X/4), VID_Y/8 + (i*VID_Y/4));
SDL_GetMouseState(&x, &y);
renderString("X", x, y);
SDL_Delay(200);
@@ -245,7 +247,7 @@ static void showConfigMenu(int * resolutionW, int * displayW, int * resolutionH,
*displayH = *displayH * (dpiScale / fontsVal[dpi]);
}
void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH)
void XSDL_generateHelp(const char * port)
{
int sd, addr, ifc_num, i;
struct ifconf ifc;
@@ -253,8 +255,6 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
SDL_Surface * surf;
int y = 40;
showConfigMenu(resolutionW, displayW, resolutionH, displayH);
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VID_X, VID_Y, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
SDL_FillRect(surf, NULL, 0xffffff);
@@ -287,10 +287,10 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
__android_log_print(ANDROID_LOG_INFO, "XSDL", "interface: %s address: %s\n", ifr[i].ifr_name, saddr);
if (strcmp(saddr, "127.0.0.1") == 0)
continue;
sprintf (msg, "env DISPLAY=%s:1111 metacity &", saddr);
sprintf (msg, "env DISPLAY=%s%s metacity &", saddr, port);
renderStringColor(msg, VID_X/2, y, 0, 0, 0, surf);
y += 15;
sprintf (msg, "env DISPLAY=%s:1111 gimp", saddr);
sprintf (msg, "env DISPLAY=%s%s gimp", saddr, port);
renderStringColor(msg, VID_X/2, y, 0, 0, 0, surf);
y += 20;
}

View File

@@ -7,5 +7,6 @@ void XSDL_initSDL();
void XSDL_deinitSDL();
void XSDL_unpackFiles();
void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH);
void XSDL_generateHelp(const char * port);
#endif

View File

@@ -1,6 +1,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <SDL/SDL.h>
#include <android/log.h>
@@ -10,12 +13,14 @@ extern int android_main( int argc, char *argv[], char *envp[] );
int main( int argc, char* argv[] )
{
int i;
char screenres[128] = "640x480x24";
char clientcmd[PATH_MAX*3] = "xhost +";
char port[16] = ":1111";
char * cmd = "";
char* args[] = {
"XSDL",
":1111",
port,
"-nolock",
"-noreset",
"-screen",
@@ -38,6 +43,26 @@ int main( int argc, char* argv[] )
XSDL_showConfigMenu(&resolutionW, &displayW, &resolutionH, &displayH);
int s = socket(AF_INET, SOCK_STREAM, 0);
if( s >= 0 )
{
for(i = 0; i < 1024; i++)
{
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(6000 + i);
if( bind (s, (struct sockaddr *) &addr, sizeof(addr) ) < 0 )
continue;
sprintf( port, ":%d", i );
}
close(s);
}
XSDL_generateHelp(port);
XSDL_deinitSDL();
sprintf( screenres, "%d/%dx%d/%dx%d", resolutionW, displayW, resolutionH, displayH, 24 );