Change Epplet_send_ipc() to printf() style
And eliminate ECommsSend().
This commit is contained in:
parent
a95cebeea1
commit
ef5b344116
91
api/epplet.c
91
api/epplet.c
|
@ -129,7 +129,7 @@ struct _etimer {
|
||||||
ETimer *next;
|
ETimer *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ESYNC ECommsSend("nop");free(ECommsWaitForMessage());
|
#define ESYNC Epplet_send_ipc("nop");free(ECommsWaitForMessage());
|
||||||
|
|
||||||
/* The structures for the config file management ... */
|
/* The structures for the config file management ... */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -143,7 +143,6 @@ static void CommsSetup(void);
|
||||||
static void CommsFindCommsWindow(void);
|
static void CommsFindCommsWindow(void);
|
||||||
static void CommsHandleDestroy(Window win);
|
static void CommsHandleDestroy(Window win);
|
||||||
static int CommsHandlePropertyNotify(XEvent * ev);
|
static int CommsHandlePropertyNotify(XEvent * ev);
|
||||||
static void ECommsSend(const char *s);
|
|
||||||
static char *ECommsGet(XEvent * ev);
|
static char *ECommsGet(XEvent * ev);
|
||||||
static char *ECommsWaitForMessage(void);
|
static char *ECommsWaitForMessage(void);
|
||||||
|
|
||||||
|
@ -396,12 +395,6 @@ EXFreeGC(GC gc)
|
||||||
XFreeGC(disp, gc);
|
XFreeGC(disp, gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Epplet_send_ipc(const char *s)
|
|
||||||
{
|
|
||||||
ECommsSend(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
Epplet_wait_for_ipc(void)
|
Epplet_wait_for_ipc(void)
|
||||||
{
|
{
|
||||||
|
@ -540,16 +533,13 @@ Epplet_Init(const char *name, const char *version, const char *info,
|
||||||
win_info = info;
|
win_info = info;
|
||||||
xid_context = XUniqueContext();
|
xid_context = XUniqueContext();
|
||||||
CommsSetup();
|
CommsSetup();
|
||||||
snprintf(s, sizeof(s), "set clientname %s", win_name);
|
Epplet_send_ipc("set clientname %s", win_name);
|
||||||
ECommsSend(s);
|
Epplet_send_ipc("set version %s", win_version);
|
||||||
snprintf(s, sizeof(s), "set version %s", win_version);
|
Epplet_send_ipc("set info %s", win_info);
|
||||||
ECommsSend(s);
|
|
||||||
snprintf(s, sizeof(s), "set info %s", win_info);
|
|
||||||
ECommsSend(s);
|
|
||||||
ESYNC;
|
ESYNC;
|
||||||
|
|
||||||
/* Check if the epplet imageclasses are there. */
|
/* Check if the epplet imageclasses are there. */
|
||||||
ECommsSend("imageclass EPPLET_BUTTON query");
|
Epplet_send_ipc("imageclass EPPLET_BUTTON query");
|
||||||
msg = ECommsWaitForMessage();
|
msg = ECommsWaitForMessage();
|
||||||
if (!msg || strstr(msg, "not"))
|
if (!msg || strstr(msg, "not"))
|
||||||
{
|
{
|
||||||
|
@ -651,7 +641,7 @@ Epplet_internal_create_window(int w, int h, const char *title, char vertical,
|
||||||
ESYNC;
|
ESYNC;
|
||||||
|
|
||||||
/* Check if the epplet imageclasses are there. */
|
/* Check if the epplet imageclasses are there. */
|
||||||
ECommsSend("imageclass EPPLET_BUTTON query");
|
Epplet_send_ipc("imageclass EPPLET_BUTTON query");
|
||||||
msg = ECommsWaitForMessage();
|
msg = ECommsWaitForMessage();
|
||||||
if (!msg || strstr(msg, "not"))
|
if (!msg || strstr(msg, "not"))
|
||||||
{
|
{
|
||||||
|
@ -998,19 +988,13 @@ Epplet_show(void)
|
||||||
void
|
void
|
||||||
Epplet_remember(void)
|
Epplet_remember(void)
|
||||||
{
|
{
|
||||||
char s[1024];
|
Epplet_send_ipc("wop %x snap all auto", (unsigned int)mainwin->win);
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "wop %x snap all auto", (unsigned int)mainwin->win);
|
|
||||||
ECommsSend(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Epplet_unremember(void)
|
Epplet_unremember(void)
|
||||||
{
|
{
|
||||||
char s[1024];
|
Epplet_send_ipc("wop %x snap none", (unsigned int)mainwin->win);
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "wop %x snap none", (unsigned int)mainwin->win);
|
|
||||||
ECommsSend(s);
|
|
||||||
ESYNC;
|
ESYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,11 +1007,8 @@ Epplet_get_main_window(void)
|
||||||
void
|
void
|
||||||
Epplet_imageclass_apply(const char *iclass, const char *state, Window ww)
|
Epplet_imageclass_apply(const char *iclass, const char *state, Window ww)
|
||||||
{
|
{
|
||||||
char s[1024];
|
Epplet_send_ipc("imageclass %s apply 0x%x %s", iclass,
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "imageclass %s apply 0x%x %s", iclass,
|
|
||||||
(unsigned int)ww, state);
|
(unsigned int)ww, state);
|
||||||
ECommsSend(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1035,12 +1016,11 @@ Epplet_imageclass_paste(const char *iclass, const char *state, Window ww,
|
||||||
int x, int y, int w, int h)
|
int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
Pixmap p = 0, m = 0;
|
Pixmap p = 0, m = 0;
|
||||||
char s[1024], *msg;
|
char *msg;
|
||||||
GC gc;
|
GC gc;
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "imageclass %s apply_copy 0x%x %s %i %i", iclass,
|
Epplet_send_ipc("imageclass %s apply_copy 0x%x %s %i %i", iclass,
|
||||||
(unsigned int)ww, state, w, h);
|
(unsigned int)ww, state, w, h);
|
||||||
ECommsSend(s);
|
|
||||||
msg = ECommsWaitForMessage();
|
msg = ECommsWaitForMessage();
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
|
@ -1050,9 +1030,8 @@ Epplet_imageclass_paste(const char *iclass, const char *state, Window ww,
|
||||||
XSetClipMask(disp, gc, m);
|
XSetClipMask(disp, gc, m);
|
||||||
XSetClipOrigin(disp, gc, x, y);
|
XSetClipOrigin(disp, gc, x, y);
|
||||||
XCopyArea(disp, p, context_win->win, gc, 0, 0, w, h, x, y);
|
XCopyArea(disp, p, context_win->win, gc, 0, 0, w, h, x, y);
|
||||||
snprintf(s, sizeof(s), "imageclass %s free_pixmap 0x%x", iclass,
|
Epplet_send_ipc("imageclass %s free_pixmap 0x%x", iclass,
|
||||||
(unsigned int)p);
|
(unsigned int)p);
|
||||||
ECommsSend(s);
|
|
||||||
EXFreeGC(gc);
|
EXFreeGC(gc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1062,12 +1041,11 @@ Epplet_imageclass_get_pixmaps(const char *iclass, const char *state, Pixmap * p,
|
||||||
Pixmap * m, int w, int h)
|
Pixmap * m, int w, int h)
|
||||||
{
|
{
|
||||||
Pixmap pp = 0, mm = 0;
|
Pixmap pp = 0, mm = 0;
|
||||||
char s[1024], *msg;
|
char *msg;
|
||||||
GC gc, mgc;
|
GC gc, mgc;
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "imageclass %s apply_copy 0x%x %s %i %i", iclass,
|
Epplet_send_ipc("imageclass %s apply_copy 0x%x %s %i %i", iclass,
|
||||||
(unsigned int)context_win->win, state, w, h);
|
(unsigned int)context_win->win, state, w, h);
|
||||||
ECommsSend(s);
|
|
||||||
msg = ECommsWaitForMessage();
|
msg = ECommsWaitForMessage();
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
|
@ -1093,9 +1071,8 @@ Epplet_imageclass_get_pixmaps(const char *iclass, const char *state, Pixmap * p,
|
||||||
XCopyArea(disp, mm, *m, mgc, 0, 0, w, h, 0, 0);
|
XCopyArea(disp, mm, *m, mgc, 0, 0, w, h, 0, 0);
|
||||||
EXFreeGC(mgc);
|
EXFreeGC(mgc);
|
||||||
}
|
}
|
||||||
snprintf(s, sizeof(s), "imageclass %s free_pixmap 0x%x", iclass,
|
Epplet_send_ipc("imageclass %s free_pixmap 0x%x", iclass,
|
||||||
(unsigned int)pp);
|
(unsigned int)pp);
|
||||||
ECommsSend(s);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,20 +1080,16 @@ void
|
||||||
Epplet_textclass_draw(const char *iclass, const char *state, Window ww, int x,
|
Epplet_textclass_draw(const char *iclass, const char *state, Window ww, int x,
|
||||||
int y, const char *txt)
|
int y, const char *txt)
|
||||||
{
|
{
|
||||||
char s[1024];
|
Epplet_send_ipc("textclass %s apply 0x%x %i %i %s %s", iclass,
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "textclass %s apply 0x%x %i %i %s %s", iclass,
|
|
||||||
(unsigned int)ww, x, y, state, txt);
|
(unsigned int)ww, x, y, state, txt);
|
||||||
ECommsSend(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Epplet_textclass_get_size(const char *iclass, int *w, int *h, const char *txt)
|
Epplet_textclass_get_size(const char *iclass, int *w, int *h, const char *txt)
|
||||||
{
|
{
|
||||||
char s[1024], *msg = NULL;
|
char *msg;
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "textclass %s query_size %s", iclass, txt);
|
Epplet_send_ipc("textclass %s query_size %s", iclass, txt);
|
||||||
ECommsSend(s);
|
|
||||||
msg = ECommsWaitForMessage();
|
msg = ECommsWaitForMessage();
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
|
@ -1786,19 +1759,28 @@ CommsFindCommsWindow(void)
|
||||||
XSelectInput(dd, comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
XSelectInput(dd, comms_win, StructureNotifyMask | SubstructureNotifyMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
ECommsSend(const char *s)
|
Epplet_send_ipc(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
static Atom a = None;
|
||||||
|
va_list args;
|
||||||
|
char buf[1024];
|
||||||
char ss[21];
|
char ss[21];
|
||||||
int i, j, k, len;
|
int i, j, k, len;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Atom a = 0;
|
|
||||||
|
|
||||||
if (!s || !dd)
|
if (!fmt || !dd)
|
||||||
return;
|
return;
|
||||||
len = strlen(s);
|
|
||||||
if (!a)
|
if (!a)
|
||||||
a = XInternAtom(dd, "ENL_MSG", False);
|
a = XInternAtom(dd, "ENL_MSG", False);
|
||||||
|
|
||||||
|
va_start(args, fmt);
|
||||||
|
len = vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
if (len >= (int)sizeof(buf))
|
||||||
|
len = sizeof(buf) - 1;
|
||||||
|
|
||||||
ev.xclient.type = ClientMessage;
|
ev.xclient.type = ClientMessage;
|
||||||
ev.xclient.serial = 0;
|
ev.xclient.serial = 0;
|
||||||
ev.xclient.send_event = True;
|
ev.xclient.send_event = True;
|
||||||
|
@ -1811,8 +1793,8 @@ ECommsSend(const char *s)
|
||||||
snprintf(ss, sizeof(ss), "%8x", (int)my_win);
|
snprintf(ss, sizeof(ss), "%8x", (int)my_win);
|
||||||
for (j = 0; j < 12; j++)
|
for (j = 0; j < 12; j++)
|
||||||
{
|
{
|
||||||
ss[8 + j] = s[i + j];
|
ss[8 + j] = buf[i + j];
|
||||||
if (!s[i + j])
|
if (!buf[i + j])
|
||||||
j = 12;
|
j = 12;
|
||||||
}
|
}
|
||||||
ss[20] = 0;
|
ss[20] = 0;
|
||||||
|
@ -5377,7 +5359,7 @@ void
|
||||||
Epplet_dialog_ok(const char *fmt, ...)
|
Epplet_dialog_ok(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char buf[1000], s[1024];
|
char buf[1000];
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
|
@ -5389,8 +5371,7 @@ Epplet_dialog_ok(const char *fmt, ...)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "dialog_ok %s", buf);
|
Epplet_send_ipc("dialog_ok %s", buf);
|
||||||
ECommsSend(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -122,8 +122,8 @@ EAPI int Epplet_gadget_get_type(Epplet_gadget gad);
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* IPC calls */
|
/* IPC calls */
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/* send the string "s" to Enlightenment */
|
/* send command to e16 */
|
||||||
EAPI void Epplet_send_ipc(const char *s);
|
EAPI void Epplet_send_ipc(const char *fmt, ...);
|
||||||
|
|
||||||
/* sit and wait for an IPc message - nothing happens whilst waiting no */
|
/* sit and wait for an IPc message - nothing happens whilst waiting no */
|
||||||
/* timers run, no events or anything else is handled. */
|
/* timers run, no events or anything else is handled. */
|
||||||
|
|
|
@ -218,30 +218,16 @@ set_background(int tiled, int keep_aspect)
|
||||||
|
|
||||||
snprintf(bg_name, sizeof(bg_name), "E_SLIDES_BG_%s", filenames[CUR_PIC()]);
|
snprintf(bg_name, sizeof(bg_name), "E_SLIDES_BG_%s", filenames[CUR_PIC()]);
|
||||||
|
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.file %s/%s", bg_name, path,
|
Epplet_send_ipc("background %s bg.file %s/%s", bg_name, path,
|
||||||
filenames[CUR_PIC()]);
|
filenames[CUR_PIC()]);
|
||||||
Epplet_send_ipc(buff);
|
Epplet_send_ipc("background %s bg.solid 0 0 0", bg_name);
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.solid 0 0 0", bg_name);
|
Epplet_send_ipc("background %s bg.tile %d", bg_name, tiled);
|
||||||
Epplet_send_ipc(buff);
|
Epplet_send_ipc("background %s bg.keep_aspect %d", bg_name, keep_aspect);
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.tile %d", bg_name, tiled);
|
Epplet_send_ipc("background %s bg.xperc %d", bg_name, (tiled ? 0 : 1024));
|
||||||
Epplet_send_ipc(buff);
|
Epplet_send_ipc("background %s bg.yperc %d", bg_name, (tiled ? 0 : 1024));
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.keep_aspect %d", bg_name,
|
Epplet_send_ipc("background %s bg.xjust %d", bg_name, (tiled ? 0 : 512));
|
||||||
keep_aspect);
|
Epplet_send_ipc("background %s bg.yjust %d", bg_name, (tiled ? 0 : 512));
|
||||||
Epplet_send_ipc(buff);
|
Epplet_send_ipc("use_bg %s %d", bg_name, current_desk);
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.xperc %d", bg_name,
|
|
||||||
(tiled ? 0 : 1024));
|
|
||||||
Epplet_send_ipc(buff);
|
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.yperc %d", bg_name,
|
|
||||||
(tiled ? 0 : 1024));
|
|
||||||
Epplet_send_ipc(buff);
|
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.xjust %d", bg_name,
|
|
||||||
(tiled ? 0 : 512));
|
|
||||||
Epplet_send_ipc(buff);
|
|
||||||
snprintf(buff, sizeof(buff), "background %s bg.yjust %d", bg_name,
|
|
||||||
(tiled ? 0 : 512));
|
|
||||||
Epplet_send_ipc(buff);
|
|
||||||
snprintf(buff, sizeof(buff), "use_bg %s %d", bg_name, current_desk);
|
|
||||||
Epplet_send_ipc(buff);
|
|
||||||
Esync();
|
Esync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue