This commit is contained in:
Adam D. Ruppe 2017-12-05 18:14:28 -05:00
parent 274627301a
commit d001d7218c
1 changed files with 28 additions and 3 deletions

View File

@ -2254,15 +2254,23 @@ struct EventLoop {
int run(bool delegate() whileCondition = null) { int run(bool delegate() whileCondition = null) {
assert(impl !is null); assert(impl !is null);
impl.notExited = true;
return impl.run(whileCondition); return impl.run(whileCondition);
} }
void exit() {
assert(impl !is null);
impl.notExited = false;
}
static EventLoopImpl* impl; static EventLoopImpl* impl;
} }
struct EventLoopImpl { struct EventLoopImpl {
int refcount; int refcount;
bool notExited = true;
version(linux) { version(linux) {
static import ep = core.sys.linux.epoll; static import ep = core.sys.linux.epoll;
static import unix = core.sys.posix.unistd; static import unix = core.sys.posix.unistd;
@ -2456,7 +2464,7 @@ struct EventLoopImpl {
scope(exit) insideXEventLoop = false; scope(exit) insideXEventLoop = false;
version(linux) { version(linux) {
while(!done && (whileCondition is null || whileCondition() == true)) { while(!done && (whileCondition is null || whileCondition() == true) && notExited) {
bool forceXPending = false; bool forceXPending = false;
auto wto = SimpleWindow.eventAllQueueTimeoutMSecs(); auto wto = SimpleWindow.eventAllQueueTimeoutMSecs();
// eh... some events may be queued for "squashing" (or "late delivery"), so we have to do the following magic // eh... some events may be queued for "squashing" (or "late delivery"), so we have to do the following magic
@ -2562,7 +2570,7 @@ struct EventLoopImpl {
// FIXME: we could probably support the POSIX timer_create // FIXME: we could probably support the POSIX timer_create
// signal-based option, but I'm in no rush to write it since // signal-based option, but I'm in no rush to write it since
// I prefer the fd-based functions. // I prefer the fd-based functions.
while (!done && (whileCondition is null || whileCondition() == true)) { while (!done && (whileCondition is null || whileCondition() == true) && notExited) {
while(!done && while(!done &&
(pulseTimeout == 0 || (XPending(display) > 0))) (pulseTimeout == 0 || (XPending(display) > 0)))
{ {
@ -2583,7 +2591,7 @@ struct EventLoopImpl {
version(Windows) { version(Windows) {
int ret = -1; int ret = -1;
MSG message; MSG message;
while(ret != 0 && (whileCondition is null || whileCondition() == true)) { while(ret != 0 && (whileCondition is null || whileCondition() == true) && notExited) {
auto wto = SimpleWindow.eventAllQueueTimeoutMSecs(); auto wto = SimpleWindow.eventAllQueueTimeoutMSecs();
auto waitResult = MsgWaitForMultipleObjectsEx( auto waitResult = MsgWaitForMultipleObjectsEx(
cast(int) handles.length, handles.ptr, cast(int) handles.length, handles.ptr,
@ -4585,6 +4593,23 @@ struct KeyEvent {
} }
} }
/// sets the application name.
@property string ApplicationName(string name) {
return _applicationName = name;
}
string _applicationName;
/// ditto
@property string ApplicationName() {
if(_applicationName is null) {
import core.runtime;
return Runtime.args[0];
}
return _applicationName;
}
/// Type of a [MouseEvent] /// Type of a [MouseEvent]
enum MouseEventType : int { enum MouseEventType : int {
motion = 0, /// The mouse moved inside the window motion = 0, /// The mouse moved inside the window