A new event handler registration/dispatching engine (not used yet).
SVN revision: 10400
This commit is contained in:
parent
a2026d9228
commit
4fc8f4e865
21
src/E.h
21
src/E.h
|
@ -2696,6 +2696,21 @@ void *MatchEwinByFunction(EWin * ewin,
|
|||
void RemoveWindowMatch(WindowMatch * wm);
|
||||
|
||||
/* x.c */
|
||||
#if INCLUDE_NEW_EVENT_DISPATCHER
|
||||
typedef void (EventCallbackFunc) (XEvent * ev, void *prm);
|
||||
void EventCallbackRegister(Window win, int type,
|
||||
EventCallbackFunc * func, void *prm);
|
||||
void EventCallbackUnregister(Window win, int type,
|
||||
EventCallbackFunc * func,
|
||||
void *prm);
|
||||
void EventCallbacksProcess(XEvent * ev);
|
||||
#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
|
||||
Pixmap ECreatePixmap(Display * display, Drawable d,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned depth);
|
||||
void EFreePixmap(Display * display, Pixmap pixmap);
|
||||
Window ECreateWindow(Window parent, int x, int y, int w, int h,
|
||||
int saveunder);
|
||||
void EMoveWindow(Display * d, Window win, int x, int y);
|
||||
void EResizeWindow(Display * d, Window win, int w, int h);
|
||||
void EMoveResizeWindow(Display * d, Window win, int x, int y,
|
||||
|
@ -2729,12 +2744,6 @@ void EConfigureWindow(Display * d, Window win, unsigned int mask,
|
|||
void ESetWindowBackgroundPixmap(Display * d, Window win,
|
||||
Pixmap pmap);
|
||||
void ESetWindowBackground(Display * d, Window win, int col);
|
||||
Pixmap ECreatePixmap(Display * display, Drawable d,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned depth);
|
||||
void EFreePixmap(Display * display, Pixmap pixmap);
|
||||
Window ECreateWindow(Window parent, int x, int y, int w, int h,
|
||||
int saveunder);
|
||||
Window ECreateEventWindow(Window parent, int x, int y, int w,
|
||||
int h);
|
||||
Window ECreateFocusWindow(Window parent, int x, int y, int w,
|
||||
|
|
103
src/x.c
103
src/x.c
|
@ -20,12 +20,30 @@
|
|||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#define INCLUDE_NEW_EVENT_DISPATCHER 0
|
||||
#include "E.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xresource.h>
|
||||
|
||||
#if INCLUDE_NEW_EVENT_DISPATCHER
|
||||
typedef struct
|
||||
{
|
||||
EventCallbackFunc *func;
|
||||
void *prm;
|
||||
} EventCallbackItem;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int num;
|
||||
EventCallbackItem *lst;
|
||||
} EventCallbackList;
|
||||
#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
|
||||
|
||||
typedef struct _exid
|
||||
{
|
||||
#if INCLUDE_NEW_EVENT_DISPATCHER
|
||||
EventCallbackList cbl;
|
||||
#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
|
||||
Window parent;
|
||||
Window win;
|
||||
int x, y, w, h;
|
||||
|
@ -36,8 +54,7 @@ typedef struct _exid
|
|||
int depth;
|
||||
Pixmap bgpmap;
|
||||
int bgcol;
|
||||
}
|
||||
EXID;
|
||||
} EXID;
|
||||
|
||||
static XContext xid_context = 0;
|
||||
|
||||
|
@ -46,20 +63,7 @@ NewXID(void)
|
|||
{
|
||||
EXID *xid;
|
||||
|
||||
xid = Emalloc(sizeof(EXID));
|
||||
xid->parent = 0;
|
||||
xid->win = 0;
|
||||
xid->x = 0;
|
||||
xid->y = 0;
|
||||
xid->w = 0;
|
||||
xid->h = 0;
|
||||
xid->num_rect = 0;
|
||||
xid->ord = 0;
|
||||
xid->rects = NULL;
|
||||
xid->depth = 0;
|
||||
xid->mapped = 0;
|
||||
xid->bgpmap = 0;
|
||||
xid->bgcol = 0;
|
||||
xid = Ecalloc(1, sizeof(EXID));
|
||||
|
||||
return xid;
|
||||
}
|
||||
|
@ -123,6 +127,73 @@ SetXID(Window win, Window parent, int x, int y, int w, int h, int depth)
|
|||
depth = 0;
|
||||
}
|
||||
|
||||
#if INCLUDE_NEW_EVENT_DISPATCHER
|
||||
void
|
||||
EventCallbackRegister(Window win, int type __UNUSED__, EventCallbackFunc * func,
|
||||
void *prm)
|
||||
{
|
||||
EXID *xid;
|
||||
EventCallbackItem *eci;
|
||||
|
||||
xid = FindXID(win);
|
||||
if (xid == NULL)
|
||||
return;
|
||||
|
||||
xid->cbl.num++;
|
||||
xid->cbl.lst =
|
||||
Erealloc(xid->cbl.lst, xid->cbl.num * sizeof(EventCallbackItem));
|
||||
eci = xid->cbl.lst + xid->cbl.num - 1;
|
||||
eci->func = func;
|
||||
eci->prm = prm;
|
||||
}
|
||||
|
||||
void
|
||||
EventCallbackUnregister(Window win, int type __UNUSED__,
|
||||
EventCallbackFunc * func, void *prm)
|
||||
{
|
||||
EXID *xid;
|
||||
EventCallbackList *ecl;
|
||||
EventCallbackItem *eci;
|
||||
int i;
|
||||
|
||||
xid = FindXID(win);
|
||||
if (xid == NULL)
|
||||
return;
|
||||
|
||||
ecl = &xid->cbl;
|
||||
eci = ecl->lst;
|
||||
for (i = 0; i < ecl->num; i++, eci++)
|
||||
if (eci->func == func && eci->prm == prm)
|
||||
{
|
||||
/* Well - remove it */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
EventCallbacksProcess(XEvent * ev)
|
||||
{
|
||||
EXID *xid;
|
||||
EventCallbackList *ecl;
|
||||
EventCallbackItem *eci;
|
||||
int i;
|
||||
|
||||
xid = FindXID(ev->xany.window);
|
||||
if (xid == NULL)
|
||||
return;
|
||||
|
||||
ecl = &xid->cbl;
|
||||
eci = ecl->lst;
|
||||
for (i = 0; i < ecl->num; i++, eci++)
|
||||
{
|
||||
if (EventDebug(200))
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif /* INCLUDE_NEW_EVENT_DISPATCHER */
|
||||
|
||||
Pixmap
|
||||
ECreatePixmap(Display * display, Drawable d, unsigned int width,
|
||||
unsigned int height, unsigned depth)
|
||||
|
|
Loading…
Reference in New Issue