This repository has been archived by the owner on Dec 21, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbindings.c
1177 lines (950 loc) · 22.6 KB
/
bindings.c
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* bindings.c - Implementation of the lua primitives.
*
* Copyright (c) 2014 by Steve Kemp. All rights reserved.
*
**
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 dated June, 1991, or (at your
* option) any later version.
*
* On Debian GNU/Linux systems, the complete text of version 2 of the GNU
* General Public License can be found in `/usr/share/common-licenses/GPL-2'
*
**
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <dirent.h>
#include <sys/stat.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xrandr.h>
#define WNCK_I_KNOW_THIS_IS_UNSTABLE 1
#include <libwnck/libwnck.h>
#include "bindings.h"
/**
* The lua_open function is present in Lua 5.1 but not Lua 5.2.
*/
#ifndef lua_open
#define lua_open luaL_newstate
#endif
/**
* Avoid warnings about unused variables.
*/
#ifndef UNUSED
#define UNUSED(x) (void)(x)
#endif
/**
* The externally defined - in kpie.c - pointer to the *current* window.
*
* The current window is updated via libwnck and all the primitives
* which are implemented in this file apply to that current window.
*/
extern WnckWindow *g_window;
/**
* The Lua state.
*
* Private to this compilation unit.
*/
lua_State *g_L;
/**
* The configuration file we'll load/execute.
*
* Private to this compilation unit.
*
* Set in init_lua().
*/
char *g_config = NULL;
/**
* The debug setting.
*
* Private to this compilation unit.
*
* Set in init_lua().
*/
int g_debug;
/**
* A flag to keep track of whether an X11-error happened.
*/
int g_error = 0;
/**
* This is an error-handler which is invoked when any of the X11-based
* primitives recieve an error.
*
* This is installed at startup, and its main purpose is to override the
* default error-handler, which would otherwise terminate the process
* when an error was raised & caught.
*
*/
int x11_error_catcher(Display *disp, XErrorEvent *xe)
{
(void)(disp);
(void)(xe);
printf("An error was caught!\n");
g_error = 1;
return 0;
}
/**
* Setup our bindings.
*/
void init_lua(int _debug, const char *config_file)
{
/**
* Open Lua, and load the standard libraries.
*/
g_L = lua_open();
luaL_openlibs(g_L);
/**
* Register our primitives to the Lua environment.
*/
lua_register(g_L, "above", lua_above);
lua_register(g_L, "activate", lua_activate);
lua_register(g_L, "activate_workspace", lua_activate_workspace);
lua_register(g_L, "below", lua_below);
lua_register(g_L, "bottom", lua_bottom);
lua_register(g_L, "exists", lua_exists);
lua_register(g_L, "decoration", lua_window_decoration);
lua_register(g_L, "focus", lua_focus);
lua_register(g_L, "fullscreen", lua_fullscreen);
lua_register(g_L, "is_focussed", lua_is_focussed);
lua_register(g_L, "is_fullscreen", lua_is_fullscreen);
lua_register(g_L, "is_maximized", lua_is_maximized);
lua_register(g_L, "is_minimized", lua_is_minimized);
lua_register(g_L, "kill", lua_kill);
lua_register(g_L, "maximize", lua_maximize);
lua_register(g_L, "maximize_horizontally", lua_maximize_horizontally);
lua_register(g_L, "maximize_vertically", lua_maximize_vertically);
lua_register(g_L, "minimize", lua_minimize);
lua_register(g_L, "pin", lua_pin);
lua_register(g_L, "pointer", lua_pointer);
lua_register(g_L, "readdir", lua_readdir);
lua_register(g_L, "screen_height", lua_screen_height);
lua_register(g_L, "screen_width", lua_screen_width);
lua_register(g_L, "shade", lua_shade);
lua_register(g_L, "size", lua_size);
lua_register(g_L, "unbottom", lua_unbottom);
lua_register(g_L, "unfullscreen", lua_unfullscreen);
lua_register(g_L, "unmaximize", lua_unmaximize);
lua_register(g_L, "unminimize", lua_unminimize);
lua_register(g_L, "unpin", lua_unpin);
lua_register(g_L, "unshade", lua_unshade);
lua_register(g_L, "window_application", lua_window_application);
lua_register(g_L, "window_class", lua_window_class);
lua_register(g_L, "window_id", lua_window_id);
lua_register(g_L, "window_xid", lua_window_xid);
lua_register(g_L, "window_pid", lua_window_pid);
lua_register(g_L, "window_role", lua_window_role_wrapper);
lua_register(g_L, "window_title", lua_window_title);
lua_register(g_L, "window_type", lua_window_type);
lua_register(g_L, "workspace", lua_workspace);
lua_register(g_L, "workspaces", lua_workspaces);
lua_register(g_L, "xy", lua_xy);
/**
* Set the value DEBUG to be true/false depending on how we were
* invoked.
*/
if (_debug)
lua_pushboolean(g_L, 1);
else
lua_pushboolean(g_L, 0);
lua_setglobal(g_L, "DEBUG");
/**
* Set the global variables VERSION and CONFIG.
*/
lua_pushstring(g_L, config_file);
lua_setglobal(g_L, "CONFIG");
lua_pushstring(g_L, VERSION);
lua_setglobal(g_L, "VERSION");
/**
* Save the constructor parameters.
*/
g_config = g_strdup(config_file);
g_debug = _debug;
}
/**
* Invoke the configuration file against the currently activated
* window, if it exists.
*/
void invoke_lua()
{
/**
* See if the users lua-file is present, if not return.
*/
struct stat sb;
if (stat(g_config, &sb) < 0)
return;
int error = luaL_dofile(g_L, g_config);
if (error)
{
if (!lua_isstring(g_L, lua_gettop(g_L)))
printf("ERROR: no detail found\n");
const char *str = lua_tostring(g_L, lua_gettop(g_L));
lua_pop(g_L, 1);
printf("ERROR: %s\n", str);
exit(1);
}
}
/**
* Close our Lua interpreter.
*/
void close_lua()
{
lua_close(g_L);
g_L = NULL;
if (g_config != NULL)
free(g_config);
g_config = NULL;
}
/**
* Show a message if we're debugging.
*/
void debug(const char *msg)
{
if (g_debug)
printf("DEBUG: %s\n", msg);
}
/**
* Some of the libwnck operations require a timestamp, for the time
* an event was emitted.
*
* This function returns something suitable.
*/
guint32 get_timestamp()
{
GTimeVal timestamp;
g_get_current_time(×tamp);
return ((guint32) timestamp.tv_sec);
}
/**
**
** The actual primitives now - in alphabetical order.
**
**
**/
/**
* Set the window to be above all other windows.
*/
int lua_above(lua_State * L)
{
UNUSED(L);
debug("above window");
wnck_window_make_above(g_window);
return 0;
}
/**
* Set the window to be in the foreground
*/
int lua_activate(lua_State * L)
{
UNUSED(L);
debug("above window");
wnck_window_activate(g_window, get_timestamp());
return 0;
}
/**
* Activate the given workspace.
*/
int lua_activate_workspace(lua_State * L)
{
int number = (int) luaL_checknumber(L, 1);
/**
* Get the count of workspaces.
*/
WnckScreen *screen = wnck_window_get_screen(g_window);
int count = wnck_screen_get_workspace_count(screen);
if (number < 1 || number > count)
{
g_warning("Workspace number out of bounds: %d", number);
}
else
{
char *x = g_strdup_printf("activate workspace %d", number);
debug(x);
g_free(x);
WnckWorkspace *workspace;
screen = wnck_window_get_screen(g_window);
workspace = wnck_screen_get_workspace(screen, number - 1);
if (workspace)
wnck_workspace_activate(workspace, get_timestamp());
else
g_warning("Failed to get workspace %d", number);
}
return 0;
}
/**
* Unset the window from being above all windows.
*/
int lua_below(lua_State * L)
{
UNUSED(L);
debug("below window");
wnck_window_unmake_above(g_window);
return 0;
}
/**
* Set the window to be below all windows.
*/
int lua_bottom(lua_State * L)
{
UNUSED(L);
debug("bottom window");
wnck_window_make_below(g_window);
return 0;
}
/**
* Does the given file/directory exist?
*/
int lua_exists(lua_State * L)
{
const char *path = luaL_checkstring(L, 1);
struct stat sb;
if (stat(path, &sb) < 0)
lua_pushboolean(L, 0);
else
lua_pushboolean(L, 1);
return 1;
}
/**
* Focus the current window.
*/
int lua_focus(lua_State * L)
{
UNUSED(L);
debug("focus window");
wnck_window_activate(g_window, get_timestamp());
return 0;
}
/**
* Set the window to be fullscreen.
*/
int lua_fullscreen(lua_State * L)
{
UNUSED(L);
debug("fullscreen window");
wnck_window_set_fullscreen(g_window, TRUE);
return 0;
}
/**
* Is the window active?
*/
int lua_is_focussed(lua_State * L)
{
WnckScreen *screen = wnck_window_get_screen(g_window);
WnckWindow *cur = wnck_screen_get_active_window(screen);
if (cur == g_window)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
/**
* Is the window fullscreen?
*/
int lua_is_fullscreen(lua_State * L)
{
if (wnck_window_is_fullscreen(g_window))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
/**
* Is the window maximized?
*/
int lua_is_maximized(lua_State * L)
{
if (wnck_window_is_maximized(g_window))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
/**
* Is the window minimized?
*/
int lua_is_minimized(lua_State * L)
{
if (wnck_window_is_minimized(g_window))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
/**
* Kill the current window.
*/
int lua_kill(lua_State * L)
{
UNUSED(L);
debug("kill window");
wnck_window_close(g_window, get_timestamp());
return (0);
}
/**
* Maximize the current window.
*/
int lua_maximize(lua_State * L)
{
UNUSED(L);
debug("maximizing window");
wnck_window_maximize(g_window);
return 0;
}
/**
* Maximize the current window horizontally.
*/
int lua_maximize_horizontally(lua_State * L)
{
UNUSED(L);
debug("maximizing window horizontally");
wnck_window_maximize_horizontally(g_window);
return 0;
}
/**
* Maximize the current window vertically.
*/
int lua_maximize_vertically(lua_State * L)
{
UNUSED(L);
debug("maximizing window vertically");
wnck_window_maximize_vertically(g_window);
return 0;
}
/**
* Minimize the current window.
*/
int lua_minimize(lua_State * L)
{
UNUSED(L);
debug("minimizing window");
wnck_window_minimize(g_window);
return 0;
}
/**
* Pin the window to all workspaces.
*/
int lua_pin(lua_State * L)
{
UNUSED(L);
debug("pin window");
wnck_window_pin(g_window);
return 0;
}
/**
* Get/Set the mouse-pointer position.
*/
int lua_pointer(lua_State *L)
{
int top = lua_gettop(L);
int x, y;
GdkDisplay *display = NULL;
GdkScreen *screen = NULL;
/* get default display and screen */
display = gdk_display_get_default();
screen = gdk_display_get_default_screen(display);
/**
* Set the value?
*/
if (top > 0)
{
x = (int) luaL_checknumber(L, 1);
y = (int) luaL_checknumber(L, 2);
gdk_display_warp_pointer(display, screen, x, y);
}
/* get cursor position */
gdk_display_get_pointer(display, NULL, &x, &y, NULL);
lua_pushinteger(L, x);
lua_pushinteger(L, y);
return 2;
}
/**
* Return a table of all files in the given directory.
*
* This is for inclusion-purposes, see the FAQ.
*/
int lua_readdir(lua_State * L)
{
struct dirent *dp;
DIR *dir;
int count = 0;
const char *directory = luaL_checkstring(L, 1);
lua_newtable(L);
dir = opendir(directory);
while (dir)
{
if ((dp = readdir(dir)) != NULL)
{
lua_pushnumber(L, count);
lua_pushstring(L, dp->d_name);
lua_settable(L, -3);
count += 1;
}
else
{
closedir(dir);
dir = 0;
}
}
lua_pushliteral(L, "n");
lua_pushnumber(L, count - 1);
lua_rawset(L, -3);
return 1;
}
/**
* Get the size of the screen.
*/
int lua_screen_height(lua_State * L)
{
Display *d = gdk_x11_get_default_xdisplay();
Window w = wnck_window_get_xid(g_window);
XRRScreenResources *xrrr = XRRGetScreenResources(d, w);
XRRCrtcInfo *xrrci;
int height = 0;
int ncrtc = xrrr->ncrtc;
for (int i = 0; i < ncrtc; ++i) {
xrrci = XRRGetCrtcInfo(d, xrrr, xrrr->crtcs[i]);
if ( xrrci->height > 0 )
height = xrrci->height;
XRRFreeCrtcInfo(xrrci);
}
XRRFreeScreenResources(xrrr);
lua_pushinteger(L, height);
return 1;
}
/**
* Get the size of the screen.
*/
int lua_screen_width(lua_State * L)
{
Display *d = gdk_x11_get_default_xdisplay();
Window w = wnck_window_get_xid(g_window);
XRRScreenResources *xrrr = XRRGetScreenResources(d, w);
XRRCrtcInfo *xrrci;
int width = 0;
int ncrtc = xrrr->ncrtc;
for (int i = 0; i < ncrtc; ++i) {
xrrci = XRRGetCrtcInfo(d, xrrr, xrrr->crtcs[i]);
if ( xrrci->width > 0 )
width = xrrci->width;
XRRFreeCrtcInfo(xrrci);
}
XRRFreeScreenResources(xrrr);
lua_pushinteger(L, width);
return 1;
}
/**
* Shade this window.
*/
int lua_shade(lua_State * L)
{
UNUSED(L);
debug("shade window");
wnck_window_shade(g_window);
return 0;
}
/**
* Get/Set the width/height of the window.
*/
int lua_size(lua_State * L)
{
int top = lua_gettop(L);
/**
* Set the values?
*/
if (top > 0)
{
int h = (int) luaL_checknumber(L, 1);
int w = (int) luaL_checknumber(L, 2);
char *x = g_strdup_printf("size(%d,%d);", h, w);
debug(x);
g_free(x);
wnck_window_set_geometry(g_window,
WNCK_WINDOW_GRAVITY_CURRENT,
WNCK_WINDOW_CHANGE_WIDTH +
WNCK_WINDOW_CHANGE_HEIGHT, -1, -1, h, w);
}
int x;
int y;
int width;
int height;
wnck_window_get_geometry(g_window, &x, &y, &width, &height);
lua_pushinteger(L, width);
lua_pushinteger(L, height);
return 2;
}
/**
* Unset the window from being below all windows.
*/
int lua_unbottom(lua_State * L)
{
UNUSED(L);
debug("unset below window");
wnck_window_unmake_below(g_window);
return 0;
}
/**
* Unset the window to be fullscreen.
*/
int lua_unfullscreen(lua_State * L)
{
UNUSED(L);
debug("unfullscreen window");
wnck_window_set_fullscreen(g_window, FALSE);
return 0;
}
/**
* Unmaximize the current window.
*/
int lua_unmaximize(lua_State * L)
{
UNUSED(L);
debug("unmaximize window");
wnck_window_unmaximize(g_window);
return 0;
}
/**
* Unminimize the current window.
*/
int lua_unminimize(lua_State * L)
{
UNUSED(L);
debug("unminimize window");
wnck_window_unminimize(g_window, get_timestamp());
return 0;
}
/**
* Unpin the window from all workspaces.
*/
int lua_unpin(lua_State * L)
{
UNUSED(L);
debug("unpin window");
wnck_window_unpin(g_window);
return 0;
}
/**
* Unshade this window.
*/
int lua_unshade(lua_State * L)
{
UNUSED(L);
debug("unshade window");
wnck_window_unshade(g_window);
return 0;
}
/**
* Return the application which created this window.
*/
int lua_window_application(lua_State * L)
{
WnckApplication *a = wnck_window_get_application(g_window);
lua_pushstring(L, wnck_application_get_name(a));
return 1;
}
/**
* Return the class of this window.
*/
int lua_window_class(lua_State * L)
{
WnckClassGroup *x = wnck_window_get_class_group(g_window);
const char *class = wnck_class_group_get_res_class(x);
lua_pushstring(L, class);
return 1;
}
/**
* Set the decorations for the current window.
*/
int lua_window_decoration(lua_State * L)
{
#define PROP_MOTIF_WM_HINTS_ELEMENTS 5
#define MWM_HINTS_DECORATIONS (1L << 1)
int enable = lua_toboolean(L, 1);
struct
{
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long inputMode;
unsigned long status;
} hints = {0,};
hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = enable ? 1 : 0;
Atom a = XInternAtom(gdk_x11_get_default_xdisplay(),
"_MOTIF_WM_HINTS", FALSE);
if (a == None)
{
lua_pushnil(L);
return 1;
}
XChangeProperty(gdk_x11_get_default_xdisplay(),
wnck_window_get_xid(g_window),
a, a, 32, PropModeReplace,
(unsigned char *)&hints, PROP_MOTIF_WM_HINTS_ELEMENTS);
return 0;
}
/**
* Return the ID of this window.
*/
int lua_window_id(lua_State * L)
{
const char *id = wnck_window_get_session_id(g_window);
if (id)
lua_pushstring(L, wnck_window_get_session_id(g_window));
else
{
g_warning("Failed to find ID");
lua_pushstring(L, "");
}
return 1;
}
/**
* Return the PID of the process that created this window.
*/
int lua_window_xid(lua_State * L)
{
gulong pid = wnck_window_get_xid(g_window);
if (pid)
lua_pushinteger(L, pid);
else
{
g_warning("Failed to find XID");
lua_pushinteger(L, 0);
}
return 1;
}
/**
* Return the PID of the process that created this window.
*/
int lua_window_pid(lua_State * L)
{
int pid = wnck_window_get_pid(g_window);
if (pid)
lua_pushinteger(L, pid);
else
{
g_warning("Failed to find PID");
lua_pushinteger(L, 0);
}
return 1;
}
/**
* Return the role of this window.
*/
int lua_window_role(lua_State * L)
{
/**
* Get the atom to get the property.
*/
Atom a = XInternAtom(gdk_x11_get_default_xdisplay(), "WM_WINDOW_ROLE", FALSE);
if (a == None)
{
lua_pushstring(L, "");
return 1;
}
Atom type;
int format;
gulong nitems;
gulong bytes_after;
unsigned char *property;
/**
* Now get the property.
*/
XGetWindowProperty(gdk_x11_get_default_xdisplay(),
wnck_window_get_xid(g_window), a,
0, G_MAXLONG,
False, AnyPropertyType, &type,
&format, &nitems,
&bytes_after, &property);
if (type == XA_STRING)
{
/**
* Success.
*/
lua_pushstring(L, ((char*)property));
return 1;
}
lua_pushstring(L, "");
return 1;
}
/**
* A simple wrapper which takes care of error-handling
* around the `lua_window_role` function.
*/
int lua_window_role_wrapper(lua_State * L)
{
/*
* Setup our error-handler.
*/
XSetErrorHandler(x11_error_catcher);
/*
* There has been no error.
*/
g_error = 0;
/*
* Call the function.
*/
int ret = lua_window_role(L);
/*
* Reset the error-wrapper.
*/
XSetErrorHandler(NULL);
/*
* If there was an error - then return nil.
*/
if (g_error != 0)
{
lua_pushnil(L);
return 1;
}
else
{
return ret;
}
}
/**
* Return the title of this window.
*/
int lua_window_title(lua_State * L)