From c8b0b9251307862e64041ebe803281af5c8fb313 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Sat, 4 Aug 2018 16:13:20 +0200 Subject: [PATCH] Remove needless code; fix KWin compositor disabling; enable GTK dialogs on XFCE --- src/i18n.cpp | 13 +++---------- src/main.cpp | 1 + src/oneshot.cpp | 35 +++++++++++++---------------------- src/settingsmenu.cpp | 2 -- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/i18n.cpp b/src/i18n.cpp index defd21d..f882162 100644 --- a/src/i18n.cpp +++ b/src/i18n.cpp @@ -2,7 +2,6 @@ Really hacked-together naiive implementation of gettext */ #include "i18n.h" -#include "debugwriter.h" #include #include @@ -16,16 +15,13 @@ int family = LOCALE_FAMILY_LATIN; size_t readSize; int getLocaleFamily() { - Debug() << "Get family:" << family; return family; } const char* findtext(unsigned int msgid, const char* fallback) { - Debug() << "Looking for msg" << msgid << fallback; if (msgid >= nStr) { return fallback; } else { - Debug() << "found" << 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) { readSize = fread(ptr, size, count, stream); if (readSize != count) { - Debug() << "Short read in i18n!"; } } void loadLocale(const char* locale) { - Debug() << "Load locale:" << locale; char pathbuf[100]; FILE* locfile; char header[8]; @@ -73,18 +67,17 @@ void loadLocale(const char* locale) { if (locfile) { _read(header, 1, 8, locfile); if (!strcmp(header, LOC_HEADER)) { - //read number of strs in this file + // Read number of strs in this file _read(&nStr, 4, 1, locfile); strdict = (char**)malloc(sizeof(char*) * nStr); 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); strdict[i] = (char*)malloc(strSize+1); if (strSize > 0) { - //read the contents of the next string + // Read the contents of the next string _read(strdict[i], 1, strSize, locfile); strdict[i][strSize] = 0; - Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; } strdict[i][strSize] = 0; } diff --git a/src/main.cpp b/src/main.cpp index 86800cd..13b0249 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -195,6 +195,7 @@ int main(int argc, char *argv[]) SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1"); + SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); /* initialize SDL first */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0) diff --git a/src/oneshot.cpp b/src/oneshot.cpp index a667606..84f0484 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -13,7 +13,7 @@ #include #include -//OS-Specific code +// OS-Specific code #if defined _WIN32 #define OS_W32 #define WIN32_LEAN_AND_MEAN @@ -296,6 +296,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : gtk_init(0, 0); } else if (desktop.find("xfce") != std::string::npos) { desktopEnv = "xfce"; + gtk_init(0, 0); } else if (desktop.find("kde") != std::string::npos) { desktopEnv = "kde"; } 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) title = ""; #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}; gdk_threads_add_idle(linux_dialog, &data); gtk_main(); @@ -485,16 +491,15 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) } #endif - //SDL message box - - //Button data + // SDL message box + // Button data static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"}; static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk}; 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 buttonsYesNo[] = {buttonNo, buttonYes}; - //Messagebox data + // Messagebox data SDL_MessageBoxData data; data.window = NULL;//p->window; data.colorScheme = 0; @@ -529,7 +534,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) break; } - //Set buttons + // Set buttons switch (type) { case MSG_INFO: @@ -545,7 +550,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) break; } - //Show messagebox + // Show messagebox #ifdef OS_W32 PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); #endif @@ -586,20 +591,6 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f // Disable text input 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; } diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp index d889f03..4489690 100644 --- a/src/settingsmenu.cpp +++ b/src/settingsmenu.cpp @@ -35,7 +35,6 @@ #include "util.h" #include "sharedstate.h" #include "i18n.h" -#include "debugwriter.h" #include @@ -539,7 +538,6 @@ struct SettingsMenuPrivate int x, int y, int alignW, Justification just, SDL_Color c, bool bold = false) { - Debug() << "draw text:" << str; SDL_Surface *txt = createTextSurface(str, c, bold); if (txt) { blitTextSurf(surf, x, y, alignW, txt, just);