This repository was archived by the owner on Mar 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinternal.m
465 lines (405 loc) · 19.2 KB
/
internal.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
@import Cocoa ;
@import LuaSkin ;
#import "CGSSpace.h"
extern CGSConnectionID _CGSDefaultConnection(void);
#define CGSDefaultConnection _CGSDefaultConnection()
static LSRefTable refTable ;
#pragma mark - Support Functions
BOOL isScreenUUIDValid(NSString *theDisplay) {
BOOL isValid = NO ;
for (NSScreen *screen in [NSScreen screens]) {
NSNumber *screenNumber = [[screen deviceDescription] objectForKey:@"NSScreenNumber"] ;
CGDirectDisplayID cgID = screenNumber.unsignedIntValue ;
CFUUIDRef theUUID = CGDisplayCreateUUIDFromDisplayID(cgID) ;
if (theUUID) {
CFStringRef UUIDString = CFUUIDCreateString(kCFAllocatorDefault, theUUID) ;
if (CFStringCompare((__bridge CFStringRef)theDisplay, UUIDString, kCFCompareCaseInsensitive) == kCFCompareEqualTo)
isValid = YES ;
CFRelease(UUIDString) ;
CFRelease(theUUID) ;
if (isValid) break ;
}
}
return isValid ;
}
NSArray *getArrayFromNumberOrArray(lua_State *L, int idx) {
NSMutableArray *theArray = [[NSMutableArray alloc] init] ;
if (lua_type(L, idx) == LUA_TNUMBER)
[theArray addObject:[NSNumber numberWithUnsignedLong:(CGSSpaceID)luaL_checkinteger(L, idx)]] ;
else {
for (int i = 0 ; i < luaL_len(L, idx) ; i++) {
lua_rawgeti(L, idx, i + 1) ;
[theArray addObject:[NSNumber numberWithUnsignedLong:(CGSSpaceID)luaL_checkinteger(L, -1)]] ;
lua_pop(L, 1) ;
}
}
return theArray ;
}
static int CGSRegionRefToLua(lua_State *L, CGSRegionRef theRegion) {
if (theRegion) {
lua_newtable(L) ;
lua_pushboolean(L, CGSRegionIsEmpty(theRegion)) ; lua_setfield(L, -2, "isEmpty") ;
lua_pushboolean(L, CGSRegionIsRectangular(theRegion)) ; lua_setfield(L, -2, "isRect") ;
CGRect theRect ;
// if (CGSRegionIsRectangular(theRegion)) {
CGError state = CGSGetRegionBounds(theRegion, &theRect) ;
if (state != kCGErrorSuccess) {
lua_pushinteger(L, state) ; lua_setfield(L, -2, "error") ;
} else {
lua_newtable(L) ;
lua_pushnumber(L, theRect.origin.x) ; lua_setfield(L, -2, "x") ;
lua_pushnumber(L, theRect.origin.y) ; lua_setfield(L, -2, "y") ;
lua_pushnumber(L, theRect.size.height) ; lua_setfield(L, -2, "h") ;
lua_pushnumber(L, theRect.size.width) ; lua_setfield(L, -2, "w") ;
lua_setfield(L, -2, "bounds") ;
}
// }
CGSRegionEnumeratorRef enumerator = CGSRegionEnumerator(theRegion) ;
lua_newtable(L) ;
if (enumerator) {
CGRect *rectRef = NULL ;
while((rectRef = CGSNextRect(enumerator))) {
lua_newtable(L) ;
lua_pushnumber(L, rectRef->origin.x) ; lua_setfield(L, -2, "x") ;
lua_pushnumber(L, rectRef->origin.y) ; lua_setfield(L, -2, "y") ;
lua_pushnumber(L, rectRef->size.height) ; lua_setfield(L, -2, "h") ;
lua_pushnumber(L, rectRef->size.width) ; lua_setfield(L, -2, "w") ;
lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
}
CGSReleaseRegionEnumerator(enumerator) ;
}
lua_setfield(L, -2, "rectangles") ;
} else {
lua_pushnil(L) ;
}
return 1 ;
}
#pragma mark - Module Functions
static int changeToSpace(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
// Moved to lua for more flexibility
// CGSHideSpaces(CGSDefaultConnection, (__bridge CFArrayRef)(@[@(CGSGetActiveSpace(CGSDefaultConnection))]));
// CGSShowSpaces(CGSDefaultConnection, (__bridge CFArrayRef)(@[@(luaL_checkinteger(L, 1))]));
CFStringRef display = CGSCopyManagedDisplayForSpace(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1));
CGSManagedDisplaySetCurrentSpace(CGSDefaultConnection, display, (CGSSpaceID)lua_tointeger(L, 1));
CFRelease(display) ;
return 0 ;
}
static int disableUpdates(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TBREAK] ;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSDisableScreenUpdates() ;
#pragma clang diagnostic pop
return 0 ;
}
static int enableUpdates(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TBREAK] ;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSEnableScreenUpdates() ;
#pragma clang diagnostic pop
return 0 ;
}
/// hs._asm.undocumented.spaces.screensHaveSeparateSpaces() -> bool
/// Function
/// Determine if the user has enabled the "Displays Have Separate Spaces" option within Mission Control.
///
/// Parameters:
/// * None
///
/// Returns:
/// * true or false representing the status of the "Displays Have Separate Spaces" option within Mission Control.
///
/// Notes:
/// * This function uses standard OS X APIs and is not likely to be affected by updates or patches.
static int screensHaveSeparateSpaces(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TBREAK] ;
lua_pushboolean(L, [NSScreen screensHaveSeparateSpaces]) ;
return 1 ;
}
static int screenUUID(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TUSERDATA, "hs.screen", LS_TBREAK] ;
NSScreen *screen = (__bridge NSScreen*)*((void**)luaL_checkudata(L, 1, "hs.screen")) ;
NSNumber *screenNumber = [[screen deviceDescription] objectForKey:@"NSScreenNumber"] ;
CGDirectDisplayID cgID = screenNumber.unsignedIntValue ;
CFUUIDRef theUUID = CGDisplayCreateUUIDFromDisplayID(cgID) ;
if (theUUID) {
CFStringRef UUIDString = CFUUIDCreateString(kCFAllocatorDefault, theUUID) ;
[skin pushNSObject:(__bridge_transfer NSString *)UUIDString] ;
CFRelease(theUUID) ;
} else {
lua_pushnil(L) ;
}
return 1 ;
}
static int spaceOwners(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CFArrayRef CGspaceOwners = CGSSpaceCopyOwners(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1));
[skin pushNSObject:(__bridge_transfer NSArray *)CGspaceOwners] ;
return 1 ;
}
static int spaceType(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
lua_pushinteger(L, CGSSpaceGetType(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1))) ;
return 1 ;
}
static int spaceName(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CFStringRef CGname = CGSSpaceCopyName(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1));
[skin pushNSObject:(__bridge_transfer NSString *)CGname] ;
return 1 ;
}
static int spaceValues(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CFDictionaryRef CGspaceValues = CGSSpaceCopyValues(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1));
[skin pushNSObject:(__bridge_transfer NSDictionary *)CGspaceValues] ;
return 1 ;
}
static int spacesMasksTable(lua_State *L) {
lua_newtable(L) ;
// lua_pushinteger(L, CGSSpaceIncludesCurrent) ; lua_setfield(L, -2, "CGSSpaceIncludesCurrent") ;
// lua_pushinteger(L, CGSSpaceIncludesOthers) ; lua_setfield(L, -2, "CGSSpaceIncludesOthers") ;
// lua_pushinteger(L, CGSSpaceIncludesUser) ; lua_setfield(L, -2, "CGSSpaceIncludesUser") ;
// lua_pushinteger(L, CGSSpaceIncludesOS) ; lua_setfield(L, -2, "CGSSpaceIncludesOS") ;
// lua_pushinteger(L, CGSSpaceVisible) ; lua_setfield(L, -2, "CGSSpaceVisible") ;
lua_pushinteger(L, kCGSCurrentSpacesMask) ; lua_setfield(L, -2, "currentSpaces") ;
lua_pushinteger(L, kCGSOtherSpacesMask) ; lua_setfield(L, -2, "otherSpaces") ;
lua_pushinteger(L, kCGSAllSpacesMask) ; lua_setfield(L, -2, "allSpaces") ;
lua_pushinteger(L, kCGSCurrentOSSpacesMask) ; lua_setfield(L, -2, "currentOSSpaces") ;
lua_pushinteger(L, kCGSOtherOSSpacesMask) ; lua_setfield(L, -2, "otherOSSpaces") ;
lua_pushinteger(L, kCGSAllOSSpacesMask) ; lua_setfield(L, -2, "allOSSpaces") ;
// lua_pushinteger(L, kCGSAllVisibleSpacesMask) ; lua_setfield(L, -2, "kCGSAllVisibleSpacesMask") ;
return 1 ;
}
static int spacesTypesTable(lua_State *L) {
lua_newtable(L) ;
lua_pushinteger(L, kCGSSpaceUser) ; lua_setfield(L, -2, "user") ;
lua_pushinteger(L, kCGSSpaceFullscreen) ; lua_setfield(L, -2, "fullscreen") ;
lua_pushinteger(L, kCGSSpaceSystem) ; lua_setfield(L, -2, "system") ;
lua_pushinteger(L, kCGSSpaceUnknown) ; lua_setfield(L, -2, "unknown") ;
lua_pushinteger(L, kCGSSpaceTiled) ; lua_setfield(L, -2, "tiled") ;
return 1 ;
}
static int activeSpace(lua_State* L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TBREAK] ;
lua_pushinteger(L, (lua_Integer)CGSGetActiveSpace(CGSDefaultConnection)) ;
return 1 ;
}
static int querySpaces(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CFArrayRef CGspaces = CGSCopySpaces(CGSDefaultConnection, (CGSSpaceMask)(lua_tointeger(L, 1)));
[skin pushNSObject:(__bridge_transfer NSArray *)CGspaces] ;
return 1 ;
}
static int fullDetails(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TBREAK] ;
CFArrayRef CGmanagedDisplaySpaces = CGSCopyManagedDisplaySpaces(CGSDefaultConnection);
[skin pushNSObject:(__bridge_transfer NSArray *)CGmanagedDisplaySpaces] ;
return 1 ;
}
static int spaceScreenUUID(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CFStringRef display = CGSCopyManagedDisplayForSpace(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1));
[skin pushNSObject:(__bridge_transfer NSArray *)display] ;
return 1 ;
}
static int screenUUIDisAnimating(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TSTRING, LS_TBREAK] ;
NSString *theDisplay = [skin toNSObjectAtIndex:1] ;
BOOL isValid = isScreenUUIDValid(theDisplay) ;
if (isValid)
lua_pushboolean(L, CGSManagedDisplayIsAnimating(CGSDefaultConnection, (__bridge CFStringRef)theDisplay)) ;
else
luaL_error(L, "screenUUIDisAnimating: invalid screen UUID") ;
return 1 ;
}
static int setScreenUUIDisAnimating(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TSTRING, LS_TBOOLEAN, LS_TBREAK] ;
NSString *theDisplay = [skin toNSObjectAtIndex:1] ;
BOOL isValid = isScreenUUIDValid(theDisplay) ;
if (isValid) {
CGSManagedDisplaySetIsAnimating(CGSDefaultConnection, (__bridge CFStringRef)theDisplay, lua_toboolean(L, 2)) ;
lua_pushboolean(L, CGSManagedDisplayIsAnimating(CGSDefaultConnection, (__bridge CFStringRef)theDisplay)) ;
} else {
luaL_error(L, "setScreenUUIDisAnimating: invalid screen UUID") ;
}
return 1 ;
}
static int mainScreenUUID(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TBREAK] ;
[skin pushNSObject:(__bridge NSString *) kCGSPackagesMainDisplayIdentifier] ;
return 1 ;
}
static int spaceLevel(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TNUMBER | LS_TOPTIONAL, LS_TBREAK] ;
if (lua_type(L, 2) != LUA_TNONE) {
CGSSpaceSetAbsoluteLevel(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1), (int)lua_tointeger(L, 2)) ;
}
lua_pushinteger(L, CGSSpaceGetAbsoluteLevel(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1))) ;
return 1 ;
}
static int spaceCompatID(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
lua_pushinteger(L, CGSSpaceGetCompatID(CGSDefaultConnection, (CGSSpaceID)lua_tointeger(L, 1))) ;
return 1 ;
}
static int spaceTransform(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TTABLE | LS_TNIL | LS_TOPTIONAL, LS_TBREAK] ;
if (lua_type(L, 2) != LUA_TNONE) {
CGAffineTransform trans = CGAffineTransformMakeScale(1, 1) ;
if (lua_type(L, 2) == LUA_TTABLE) {
if (lua_rawgeti(L, 2, 1) == LUA_TNUMBER) trans.a = lua_tonumber(L, -1) ; lua_pop(L, 1) ;
if (lua_rawgeti(L, 2, 2) == LUA_TNUMBER) trans.b = lua_tonumber(L, -1) ; lua_pop(L, 1) ;
if (lua_rawgeti(L, 2, 3) == LUA_TNUMBER) trans.c = lua_tonumber(L, -1) ; lua_pop(L, 1) ;
if (lua_rawgeti(L, 2, 4) == LUA_TNUMBER) trans.d = lua_tonumber(L, -1) ; lua_pop(L, 1) ;
if (lua_rawgeti(L, 2, 5) == LUA_TNUMBER) trans.tx = lua_tonumber(L, -1) ; lua_pop(L, 1) ;
if (lua_rawgeti(L, 2, 6) == LUA_TNUMBER) trans.ty = lua_tonumber(L, -1) ; lua_pop(L, 1) ;
}
CGSSpaceSetTransform(CGSDefaultConnection, (CGSSpaceID)luaL_checkinteger(L, 1), trans);
}
CGAffineTransform trans = CGSSpaceGetTransform(CGSDefaultConnection, (CGSSpaceID)luaL_checkinteger(L, 1)) ;
lua_newtable(L) ;
lua_pushnumber(L, trans.a) ; lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
lua_pushnumber(L, trans.b) ; lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
lua_pushnumber(L, trans.c) ; lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
lua_pushnumber(L, trans.d) ; lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
lua_pushnumber(L, trans.tx) ; lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
lua_pushnumber(L, trans.ty) ; lua_rawseti(L, -2, luaL_len(L, -2) + 1) ;
return 1 ;
}
static int showSpaces(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER | LS_TTABLE, LS_TBREAK] ;
NSArray *theSpaces = getArrayFromNumberOrArray(L, 1) ;
CGSShowSpaces(CGSDefaultConnection, (__bridge CFArrayRef)theSpaces) ;
return 0 ;
}
static int hideSpaces(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER | LS_TTABLE, LS_TBREAK] ;
NSArray *theSpaces = getArrayFromNumberOrArray(L, 1) ;
CGSHideSpaces(CGSDefaultConnection, (__bridge CFArrayRef)theSpaces) ;
return 0 ;
}
static int createSpace(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TSTRING, LS_TBREAK] ;
NSDictionary *stuff = @{@"type":@(kCGSSpaceUser), @"uuid":[[NSUUID UUID] UUIDString]} ;
NSString *theDisplay = [skin toNSObjectAtIndex:1] ;
BOOL isValid = isScreenUUIDValid(theDisplay) ;
if (isValid) {
lua_pushboolean(L, CGSManagedDisplayIsAnimating(CGSDefaultConnection, (__bridge CFStringRef)theDisplay)) ;
CGSSpaceID theSpace = CGSSpaceCreate(CGSDefaultConnection, (__bridge void *)theDisplay, (__bridge CFDictionaryRef)stuff) ;
CGSSpaceSetType(CGSDefaultConnection, theSpace, kCGSSpaceUser) ;
lua_pushinteger(L, (lua_Integer)theSpace) ;
return 1 ;
} else {
return luaL_error(L, "createSpace: invalid screen UUID") ;
}
}
static int removeSpace(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CGSSpaceDestroy(CGSDefaultConnection, (CGSSpaceID)luaL_checkinteger(L, 1)) ;
return 0 ;
}
static int windowsAddTo(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER | LS_TTABLE, LS_TNUMBER | LS_TTABLE, LS_TBREAK] ;
NSArray *theWindows = getArrayFromNumberOrArray(L, 1) ;
NSArray *theSpaces = getArrayFromNumberOrArray(L, 2) ;
CGSAddWindowsToSpaces(CGSDefaultConnection, (__bridge CFArrayRef)theWindows, (__bridge CFArrayRef)theSpaces);
return 0 ;
}
static int windowsRemoveFrom(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER | LS_TTABLE, LS_TNUMBER | LS_TTABLE, LS_TBREAK] ;
NSArray *theWindows = getArrayFromNumberOrArray(L, 1) ;
NSArray *theSpaces = getArrayFromNumberOrArray(L, 2) ;
CGSRemoveWindowsFromSpaces(CGSDefaultConnection, (__bridge CFArrayRef)theWindows, (__bridge CFArrayRef)theSpaces);
return 0 ;
}
static int windowsOnSpaces(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER | LS_TTABLE, LS_TBREAK] ;
NSArray *theWindows = getArrayFromNumberOrArray(L, 1) ;
NSArray *results = (__bridge_transfer NSArray *)CGSCopySpacesForWindows(CGSDefaultConnection, kCGSAllSpacesMask, (__bridge CFArrayRef)theWindows) ;
[skin pushNSObject:results] ;
return 1 ;
}
static int spaceShape(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CGSRegionRef theRegion = CGSSpaceCopyShape(CGSDefaultConnection, (CGSSpaceID)luaL_checkinteger(L, 1)) ;
CGSRegionRefToLua(L, theRegion) ;
if (theRegion) CGSReleaseRegion(theRegion) ;
return 1 ;
}
static int spaceManagedShape(lua_State *L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
[skin checkArgs:LS_TNUMBER, LS_TBREAK] ;
CGSRegionRef theRegion = CGSSpaceCopyManagedShape(CGSDefaultConnection, (CGSSpaceID)luaL_checkinteger(L, 1)) ;
CGSRegionRefToLua(L, theRegion) ;
if (theRegion) CGSReleaseRegion(theRegion) ;
return 1 ;
}
#pragma mark - Lua Infrastructure
static luaL_Reg moduleLib[] = {
{"screensHaveSeparateSpaces", screensHaveSeparateSpaces},
{"activeSpace", activeSpace},
{"spaceType", spaceType}, //
{"spaceName", spaceName},
{"spaceLevel", spaceLevel}, //
{"spaceCompatID", spaceCompatID}, //
{"spaceOwners", spaceOwners}, //
{"spaceValues", spaceValues}, //
{"spaceScreenUUID", spaceScreenUUID}, //
{"spaceTransform", spaceTransform}, //
{"spaceShape", spaceShape}, //
{"spaceManagedShape", spaceManagedShape}, //
{"query", querySpaces},
{"details", fullDetails},
{"mainScreenUUID", mainScreenUUID},
{"UUIDforScreen", screenUUID},
{"screenUUIDisAnimating", screenUUIDisAnimating},
{"setScreenUUIDisAnimating", setScreenUUIDisAnimating},
{"showSpaces", showSpaces},
{"hideSpaces", hideSpaces},
// wrapped in init.lua
{"_changeToSpace", changeToSpace},
{"createSpace", createSpace},
{"_removeSpace", removeSpace},
{"enableUpdates", enableUpdates},
{"disableUpdates", disableUpdates},
{"windowsOnSpaces", windowsOnSpaces},
{"windowsAddTo", windowsAddTo},
{"windowsRemoveFrom", windowsRemoveFrom},
{NULL, NULL},
};
int luaopen_hs__asm_undocumented_spaces_internal(lua_State* L) {
LuaSkin *skin = [LuaSkin sharedWithState:L] ;
refTable = [skin registerLibrary:"hs._asm.undocumented.spaces" functions:moduleLib metaFunctions:nil] ;
spacesMasksTable(L) ; lua_setfield(L, -2, "masks") ;
spacesTypesTable(L) ; lua_setfield(L, -2, "types") ;
return 1;
}