Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debian bug 1034054: backport fvwm3 xthreadlock() #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion fvwm/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ static int _pred_weed_accumulate_expose(
return 1;
}

static int _pred_weed_is_expose(
Display *display, XEvent *event, XPointer arg)
{
return (event->type == Expose);
}

static int _pred_weed_handle_expose(
Display *display, XEvent *event, XPointer arg)
{
Expand Down Expand Up @@ -4542,7 +4548,8 @@ void handle_all_expose(void)

saved_event = fev_save_event();
FPending(dpy);
FWeedIfEvents(dpy, _pred_weed_handle_expose, NULL);
FWeedAndHandleIfEvents(dpy, _pred_weed_is_expose,
_pred_weed_handle_expose, NULL);
fev_restore_event(saved_event);

return;
Expand Down
22 changes: 22 additions & 0 deletions libs/FEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,28 @@ int FWeedIfEvents(
return weed_args.count;
}

int FWeedAndHandleIfEvents(
Display *display,
int (*weed_predicate) (Display *display, XEvent *event, XPointer arg),
int (*handler) (Display *display, XEvent *event, XPointer arg),
XPointer arg)
{
_fev_weed_args weed_args;
XEvent e;

assert(fev_is_invalid_event_type_set);
memset(&weed_args, 0, sizeof(weed_args));
weed_args.weed_predicate = weed_predicate;
weed_args.arg = arg;
if (FCheckPeekIfEvent(display, &e, _fev_pred_weed_if,
(XPointer)&weed_args)) {
handler(display, &e, arg);
}
_fev_pred_weed_if_finish(&weed_args);

return weed_args.count;
}

int FWeedIfWindowEvents(
Display *display, Window window,
int (*weed_predicate) (
Expand Down
8 changes: 8 additions & 0 deletions libs/FEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ int FWeedIfEvents(
Display *display, XEvent *current_event, XPointer arg),
XPointer arg);

/* Same as FWeedIfEvents but with a second callback out of XLockDisplay()
* to handle events in a lock-safe manner */
int FWeedAndHandleIfEvents(
Display *display,
int (*weed_predicate) (Display *display, XEvent *event, XPointer arg),
int (*handler) (Display *display, XEvent *event, XPointer arg),
XPointer arg);

/* Same as FWeedIfEvents but weeds only events for the given window. The
* weed_predicate is only called for events with a matching window. */
int FWeedIfWindowEvents(
Expand Down