void *win;
int (*rotate_cb) (void *, void *, void *);
bundle *dupped_bundle;
- struct _syspopup *next;
};
typedef struct _syspopup syspopup;
-syspopup *_syspopup_get_head(void);
int _syspopup_add_new(syspopup *pinfo);
syspopup *_syspopup_find(const char *name);
syspopup *_syspopup_find_by_id(int id);
void _syspopup_del(int id);
-int _syspopup_init(void (*term_handler)(void *),
- gboolean (*timeout_handler)(gpointer));
+int _syspopup_init(void (*term_handler)(gpointer, gpointer),
+ gboolean (*timeout_handler)(gpointer));
int _syspopup_reset_timeout(syspopup *sp, syspopup_info_t *info);
int _syspopup_set_term_type(syspopup *sp, syspopup_info_t *info);
int _syspopup_set_endkey_type(syspopup *sp, syspopup_info_t *info);
#define SYSPOPUP_NAME "_INTERNAL_SYSPOPUP_NAME_"
-static syspopup *syspopup_head = NULL;
-
+static GList *syspopup_list = NULL;
static int initialized = 0;
static int sp_id = 0;
-static void (*_term_handler)(void *data);
+static void (*_term_handler)(gpointer data, gpointer user_data);
static gboolean (*_timeout_handler)(gpointer data);
-syspopup *_syspopup_get_head(void)
-{
- return syspopup_head;
-}
-
int _syspopup_add_new(syspopup *sp)
{
if (sp == NULL)
return -1;
sp->id = sp_id++;
- sp->next = syspopup_head;
- syspopup_head = sp;
+ syspopup_list = g_list_append(syspopup_list, sp);
return 0;
}
syspopup *_syspopup_find(const char *name)
{
- syspopup *tmp;
+ GList *list;
+ syspopup *sp;
- tmp = syspopup_head;
- while (tmp) {
- if (tmp->name) {
- if (strcmp(tmp->name, name) == 0)
- return tmp;
- }
+ if (syspopup_list == NULL)
+ return NULL;
+
+ list = g_list_first(syspopup_list);
+ while (list) {
+ sp = list->data;
+ if (sp->name && strcmp(sp->name, name) == 0)
+ return sp;
- tmp = tmp->next;
+ list = list->next;
}
return NULL;
syspopup *_syspopup_find_by_id(int id)
{
- syspopup *tmp;
+ GList *list;
+ syspopup *sp;
- tmp = syspopup_head;
- while (tmp) {
- if (tmp->id == id)
- return tmp;
+ if (syspopup_list == NULL)
+ return NULL;
+
+ list = g_list_first(syspopup_list);
+ while (list) {
+ sp = list->data;
+ if (sp->id == id)
+ return sp;
- tmp = tmp->next;
+ list = list->next;
}
return NULL;
void _syspopup_del(int id)
{
- syspopup *tmp;
- syspopup *target;
-
- if (syspopup_head == NULL)
- return;
+ GList *list;
+ syspopup *sp;
- target = _syspopup_find_by_id(id);
- if (target == NULL)
+ if (syspopup_list == NULL)
return;
- if (syspopup_head == target) {
- syspopup_head = target->next;
- __syspopup_free(target);
- return;
- }
-
- tmp = syspopup_head;
- while (tmp) {
- if (tmp->next == target) {
- tmp->next = target->next;
- __syspopup_free(target);
+ list = g_list_first(syspopup_list);
+ while (list) {
+ sp = list->data;
+ if (sp->id == id) {
+ syspopup_list = g_list_remove(syspopup_list, sp);
+ __syspopup_free(sp);
return;
}
- tmp = tmp->next;
+ list = list->next;
}
}
if (signal_name
&& strcmp(signal_name, SYSPOPUP_DBUS_SP_TERM_SIGNAL) == 0) {
if (_term_handler)
- _term_handler(NULL);
+ g_list_foreach(syspopup_list, _term_handler, NULL);
_D("term handler has been called");
}
}
-int _syspopup_init(void (*term_handler)(void *),
- gboolean (*timeout_handler)(gpointer))
+int _syspopup_init(void (*term_handler)(gpointer, gpointer),
+ gboolean (*timeout_handler)(gpointer))
{
GDBusConnection *conn = NULL;
GError *err = NULL;
#include "syspopup_wayland.h"
#include "simple_util.h"
-static void __wl_syspopup_term_handler(void *data)
+static void __wl_syspopup_term_handler(gpointer data, gpointer user_data)
{
- syspopup *tmp;
-
- tmp = _syspopup_get_head();
- while (tmp) {
- _D("term action %d - %s", tmp->term_act, tmp->name);
-
- switch (tmp->term_act) {
- case SYSPOPUP_TERM:
- if (tmp->def_term_fn)
- tmp->def_term_fn(tmp->dupped_bundle,
- tmp->user_data);
- break;
- case SYSPOPUP_HIDE:
- if (tmp->def_term_fn)
- tmp->def_term_fn(tmp->dupped_bundle,
- tmp->user_data);
-
- ecore_wl_window_hide((Ecore_Wl_Window *)tmp->internal_data);
- break;
- default:
- _D("term action IGNORED: %s", tmp->name);
- }
-
- tmp = tmp->next;
+ syspopup *sp = data;
+
+ if (sp == NULL)
+ return;
+
+ _D("term action %d - %s", sp->term_act, sp->name);
+
+ switch (sp->term_act) {
+ case SYSPOPUP_TERM:
+ if (sp->def_term_fn)
+ sp->def_term_fn(sp->dupped_bundle, sp->user_data);
+ break;
+ case SYSPOPUP_HIDE:
+ if (sp->def_term_fn)
+ sp->def_term_fn(sp->dupped_bundle, sp->user_data);
+ ecore_wl_window_hide((Ecore_Wl_Window *)sp->internal_data);
+ break;
+ default:
+ _D("term action IGNORED: %s", sp->name);
+ break;
}
}
static void __x_rotation_set(Display *dpy, Window win, syspopup *sp);
-static void __x_syspopup_term_handler(void *data)
+static void __x_syspopup_term_handler(gpointer data, gpointer user_data)
{
- syspopup *tmp;
+ syspopup *sp = data;
Display *dpy;
Window win;
- dpy = XOpenDisplay(NULL);
- tmp = _syspopup_get_head();
- while (tmp) {
- _D("term action %d - %s", tmp->term_act, tmp->name);
-
- switch (tmp->term_act) {
- case SYSPOPUP_TERM:
- win = (Window)tmp->internal_data;
-
- if (tmp->def_term_fn)
- tmp->def_term_fn(tmp->dupped_bundle,
- tmp->user_data);
-
- XKillClient(dpy, win);
- break;
- case SYSPOPUP_HIDE:
- win = (Window)tmp->internal_data;
+ if (sp == NULL)
+ return;
- if (tmp->def_term_fn)
- tmp->def_term_fn(tmp->dupped_bundle,
- tmp->user_data);
- XUnmapWindow(dpy, win);
- break;
- default:
- _D("term action IGNORED: %s", tmp->name);
- }
+ dpy = XOpenDisplay(NULL);
+ win = (Window)sp->internal_data;
+ _D("term action %d - %s", sp->term_act, sp->name);
- tmp = tmp->next;
+ switch (sp->term_act) {
+ case SYSPOPUP_TERM:
+ if (sp->def_term_fn)
+ sp->def_term_fn(sp->dupped_bundle, sp->user_data);
+ XKillClient(dpy, win);
+ break;
+ case SYSPOPUP_HIDE:
+ if (sp->def_term_fn)
+ sp->def_term_fn(sp->dupped_bundle, sp->user_data);
+ XUnmapWindow(dpy, win);
+ break;
+ default:
+ _D("term action IGNORED: %s", tmp->name);
+ break;
}
XCloseDisplay(dpy);