Removed FocusBugWorkaround() #581

This commit is contained in:
Dimitris Panokostas 2020-02-07 10:36:53 +01:00
parent 615e9520e7
commit 0c56349025
9 changed files with 43 additions and 78 deletions

View file

@ -200,7 +200,7 @@ static void ExitCreateFilesysHardfile()
static void CreateFilesysHardfileLoop()
{
FocusBugWorkaround(wndCreateFilesysHardfile);
//FocusBugWorkaround(wndCreateFilesysHardfile);
int gotEvent = 0;
SDL_Event event;

View file

@ -371,7 +371,7 @@ static void ExitEditFilesysHardfile()
static void EditFilesysHardfileLoop()
{
FocusBugWorkaround(wndEditFilesysHardfile);
//FocusBugWorkaround(wndEditFilesysHardfile);
int gotEvent = 0;
SDL_Event event;

View file

@ -211,7 +211,7 @@ static void ExitEditFilesysVirtual()
static void EditFilesysVirtualLoop()
{
FocusBugWorkaround(wndEditFilesysVirtual);
//FocusBugWorkaround(wndEditFilesysVirtual);
int gotEvent = 0;
SDL_Event event;
@ -359,7 +359,7 @@ static void EditFilesysVirtualLoop()
}
//-------------------------------------------------
// Send event to guichan-controls
// Send event to guisan-controls
//-------------------------------------------------
#ifdef ANDROID
androidsdl_event(event, gui_input);

View file

@ -58,14 +58,14 @@ public:
int getNumberOfElements() override
{
return dirs.size() + files.size();
return int(dirs.size() + files.size());
}
std::string getElementAt(const int i) override
{
if (i >= dirs.size() + files.size() || i < 0)
if (i >= int(dirs.size() + files.size()) || i < 0)
return "---";
if (i < dirs.size())
if (i < int(dirs.size()))
return dirs[i];
return files[i - dirs.size()];
}
@ -78,7 +78,7 @@ public:
FilterFiles(&files, filefilter);
}
bool isDir(unsigned int i) const
[[nodiscard]] bool isDir(const unsigned int i) const
{
return (i < dirs.size());
}
@ -134,7 +134,7 @@ static void checkfoldername(char* current)
if ((dir = opendir(current)))
{
fileList->changeDir(current);
char* ptr = realpath(current, actualpath);
const auto ptr = realpath(current, actualpath);
strncpy(workingDir, ptr, MAX_DPATH);
closedir(dir);
}
@ -225,9 +225,9 @@ static void InitSelectFile(const char* title)
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
txtCurrent->setPosition(DISTANCE_BORDER, 10);
#ifdef ANDROID
txtCurrent->setEnabled(true);
editFilePathActionListener = new EditFilePathActionListener();
txtCurrent->addActionListener(editFilePathActionListener);
txtCurrent->setEnabled(true);
editFilePathActionListener = new EditFilePathActionListener();
txtCurrent->addActionListener(editFilePathActionListener);
#else
txtCurrent->setEnabled(false);
#endif
@ -245,11 +245,7 @@ static void InitSelectFile(const char* title)
scrAreaFiles->setBorderSize(1);
scrAreaFiles->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
scrAreaFiles->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
#ifdef ANDROID
scrAreaFiles->setScrollbarWidth(30);
#else
scrAreaFiles->setScrollbarWidth(20);
#endif
scrAreaFiles->setScrollbarWidth(30);
scrAreaFiles->setBaseColor(gui_baseCol);
if (createNew)
@ -343,9 +339,7 @@ static void navigate_left()
static void SelectFileLoop()
{
FocusBugWorkaround(wndSelectFile);
int gotEvent = 0;
auto got_event = 0;
SDL_Event event;
SDL_Event touch_event;
while (SDL_PollEvent(&event))
@ -353,7 +347,7 @@ static void SelectFileLoop()
switch (event.type)
{
case SDL_KEYDOWN:
gotEvent = 1;
got_event = 1;
switch (event.key.keysym.sym)
{
case VK_ESCAPE:
@ -385,7 +379,7 @@ static void SelectFileLoop()
case SDL_CONTROLLER_AXIS_LEFTY:
if (gui_joystick)
{
gotEvent = 1;
got_event = 1;
const int hat = SDL_JoystickGetHat(gui_joystick, 0);
if (SDL_JoystickGetButton(gui_joystick, host_input_buttons[0].south_button))
@ -427,37 +421,37 @@ static void SelectFileLoop()
break;
case SDL_FINGERDOWN:
gotEvent = 1;
got_event = 1;
memcpy(&touch_event, &event, sizeof event);
touch_event.type = SDL_MOUSEBUTTONDOWN;
touch_event.button.which = 0;
touch_event.button.button = SDL_BUTTON_LEFT;
touch_event.button.state = SDL_PRESSED;
touch_event.button.x = gui_graphics->getTarget()->w * event.tfinger.x;
touch_event.button.y = gui_graphics->getTarget()->h * event.tfinger.y;
touch_event.button.x = float(gui_graphics->getTarget()->w) * event.tfinger.x;
touch_event.button.y = float(gui_graphics->getTarget()->h) * event.tfinger.y;
gui_input->pushInput(touch_event);
break;
case SDL_FINGERUP:
gotEvent = 1;
got_event = 1;
memcpy(&touch_event, &event, sizeof event);
touch_event.type = SDL_MOUSEBUTTONUP;
touch_event.button.which = 0;
touch_event.button.button = SDL_BUTTON_LEFT;
touch_event.button.state = SDL_RELEASED;
touch_event.button.x = gui_graphics->getTarget()->w * event.tfinger.x;
touch_event.button.y = gui_graphics->getTarget()->h * event.tfinger.y;
touch_event.button.x = float(gui_graphics->getTarget()->w) * event.tfinger.x;
touch_event.button.y = float(gui_graphics->getTarget()->h) * event.tfinger.y;
gui_input->pushInput(touch_event);
break;
case SDL_FINGERMOTION:
gotEvent = 1;
got_event = 1;
memcpy(&touch_event, &event, sizeof event);
touch_event.type = SDL_MOUSEMOTION;
touch_event.motion.which = 0;
touch_event.motion.state = 0;
touch_event.motion.x = gui_graphics->getTarget()->w * event.tfinger.x;
touch_event.motion.y = gui_graphics->getTarget()->h * event.tfinger.y;
touch_event.motion.x = float(gui_graphics->getTarget()->w) * event.tfinger.x;
touch_event.motion.y = float(gui_graphics->getTarget()->h) * event.tfinger.y;
gui_input->pushInput(touch_event);
break;
@ -467,7 +461,7 @@ static void SelectFileLoop()
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEMOTION:
case SDL_MOUSEWHEEL:
gotEvent = 1;
got_event = 1;
break;
default:
@ -484,7 +478,7 @@ static void SelectFileLoop()
#endif
}
if (gotEvent)
if (got_event)
{
// Now we let the Gui object perform its logic.
uae_gui->logic();

View file

@ -73,7 +73,7 @@ public:
std::string getElementAt(const int i) override
{
if (i >= dirs.size() || i < 0)
if (i >= int(dirs.size()) || i < 0)
return "---";
return dirs[i];
}
@ -187,11 +187,7 @@ static void InitSelectFolder(const char* title)
scrAreaFolders->setBorderSize(1);
scrAreaFolders->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
scrAreaFolders->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
#ifdef ANDROID
scrAreaFolders->setScrollbarWidth(30);
#else
scrAreaFolders->setScrollbarWidth(20);
#endif
scrAreaFolders->setScrollbarWidth(30);
scrAreaFolders->setBaseColor(gui_baseCol);
wndSelectFolder->add(cmdOK);
@ -250,9 +246,7 @@ static void navigate_left()
static void SelectFolderLoop()
{
FocusBugWorkaround(wndSelectFolder);
int gotEvent = 0;
auto got_event = 0;
SDL_Event event;
SDL_Event touch_event;
while (SDL_PollEvent(&event))
@ -260,7 +254,7 @@ static void SelectFolderLoop()
switch (event.type)
{
case SDL_KEYDOWN:
gotEvent = 1;
got_event = 1;
switch (event.key.keysym.sym)
{
case VK_ESCAPE:
@ -292,7 +286,7 @@ static void SelectFolderLoop()
case SDL_CONTROLLER_AXIS_LEFTY:
if (gui_joystick)
{
gotEvent = 1;
got_event = 1;
const int hat = SDL_JoystickGetHat(gui_joystick, 0);
if (SDL_JoystickGetButton(gui_joystick, host_input_buttons[0].south_button))
@ -339,37 +333,37 @@ static void SelectFolderLoop()
break;
case SDL_FINGERDOWN:
gotEvent = 1;
got_event = 1;
memcpy(&touch_event, &event, sizeof event);
touch_event.type = SDL_MOUSEBUTTONDOWN;
touch_event.button.which = 0;
touch_event.button.button = SDL_BUTTON_LEFT;
touch_event.button.state = SDL_PRESSED;
touch_event.button.x = gui_graphics->getTarget()->w * event.tfinger.x;
touch_event.button.y = gui_graphics->getTarget()->h * event.tfinger.y;
touch_event.button.x = float(gui_graphics->getTarget()->w) * event.tfinger.x;
touch_event.button.y = float(gui_graphics->getTarget()->h) * event.tfinger.y;
gui_input->pushInput(touch_event);
break;
case SDL_FINGERUP:
gotEvent = 1;
got_event = 1;
memcpy(&touch_event, &event, sizeof event);
touch_event.type = SDL_MOUSEBUTTONUP;
touch_event.button.which = 0;
touch_event.button.button = SDL_BUTTON_LEFT;
touch_event.button.state = SDL_RELEASED;
touch_event.button.x = gui_graphics->getTarget()->w * event.tfinger.x;
touch_event.button.y = gui_graphics->getTarget()->h * event.tfinger.y;
touch_event.button.x = float(gui_graphics->getTarget()->w) * event.tfinger.x;
touch_event.button.y = float(gui_graphics->getTarget()->h) * event.tfinger.y;
gui_input->pushInput(touch_event);
break;
case SDL_FINGERMOTION:
gotEvent = 1;
got_event = 1;
memcpy(&touch_event, &event, sizeof event);
touch_event.type = SDL_MOUSEMOTION;
touch_event.motion.which = 0;
touch_event.motion.state = 0;
touch_event.motion.x = gui_graphics->getTarget()->w * event.tfinger.x;
touch_event.motion.y = gui_graphics->getTarget()->h * event.tfinger.y;
touch_event.motion.x = float(gui_graphics->getTarget()->w) * event.tfinger.x;
touch_event.motion.y = float(gui_graphics->getTarget()->h) * event.tfinger.y;
gui_input->pushInput(touch_event);
break;
@ -379,7 +373,7 @@ static void SelectFolderLoop()
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEMOTION:
case SDL_MOUSEWHEEL:
gotEvent = 1;
got_event = 1;
break;
default:
@ -396,7 +390,7 @@ static void SelectFolderLoop()
#endif
}
if (gotEvent)
if (got_event)
{
// Now we let the Gui object perform its logic.
uae_gui->logic();

View file

@ -129,8 +129,6 @@ static void ExitShowHelp(void)
static void ShowHelpLoop(void)
{
FocusBugWorkaround(wndShowHelp);
int gotEvent = 0;
SDL_Event event;
SDL_Event touch_event;

View file

@ -103,8 +103,6 @@ static void ExitShowMessage()
static void ShowMessageWaitInputLoop()
{
FocusBugWorkaround(wndShowMessage);
int gotEvent = 0;
SDL_Event event;
while (SDL_PollEvent(&event))
@ -164,8 +162,6 @@ static void navigate_left_right()
static void ShowMessageLoop()
{
FocusBugWorkaround(wndShowMessage);
int gotEvent = 0;
SDL_Event event;
SDL_Event touch_event;

View file

@ -149,8 +149,6 @@ bool HelpPanelOnScreen(std::vector<std::string> &helptext);
void RefreshAllPanels(void);
void RegisterRefreshFunc(void (*func)(void));
void FocusBugWorkaround(gcn::Window* wnd);
void DisableResume(void);
bool ShowMessage(const char* title, const char* line1, const char* line2, const char* button1, const char* button2);

View file

@ -212,21 +212,6 @@ void RegisterRefreshFunc(void (*func)(void))
refreshFuncAfterDraw = func;
}
void FocusBugWorkaround(gcn::Window* wnd)
{
// When modal dialog opens via mouse, the dialog will not
// have the focus unless there is a mouse click. We simulate the click...
SDL_Event event;
event.type = SDL_MOUSEBUTTONDOWN;
event.button.button = SDL_BUTTON_LEFT;
event.button.state = SDL_PRESSED;
event.button.x = wnd->getX() + 2;
event.button.y = wnd->getY() + 2;
gui_input->pushInput(event);
event.type = SDL_MOUSEBUTTONUP;
gui_input->pushInput(event);
}
static void ShowHelpRequested()
{
vector<string> helptext;