Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
Tag: branch-exp
E.h buttons.c dialog.c econfig.c evhandlers.c finders.c x.c
Log Message:
Buttons and Dialogs now use new event dispatching.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.314.2.9
retrieving revision 1.314.2.10
diff -u -3 -r1.314.2.9 -r1.314.2.10
--- E.h 8 Aug 2004 22:49:04 -0000 1.314.2.9
+++ E.h 9 Aug 2004 22:35:19 -0000 1.314.2.10
@@ -1576,11 +1576,6 @@
Window WindowToEmbed);
void ButtonFindEmptySpotFor(Button * bt, const char *listname,
char dirtomove);
-int ButtonsEventExpose(XEvent * ev);
-int ButtonsEventMouseDown(XEvent * ev);
-int ButtonsEventMouseUp(XEvent * ev);
-int ButtonsEventMouseIn(XEvent * ev);
-int ButtonsEventMouseOut(XEvent * ev);
int ButtonsConfigLoad(FILE * fs);
int ButtonsConfigSave(FILE * fs);
@@ -1771,13 +1766,8 @@
void DialogAlert(const char *fmt, ...);
void DialogAlertOK(const char *fmt, ...);
-int DialogEventKeyPress(XEvent * ev);
-int DialogEventMotion(XEvent * ev);
-int DialogEventExpose(XEvent * ev);
-int DialogEventMouseDown(XEvent * ev);
-int DialogEventMouseUp(XEvent * ev);
-int DialogEventMouseIn(XEvent * ev);
-int DialogEventMouseOut(XEvent * ev);
+EWin *FindEwinByDialog(Dialog * d);
+int FindADialog(void);
/* dock.c */
void DockIt(EWin * ewin);
@@ -1945,11 +1935,6 @@
EWin **EwinListTransients(EWin * ewin, int *num, int group);
EWin **EwinListTransientFor(EWin * ewin, int *num);
EWin **ListGroupMembers(Window win, int *num);
-EWin *FindEwinByDialog(Dialog * d);
-Dialog *FindDialogButton(Window win, int *bnum);
-Dialog *FindDialog(Window win);
-int FindADialog(void);
-DItem *FindDialogItem(Window win, Dialog ** dret);
/* focus.c */
#define FOCUS_SET 0
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/buttons.c,v
retrieving revision 1.36.2.1
retrieving revision 1.36.2.2
diff -u -3 -r1.36.2.1 -r1.36.2.2
--- buttons.c 8 Aug 2004 22:31:40 -0000 1.36.2.1
+++ buttons.c 9 Aug 2004 22:35:19 -0000 1.36.2.2
@@ -63,6 +63,8 @@
unsigned int ref_count;
};
+static void ButtonHandleEvents(XEvent * ev, void *btn);
+
Button *
ButtonCreate(const char *name, int id, ImageClass * iclass,
ActionClass * aclass, TextClass * tclass, char *label, char ontop,
@@ -74,6 +76,9 @@
EDBUG(5, "ButtonCreate");
+ if (desk < 0 || desk >= ENLIGHTENMENT_CONF_NUM_DESKTOPS)
+ return NULL;
+
b = Emalloc(sizeof(Button));
b->name = Estrdup(name);
@@ -129,13 +134,12 @@
b->default_show = 1;
b->used = 0;
b->left = 0;
- b->win =
- ECreateWindow(desks.desk[desk % ENLIGHTENMENT_CONF_NUM_DESKTOPS].win,
- -100, -100, 50, 50, 0);
+ b->win = ECreateWindow(desks.desk[desk].win, -100, -100, 50, 50, 0);
XSelectInput(disp, b->win,
- ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask
- | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
+ ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
+ ButtonReleaseMask | EnterWindowMask | LeaveWindowMask |
PointerMotionMask);
+ EventCallbackRegister(b->win, 0, ButtonHandleEvents, b);
b->x = -1;
b->y = -1;
b->w = -1;
@@ -554,26 +558,25 @@
}
int
-ButtonEmbedWindow(Button * ButtonToUse, Window WindowToEmbed)
+ButtonEmbedWindow(Button * b, Window WindowToEmbed)
{
unsigned int w, h;
EDBUG(4, "ButtonEmbedWindow");
- EReparentWindow(disp, WindowToEmbed, ButtonToUse->win, 0, 0);
- ButtonToUse->inside_win = WindowToEmbed;
+ EReparentWindow(disp, WindowToEmbed, b->win, 0, 0);
+ b->inside_win = WindowToEmbed;
GetWinWH(WindowToEmbed, &w, &h);
- EMoveWindow(disp, ButtonToUse->inside_win, (ButtonToUse->w - w) >> 1,
- (ButtonToUse->h - h) >> 1);
- ButtonToUse->event_win = ECreateEventWindow(ButtonToUse->win, 0, 0, w, h);
+ EMoveWindow(disp, b->inside_win, (b->w - w) >> 1, (b->h - h) >> 1);
+ b->event_win = ECreateEventWindow(b->win, 0, 0, w, h);
+ EventCallbackRegister(b->event_win, 0, ButtonHandleEvents, b);
- XSelectInput(disp, ButtonToUse->event_win,
+ XSelectInput(disp, b->event_win,
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
LeaveWindowMask | ButtonMotionMask);
- EMoveWindow(disp, ButtonToUse->event_win, (ButtonToUse->w - w) >> 1,
- (ButtonToUse->h - h) >> 1);
- EMapRaised(disp, ButtonToUse->event_win);
+ EMoveWindow(disp, b->event_win, (b->w - w) >> 1, (b->h - h) >> 1);
+ EMapRaised(disp, b->event_win);
EDBUG_RETURN(0);
}
@@ -658,189 +661,115 @@
* Button event handlers
*/
-int
-ButtonsEventExpose(XEvent * ev)
+static void
+ButtonEventExpose(Button * b, XEvent * ev __UNUSED__)
{
- int used = 0;
- int i, num;
- Button **buttons;
- Window win = ev->xexpose.window;
-
- buttons = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
- if (buttons == NULL)
- return 0;
-
- for (i = 0; i < num; i++)
- {
- if (win != buttons[i]->win)
- continue;
-
- ButtonDraw(buttons[i]);
- used = 1;
- break;
- }
- Efree(buttons);
-
- return used;
+ ButtonDraw(b);
}
-int
-ButtonsEventMouseDown(XEvent * ev)
+static void
+ButtonEventMouseDown(Button * b, XEvent * ev)
{
- int used = 0;
- int i, num;
- Button **buttons;
Window win = ev->xbutton.window;
ActionClass *ac;
- buttons = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
- if (buttons == NULL)
- return 0;
+ GrabThePointer(win, ECSR_GRAB);
- for (i = 0; i < num; i++)
+ if (b->inside_win)
{
- if ((win != buttons[i]->win) && (win != buttons[i]->event_win))
- continue;
-
- GrabThePointer(win, ECSR_GRAB);
- if (buttons[i]->inside_win)
- {
- Window id = ev->xany.window; /* ??? */
-
- ev->xany.window = buttons[i]->inside_win;
- XSendEvent(disp, buttons[i]->inside_win, False,
- ButtonPressMask, ev);
- ev->xany.window = id;
- }
-
- Mode.button = buttons[i];
- buttons[i]->state = STATE_CLICKED;
- ButtonDraw(buttons[i]);
- ac = FindItem("ACTION_BUTTON_DRAG", 0, LIST_FINDBY_NAME,
- LIST_TYPE_ACLASS);
- if (ac)
- EventAclass(ev, NULL, ac);
- if (buttons[i]->aclass)
- EventAclass(ev, NULL, buttons[i]->aclass);
- used = 1;
- break;
+ ev->xbutton.window = b->inside_win;
+ XSendEvent(disp, b->inside_win, False, ButtonPressMask, ev);
+ ev->xbutton.window = win;
}
- Efree(buttons);
- return used;
+ Mode.button = b;
+ b->state = STATE_CLICKED;
+ ButtonDraw(b);
+
+ ac = FindItem("ACTION_BUTTON_DRAG", 0, LIST_FINDBY_NAME, LIST_TYPE_ACLASS);
+ if (ac)
+ EventAclass(ev, NULL, ac);
+ if (b->aclass)
+ EventAclass(ev, NULL, b->aclass);
}
-int
-ButtonsEventMouseUp(XEvent * ev)
+static void
+ButtonEventMouseUp(Button * b, XEvent * ev)
{
- int used = 0;
- int i, num;
- Button **buttons;
Window win = ev->xbutton.window;
- buttons = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
- if (buttons == NULL)
- return 0;
-
- for (i = 0; i < num; i++)
+ if (b->inside_win && !Mode.action_inhibit)
{
- if ((win != buttons[i]->win) && (win != buttons[i]->event_win))
- continue;
-
- if (buttons[i]->inside_win && !Mode.action_inhibit)
- {
- Window id = ev->xany.window; /* ??? */
-
- ev->xany.window = buttons[i]->inside_win;
- XSendEvent(disp, buttons[i]->inside_win, False,
- ButtonReleaseMask, ev);
- ev->xany.window = id;
- }
- Mode.button = buttons[i];
- if ((buttons[i]->state == STATE_CLICKED) && (!buttons[i]->left))
- buttons[i]->state = STATE_HILITED;
- else
- buttons[i]->state = STATE_NORMAL;
- buttons[i]->left = 0;
- ButtonDraw(buttons[i]);
- if (buttons[i]->aclass)
- EventAclass(ev, NULL, buttons[i]->aclass);
- used = 1;
- break;
+ ev->xbutton.window = b->inside_win;
+ XSendEvent(disp, b->inside_win, False, ButtonReleaseMask, ev);
+ ev->xbutton.window = win;
}
- Efree(buttons);
- return used;
+ Mode.button = b;
+ if ((b->state == STATE_CLICKED) && (!b->left))
+ b->state = STATE_HILITED;
+ else
+ b->state = STATE_NORMAL;
+ b->left = 0;
+ ButtonDraw(b);
+
+ if (b->aclass)
+ EventAclass(ev, NULL, b->aclass);
}
-int
-ButtonsEventMouseIn(XEvent * ev)
+static void
+ButtonEventMouseIn(Button * b, XEvent * ev)
{
- int used = 0;
- int i, num;
- Button **buttons;
- Window win = ev->xcrossing.window;
-
- buttons = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
- if (buttons == NULL)
- return 0;
-
- for (i = 0; i < num; i++)
+ Mode.button = b;
+ if (b->state == STATE_CLICKED)
+ b->left = 0;
+ else
{
- if ((win != buttons[i]->win) && (win != buttons[i]->event_win))
- continue;
-
- Mode.button = buttons[i];
- if (buttons[i]->state == STATE_CLICKED)
- buttons[i]->left = 0;
- else
- {
- buttons[i]->state = STATE_HILITED;
- ButtonDraw(buttons[i]);
- if (buttons[i]->aclass)
- EventAclass(ev, NULL, buttons[i]->aclass);
- }
- used = 1;
- break;
+ b->state = STATE_HILITED;
+ ButtonDraw(b);
+ if (b->aclass)
+ EventAclass(ev, NULL, b->aclass);
}
- Efree(buttons);
-
- return used;
}
-int
-ButtonsEventMouseOut(XEvent * ev)
+static void
+ButtonEventMouseOut(Button * b, XEvent * ev)
{
- int used = 0;
- int i, num;
- Button **buttons;
- Window win = ev->xcrossing.window;
+ Mode.button = NULL;
+ if (b->state == STATE_CLICKED)
+ b->left = 1;
+ else
+ {
+ b->state = STATE_NORMAL;
+ ButtonDraw(b);
+ if (b->aclass)
+ EventAclass(ev, NULL, b->aclass);
+ }
+}
- buttons = (Button **) ListItemType(&num, LIST_TYPE_BUTTON);
- if (buttons == NULL)
- return 0;
+static void
+ButtonHandleEvents(XEvent * ev, void *prm)
+{
+ Button *b = (Button *) prm;
- for (i = 0; i < num; i++)
+ switch (ev->type)
{
- if ((win != buttons[i]->win) && (win != buttons[i]->event_win))
- continue;
-
- Mode.button = NULL;
- if (buttons[i]->state == STATE_CLICKED)
- buttons[i]->left = 1;
- else
- {
- buttons[i]->state = STATE_NORMAL;
- ButtonDraw(buttons[i]);
- if (buttons[i]->aclass)
- EventAclass(ev, NULL, buttons[i]->aclass);
- }
- used = 1;
+ case ButtonPress:
+ ButtonEventMouseDown(b, ev);
+ break;
+ case ButtonRelease:
+ ButtonEventMouseUp(b, ev);
+ break;
+ case EnterNotify:
+ ButtonEventMouseIn(b, ev);
+ break;
+ case LeaveNotify:
+ ButtonEventMouseOut(b, ev);
+ break;
+ case Expose:
+ ButtonEventExpose(b, ev);
break;
}
- Efree(buttons);
-
- return used;
}
/*
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/dialog.c,v
retrieving revision 1.91.2.3
retrieving revision 1.91.2.4
diff -u -3 -r1.91.2.3 -r1.91.2.4
--- dialog.c 7 Aug 2004 15:34:26 -0000 1.91.2.3
+++ dialog.c 9 Aug 2004 22:35:19 -0000 1.91.2.4
@@ -153,8 +153,9 @@
item;
};
-typedef struct _dbutton
+typedef struct
{
+ Dialog *parent;
char *text;
void (*func) (int val, void *data);
Window win;
@@ -164,17 +165,15 @@
char close;
TextClass *tclass;
ImageClass *iclass;
-}
-DButton;
+} DButton;
-typedef struct _Dkeybind
+typedef struct
{
KeyCode key;
int val;
void *data;
void (*func) (int val, void *data);
-}
-DKeyBind;
+} DKeyBind;
struct _dialog
{
@@ -195,6 +194,11 @@
DKeyBind *keybindings;
};
+static Dialog *FindDialog(Window win);
+
+static void DialogHandleEvents(XEvent * ev, void *prm);
+static void DButtonHandleEvents(XEvent * ev, void *prm);
+
static void MoveTableBy(Dialog * d, DItem * di, int dx, int dy);
static void DialogItemsRealize(Dialog * d);
@@ -311,6 +315,7 @@
d->win = 0;
d->button = NULL;
d->win = ECreateWindow(VRoot.win, -20, -20, 2, 2, 0);
+ EventCallbackRegister(d->win, 0, DialogHandleEvents, d);
d->item = NULL;
d->exit_func = NULL;
@@ -419,12 +424,16 @@
int w, h;
db = Emalloc(sizeof(DButton));
+
d->num_buttons++;
d->button = Erealloc(d->button, d->num_buttons * (sizeof(DButton *)));
d->button[d->num_buttons - 1] = db;
+
+ db->parent = d;
db->text = Estrdup(text);
db->func = func;
db->win = ECreateWindow(d->win, -20, -20, 2, 2, 0);
+ EventCallbackRegister(db->win, 0, DButtonHandleEvents, db);
EMapWindow(disp, db->win);
db->x = -1;
db->y = -1;
@@ -463,57 +472,27 @@
}
static void
-DialogDrawButton(Dialog * d, int bnum)
+DialogDrawButton(Dialog * d __UNUSED__, DButton * db)
{
int state;
state = STATE_NORMAL;
- if ((d->button[bnum]->hilited) && (d->button[bnum]->clicked))
+ if ((db->hilited) && (db->clicked))
{
state = STATE_CLICKED;
}
- else if ((d->button[bnum]->hilited) && (!d->button[bnum]->clicked))
+ else if ((db->hilited) && (!db->clicked))
{
state = STATE_HILITED;
}
- else if (!(d->button[bnum]->hilited) && (d->button[bnum]->clicked))
+ else if (!(db->hilited) && (db->clicked))
{
state = STATE_CLICKED;
}
- IclassApply(d->button[bnum]->iclass, d->button[bnum]->win,
- d->button[bnum]->w, d->button[bnum]->h, 0, 0, state, 0,
- ST_WIDGET);
- TclassApply(d->button[bnum]->iclass, d->button[bnum]->win,
- d->button[bnum]->w, d->button[bnum]->h, 0, 0, state, 1,
- d->button[bnum]->tclass, d->button[bnum]->text);
-}
-static void
-DialogActivateButton(Window win, int inclick)
-{
- Dialog *d;
- int bnum;
- char doact = 0;
-
- d = FindDialogButton(win, &bnum);
- if (!d)
- return;
- if ((d->button[bnum]->hilited) && (d->button[bnum]->clicked)
- && (inclick == 3))
- doact = 1;
- if (inclick == 0)
- d->button[bnum]->hilited = 1;
- if (inclick == 1)
- d->button[bnum]->hilited = 0;
- if (inclick == 2)
- d->button[bnum]->clicked = 1;
- if (inclick == 3)
- d->button[bnum]->clicked = 0;
- DialogDrawButton(d, bnum);
- if ((doact) && (d->button[bnum]->func))
- (d->button[bnum]->func) (bnum, d);
- if ((doact) && (d->button[bnum]->close))
- DialogClose(d);
+ IclassApply(db->iclass, db->win, db->w, db->h, 0, 0, state, 0, ST_WIDGET);
+ TclassApply(db->iclass, db->win, db->w, db->h, 0, 0, state, 1,
+ db->tclass, db->text);
}
static void
@@ -561,7 +540,7 @@
IclassApply(d->iclass, d->win, d->w, d->h, 0, 0, STATE_NORMAL, 0, ST_DIALOG);
for (i = 0; i < d->num_buttons; i++)
- DialogDrawButton(d, i);
+ DialogDrawButton(d, d->button[i]);
DialogDraw(d);
}
@@ -971,6 +950,7 @@
{
const char *def = NULL;
int iw = 0, ih = 0;
+ int register_win_callback;
if (di->type == DITEM_BUTTON)
{
@@ -1035,6 +1015,8 @@
for (i = 0; i < di->item.table.num_items; i++)
DialogRealizeItem(d, di->item.table.items[i]);
}
+
+ register_win_callback = 1;
switch (di->type)
{
case DITEM_SLIDER:
@@ -1053,8 +1035,12 @@
XSelectInput(disp, di->item.slider.base_win,
EnterWindowMask | LeaveWindowMask | ButtonPressMask |
ButtonReleaseMask);
+ EventCallbackRegister(di->item.slider.base_win, 0, DialogHandleEvents,
+ d);
XSelectInput(disp, di->item.slider.knob_win,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
+ EventCallbackRegister(di->item.slider.knob_win, 0, DialogHandleEvents,
+ d);
if (!di->item.slider.ic_base)
{
if (di->item.slider.horizontal)
@@ -1206,6 +1192,7 @@
XSelectInput(disp, di->item.area.area_win,
EnterWindowMask | LeaveWindowMask | ButtonPressMask |
ButtonReleaseMask | ExposureMask | PointerMotionMask);
+ EventCallbackRegister(di->item.area.area_win, 0, DialogHandleEvents, d);
di->w = iw;
di->h = ih;
break;
@@ -1259,6 +1246,7 @@
ih = imlib_image_get_height();
di->win = ECreateWindow(d->win, 0, 0, iw, ih, 0);
EMapWindow(disp, di->win);
+ register_win_callback = 0;
imlib_render_pixmaps_for_whole_image(&pmap, &mask);
ESetWindowBackgroundPixmap(disp, di->win, pmap);
EShapeCombineMask(disp, di->win, ShapeBounding, 0,
@@ -1275,6 +1263,7 @@
ih = di->iclass->padding.top + di->iclass->padding.bottom;
di->win = ECreateWindow(d->win, -20, -20, 2, 2, 0);
EMapWindow(disp, di->win);
+ register_win_callback = 0;
di->w = iw;
di->h = ih;
break;
@@ -1544,6 +1533,9 @@
di->h = 0;
break;
}
+
+ if (di->win && register_win_callback)
+ EventCallbackRegister(di->win, 0, DialogHandleEvents, d);
}
static void
@@ -1627,6 +1619,7 @@
AddItem(dq, "DRAW", 0, LIST_TYPE_DRAW);
EDBUG_RETURN_;
}
+
if (di->type == DITEM_TABLE)
{
int i;
@@ -1638,6 +1631,7 @@
}
return;
}
+
if (INTERSECTS(x, y, w, h, di->x, di->y, di->w, di->h))
{
switch (di->type)
@@ -2182,47 +2176,46 @@
* Dialog event handlers
*/
-int
-DialogEventKeyPress(XEvent * ev)
+static void
+DialogEventKeyPress(Dialog * d, XEvent * ev)
{
- Dialog *d;
int i;
- d = FindDialog(ev->xkey.window);
- if (d == NULL)
- return 0;
-
for (i = 0; i < d->num_bindings; i++)
{
if (ev->xkey.keycode == d->keybindings[i].key)
(d->keybindings[i].func) (d->keybindings[i].val,
d->keybindings[i].data);
}
+}
- return 1;
+static DItem *
+DialogFindDItem(Dialog * d, Window win)
+{
+ return (d->item) ? DialogItemFindWindow(d->item, win) : NULL;
}
-int
-DialogEventMotion(XEvent * ev)
+static void
+DialogEventMotion(Dialog * d, XEvent * ev)
{
- Dialog *d;
+ Window win = ev->xmotion.window;
DItem *di;
int dx, dy;
- di = FindDialogItem(ev->xmotion.window, &d);
- if (d == NULL)
- return 0;
-
- if (di == NULL)
- goto done;
+ di = DialogFindDItem(d, win);
+ if (!di)
+ return;
- if (di->type == DITEM_AREA)
+ switch (di->type)
{
+ case DITEM_AREA:
if (di->item.area.event_func)
- (di->item.area.event_func) (0, ev);
- }
- else if ((di->type == DITEM_SLIDER) && (di->item.slider.in_drag))
- {
+ di->item.area.event_func(0, ev);
+ break;
+
+ case DITEM_SLIDER:
+ if (!di->item.slider.in_drag)
+ break;
if (ev->xmotion.window == di->item.slider.knob_win)
{
dx = Mode.x - Mode.px;
@@ -2262,87 +2255,52 @@
if (di->func)
(di->func) (di->val, di->data);
}
+
DialogDrawItems(d, di, 0, 0, 99999, 99999);
+ break;
}
-
- done:
- return 1;
}
-int
-DialogEventExpose(XEvent * ev)
+static void
+DialogEventExpose(Dialog * d, XEvent * ev)
{
Window win = ev->xexpose.window;
- Dialog *d;
- int bnum;
DItem *di;
- int x, y, w, h;
- d = FindDialog(win);
- if (d)
- {
- DialogDrawArea(d, ev->xexpose.x, ev->xexpose.y,
+ DialogDrawArea(d, ev->xexpose.x, ev->xexpose.y,
ev->xexpose.width, ev->xexpose.height);
- goto done;
- }
- d = FindDialogButton(win, &bnum);
- if (d)
- {
- DialogDrawButton(d, bnum);
- goto done;
- }
-
- di = FindDialogItem(win, &d);
- if (d == NULL)
- return 0;
-
- GetWinXY(win, &x, &y);
- GetWinWH(win, (unsigned int *)&w, (unsigned int *)&h);
- DialogDrawArea(d, x, y, w, h);
-
- if (di == NULL)
- goto done;
+ di = DialogFindDItem(d, win);
+ if (!di)
+ return;
- if (di->type == DITEM_AREA)
+ switch (di->type)
{
+ case DITEM_AREA:
if (di->func)
- (di->func) (di->val, di->data);
+ di->func(di->val, di->data);
+ break;
}
-
- done:
- return 1;
}
-int
-DialogEventMouseDown(XEvent * ev)
+static void
+DialogEventMouseDown(Dialog * d, XEvent * ev)
{
Window win = ev->xbutton.window;
- Dialog *d;
- int bnum;
DItem *di;
- d = FindDialogButton(win, &bnum);
- if (d)
- {
- DialogActivateButton(win, 2);
- goto done;
- }
-
- di = FindDialogItem(win, &d);
- if (d == NULL)
- return 0;
-
- if (di == NULL)
- goto done;
+ di = DialogFindDItem(d, win);
+ if (!di)
+ return;
- if (di->type == DITEM_AREA)
+ switch (di->type)
{
+ case DITEM_AREA:
if (di->item.area.event_func)
- (di->item.area.event_func) (0, ev);
- }
- else if (di->type == DITEM_SLIDER)
- {
+ di->item.area.event_func(0, ev);
+ break;
+
+ case DITEM_SLIDER:
if (win == di->item.slider.base_win)
{
if (di->item.slider.horizontal)
@@ -2378,240 +2336,285 @@
else
di->item.slider.wanted_val = di->item.slider.knob_y;
}
+ break;
}
+
di->clicked = 1;
- DialogDrawItems(d, di, 0, 0, 99999, 99999);
- done:
- return 1;
+ DialogDrawItems(d, di, 0, 0, 99999, 99999);
}
-int
-DialogEventMouseUp(XEvent * ev)
+static void
+DialogEventMouseUp(Dialog * d, XEvent * ev)
{
Window win = Mode.context_win;
- Dialog *d;
- int bnum;
- DItem *di;
-
- d = FindDialogButton(win, &bnum);
- if (d)
- {
- DialogActivateButton(win, 3);
- goto done;
- }
-
- di = FindDialogItem(win, &d);
- if (d == NULL)
- return 0;
+ DItem *di, *dii;
- if (di == NULL)
- goto done;
+ di = DialogFindDItem(d, win);
+ if (!di)
+ return;
di->clicked = 0;
- if (win)
+
+ switch (di->type)
{
- if (di->type == DITEM_AREA)
- {
- if (di->item.area.event_func)
- (di->item.area.event_func) (0, ev);
- }
- else if (di->type == DITEM_CHECKBUTTON)
- {
- if (di->item.check_button.onoff)
- di->item.check_button.onoff = 0;
- else
- di->item.check_button.onoff = 1;
- if (di->item.check_button.onoff_ptr)
- *di->item.check_button.onoff_ptr = di->item.check_button.onoff;
- }
- else if (di->type == DITEM_RADIOBUTTON)
- {
- DItem *dii;
+ case DITEM_AREA:
+ if (di->item.area.event_func)
+ di->item.area.event_func(0, ev);
+ break;
- dii = di->item.radio_button.first;
- while (dii)
+ case DITEM_CHECKBUTTON:
+ if (di->item.check_button.onoff)
+ di->item.check_button.onoff = 0;
+ else
+ di->item.check_button.onoff = 1;
+ if (di->item.check_button.onoff_ptr)
+ *di->item.check_button.onoff_ptr = di->item.check_button.onoff;
+ break;
+
+ case DITEM_RADIOBUTTON:
+ dii = di->item.radio_button.first;
+ while (dii)
+ {
+ if (dii->item.radio_button.onoff)
{
- if (dii->item.radio_button.onoff)
- {
- dii->item.radio_button.onoff = 0;
- DialogDrawItems(d, dii, 0, 0, 99999, 99999);
- }
- dii = dii->item.radio_button.next;
+ dii->item.radio_button.onoff = 0;
+ DialogDrawItems(d, dii, 0, 0, 99999, 99999);
}
- di->item.radio_button.onoff = 1;
- if (di->item.radio_button.val_ptr)
- *di->item.radio_button.val_ptr = di->item.radio_button.val;
- }
- else if (di->type == DITEM_SLIDER)
- {
- if (win == di->item.slider.knob_win)
- di->item.slider.in_drag = 0;
+ dii = dii->item.radio_button.next;
}
+ di->item.radio_button.onoff = 1;
+ if (di->item.radio_button.val_ptr)
+ *di->item.radio_button.val_ptr = di->item.radio_button.val;
+ break;
+ case DITEM_SLIDER:
+ if (win == di->item.slider.knob_win)
+ di->item.slider.in_drag = 0;
+ break;
}
+
DialogDrawItems(d, di, 0, 0, 99999, 99999);
- if (win)
- {
- if (di->func)
- (di->func) (di->val, di->data);
- }
- done:
- return 1;
+ if (di->func)
+ di->func(di->val, di->data);
}
-int
-DialogEventMouseIn(XEvent * ev)
+static void
+DialogEventMouseIn(Dialog * d, XEvent * ev)
{
Window win = ev->xcrossing.window;
- Dialog *d;
- int bnum;
DItem *di;
- d = FindDialogButton(win, &bnum);
- if (d)
+ di = DialogFindDItem(d, win);
+ if (!di)
+ return;
+
+ switch (di->type)
{
- DialogActivateButton(win, 0);
- goto done;
+ case DITEM_AREA:
+ if (di->item.area.event_func)
+ di->item.area.event_func(0, ev);
+ break;
+
+ case DITEM_RADIOBUTTON:
+ if (di->item.radio_button.event_func)
+ di->item.radio_button.event_func(di->item.radio_button.val, ev);
+ break;
}
- di = FindDialogItem(win, &d);
- if (d == NULL)
- return 0;
+ di->hilited = 1;
+
+ DialogDrawItems(d, di, 0, 0, 99999, 99999);
+}
+
+static void
+DialogEventMouseOut(Dialog * d, XEvent * ev)
+{
+ Window win = ev->xcrossing.window;
+ DItem *di;
- if (di == NULL)
- goto done;
+ di = DialogFindDItem(d, win);
+ if (!di)
+ return;
- if (di->type == DITEM_AREA)
+ switch (di->type)
{
+ case DITEM_AREA:
if (di->item.area.event_func)
- (di->item.area.event_func) (0, ev);
- }
- else if (di->type == DITEM_RADIOBUTTON)
- {
+ di->item.area.event_func(0, ev);
+ break;
+
+ case DITEM_RADIOBUTTON:
if (di->item.radio_button.event_func)
- (di->item.radio_button.event_func) (di->item.radio_button.val, ev);
+ di->item.radio_button.event_func(di->item.radio_button.val, NULL);
+ break;
}
- di->hilited = 1;
+
+ di->hilited = 0;
+
DialogDrawItems(d, di, 0, 0, 99999, 99999);
+}
- done:
- return 1;
+static void
+DialogHandleEvents(XEvent * ev, void *prm)
+{
+ Dialog *d = (Dialog *) prm;
+
+ switch (ev->type)
+ {
+ case KeyPress:
+ DialogEventKeyPress(d, ev);
+ break;
+ case ButtonPress:
+ DialogEventMouseDown(d, ev);
+ break;
+ case ButtonRelease:
+ DialogEventMouseUp(d, ev);
+ break;
+ case MotionNotify:
+ DialogEventMotion(d, ev);
+ break;
+ case EnterNotify:
+ DialogEventMouseIn(d, ev);
+ break;
+ case LeaveNotify:
+ DialogEventMouseOut(d, ev);
+ break;
+ case Expose:
+ DialogEventExpose(d, ev);
+ break;
+ }
}
-int
-DialogEventMouseOut(XEvent * ev)
+#if 0 /* TBD */
+static void
+DItemHandleEvents(XEvent * ev, void *prm)
{
- Window win = ev->xcrossing.window;
- Dialog *d;
- int bnum;
- DItem *di;
+ DItem *di = (Dialog *) prm;
+ Window win = ev->xany.window;
- d = FindDialogButton(win, &bnum);
- if (d)
+ switch (ev->type)
{
- DialogActivateButton(win, 1);
- goto done;
+ case ButtonPress:
+ break;
+ case ButtonRelease:
+ break;
+ case EnterNotify:
+ break;
+ case LeaveNotify:
+ break;
+ case Expose:
+ break;
}
+}
+#endif
- di = FindDialogItem(win, &d);
- if (d == NULL)
- return 0;
+static void
+DButtonHandleEvents(XEvent * ev, void *prm)
+{
+ DButton *db = (DButton *) prm;
+ Dialog *d;
+ int doact = 0;
- if (di == NULL)
- goto done;
+ d = db->parent;
- if (di->type == DITEM_AREA)
+ switch (ev->type)
{
- if (di->item.area.event_func)
- (di->item.area.event_func) (0, ev);
+ case ButtonPress:
+ db->clicked = 1;
+ break;
+ case ButtonRelease:
+ if (db->hilited && db->clicked)
+ doact = 1;
+ db->clicked = 0;
+ break;
+ case EnterNotify:
+ db->hilited = 1;
+ break;
+ case LeaveNotify:
+ db->hilited = 0;
+ break;
+ case Expose:
+ break;
+ default:
+ return;
}
- else if (di->type == DITEM_RADIOBUTTON)
+
+ DialogDrawButton(d, db);
+
+ if (doact)
{
- if (di->item.radio_button.event_func)
- (di->item.radio_button.event_func) (di->item.radio_button.val, NULL);
- }
- di->hilited = 0;
- DialogDrawItems(d, di, 0, 0, 99999, 99999);
+ if (db->func)
+ {
+ int i;
+
+ for (i = 0; i < d->num_buttons; i++)
+ if (d->button[i] == db)
+ break;
+ db->func(i, d);
+ }
- done:
- return 1;
+ if (db->close)
+ DialogClose(d);
+ }
}
/*
* Finders
*/
-Dialog *
-FindDialogButton(Window win, int *bnum)
+static Dialog *
+FindDialog(Window win)
{
Dialog **ds, *d = NULL;
- int i, j, num, b = 0;
-
- EDBUG(6, "FindDialogButton");
+ int i, num;
+ EDBUG(6, "FindDialog");
ds = (Dialog **) ListItemType(&num, LIST_TYPE_DIALOG);
for (i = 0; i < num; i++)
{
- for (j = 0; j < ds[i]->num_buttons; j++)
- {
- if (win != ds[i]->button[j]->win)
- continue;
- d = ds[i];
- b = j;
- goto done;
- }
+ if (ds[i]->win != win)
+ continue;
+ d = ds[i];
+ break;
}
- done:
if (ds)
Efree(ds);
- *bnum = b;
EDBUG_RETURN(d);
}
-DItem *
-FindDialogItem(Window win, Dialog ** dret)
+EWin *
+FindEwinByDialog(Dialog * d)
{
- Dialog **ds, *d = NULL;
- DItem *di = NULL;
+ EWin *const *ewins;
int i, num;
- EDBUG(6, "FindDialogButton");
+ EDBUG(6, "FindEwinByDialog");
- ds = (Dialog **) ListItemType(&num, LIST_TYPE_DIALOG);
+ ewins = EwinListGetAll(&num);
for (i = 0; i < num; i++)
{
- if (!ds[i]->item)
- continue;
-
- di = DialogItemFindWindow(ds[i]->item, win);
- if (di == NULL)
- continue;
- d = ds[i];
- break;
+ if (ewins[i]->dialog == d)
+ return ewins[i];
}
- if (ds)
- Efree(ds);
- *dret = d;
- EDBUG_RETURN(di);
+
+ EDBUG_RETURN(NULL);
}
-Dialog *
-FindDialog(Window win)
+int
+FindADialog(void)
{
- Dialog **ds, *d = NULL;
- int i, num;
+ EWin *const *ewins;
+ int i, num, n;
- EDBUG(6, "FindDialog");
- ds = (Dialog **) ListItemType(&num, LIST_TYPE_DIALOG);
- for (i = 0; i < num; i++)
+ EDBUG(6, "FindADialog");
+
+ ewins = EwinListGetAll(&num);
+ for (i = n = 0; i < num; i++)
{
- if (ds[i]->win != win)
- continue;
- d = ds[i];
- break;
+ if (ewins[i]->dialog)
+ n++;
}
- if (ds)
- Efree(ds);
- EDBUG_RETURN(d);
+
+ EDBUG_RETURN(n);
}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/Attic/econfig.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -3 -r1.1.2.3 -r1.1.2.4
--- econfig.c 7 Aug 2004 15:34:26 -0000 1.1.2.3
+++ econfig.c 9 Aug 2004 22:35:19 -0000 1.1.2.4
@@ -27,6 +27,16 @@
#include <Edb.h>
+/* Work around missing const in API */
+#define eX_db_int_get(edf, name, ptr) e_db_int_get(edf, (char*)name, ptr)
+#define eX_db_float_get(edf, name, ptr) e_db_float_get(edf, (char*)name, ptr)
+#define eX_db_str_get(edf, name) e_db_str_get(edf, (char*)name)
+#define eX_db_int_set(edf, name, val) e_db_int_set(edf, (char*)name, val)
+#define eX_db_float_set(edf, name, val) e_db_float_set(edf, (char*)name, val)
+#define eX_db_str_set(edf, name, val) e_db_str_set(edf, (char*)name, val)
+#define eX_db_open_read(file) e_db_open_read((char*)file)
+#define eX_db_open(file) e_db_open((char*)file)
+
static void
CfgItemLoad(E_DB_File * edf, const char *prefix, const CfgItem * ci)
{
@@ -46,22 +56,22 @@
switch (ci->type)
{
case ITEM_TYPE_BOOL:
- if (!e_db_int_get(edf, name, &my_int))
+ if (!eX_db_int_get(edf, name, &my_int))
my_int = (ci->dflt) ? 1 : 0;
*((char *)ci->ptr) = my_int;
break;
case ITEM_TYPE_INT:
- if (!e_db_int_get(edf, name, &my_int))
+ if (!eX_db_int_get(edf, name, &my_int))
my_int = ci->dflt;
*((int *)ci->ptr) = my_int;
break;
case ITEM_TYPE_FLOAT:
- if (!e_db_float_get(edf, name, &my_float))
+ if (!eX_db_float_get(edf, name, &my_float))
my_float = ci->dflt;
*((float *)ci->ptr) = my_float;
break;
case ITEM_TYPE_STRING:
- *((char **)ci->ptr) = e_db_str_get(edf, name);
+ *((char **)ci->ptr) = eX_db_str_get(edf, name);
break;
}
}
@@ -83,16 +93,16 @@
switch (ci->type)
{
case ITEM_TYPE_BOOL:
- e_db_int_set(edf, name, *((char *)ci->ptr));
+ eX_db_int_set(edf, name, *((char *)ci->ptr));
break;
case ITEM_TYPE_INT:
- e_db_int_set(edf, name, *((int *)ci->ptr));
+ eX_db_int_set(edf, name, *((int *)ci->ptr));
break;
case ITEM_TYPE_FLOAT:
- e_db_float_set(edf, name, *((float *)ci->ptr));
+ eX_db_float_set(edf, name, *((float *)ci->ptr));
break;
case ITEM_TYPE_STRING:
- e_db_str_set(edf, name, ci->ptr);
+ eX_db_str_set(edf, name, ci->ptr);
break;
}
}
@@ -115,7 +125,7 @@
memset(&Conf, 0, sizeof(EConf));
- edf = e_db_open_read(ConfigurationGetFile(buf, sizeof(buf)));
+ edf = eX_db_open_read(ConfigurationGetFile(buf, sizeof(buf)));
if (edf == NULL)
return;
@@ -143,7 +153,7 @@
char buf[4096];
E_DB_File *edf;
- edf = e_db_open(ConfigurationGetFile(buf, sizeof(buf)));
+ edf = eX_db_open(ConfigurationGetFile(buf, sizeof(buf)));
if (edf == NULL)
return;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/evhandlers.c,v
retrieving revision 1.173.2.5
retrieving revision 1.173.2.6
diff -u -3 -r1.173.2.5 -r1.173.2.6
--- evhandlers.c 8 Aug 2004 00:02:18 -0000 1.173.2.5
+++ evhandlers.c 9 Aug 2004 22:35:19 -0000 1.173.2.6
@@ -114,14 +114,9 @@
}
void
-HandleKeyPress(XEvent * ev)
+HandleKeyPress(XEvent * ev __UNUSED__)
{
EDBUG(5, "HandleKeyPress");
-
- if (DialogEventKeyPress(ev))
- goto done;
-
- done:
EDBUG_RETURN_;
}
@@ -219,12 +214,6 @@
if ( /*!Mode.menus.clicked && */ BordersEventMouseDown(ev))
goto done;
- if (ButtonsEventMouseDown(ev))
- goto done;
-
- if (DialogEventMouseDown(ev))
- goto done;
-
ewin = FindEwinByBase(win);
if (ewin)
{
@@ -308,12 +297,6 @@
if (Mode.action_inhibit)
goto done;
- if (ButtonsEventMouseUp(ev))
- goto done;
-
- if (DialogEventMouseUp(ev))
- goto done;
-
ewin = FindEwinByBase(win);
if (ewin)
{
@@ -521,8 +504,6 @@
}
}
- DialogEventMotion(ev);
-
EDBUG_RETURN_;
}
@@ -546,12 +527,6 @@
if ( /*!Mode.menus.clicked && */ BordersEventMouseIn(ev))
goto done;
- if (ButtonsEventMouseIn(ev))
- goto done;
-
- if (DialogEventMouseIn(ev))
- goto done;
-
done:
FocusHandleEnter(ev);
@@ -575,12 +550,6 @@
if ( /*!Mode.menus.clicked && */ BordersEventMouseOut(ev))
goto done;
- if (ButtonsEventMouseOut(ev))
- goto done;
-
- if (DialogEventMouseOut(ev))
- goto done;
-
done:
FocusHandleLeave(ev);
@@ -590,50 +559,11 @@
void
HandleFocusIn(XEvent * ev __UNUSED__)
{
-#if 0
- Window win = ev->xfocus.window;
- EWin *ewin;
-
- EDBUG(5, "HandleFocusIn");
-
- ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
- if (ewin && !ewin->active)
- {
- ewin->active = 1;
- DrawEwin(ewin);
-
- FocusEwinSetGrabs(ewin);
- }
-
- EDBUG_RETURN_;
-#endif
}
void
HandleFocusOut(XEvent * ev __UNUSED__)
{
-#if 0
- Window win = ev->xfocus.window;
- EWin *ewin;
-
- EDBUG(5, "HandleFocusOut");
-
- /* Do nothing if the focus is passed down to child */
- if (ev->xfocus.detail == NotifyInferior)
- goto done;
-
- ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN);
- if (ewin && ewin->active)
- {
- ewin->active = 0;
- DrawEwin(ewin);
-
- FocusEwinSetGrabs(ewin);
- }
-
- done:
- EDBUG_RETURN_;
-#endif
}
void
@@ -644,12 +574,6 @@
if (BordersEventExpose(ev))
goto done;
- if (ButtonsEventExpose(ev))
- goto done;
-
- if (DialogEventExpose(ev))
- goto done;
-
done:
EDBUG_RETURN_;
}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/finders.c,v
retrieving revision 1.31
retrieving revision 1.31.2.1
diff -u -3 -r1.31 -r1.31.2.1
--- finders.c 19 Jun 2004 01:31:21 -0000 1.31
+++ finders.c 9 Aug 2004 22:35:20 -0000 1.31.2.1
@@ -460,39 +460,3 @@
EDBUG_RETURN(lst);
}
#endif
-
-EWin *
-FindEwinByDialog(Dialog * d)
-{
- EWin *const *ewins;
- int i, num;
-
- EDBUG(6, "FindEwinByDialog");
-
- ewins = EwinListGetAll(&num);
- for (i = 0; i < num; i++)
- {
- if (ewins[i]->dialog == d)
- return ewins[i];
- }
-
- EDBUG_RETURN(NULL);
-}
-
-int
-FindADialog(void)
-{
- EWin *const *ewins;
- int i, num, n;
-
- EDBUG(6, "FindADialog");
-
- ewins = EwinListGetAll(&num);
- for (i = n = 0; i < num; i++)
- {
- if (ewins[i]->dialog)
- n++;
- }
-
- EDBUG_RETURN(n);
-}
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/x.c,v
retrieving revision 1.71.2.2
retrieving revision 1.71.2.3
diff -u -3 -r1.71.2.2 -r1.71.2.3
--- x.c 31 Jul 2004 20:25:55 -0000 1.71.2.2
+++ x.c 9 Aug 2004 22:35:20 -0000 1.71.2.3
@@ -43,6 +43,9 @@
Window win;
int x, y, w, h;
char mapped;
+ char in_use;
+ char do_del;
+ char rsvd;
int num_rect;
int ord;
XRectangle *rects;
@@ -200,15 +203,23 @@
if (xid == NULL)
return;
+ xid->in_use = 1;
ecl = &xid->cbl;
eci = ecl->lst;
for (i = 0; i < ecl->num; i++, eci++)
{
- if (EventDebug(200))
+ if (EventDebug(EDBUG_TYPE_DISPATCH))
Eprintf("EventDispatch: type=%d win=%#lx func=%p prm=%p\n",
ev->type, ev->xany.window, eci->func, eci->prm);
eci->func(ev, eci->prm);
+ if (xid->do_del)
+ {
+ xid->in_use = 0;
+ EDestroyWindow(disp, xid->win); // Pass disp?
+ return;
+ }
}
+ xid->in_use = 0;
}
Pixmap
@@ -319,7 +330,9 @@
{
EXID *xid;
+#if 0 /* FIXME */
SlideoutsHideIfContextWin(win);
+#endif
xid = FindXID(win);
if (xid)
@@ -327,6 +340,11 @@
EXID **lst;
int i, num;
+ if (xid->in_use)
+ {
+ xid->do_del = 1;
+ return;
+ }
DelXID(win);
XDestroyWindow(d, win);
lst = (EXID **) ListItemType(&num, LIST_TYPE_XID);
@@ -345,11 +363,9 @@
}
void
-EForgetWindow(Display * d, Window win)
+EForgetWindow(Display * d __UNUSED__, Window win)
{
DelXID(win);
- return;
- d = NULL;
}
void
@@ -446,16 +462,13 @@
gcv.tile = pmap;
gcv.ts_x_origin = 0;
gcv.ts_y_origin = 0;
- tm = ECreatePixmap(disp, win, w, h, 1);
- gc = XCreateGC(disp, tm, GCFillStyle | GCTile |
+ tm = ECreatePixmap(d, win, w, h, 1);
+ gc = XCreateGC(d, tm, GCFillStyle | GCTile |
GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
- XFillRectangle(disp, tm, gc, 0, 0, w, h);
- XFreeGC(disp, gc);
- EShapeCombineMask(disp, win, dest, x, y, tm, op);
- EFreePixmap(disp, tm);
-
- return;
- d = NULL;
+ XFillRectangle(d, tm, gc, 0, 0, w, h);
+ XFreeGC(d, gc);
+ EShapeCombineMask(d, win, dest, x, y, tm, op);
+ EFreePixmap(d, tm);
}
void
@@ -807,7 +820,7 @@
}
void
-GrabX()
+GrabX(void)
{
EDBUG(6, "GrabX");
if (Mode.server_grabbed <= 0)
@@ -817,7 +830,7 @@
}
void
-UngrabX()
+UngrabX(void)
{
EDBUG(6, "UngrabX");
if (Mode.server_grabbed == 1)
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs