Skip to content

Commit

Permalink
poser: Update to new timer implementation
Browse files Browse the repository at this point in the history
Update poser and adapt to the slightly changed API for PSC_Timer.
The new implementation doesn't use POSIX interval timers but instead
multiplexes on top of setitimer(). This should make Xmoji compatible
with systems like OpenBSD that don't offer the newer interval timers.

Fixes:	#4
  • Loading branch information
Zirias committed Aug 9, 2024
1 parent fe69c78 commit eb06b53
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion poser
6 changes: 2 additions & 4 deletions src/bin/xmoji/keyinjector.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static void resetkmap(void *receiver, void *sender, void *args)
(void)sender;
(void)args;

PSC_Timer_stop(after);
xcb_connection_t *c = X11Adapter_connection();
const xcb_setup_t *setup = xcb_get_setup(c);
CHECK(xcb_change_keyboard_mapping(c, queue[queuefront].len,
Expand All @@ -64,7 +63,6 @@ static void fakekeys(void *receiver, void *sender, void *args)
(void)sender;
(void)args;

PSC_Timer_stop(before);
xcb_connection_t *c = X11Adapter_connection();
const xcb_setup_t *setup = xcb_get_setup(c);
for (unsigned x = 0; x < queue[queuefront].len; ++x)
Expand All @@ -77,7 +75,7 @@ static void fakekeys(void *receiver, void *sender, void *args)
"KeyInjector: Cannot inject fake key release event", 0);
}

PSC_Timer_start(after);
PSC_Timer_start(after, 0);
}

static void doinject(void *obj, unsigned sequence,
Expand Down Expand Up @@ -151,7 +149,7 @@ static void doinject(void *obj, unsigned sequence,
queue[queuefront].len = len;
queue[queuefront].symspercode = kmap->keysyms_per_keycode;

if (before) PSC_Timer_start(before);
if (before) PSC_Timer_start(before, 0);
else fakekeys(0, 0, 0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/bin/xmoji/textbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static void keyboardGrabbed(void *obj, unsigned sequence,
static int activate(void *obj)
{
TextBox *self = Object_instance(obj);
PSC_Timer_start(self->cursorBlink);
PSC_Timer_start(self->cursorBlink, 1);
self->cursorvisible = 1;
Widget_setBackground(self, 1, COLOR_BG_ACTIVE);
Widget_invalidate(self);
Expand Down
3 changes: 1 addition & 2 deletions src/bin/xmoji/tooltip.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static void timeout(void *receiver, void *sender, void *args)
(void)args;

Tooltip *self = receiver;
PSC_Timer_stop(self->timer);
if (self->window)
{
Window_showTooltip(self->window, self->label, self->parent);
Expand Down Expand Up @@ -47,7 +46,7 @@ Tooltip *Tooltip_create(const UniStr *text, Widget *parent, unsigned delay)
void Tooltip_activate(Tooltip *self, Window *window)
{
self->window = window;
PSC_Timer_start(self->timer);
PSC_Timer_start(self->timer, 0);
}

void Tooltip_cancel(Tooltip *self)
Expand Down
1 change: 0 additions & 1 deletion src/bin/xmoji/x11app.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ static void svshutdown(void *receiver, void *sender, void *args)
Object_vcallv(X11App, shutdown, self);
if (PSC_List_size(self->windows))
{
PSC_Service_setTickInterval(1000);
PSC_Service_shutdownLock();
self->quitting = 1;
PSC_ListIterator *i = PSC_List_iterator(self->windows);
Expand Down
6 changes: 3 additions & 3 deletions src/bin/xmoji/xselection.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ static void XSelectionRequest_start(XSelectionRequest *self)
PSC_Timer_setMs(self->timeout, REQUESTTIMEOUT);
PSC_Event_register(PSC_Timer_expired(self->timeout), self,
XSelectionRequest_timedout, 0);
PSC_Timer_start(self->timeout);
PSC_Timer_start(self->timeout, 0);
AWAIT(xcb_change_property(c, XCB_PROP_MODE_REPLACE, self->requestor,
self->property, A(INCR), 32, 1, &incr),
self, XSelectionRequest_checkError);
Expand Down Expand Up @@ -720,7 +720,7 @@ static void XSelectionConvert_readProperty(void *obj, unsigned sequence,
PSC_Timer_setMs(self->timeout, REQUESTTIMEOUT);
PSC_Event_register(Window_propertyChanged(self->selection->w),
self, XSelectionConvert_readIncr, self->property);
PSC_Timer_start(self->timeout);
PSC_Timer_start(self->timeout, 0);
self->recvincr = 1;
if (self->next) XSelectionConvert_start(self->next);
return;
Expand Down Expand Up @@ -851,7 +851,7 @@ static void XSelectionConvert_start(XSelectionConvert *self)
PSC_Timer_setMs(self->timeout, CONVERTTIMEOUT);
PSC_Event_register(PSC_Timer_expired(self->timeout), self,
XSelectionConvert_timedout, 0);
PSC_Timer_start(self->timeout);
PSC_Timer_start(self->timeout, 0);
self->target = A(TARGETS);
XSelectionConvert_convert(self);
}
Expand Down

0 comments on commit eb06b53

Please sign in to comment.