1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2025-04-21 12:27:27 +03:00

Code factorisation (Add function inject_user_event() to utilities)

This commit is contained in:
Paul Cercueil
2013-08-28 13:14:08 -04:00
parent 3ff6dc93f2
commit 5d8fb6520f
5 changed files with 34 additions and 39 deletions

View File

@@ -10,19 +10,14 @@
#include "inputmanager.h"
#include "monitor.h"
#include "utilities.h"
void Monitor::inject_event(bool is_add, const char *path)
{
SDL_UserEvent e = {
.type = SDL_USEREVENT,
.code = is_add ? OPEN_PACKAGE : REMOVE_LINKS,
.data1 = strdup(path),
.data2 = NULL,
};
/* Inject an user event, that will be handled as a "repaint"
* event by the InputManager */
SDL_PushEvent((SDL_Event *) &e);
if (is_add)
inject_user_event(OPEN_PACKAGE, strdup(path));
else
inject_user_event(REMOVE_LINKS, strdup(path));
}
bool Monitor::event_accepted(struct inotify_event &event)
@@ -70,8 +65,7 @@ int Monitor::run(void)
if (!event_accepted(event))
continue;
inject_event(event.mask & (IN_MOVED_TO | IN_CLOSE_WRITE |
IN_CREATE), buf);
inject_event(event.mask & (IN_MOVED_TO | IN_CLOSE_WRITE | IN_CREATE), buf);
}
return 0;