Skip to content

Commit 91cd9ce

Browse files
jub3iillegalprime
authored andcommitted
fix os compatibility
1 parent 9257211 commit 91cd9ce

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/robotjs.cc

+13-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "MMBitmap.h"
1111
#include "snprintf.h"
1212
#include "microsleep.h"
13-
#include "xdisplay.h"
13+
#if defined(USE_X11)
14+
#include "xdisplay.h"
15+
#endif
1416

1517
using namespace v8;
1618

@@ -682,17 +684,25 @@ NAN_METHOD(getScreenSize)
682684
NAN_METHOD(getXDisplayName)
683685
{
684686
NanScope();
687+
688+
#if defined(USE_X11)
685689
NanReturnValue(NanNew<String>(getXDisplay()));
690+
#else
691+
NanThrowError("getXDisplayName is only supported on Linux");
692+
#endif
686693
}
687694

688695
NAN_METHOD(setXDisplayName)
689696
{
690697
NanScope();
691698

699+
#if defined(USE_X11)
692700
NanUtf8String name(args[0]);
693701
setXDisplay(*name);
694-
695-
NanReturnUndefined();
702+
NanReturnValue(NanNew("1"));
703+
#else
704+
NanThrowError("setXDisplayName is only supported on Linux");
705+
#endif
696706
}
697707

698708
NAN_METHOD(captureScreen)

0 commit comments

Comments
 (0)