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);
|
PThreadCondSignal(&thread.cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Yield()
|
||||||
|
{
|
||||||
|
version(linux)
|
||||||
|
{
|
||||||
|
import core.sys.posix.sched;
|
||||||
|
sched_yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Kill()
|
Kill()
|
||||||
{
|
{
|
||||||
PThreadExit(null);
|
PThreadExit(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ResetInputs(Inputs* inputs)
|
ResetInputs(Inputs* inputs)
|
||||||
{
|
{
|
||||||
@ -1097,6 +1106,7 @@ HandleEvents(void* window_ptr)
|
|||||||
|
|
||||||
bool ignore_mouse_events = false;
|
bool ignore_mouse_events = false;
|
||||||
|
|
||||||
|
u64 no_ev_count;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(w.close)
|
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_send_event(w.conn, false, req.requestor, XCB_EVENT_MASK_PROPERTY_CHANGE, cast(char*)¬ify);
|
||||||
xcb_flush(w.conn);
|
xcb_flush(w.conn);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnInputs(w);
|
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