attempt to make input handling a bit more power efficient on no activity
This commit is contained in:
parent
92c4f8eb66
commit
4f3082f71d
24
platform.d
24
platform.d
@ -466,13 +466,22 @@ Wake(SysThread* thread)
|
||||
PThreadCondSignal(&thread.cond);
|
||||
}
|
||||
|
||||
void
|
||||
Yield()
|
||||
{
|
||||
version(linux)
|
||||
{
|
||||
import core.sys.posix.sched;
|
||||
sched_yield();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Kill()
|
||||
{
|
||||
PThreadExit(null);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ResetInputs(Inputs* inputs)
|
||||
{
|
||||
@ -1097,6 +1106,7 @@ HandleEvents(void* window_ptr)
|
||||
|
||||
bool ignore_mouse_events = false;
|
||||
|
||||
u64 no_ev_count;
|
||||
for(;;)
|
||||
{
|
||||
if(w.close)
|
||||
@ -1289,12 +1299,20 @@ HandleEvents(void* window_ptr)
|
||||
xcb_send_event(w.conn, false, req.requestor, XCB_EVENT_MASK_PROPERTY_CHANGE, cast(char*)¬ify);
|
||||
xcb_flush(w.conn);
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
ReturnInputs(w);
|
||||
}
|
||||
else
|
||||
{
|
||||
no_ev_count += 1;
|
||||
if(no_ev_count >= 5)
|
||||
{
|
||||
no_ev_count = 0;
|
||||
Yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user