Remove needless code; fix KWin compositor disabling; enable GTK dialogs on XFCE

This commit is contained in:
KockaAdmiralac 2018-08-04 16:13:20 +02:00
parent 474bb2ce30
commit c8b0b92513
No known key found for this signature in database
GPG key ID: A6007A5107D8CFBD
4 changed files with 17 additions and 34 deletions

View file

@ -2,7 +2,6 @@
Really hacked-together naiive implementation of gettext Really hacked-together naiive implementation of gettext
*/ */
#include "i18n.h" #include "i18n.h"
#include "debugwriter.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -16,16 +15,13 @@ int family = LOCALE_FAMILY_LATIN;
size_t readSize; size_t readSize;
int getLocaleFamily() { int getLocaleFamily() {
Debug() << "Get family:" << family;
return family; return family;
} }
const char* findtext(unsigned int msgid, const char* fallback) { const char* findtext(unsigned int msgid, const char* fallback) {
Debug() << "Looking for msg" << msgid << fallback;
if (msgid >= nStr) { if (msgid >= nStr) {
return fallback; return fallback;
} else { } else {
Debug() << "found" << strdict[msgid];
return strdict[msgid]; return strdict[msgid];
} }
} }
@ -52,12 +48,10 @@ void _setLocaleFamily(const char* locale) {
void _read(void * ptr, size_t size, size_t count, FILE * stream) { void _read(void * ptr, size_t size, size_t count, FILE * stream) {
readSize = fread(ptr, size, count, stream); readSize = fread(ptr, size, count, stream);
if (readSize != count) { if (readSize != count) {
Debug() << "Short read in i18n!";
} }
} }
void loadLocale(const char* locale) { void loadLocale(const char* locale) {
Debug() << "Load locale:" << locale;
char pathbuf[100]; char pathbuf[100];
FILE* locfile; FILE* locfile;
char header[8]; char header[8];
@ -73,18 +67,17 @@ void loadLocale(const char* locale) {
if (locfile) { if (locfile) {
_read(header, 1, 8, locfile); _read(header, 1, 8, locfile);
if (!strcmp(header, LOC_HEADER)) { if (!strcmp(header, LOC_HEADER)) {
//read number of strs in this file // Read number of strs in this file
_read(&nStr, 4, 1, locfile); _read(&nStr, 4, 1, locfile);
strdict = (char**)malloc(sizeof(char*) * nStr); strdict = (char**)malloc(sizeof(char*) * nStr);
for (i = 0; i < nStr; i++) { for (i = 0; i < nStr; i++) {
//read the size of the next string // Read the size of the next string
_read(&strSize, 4, 1, locfile); _read(&strSize, 4, 1, locfile);
strdict[i] = (char*)malloc(strSize+1); strdict[i] = (char*)malloc(strSize+1);
if (strSize > 0) { if (strSize > 0) {
//read the contents of the next string // Read the contents of the next string
_read(strdict[i], 1, strSize, locfile); _read(strdict[i], 1, strSize, locfile);
strdict[i][strSize] = 0; strdict[i][strSize] = 0;
Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize;
} }
strdict[i][strSize] = 0; strdict[i][strSize] = 0;
} }

View file

@ -195,6 +195,7 @@ int main(int argc, char *argv[])
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1"); SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
/* initialize SDL first */ /* initialize SDL first */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0)

View file

@ -13,7 +13,7 @@
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h> #include <SDL2/SDL_ttf.h>
//OS-Specific code // OS-Specific code
#if defined _WIN32 #if defined _WIN32
#define OS_W32 #define OS_W32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
@ -296,6 +296,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
gtk_init(0, 0); gtk_init(0, 0);
} else if (desktop.find("xfce") != std::string::npos) { } else if (desktop.find("xfce") != std::string::npos) {
desktopEnv = "xfce"; desktopEnv = "xfce";
gtk_init(0, 0);
} else if (desktop.find("kde") != std::string::npos) { } else if (desktop.find("kde") != std::string::npos) {
desktopEnv = "kde"; desktopEnv = "kde";
} else if (desktop.find("lxde") != std::string::npos) { } else if (desktop.find("lxde") != std::string::npos) {
@ -477,7 +478,12 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
if (!title) if (!title)
title = ""; title = "";
#if defined OS_LINUX #if defined OS_LINUX
if (desktopEnv == "gnome" || desktopEnv == "mate" || desktopEnv == "cinnamon") { if (
desktopEnv == "gnome" ||
desktopEnv == "mate" ||
desktopEnv == "cinnamon" ||
desktopEnv == "xfce"
) {
linux_DialogData data = {type, body, title, 0}; linux_DialogData data = {type, body, title, 0};
gdk_threads_add_idle(linux_dialog, &data); gdk_threads_add_idle(linux_dialog, &data);
gtk_main(); gtk_main();
@ -485,16 +491,15 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
} }
#endif #endif
//SDL message box // SDL message box
// Button data
//Button data
static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"}; static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"};
static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk}; static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk};
SDL_MessageBoxButtonData buttonYes = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, p->txtYes.c_str()}; SDL_MessageBoxButtonData buttonYes = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, p->txtYes.c_str()};
SDL_MessageBoxButtonData buttonNo = {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, p->txtNo.c_str()}; SDL_MessageBoxButtonData buttonNo = {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, p->txtNo.c_str()};
SDL_MessageBoxButtonData buttonsYesNo[] = {buttonNo, buttonYes}; SDL_MessageBoxButtonData buttonsYesNo[] = {buttonNo, buttonYes};
//Messagebox data // Messagebox data
SDL_MessageBoxData data; SDL_MessageBoxData data;
data.window = NULL;//p->window; data.window = NULL;//p->window;
data.colorScheme = 0; data.colorScheme = 0;
@ -529,7 +534,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
break; break;
} }
//Set buttons // Set buttons
switch (type) switch (type)
{ {
case MSG_INFO: case MSG_INFO:
@ -545,7 +550,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
break; break;
} }
//Show messagebox // Show messagebox
#ifdef OS_W32 #ifdef OS_W32
PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC);
#endif #endif
@ -586,20 +591,6 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f
// Disable text input // Disable text input
SDL_StopTextInput(); SDL_StopTextInput();
// //Free loaded images
// gPromptTextTexture.free();
// gInputTextTexture.free();
// //Free global font
// TTF_CloseFont(gFont);
// gFont = NULL;
// //Destroy renderer
// SDL_DestroyRenderer(gRenderer);
// gRenderer = NULL;
// delete promptBmp;
// delete inputBmp;
return threadData.inputText; return threadData.inputText;
} }

View file

@ -35,7 +35,6 @@
#include "util.h" #include "util.h"
#include "sharedstate.h" #include "sharedstate.h"
#include "i18n.h" #include "i18n.h"
#include "debugwriter.h"
#include <algorithm> #include <algorithm>
@ -539,7 +538,6 @@ struct SettingsMenuPrivate
int x, int y, int alignW, int x, int y, int alignW,
Justification just, SDL_Color c, bool bold = false) Justification just, SDL_Color c, bool bold = false)
{ {
Debug() << "draw text:" << str;
SDL_Surface *txt = createTextSurface(str, c, bold); SDL_Surface *txt = createTextSurface(str, c, bold);
if (txt) { if (txt) {
blitTextSurf(surf, x, y, alignW, txt, just); blitTextSurf(surf, x, y, alignW, txt, just);