added more experimental xcb code
This commit is contained in:
parent
3fcfcff0ad
commit
df1619bf7d
@ -270,10 +270,6 @@ class MyObject(Object)
|
|||||||
{
|
{
|
||||||
|a i|
|
|a i|
|
||||||
|
|
||||||
System _getUint8(1,2).
|
|
||||||
'JJJJJJJJJJ' dump.
|
|
||||||
|
|
||||||
|
|
||||||
a := 100.
|
a := 100.
|
||||||
## PROBLEM: the following double loop will exhaust the stack
|
## PROBLEM: the following double loop will exhaust the stack
|
||||||
(*
|
(*
|
||||||
|
@ -120,31 +120,5 @@ extend System
|
|||||||
method(#class,#primitive) _putUint32 (rawptr, offset, value).
|
method(#class,#primitive) _putUint32 (rawptr, offset, value).
|
||||||
method(#class,#primitive) _putUint64 (rawptr, offset, value),
|
method(#class,#primitive) _putUint64 (rawptr, offset, value),
|
||||||
*)
|
*)
|
||||||
|
|
||||||
(*
|
|
||||||
method(#class) getUint8: rawptr at: offset
|
|
||||||
{
|
|
||||||
<primitive: #_get_uint8>
|
|
||||||
}
|
|
||||||
|
|
||||||
method(#class) getUint16: rawptr at: offset
|
|
||||||
{
|
|
||||||
<primitive: #_get_uint16>
|
|
||||||
}
|
|
||||||
|
|
||||||
method(#class) getUint32: rawptr at: offset
|
|
||||||
{
|
|
||||||
<primitive: #_get_uint32>
|
|
||||||
}
|
|
||||||
|
|
||||||
method(#class) getUint64: rawptr at: offset
|
|
||||||
{
|
|
||||||
<primitive: #_get_uint64>
|
|
||||||
}
|
|
||||||
|
|
||||||
method(#class) putUint8: value rawptr: rawptr at: offset
|
|
||||||
{
|
|
||||||
<primitive: #_get_uint8>
|
|
||||||
}*)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1791,11 +1791,9 @@ static moo_pfrc_t _get_raw_uint (moo_t* moo, moo_ooi_t nargs, int size)
|
|||||||
moo_oow_t value;
|
moo_oow_t value;
|
||||||
moo_oop_t result;
|
moo_oop_t result;
|
||||||
|
|
||||||
MOO_DEBUG1 (moo, "get_raw_uint ..%d\n", size);
|
|
||||||
if (moo_inttooow (moo, MOO_STACK_GETARG(moo, nargs, 0), (moo_oow_t*)&rawptr) <= 0 ||
|
if (moo_inttooow (moo, MOO_STACK_GETARG(moo, nargs, 0), (moo_oow_t*)&rawptr) <= 0 ||
|
||||||
moo_inttooow (moo, MOO_STACK_GETARG(moo, nargs, 1), &offset) <= 0)
|
moo_inttooow (moo, MOO_STACK_GETARG(moo, nargs, 1), &offset) <= 0)
|
||||||
{
|
{
|
||||||
MOO_DEBUG0 (moo, "get_raw_uint failure...\n");
|
|
||||||
moo->errnum = MOO_EINVAL;
|
moo->errnum = MOO_EINVAL;
|
||||||
return MOO_PF_FAILURE;
|
return MOO_PF_FAILURE;
|
||||||
}
|
}
|
||||||
@ -1826,7 +1824,6 @@ MOO_DEBUG0 (moo, "get_raw_uint failure...\n");
|
|||||||
result = moo_oowtoint (moo, value);
|
result = moo_oowtoint (moo, value);
|
||||||
if (!result) return MOO_PF_FAILURE;
|
if (!result) return MOO_PF_FAILURE;
|
||||||
|
|
||||||
MOO_DEBUG1 (moo, "get_raw_uint failure..%O.\n", result);
|
|
||||||
MOO_STACK_SETRET (moo, nargs, result);
|
MOO_STACK_SETRET (moo, nargs, result);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1917,11 +1914,10 @@ static moo_pfrc_t pf_perform (moo_t* moo, moo_ooi_t nargs)
|
|||||||
/* remove the selector from the stack */
|
/* remove the selector from the stack */
|
||||||
ssp = MOO_STACK_GETARGSP (moo, nargs, 0);
|
ssp = MOO_STACK_GETARGSP (moo, nargs, 0);
|
||||||
esp = MOO_STACK_GETARGSP (moo, nargs, nargs - 1);
|
esp = MOO_STACK_GETARGSP (moo, nargs, nargs - 1);
|
||||||
for (i = ssp; i < esp;)
|
for (i = ssp; i < esp; i++)
|
||||||
{
|
{
|
||||||
moo_oop_t t;
|
moo_oop_t t;
|
||||||
t = MOO_STACK_GET (moo, i);
|
t = MOO_STACK_GET (moo, i + 1);
|
||||||
i++;
|
|
||||||
MOO_STACK_SET(moo, i, t);
|
MOO_STACK_SET(moo, i, t);
|
||||||
}
|
}
|
||||||
MOO_STACK_POP (moo);
|
MOO_STACK_POP (moo);
|
||||||
|
107
moo/mod/x11.c
107
moo/mod/x11.c
@ -34,6 +34,21 @@
|
|||||||
#define C MOO_METHOD_CLASS
|
#define C MOO_METHOD_CLASS
|
||||||
#define I MOO_METHOD_INSTANCE
|
#define I MOO_METHOD_INSTANCE
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bit mask to find event type regardless of event source.
|
||||||
|
*
|
||||||
|
* Each event in the X11 protocol contains an 8-bit type code.
|
||||||
|
* The most-significant bit in this code is set if the event was
|
||||||
|
* generated from a SendEvent request. This mask can be used to
|
||||||
|
* determine the type of event regardless of how the event was
|
||||||
|
* generated. See the X11R6 protocol specification for details.
|
||||||
|
*/
|
||||||
|
#define XCB_EVENT_RESPONSE_TYPE_MASK (0x7f)
|
||||||
|
#define XCB_EVENT_RESPONSE_TYPE(e) (e->response_type & XCB_EVENT_RESPONSE_TYPE_MASK)
|
||||||
|
#define XCB_EVENT_SENT(e) (e->response_type & ~XCB_EVENT_RESPONSE_TYPE_MASK)
|
||||||
|
|
||||||
|
|
||||||
typedef struct x11_modctx_t x11_modctx_t;
|
typedef struct x11_modctx_t x11_modctx_t;
|
||||||
struct x11_modctx_t
|
struct x11_modctx_t
|
||||||
{
|
{
|
||||||
@ -55,7 +70,7 @@ typedef struct x11_win_t x11_win_t;
|
|||||||
struct x11_win_t
|
struct x11_win_t
|
||||||
{
|
{
|
||||||
xcb_window_t id;
|
xcb_window_t id;
|
||||||
xcb_intern_atom_reply_t* dwcr;
|
xcb_intern_atom_reply_t* dwar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -171,54 +186,21 @@ static moo_pfrc_t pf_getevent (moo_t* moo, moo_ooi_t nargs)
|
|||||||
|
|
||||||
if (evt)
|
if (evt)
|
||||||
{
|
{
|
||||||
uint8_t evttype = evt->response_type & 0x7F;
|
moo_oop_t llevt;
|
||||||
|
uint8_t evttype;
|
||||||
|
|
||||||
|
evttype = evt->response_type & 0x7F;
|
||||||
x11->curevt = evt;
|
x11->curevt = evt;
|
||||||
if (evttype == XCB_CLIENT_MESSAGE)
|
|
||||||
|
llevt = moo_oowtoint (moo, (moo_oow_t)evt);
|
||||||
|
if (!llevt)
|
||||||
{
|
{
|
||||||
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(9999)); /* TODO: translate evt to the event object */
|
llevt = MOO_ERROR_TO_OOP(moo->errnum);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(evttype)); /* TODO: translate evt to the event object */
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
switch (evttype)
|
|
||||||
{
|
|
||||||
case XCB_CLIENT_MESSAGE:
|
|
||||||
#if 0
|
|
||||||
if (((xcb_client_message_event_t*)evt)->data.data32[0] == x11->dwcr->atom)
|
|
||||||
{
|
|
||||||
xcb_unmap_window (x11->c, x11->w);
|
|
||||||
xcb_destroy_window (x11->c, x11->w);
|
|
||||||
xcb_flush (x11->c);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(9999)); /* TODO: translate evt to the event object */
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case XCB_BUTTON_PRESS:
|
|
||||||
case XCB_BUTTON_RELEASE:
|
|
||||||
{
|
|
||||||
xcb_button_press_event_t* bpe = (xcb_button_press_event_t*)evt;
|
|
||||||
|
|
||||||
|
|
||||||
MOO_STACK_SETRET (moo, nargs, e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(evttype)); /* TODO: translate evt to the event object */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
free (evt);
|
free (evt);
|
||||||
#endif
|
x11->curevt = MOO_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOO_STACK_SETRET (moo, nargs, llevt);
|
||||||
}
|
}
|
||||||
else if (xcb_connection_has_error(x11->c))
|
else if (xcb_connection_has_error(x11->c))
|
||||||
{
|
{
|
||||||
@ -227,6 +209,7 @@ static moo_pfrc_t pf_getevent (moo_t* moo, moo_ooi_t nargs)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* nil if there is no event */
|
||||||
MOO_STACK_SETRET (moo, nargs, moo->_nil);
|
MOO_STACK_SETRET (moo, nargs, moo->_nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +218,21 @@ static moo_pfrc_t pf_getevent (moo_t* moo, moo_ooi_t nargs)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
static moo_pfrc_t pf_win_get_dwatom (moo_t* moo, moo_ooi_t nargs)
|
||||||
|
{
|
||||||
|
x11_win_t* win;
|
||||||
|
moo_oop_t x;
|
||||||
|
|
||||||
|
win = (x11_win_t*)moo_getobjtrailer(moo, MOO_STACK_GETRCV(moo, nargs), MOO_NULL);
|
||||||
|
|
||||||
|
x = moo_oowtoint (moo, win->dwar->atom);
|
||||||
|
if (!x) return MOO_PF_HARD_FAILURE;
|
||||||
|
|
||||||
|
MOO_STACK_SETRET (moo, nargs, x);
|
||||||
|
return MOO_PF_SUCCESS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static moo_pfrc_t pf_win_get_id (moo_t* moo, moo_ooi_t nargs)
|
static moo_pfrc_t pf_win_get_id (moo_t* moo, moo_ooi_t nargs)
|
||||||
{
|
{
|
||||||
x11_win_t* win;
|
x11_win_t* win;
|
||||||
@ -247,7 +245,6 @@ static moo_pfrc_t pf_win_get_id (moo_t* moo, moo_ooi_t nargs)
|
|||||||
|
|
||||||
MOO_STACK_SETRET (moo, nargs, x);
|
MOO_STACK_SETRET (moo, nargs, x);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static moo_pfrc_t pf_win_kill_on (moo_t* moo, moo_ooi_t nargs)
|
static moo_pfrc_t pf_win_kill_on (moo_t* moo, moo_ooi_t nargs)
|
||||||
@ -287,15 +284,12 @@ static moo_pfrc_t pf_win_make_on (moo_t* moo, moo_ooi_t nargs)
|
|||||||
|
|
||||||
MOO_DEBUG0 (moo, "<x11.win._make_on:> %p\n");
|
MOO_DEBUG0 (moo, "<x11.win._make_on:> %p\n");
|
||||||
|
|
||||||
x11 = (x11_t*)moo_getobjtrailer(moo, MOO_STACK_GETARG(moo, nargs, 0), MOO_NULL);
|
|
||||||
win = (x11_win_t*)moo_getobjtrailer(moo, MOO_STACK_GETRCV(moo, nargs), MOO_NULL);
|
win = (x11_win_t*)moo_getobjtrailer(moo, MOO_STACK_GETRCV(moo, nargs), MOO_NULL);
|
||||||
|
|
||||||
if (!x11->c)
|
if (MOO_STACK_GETARG(moo, nargs, 0) == moo->_nil) goto reterr;
|
||||||
{
|
x11 = (x11_t*)moo_getobjtrailer(moo, MOO_STACK_GETARG(moo, nargs, 0), MOO_NULL);
|
||||||
MOO_STACK_SETRETTOERROR (moo, nargs); /* TODO: be more specific about error */
|
|
||||||
return MOO_PF_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!x11->c) goto reterr;
|
||||||
win->id = xcb_generate_id (x11->c);
|
win->id = xcb_generate_id (x11->c);
|
||||||
|
|
||||||
id = moo_oowtoint (moo, win->id);
|
id = moo_oowtoint (moo, win->id);
|
||||||
@ -305,6 +299,8 @@ MOO_DEBUG0 (moo, "<x11.win._make_on:> %p\n");
|
|||||||
values[0] = x11->screen->white_pixel;
|
values[0] = x11->screen->white_pixel;
|
||||||
values[1] = XCB_EVENT_MASK_KEY_RELEASE |
|
values[1] = XCB_EVENT_MASK_KEY_RELEASE |
|
||||||
XCB_EVENT_MASK_BUTTON_PRESS |
|
XCB_EVENT_MASK_BUTTON_PRESS |
|
||||||
|
XCB_EVENT_MASK_BUTTON_RELEASE |
|
||||||
|
/*XCB_EVENT_MASK_BUTTON_MOTION |*/
|
||||||
XCB_EVENT_MASK_EXPOSURE |
|
XCB_EVENT_MASK_EXPOSURE |
|
||||||
/*XCB_EVENT_MASK_POINTER_MOTION |*/
|
/*XCB_EVENT_MASK_POINTER_MOTION |*/
|
||||||
XCB_EVENT_MASK_ENTER_WINDOW |
|
XCB_EVENT_MASK_ENTER_WINDOW |
|
||||||
@ -324,9 +320,9 @@ MOO_DEBUG0 (moo, "<x11.win._make_on:> %p\n");
|
|||||||
reply = xcb_intern_atom_reply(x11->c, cookie, 0);
|
reply = xcb_intern_atom_reply(x11->c, cookie, 0);
|
||||||
|
|
||||||
cookie = xcb_intern_atom(x11->c, 0, 16, "WM_DELETE_WINDOW");
|
cookie = xcb_intern_atom(x11->c, 0, 16, "WM_DELETE_WINDOW");
|
||||||
win->dwcr = xcb_intern_atom_reply(x11->c, cookie, 0);
|
win->dwar = xcb_intern_atom_reply(x11->c, cookie, 0);
|
||||||
|
|
||||||
xcb_change_property(x11->c, XCB_PROP_MODE_REPLACE, win->id, reply->atom, 4, 32, 1, &win->dwcr->atom);
|
xcb_change_property(x11->c, XCB_PROP_MODE_REPLACE, win->id, reply->atom, 4, 32, 1, &win->dwar->atom);
|
||||||
|
|
||||||
/*TODO: use xcb_request_check() for error handling. you need to call create_x11->wdwo_checked(). xxx_checked()... */
|
/*TODO: use xcb_request_check() for error handling. you need to call create_x11->wdwo_checked(). xxx_checked()... */
|
||||||
xcb_map_window (x11->c, win->id);
|
xcb_map_window (x11->c, win->id);
|
||||||
@ -334,6 +330,10 @@ MOO_DEBUG0 (moo, "<x11.win._make_on:> %p\n");
|
|||||||
|
|
||||||
MOO_STACK_SETRET (moo, nargs, id);
|
MOO_STACK_SETRET (moo, nargs, id);
|
||||||
return MOO_PF_SUCCESS;
|
return MOO_PF_SUCCESS;
|
||||||
|
|
||||||
|
reterr:
|
||||||
|
MOO_STACK_SETRETTOERROR (moo, nargs); /* TODO: be more specific about error */
|
||||||
|
return MOO_PF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -440,6 +440,7 @@ int moo_mod_x11 (moo_t* moo, moo_mod_t* mod)
|
|||||||
|
|
||||||
static moo_pfinfo_t x11_win_pfinfo[] =
|
static moo_pfinfo_t x11_win_pfinfo[] =
|
||||||
{
|
{
|
||||||
|
{ I, { '_','g','e','t','_','d','w','a','t','o','m','\0'}, 0, pf_win_get_dwatom },
|
||||||
{ I, { '_','g','e','t','_','i','d','\0' }, 0, pf_win_get_id },
|
{ I, { '_','g','e','t','_','i','d','\0' }, 0, pf_win_get_id },
|
||||||
{ I, { '_','k','i','l','l','_','o','n',':','\0' }, 0, pf_win_kill_on },
|
{ I, { '_','k','i','l','l','_','o','n',':','\0' }, 0, pf_win_kill_on },
|
||||||
{ I, { '_','m','a','k','e','_','o','n',':','\0' }, 0, pf_win_make_on }
|
{ I, { '_','m','a','k','e','_','o','n',':','\0' }, 0, pf_win_make_on }
|
||||||
|
Loading…
Reference in New Issue
Block a user