Skip to content

Commit

Permalink
Fixed bad windowtypes/states when using UpdateProp + better thread ha…
Browse files Browse the repository at this point in the history
…ndling (#282)
  • Loading branch information
DerjenigeUberMensch authored Jul 6, 2024
1 parent 2212fa8 commit b50d423
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions getprop.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ UpdateWindowState(XCBDisplay *display, __Property__Cookie__ *cookie, XCBCookie _
Client *c = wintoclient(cookie->win);
if(c)
{
clientinitwtype(c, prop);
clientinitwstate(c, prop);
arrange(c->desktop);
XCBFlush(_wm.dpy);
}
Expand All @@ -184,7 +184,7 @@ UpdateWindowType(XCBDisplay *display, __Property__Cookie__ *cookie, XCBCookie _X
Client *c = wintoclient(cookie->win);
if(c)
{
clientinitwstate(c, prop);
clientinitwtype(c, prop);
arrange(c->desktop);
XCBFlush(_wm.dpy);
}
Expand Down Expand Up @@ -505,7 +505,7 @@ PropGetThreadCount(void)
uint32_t aloc_threads = 4;
long cores = sysconf(_SC_NPROCESSORS_ONLN);
if(cores > aloc_threads)
{ aloc_threads = cores;
{ aloc_threads = cores * 2; /* 2 threads per core */
}
if(aloc_threads > MAX_THREADS)
{ aloc_threads = MAX_THREADS;
Expand All @@ -528,8 +528,15 @@ static void
PropDestroyWorkers(uint32_t threads)
{
uint32_t i;
if(CQueueIsFull(&__queue))
{
}
for(i = 0; i < threads; ++i)
{ PropListen(NULL, 0, PropExitThread);
{
if(CQueueIsFull(&__queue))
{ CQueuePop(&__queue);
}
PropListen(NULL, 0, PropExitThread);
}
volatile uint32_t j;
for(j = 0; j < threads; ++j)
Expand Down Expand Up @@ -565,13 +572,16 @@ PropDestroy(void)
void
PropListen(XCBDisplay *display, XCBWindow win, enum PropertyType type)
{
int full = 0;
int usethreads = USING_THREADS && _wm.use_threads;
__Property__Cookie__ cookie;
cookie.win = win;
cookie.type = type;
if(USING_THREADS && _wm.use_threads)
{ CQueueAdd(&__queue, (void *)&cookie);
if(usethreads)
{ full = CQueueAdd(&__queue, (void *)&cookie);
}
else /* single thread operation */
/* single thread operation */
if(!usethreads || full)
{ UpdateProperty(display, &cookie);
}
}

0 comments on commit b50d423

Please sign in to comment.