annotate src/subtle/ruby.c @ 3214:a71e599fb6eb

Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
author unexist
date Thu, 31 May 2012 15:42:48 +0200
parents 8e428e825838
children 09ffa2ec6fbf
rev   line source
131
72cf9d02aa58 [svn] Added GPL text
unexist
parents: 108
diff changeset
1
72cf9d02aa58 [svn] Added GPL text
unexist
parents: 108
diff changeset
2 /**
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 611
diff changeset
3 * @package subtle
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 611
diff changeset
4 *
629
847e36504deb Added ruby.c
unexist
parents: 616
diff changeset
5 * @file Ruby functions
3168
4733bdd6f197 Updated year in copyright header and version info
unexist
parents: 3166
diff changeset
6 * @copyright (c) 2005-2012 Christoph Kappel <unexist@subforge.org>
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 611
diff changeset
7 * @version $Id$
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1871
diff changeset
8 *
2736
72e9e761d6a1 Updated file header
unexist
parents: 2711
diff changeset
9 * This program can be distributed under the terms of the GNU GPLv2.
72e9e761d6a1 Updated file header
unexist
parents: 2711
diff changeset
10 * See the file COPYING for details.
616
d5a0af0335f3 Replaced indenting tabs with whitespaces
unexist
parents: 611
diff changeset
11 **/
131
72cf9d02aa58 [svn] Added GPL text
unexist
parents: 108
diff changeset
12
68
ba7d049f51e5 [svn] Fixed search path for config files and greatly improved the loading and handling of the Lua scripts
unexist
parents: 50
diff changeset
13 #include <stdarg.h>
707
9e17a60b7236 Updated includes and config
unexist
parents: 703
diff changeset
14 #include <unistd.h>
9e17a60b7236 Updated includes and config
unexist
parents: 703
diff changeset
15 #include <sys/types.h>
42
d7ddeefc94af [svn] Completely re-wrote Lua functions
unexist
parents: 0
diff changeset
16 #include <dirent.h>
d7ddeefc94af [svn] Completely re-wrote Lua functions
unexist
parents: 0
diff changeset
17 #include <fnmatch.h>
266
af28c97de574 [svn] Some new comments, inotify stuff and the new sublet type
unexist
parents: 245
diff changeset
18 #include <fcntl.h>
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
19 #include <ctype.h>
629
847e36504deb Added ruby.c
unexist
parents: 616
diff changeset
20 #include <ruby.h>
2066
4c6501963b1e Set internal and external to filesystem encoding
unexist
parents: 2062
diff changeset
21 #include <ruby/encoding.h>
3214
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
22 #include <X11/Xresource.h>
0
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
23 #include "subtle.h"
40917ee3b688 [svn] Initial import
unexist
parents:
diff changeset
24
2628
eadf3564fb1f Added path expanding to Subtle::Subtle#watch
unexist
parents: 2620
diff changeset
25 #ifdef HAVE_WORDEXP_H
eadf3564fb1f Added path expanding to Subtle::Subtle#watch
unexist
parents: 2620
diff changeset
26 #include <wordexp.h>
eadf3564fb1f Added path expanding to Subtle::Subtle#watch
unexist
parents: 2620
diff changeset
27 #endif /* HAVE_WORDEXP_H */
eadf3564fb1f Added path expanding to Subtle::Subtle#watch
unexist
parents: 2620
diff changeset
28
2911
faecca3a4336 Closed #226: Replaced mode translation by subEwmhTranslateClientMode()
unexist
parents: 2908
diff changeset
29 /* Macros {{{ */
1232
b0397e22c948 Extended tags and updated value getter for identifier fetching
unexist
parents: 1221
diff changeset
30 #define CHAR2SYM(name) ID2SYM(rb_intern(name))
b0397e22c948 Extended tags and updated value getter for identifier fetching
unexist
parents: 1221
diff changeset
31 #define SYM2CHAR(sym) rb_id2name(SYM2ID(sym))
2911
faecca3a4336 Closed #226: Replaced mode translation by subEwmhTranslateClientMode()
unexist
parents: 2908
diff changeset
32 /* }}} */
1111
26547736e4aa Removed grab constants and replaced it with string handler
unexist
parents: 1103
diff changeset
33
2912
98947b828481 Fixed #227: Added check of singleton methods in options dispatcher
unexist
parents: 2911
diff changeset
34 /* Globals {{{ */
98947b828481 Fixed #227: Added check of singleton methods in options dispatcher
unexist
parents: 2911
diff changeset
35 static VALUE shelter = Qnil, mod = Qnil, config_sublets = Qnil;
98947b828481 Fixed #227: Added check of singleton methods in options dispatcher
unexist
parents: 2911
diff changeset
36 static VALUE config_instance = Qnil, config_methods = Qnil;
98947b828481 Fixed #227: Added check of singleton methods in options dispatcher
unexist
parents: 2911
diff changeset
37 /* }}} */
98947b828481 Fixed #227: Added check of singleton methods in options dispatcher
unexist
parents: 2911
diff changeset
38
1111
26547736e4aa Removed grab constants and replaced it with string handler
unexist
parents: 1103
diff changeset
39 /* Typedef {{{ */
1502
c896972cbc2a Added gravity parsing and updated ruby code
unexist
parents: 1497
diff changeset
40 typedef struct rubysymbol_t
1461
a9c3d518cc05 Added match property to tags and refactored parsing code
unexist
parents: 1445
diff changeset
41 {
a9c3d518cc05 Added match property to tags and refactored parsing code
unexist
parents: 1445
diff changeset
42 VALUE sym;
a9c3d518cc05 Added match property to tags and refactored parsing code
unexist
parents: 1445
diff changeset
43 int flags;
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
44 } RubySymbols;
1655
fada97cd7df3 Added mouse_over and mouse_out sublet hooks and renamed click to mouse_down
unexist
parents: 1646
diff changeset
45
fada97cd7df3 Added mouse_over and mouse_out sublet hooks and renamed click to mouse_down
unexist
parents: 1646
diff changeset
46 typedef struct rubymethods_t
fada97cd7df3 Added mouse_over and mouse_out sublet hooks and renamed click to mouse_down
unexist
parents: 1646
diff changeset
47 {
1738
4f7795a51695 Added Sublet#show, Sublet#hide, Sublet#hidden?
unexist
parents: 1736
diff changeset
48 VALUE sym, real;
1655
fada97cd7df3 Added mouse_over and mouse_out sublet hooks and renamed click to mouse_down
unexist
parents: 1646
diff changeset
49 int flags, arity;
fada97cd7df3 Added mouse_over and mouse_out sublet hooks and renamed click to mouse_down
unexist
parents: 1646
diff changeset
50 } RubyMethods;
1111
26547736e4aa Removed grab constants and replaced it with string handler
unexist
parents: 1103
diff changeset
51 /* }}} */
990
90d4f3592f20 Added GC marking array and fixed #11
unexist
parents: 985
diff changeset
52
1491
5da8cbd5d0d0 Improved ruby error messages and added backtrace
unexist
parents: 1484
diff changeset
53 /* RubyBacktrace {{{ */
2091
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
54 static void
1491
5da8cbd5d0d0 Improved ruby error messages and added backtrace
unexist
parents: 1484
diff changeset
55 RubyBacktrace(void)
1153
e4f7422f55c7 Updated ruby error handling
unexist
parents: 1150
diff changeset
56 {
2091
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
57 VALUE lasterr = Qnil;
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
58
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
59 /* Get last error */
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
60 if(!NIL_P(lasterr = rb_gv_get("$!")))
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
61 {
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
62 int i;
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
63 VALUE message = Qnil, klass = Qnil, backtrace = Qnil, entry = Qnil;
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
64
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
65 /* Fetching backtrace data */
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
66 message = rb_obj_as_string(lasterr);
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
67 klass = rb_class_path(CLASS_OF(lasterr));
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
68 backtrace = rb_funcall(lasterr, rb_intern("backtrace"), 0, NULL);
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
69
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
70 /* Print error and backtrace */
3085
bb77ecdbac2e Updated due to changes in r2084
unexist
parents: 3074
diff changeset
71 subSubtleLogWarn("%s: %s\n", RSTRING_PTR(klass), RSTRING_PTR(message));
2091
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
72 for(i = 0; Qnil != (entry = rb_ary_entry(backtrace, i)); ++i)
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
73 printf("\tfrom %s\n", RSTRING_PTR(entry));
b0870a1b3157 Updated error checking in RubyBacktrace() and fixed tags without matcher
unexist
parents: 2088
diff changeset
74 }
1153
e4f7422f55c7 Updated ruby error handling
unexist
parents: 1150
diff changeset
75 } /* }}} */
e4f7422f55c7 Updated ruby error handling
unexist
parents: 1150
diff changeset
76
1543
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
77 /* RubyFilter {{{ */
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
78 static inline int
3196
60af832fd27d Fixed #285: Added proprocessor check to update prototype for scandir sort
unexist
parents: 3192
diff changeset
79 #ifdef IS_OPENBSD
60af832fd27d Fixed #285: Added proprocessor check to update prototype for scandir sort
unexist
parents: 3192
diff changeset
80 RubyFilter(struct dirent *entry)
60af832fd27d Fixed #285: Added proprocessor check to update prototype for scandir sort
unexist
parents: 3192
diff changeset
81 #else
1543
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
82 RubyFilter(const struct dirent *entry)
3196
60af832fd27d Fixed #285: Added proprocessor check to update prototype for scandir sort
unexist
parents: 3192
diff changeset
83 #endif
1543
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
84 {
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
85 return !fnmatch("*.rb", entry->d_name, FNM_PATHNAME);
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
86 } /* }}} */
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
87
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
88 /* RubyReceiver {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
89 static int
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
90 RubyReceiver(unsigned long instance,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
91 unsigned long meth)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
92 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
93 VALUE receiver = Qnil;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
94
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
95 /* Check object instance */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
96 if(rb_obj_is_instance_of(meth, rb_cMethod))
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
97 receiver = rb_funcall(meth, rb_intern("receiver"), 0, NULL);
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
98
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
99 return receiver == instance;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
100 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
101
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
102 /* RubyFont {{{ */
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
103 static SubFont *
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
104 RubyFont(const char *fontname)
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
105 {
3086
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
106 SubFont *f = NULL;
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
107
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
108 /* Load font */
3086
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
109 if(!(f = subSharedFontNew(subtle->dpy, fontname)))
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
110 {
3086
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
111 subSubtleLogWarn("Cannot load font `%s'\n", fontname);
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
112
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
113 /* Load fallback font */
3086
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
114 if(!(f = subSharedFontNew(subtle->dpy, DEFFONT)))
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
115 {
3086
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
116 subSubtleLogError("Cannot load fallback font `%s'\n", DEFFONT);
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
117
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
118 subSubtleFinish();
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
119
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
120 exit(-1); ///< Should never happen
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
121 }
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
122 }
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
123
3086
520d1df430bb Updated font loading and error handling
unexist
parents: 3085
diff changeset
124 return f;
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
125 } /* }}} */
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
126
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
127 /* Type converter */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
128
2815
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
129 /* RubySubtleToSubtlext {{{ */
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
130 static VALUE
2815
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
131 RubySubtleToSubtlext(void *data)
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
132 {
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
133 SubClient *c = NULL;
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
134 VALUE object = Qnil;
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
135
2815
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
136 /* Convert subtle object to subtlext */
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
137 if((c = CLIENT(data)))
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
138 {
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
139 int id = 0;
2257
fcd134138acb Replaced autoload by const_missing dispatcher to ensure compatibility <1.9.2
unexist
parents: 2251
diff changeset
140 VALUE subtlext = Qnil, klass = Qnil;
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
141
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
142 XSync(subtle->dpy, False); ///< Sync before going on
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
143
2257
fcd134138acb Replaced autoload by const_missing dispatcher to ensure compatibility <1.9.2
unexist
parents: 2251
diff changeset
144 subtlext = rb_const_get(rb_mKernel, rb_intern("Subtlext"));
fcd134138acb Replaced autoload by const_missing dispatcher to ensure compatibility <1.9.2
unexist
parents: 2251
diff changeset
145
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
146 if(c->flags & SUB_TYPE_CLIENT) /* {{{ */
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
147 {
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
148 int flags = 0;
3214
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
149 VALUE value = Qnil;
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
150
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
151 /* Create client instance */
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
152 id = subArrayIndex(subtle->clients, (void *)c);
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
153 klass = rb_const_get(subtlext, rb_intern("Client"));
2302
d5d9abdc3ff6 Updated Subtlext::Client instantiation due to r2301
unexist
parents: 2294
diff changeset
154 object = rb_funcall(klass, rb_intern("new"), 1, INT2FIX(id));
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
155
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
156 /* Translate flags */
2911
faecca3a4336 Closed #226: Replaced mode translation by subEwmhTranslateClientMode()
unexist
parents: 2908
diff changeset
157 subEwmhTranslateClientMode(c->flags, &flags);
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
158
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
159 /* Set properties */
2302
d5d9abdc3ff6 Updated Subtlext::Client instantiation due to r2301
unexist
parents: 2294
diff changeset
160 rb_iv_set(object, "@win", LONG2NUM(c->win));
2508
1c0f1350ad88 Added init code for geometry/gravity instance variables of Subtlext::Client
unexist
parents: 2499
diff changeset
161 rb_iv_set(object, "@flags", INT2FIX(flags));
3210
8e428e825838 Updated #295: Added @tags to Subtlext::Client and Subtlext::View
unexist
parents: 3207
diff changeset
162 rb_iv_set(object, "@tags", INT2FIX(c->tags));
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
163 rb_iv_set(object, "@name", rb_str_new2(c->name));
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
164 rb_iv_set(object, "@instance", rb_str_new2(c->instance));
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
165 rb_iv_set(object, "@klass", rb_str_new2(c->klass));
3214
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
166 rb_iv_set(object, "@role", c->role ? rb_str_new2(c->role) :
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
167 Qnil);
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
168
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
169 /* Create and set geometry */
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
170 klass = rb_const_get(subtlext, rb_intern("Geometry"));
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
171 value = rb_funcall(klass, rb_intern("new"), 4, INT2FIX(c->geom.x),
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
172 INT2FIX(c->geom.y), INT2FIX(c->geom.width),
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
173 INT2FIX(c->geom.height));
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
174
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
175 rb_iv_set(object, "@geometry", value);
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
176
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
177 /* Create and set gravity if any */
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
178 if(-1 != c->gravityid)
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
179 {
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
180 SubGravity *g = GRAVITY(subArrayGet(subtle->gravities,
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
181 c->gravityid));
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
182
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
183 klass = rb_const_get(mod, rb_intern("Gravity"));
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
184 value = rb_funcall(klass, rb_intern("new"), 1,
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
185 rb_str_new2(XrmQuarkToString(g->quark)));
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
186
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
187 rb_funcall(value, rb_intern("geometry="), 4, INT2FIX(g->geom.x),
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
188 INT2FIX(g->geom.y), INT2FIX(g->geom.width),
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
189 INT2FIX(g->geom.height));
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
190 }
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
191 else value = Qnil;
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
192
a71e599fb6eb Updated #295: Added gravity and geometry values to Subtlext::Client instances in tag procs
unexist
parents: 3210
diff changeset
193 rb_iv_set(object, "@gravity", value);
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
194 } /* }}} */
2431
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
195 else if(c->flags & SUB_TYPE_SCREEN) /* {{{ */
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
196 {
2431
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
197 SubScreen *s = SCREEN(c);
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
198 VALUE klass_geom, geom = Qnil;
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
199
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
200 /* Create tag instance */
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
201 id = subArrayIndex(subtle->screens, (void *)s);
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
202 klass = rb_const_get(subtlext, rb_intern("Screen"));
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
203 klass_geom = rb_const_get(subtlext, rb_intern("Geometry"));
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
204 object = rb_funcall(klass, rb_intern("new"), 1, INT2FIX(id));
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
205 geom = rb_funcall(klass_geom, rb_intern("new"), 4,
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
206 INT2FIX(s->geom.x), INT2FIX(s->geom.y),
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
207 INT2FIX(s->geom.width), INT2FIX(s->geom.height));
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
208
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
209 /* Set properties */
2431
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
210 rb_iv_set(object, "@geometry", geom);
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
211 } /* }}} */
1713
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
212 else if(c->flags & SUB_TYPE_TAG) /* {{{ */
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
213 {
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
214 SubTag *t = TAG(c);
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
215
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
216 /* Create tag instance */
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
217 id = subArrayIndex(subtle->tags, (void *)t);
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
218 klass = rb_const_get(subtlext, rb_intern("Tag"));
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
219 object = rb_funcall(klass, rb_intern("new"), 1, rb_str_new2(t->name));
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
220
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
221 /* Set properties */
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
222 rb_iv_set(object, "@id", INT2FIX(id));
a649eed44e25 Added tag_create, tag_kill and exit hooks
unexist
parents: 1699
diff changeset
223 } /* }}} */
2431
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
224 else if(c->flags & SUB_TYPE_VIEW) /* {{{ */
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
225 {
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
226 SubView *v = VIEW(c);
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
227
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
228 /* Create view instance */
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
229 id = subArrayIndex(subtle->views, (void *)v);
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
230 klass = rb_const_get(subtlext, rb_intern("View"));
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
231 object = rb_funcall(klass, rb_intern("new"), 1, rb_str_new2(v->name));
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
232
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
233 /* Set properties */
3210
8e428e825838 Updated #295: Added @tags to Subtlext::Client and Subtlext::View
unexist
parents: 3207
diff changeset
234 rb_iv_set(object, "@id", INT2FIX(id));
8e428e825838 Updated #295: Added @tags to Subtlext::Client and Subtlext::View
unexist
parents: 3207
diff changeset
235 rb_iv_set(object, "@tags", INT2FIX(v->tags));
2431
c643f3430c89 Added Subtle::Sublet#screen
unexist
parents: 2428
diff changeset
236 } /* }}} */
1610
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
237 }
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
238
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
239 return object;
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
240 } /* }}} */
d6b71240abbc Updated hook parsing and calling
unexist
parents: 1604
diff changeset
241
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
242 /* RubyIconToIcon {{{ */
2461
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
243 static void
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
244 RubyIconToIcon(VALUE icon,
2461
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
245 SubIcon *i)
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
246 {
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
247 VALUE width = Qnil, height = Qnil, pixmap = Qnil, bitmap = Qnil;
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
248
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
249 assert(i);
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
250
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
251 /* Get properties */
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
252 width = rb_iv_get(icon, "@width");
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
253 height = rb_iv_get(icon, "@height");
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
254 pixmap = rb_iv_get(icon, "@pixmap");
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
255 bitmap = rb_funcall(icon, rb_intern("bitmap?"), 0, NULL);
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
256
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
257 /* Update panel */
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
258 i->pixmap = NUM2LONG(pixmap);
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
259 i->width = FIX2INT(width);
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
260 i->height = FIX2INT(height);
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
261 i->bitmap = (Qtrue == bitmap) ? True : False;
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
262 } /* }}} */
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
263
2749
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
264 /* RubySymbolToFlag {{{ */
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
265 static void
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
266 RubySymbolToFlag(VALUE sym,
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
267 int *flags)
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
268 {
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
269 /* Translate symbols to flags */
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
270 if(CHAR2SYM("name") == sym) (*flags) |= SUB_TAG_MATCH_NAME;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
271 else if(CHAR2SYM("instance") == sym) (*flags) |= SUB_TAG_MATCH_INSTANCE;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
272 else if(CHAR2SYM("class") == sym) (*flags) |= SUB_TAG_MATCH_CLASS;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
273 else if(CHAR2SYM("role") == sym) (*flags) |= SUB_TAG_MATCH_ROLE;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
274 else if(CHAR2SYM("type") == sym) (*flags) |= SUB_TAG_MATCH_TYPE;
2905
861d8b3e6320 Closed #224: Added handling of normal type windows
unexist
parents: 2895
diff changeset
275 else if(CHAR2SYM("normal") == sym) (*flags) |= SUB_CLIENT_TYPE_NORMAL;
2749
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
276 else if(CHAR2SYM("desktop") == sym) (*flags) |= SUB_CLIENT_TYPE_DESKTOP;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
277 else if(CHAR2SYM("dock") == sym) (*flags) |= SUB_CLIENT_TYPE_DOCK;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
278 else if(CHAR2SYM("toolbar") == sym) (*flags) |= SUB_CLIENT_TYPE_TOOLBAR;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
279 else if(CHAR2SYM("splash") == sym) (*flags) |= SUB_CLIENT_TYPE_SPLASH;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
280 else if(CHAR2SYM("dialog") == sym) (*flags) |= SUB_CLIENT_TYPE_DIALOG;
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
281 } /* }}} */
66a19618c855 Updated match/exclude parsing
unexist
parents: 2747
diff changeset
282
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
283 /* RubyArrayToArray {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
284 static void
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
285 RubyArrayToArray(VALUE ary,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
286 int *values,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
287 int len)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
288 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
289 /* Check value type */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
290 if(T_ARRAY == rb_type(ary))
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
291 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
292 int i;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
293 VALUE value = Qnil;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
294
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
295 for(i = 0; i < len; i++)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
296 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
297 /* Check and convert value type */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
298 switch(rb_type(value = rb_ary_entry(ary, i)))
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
299 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
300 case T_FIXNUM: values[i] = FIX2INT(value); break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
301 case T_FLOAT: values[i] = FIX2INT(rb_to_int(value)); break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
302 default: values[i] = 0; break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
303 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
304 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
305 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
306 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
307
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
308 /* RubyArrayToGeometry {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
309 static void
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
310 RubyArrayToGeometry(VALUE ary,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
311 XRectangle *geometry)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
312 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
313 int values[4] = { 0 };
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
314
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
315 RubyArrayToArray(ary, values, 4);
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
316
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
317 /* Assign data to geometry */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
318 geometry->x = values[0];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
319 geometry->y = values[1];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
320 geometry->width = values[2];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
321 geometry->height = values[3];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
322 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
323
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
324 /* RubyArrayToSides {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
325 static void
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
326 RubyArrayToSides(VALUE ary,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
327 SubSides *sides)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
328 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
329 int values[4] = { 0 };
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
330
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
331 RubyArrayToArray(ary, values, 4);
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
332
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
333 /* Assign data to sides CSS-alike:
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
334 * 2 values => 1. top/bottom, 2. left/right
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
335 * 3 values => 1. top, 2. left/right, 3. bottom
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
336 * 4 values => 1. top, 2. right, 3. bottom, 4. left
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
337 **/
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
338
2787
b0ff461ea190 Fixed missing RARRAY_LENINT (ruby 1.9.0)
unexist
parents: 2784
diff changeset
339 switch((int)RARRAY_LEN(ary))
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
340 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
341 case 2:
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
342 sides->top = sides->bottom = values[0];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
343 sides->right = sides->left = values[1];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
344 break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
345 case 3:
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
346 sides->top = values[0];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
347 sides->left = sides->right = values[1];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
348 sides->bottom = values[2];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
349 break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
350 case 4:
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
351 sides->top = values[0];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
352 sides->right = values[1];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
353 sides->bottom = values[2];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
354 sides->left = values[3];
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
355 break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
356 default:
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
357 rb_raise(rb_eArgError, "Too many array values");
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
358 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
359 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
360
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
361 /* RubyValueToGravity {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
362 static int
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
363 RubyValueToGravity(VALUE value)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
364 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
365 int gravity = -1;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
366
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
367 /* Check value type */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
368 switch(rb_type(value))
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
369 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
370 case T_FIXNUM: gravity = FIX2INT(value); break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
371 case T_SYMBOL: gravity = subGravityFind(SYM2CHAR(value), 0); break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
372 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
373
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
374 return 0 <= gravity && gravity < subtle->gravities->ndata ? gravity : -1;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
375 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
376
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
377 /* RubyValueToGravityString {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
378 static void
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
379 RubyValueToGravityString(VALUE value,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
380 char **string)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
381 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
382 /* Check value type */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
383 if(T_ARRAY == rb_type(value))
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
384 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
385 int i = 0, j = 0, id = -1, size = 0;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
386 VALUE entry = Qnil;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
387
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
388 /* Create gravity string */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
389 size = RARRAY_LEN(value);
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
390 *string = (char *)subSharedMemoryAlloc(size + 1, sizeof(char));
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
391
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
392 /* Add gravities */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
393 for(i = 0, j = 0; Qnil != (entry = rb_ary_entry(value, i)); i++)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
394 {
3055
9fc8eb805e65 Fixed #257: Replaced gravity string limit by a macro and set it to zero to skip just the null byte
unexist
parents: 3046
diff changeset
395 /* We store gravity ids in a string to save a bit of memory */
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
396 if(-1 != (id = RubyValueToGravity(entry)))
3055
9fc8eb805e65 Fixed #257: Replaced gravity string limit by a macro and set it to zero to skip just the null byte
unexist
parents: 3046
diff changeset
397 (*string)[j++] = id+ GRAVITYSTRLIMIT;
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
398 else subSubtleLogWarn("Cannot find gravity `%s'\n", SYM2CHAR(entry));
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
399 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
400 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
401 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
402
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
403 /* RubyValueToIcon {{{ */
2651
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
404 static VALUE
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
405 RubyValueToIcon(VALUE value)
2651
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
406 {
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
407 VALUE icon = Qnil, subtlext = Qnil, klass = Qnil;
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
408
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
409 /* Fetch data */
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
410 subtlext = rb_const_get(rb_cObject, rb_intern("Subtlext"));
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
411 klass = rb_const_get(subtlext, rb_intern("Icon"));
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
412
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
413 /* Check icon */
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
414 switch(rb_type(value))
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
415 {
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
416 case T_DATA:
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
417 /* Check object instance */
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
418 if(rb_obj_is_instance_of(value, klass))
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
419 {
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
420 icon = value; ///< Lazy eval
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
421
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
422 rb_ary_push(shelter, icon); ///< Protect from GC
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
423 }
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
424 break;
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
425 case T_STRING:
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
426 /* Create new text icon */
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
427 icon = rb_funcall(klass, rb_intern("new"), 1, value);
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
428
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
429 rb_ary_push(shelter, icon); ///< Protect from GC
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
430 break;
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
431 default: break;
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
432 }
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
433
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
434 return icon;
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
435 } /* }}} */
ea72894d1204 Refactored icon fetching code
unexist
parents: 2649
diff changeset
436
2815
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
437 /* RubyValueToHash {{{ */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
438 static VALUE
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
439 RubyValueToHash(VALUE value)
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
440 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
441 VALUE hash = Qnil;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
442
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
443 /* Check value type */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
444 switch(rb_type(value))
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
445 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
446 case T_HASH: hash = value; break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
447 case T_NIL: break; ///< Ignore this case
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
448 default:
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
449 /* Convert to hash */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
450 hash = rb_hash_new();
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
451
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
452 rb_hash_aset(hash, Qnil, value);
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
453 }
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
454
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
455 return hash;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
456 } /* }}} */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
457
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
458 /* RubyHashToColor {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
459 static void
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
460 RubyHashToColor(VALUE hash,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
461 const char *key,
2938
69753c886e4e Fixed #237: Added proper cascading: specific (> views) > all
unexist
parents: 2935
diff changeset
462 long *col)
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
463 {
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
464 VALUE value = Qnil;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
465
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
466 /* Parse and set color if key found */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
467 if(T_STRING == rb_type(value = rb_hash_lookup(hash, CHAR2SYM(key))))
2938
69753c886e4e Fixed #237: Added proper cascading: specific (> views) > all
unexist
parents: 2935
diff changeset
468 *col = (long)subSharedParseColor(subtle->dpy, RSTRING_PTR(value));
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
469 } /* }}} */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
470
2783
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
471 /* RubyHashToInt {{{ */
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
472 static void
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
473 RubyHashToInt(VALUE hash,
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
474 const char *key,
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
475 int *val)
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
476 {
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
477 VALUE value = Qnil;
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
478
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
479 /* Parse and set color if key found */
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
480 if(FIXNUM_P(value = rb_hash_lookup(hash, CHAR2SYM(key))))
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
481 *val = FIX2INT(value);
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
482 } /* }}} */
0a59805015f8 Updated #190: Added margin/padding top/right/bottom/left properties
unexist
parents: 2778
diff changeset
483
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
484 /* RubyHashToBorder {{{ */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
485 static void
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
486 RubyHashToBorder(VALUE hash,
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
487 const char *key,
2938
69753c886e4e Fixed #237: Added proper cascading: specific (> views) > all
unexist
parents: 2935
diff changeset
488 long *col,
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
489 int *bw)
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
490 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
491 VALUE value = Qnil;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
492
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
493 /* Parse and set color if key found */
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
494 switch(rb_type(value = rb_hash_lookup(hash, CHAR2SYM(key))))
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
495 {
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
496 case T_ARRAY:
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
497 {
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
498 VALUE val = Qnil;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
499
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
500 if(T_STRING == rb_type(val = rb_ary_entry(value, 0)))
2938
69753c886e4e Fixed #237: Added proper cascading: specific (> views) > all
unexist
parents: 2935
diff changeset
501 *col = (long)subSharedParseColor(subtle->dpy, RSTRING_PTR(val));
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
502
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
503 if(FIXNUM_P(val = rb_ary_entry(value, 1)))
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
504 *bw = FIX2INT(val);
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
505 }
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
506 break;
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
507 case T_STRING:
2938
69753c886e4e Fixed #237: Added proper cascading: specific (> views) > all
unexist
parents: 2935
diff changeset
508 *col = (long)subSharedParseColor(subtle->dpy, RSTRING_PTR(value));
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
509 break;
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
510 }
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
511 } /* }}} */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
512
3187
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
513 /* RubyHashToSides {{{ */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
514 static void
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
515 RubyHashToSides(VALUE params,
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
516 const char *name,
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
517 SubSides *s)
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
518 {
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
519 VALUE value = Qnil;
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
520
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
521 /* Get sides value */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
522 if(T_ARRAY == rb_type(value = rb_hash_lookup(params,
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
523 CHAR2SYM(name)))) ///< Two or more values
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
524 RubyArrayToSides(value, s);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
525 else if(FIXNUM_P(value)) ///< Single value
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
526 {
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
527 s->top = s->right = s->bottom = s->left = FIX2INT(value);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
528 }
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
529 else
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
530 {
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
531 char buf[15] = { 0 };
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
532
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
533 /* Painful string concat.. */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
534 snprintf(buf, sizeof(buf), "%s_top", name);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
535 RubyHashToInt(params, buf, &s->top);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
536
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
537 snprintf(buf, sizeof(buf), "%s_right", name);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
538 RubyHashToInt(params, buf, &s->right);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
539
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
540 snprintf(buf, sizeof(buf), "%s_bottom", name);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
541 RubyHashToInt(params, buf, &s->bottom);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
542
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
543 snprintf(buf, sizeof(buf), "%s_left", name);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
544 RubyHashToInt(params, buf, &s->left);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
545 }
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
546 } /* }}} */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
547
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
548 /* Eval */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
549
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
550 /* RubyEvalHook {{{ */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
551 static void
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
552 RubyEvalHook(VALUE event,
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
553 VALUE proc)
1997
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
554 {
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
555 int i;
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
556 SubHook *h = NULL;
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
557
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
558 RubySymbols hooks[] =
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
559 {
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
560 { CHAR2SYM("start"), SUB_HOOK_START },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
561 { CHAR2SYM("exit"), SUB_HOOK_EXIT },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
562 { CHAR2SYM("tile"), SUB_HOOK_TILE },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
563 { CHAR2SYM("reload"), SUB_HOOK_RELOAD },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
564 { CHAR2SYM("client_create"), (SUB_HOOK_TYPE_CLIENT|SUB_HOOK_ACTION_CREATE) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
565 { CHAR2SYM("client_mode"), (SUB_HOOK_TYPE_CLIENT|SUB_HOOK_ACTION_MODE) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
566 { CHAR2SYM("client_gravity"), (SUB_HOOK_TYPE_CLIENT|SUB_HOOK_ACTION_GRAVITY) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
567 { CHAR2SYM("client_focus"), (SUB_HOOK_TYPE_CLIENT|SUB_HOOK_ACTION_FOCUS) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
568 { CHAR2SYM("client_kill"), (SUB_HOOK_TYPE_CLIENT|SUB_HOOK_ACTION_KILL) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
569 { CHAR2SYM("tag_create"), (SUB_HOOK_TYPE_TAG|SUB_HOOK_ACTION_CREATE) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
570 { CHAR2SYM("tag_kill"), (SUB_HOOK_TYPE_TAG|SUB_HOOK_ACTION_KILL) },
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
571 { CHAR2SYM("view_create"), (SUB_HOOK_TYPE_VIEW|SUB_HOOK_ACTION_CREATE) },
3154
3051728c5e46 Added skip_pointer_warp_option
unexist
parents: 3148
diff changeset
572 { CHAR2SYM("view_focus"), (SUB_HOOK_TYPE_VIEW|SUB_HOOK_ACTION_FOCUS) },
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
573 { CHAR2SYM("view_kill"), (SUB_HOOK_TYPE_VIEW|SUB_HOOK_ACTION_KILL) }
1997
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
574 };
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
575
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
576 if(subtle->flags & SUB_SUBTLE_CHECK) return; ///< Skip on check
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
577
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
578 /* Generic hooks */
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
579 for(i = 0; LENGTH(hooks) > i; i++)
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
580 {
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
581 if(hooks[i].sym == event)
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
582 {
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
583 /* Create new hook */
2417
658029e88a30 Added data callback and updated hook masks
unexist
parents: 2409
diff changeset
584 if((h = subHookNew(hooks[i].flags, proc)))
1997
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
585 {
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
586 subArrayPush(subtle->hooks, (void *)h);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
587 rb_ary_push(shelter, proc); ///< Protect from GC
1997
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
588 }
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
589
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
590 break;
1997
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
591 }
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
592 }
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
593 } /* }}} */
692ec53a489b Added Subtle::Sandbox for sublet loading and updated on method
unexist
parents: 1994
diff changeset
594
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
595 /* RubyEvalGrab {{{ */
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
596 static void
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
597 RubyEvalGrab(VALUE keys,
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
598 VALUE value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
599 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
600 int type = -1;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
601 SubData data = { None };
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
602
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
603 /* Check value type */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
604 switch(rb_type(value))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
605 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
606 case T_SYMBOL: /* {{{ */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
607 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
608 /* Find symbol and add flag */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
609 if(CHAR2SYM("ViewNext") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
610 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
611 type = SUB_GRAB_VIEW_SELECT;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
612 data = DATA((unsigned long)SUB_VIEW_NEXT);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
613 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
614 else if(CHAR2SYM("ViewPrev") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
615 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
616 type = SUB_GRAB_VIEW_SELECT;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
617 data = DATA((unsigned long)SUB_VIEW_PREV);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
618 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
619 else if(CHAR2SYM("SubtleReload") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
620 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
621 type = SUB_GRAB_SUBTLE_RELOAD;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
622 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
623 else if(CHAR2SYM("SubtleRestart") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
624 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
625 type = SUB_GRAB_SUBTLE_RESTART;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
626 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
627 else if(CHAR2SYM("SubtleQuit") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
628 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
629 type = SUB_GRAB_SUBTLE_QUIT;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
630 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
631 else if(CHAR2SYM("WindowMove") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
632 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
633 type = SUB_GRAB_WINDOW_MOVE;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
634 }
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
635 else if(CHAR2SYM("WindowMoveUp") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
636 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
637 type = SUB_GRAB_WINDOW_MOVE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
638 data = DATA((unsigned long)SUB_GRAB_DIRECTION_UP);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
639 }
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
640 else if(CHAR2SYM("WindowMoveRight") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
641 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
642 type = SUB_GRAB_WINDOW_MOVE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
643 data = DATA((unsigned long)SUB_GRAB_DIRECTION_RIGHT);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
644 }
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
645 else if(CHAR2SYM("WindowMoveDown") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
646 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
647 type = SUB_GRAB_WINDOW_MOVE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
648 data = DATA((unsigned long)SUB_GRAB_DIRECTION_DOWN);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
649 }
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
650 else if(CHAR2SYM("WindowMoveLeft") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
651 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
652 type = SUB_GRAB_WINDOW_MOVE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
653 data = DATA((unsigned long)SUB_GRAB_DIRECTION_LEFT);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
654 }
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
655 else if(CHAR2SYM("WindowResize") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
656 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
657 type = SUB_GRAB_WINDOW_RESIZE;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
658 }
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
659 else if(CHAR2SYM("WindowResizeUp") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
660 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
661 type = SUB_GRAB_WINDOW_RESIZE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
662 data = DATA((unsigned long)SUB_GRAB_DIRECTION_UP);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
663 }
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
664 else if(CHAR2SYM("WindowResizeRight") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
665 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
666 type = SUB_GRAB_WINDOW_RESIZE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
667 data = DATA((unsigned long)SUB_GRAB_DIRECTION_RIGHT);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
668 }
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
669 else if(CHAR2SYM("WindowResizeDown") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
670 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
671 type = SUB_GRAB_WINDOW_RESIZE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
672 data = DATA((unsigned long)SUB_GRAB_DIRECTION_DOWN);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
673 }
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
674 else if(CHAR2SYM("WindowResizeLeft") == value)
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
675 {
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
676 type = SUB_GRAB_WINDOW_RESIZE;
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
677 data = DATA((unsigned long)SUB_GRAB_DIRECTION_LEFT);
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
678 }
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
679 else if(CHAR2SYM("WindowFloat") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
680 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
681 type = SUB_GRAB_WINDOW_TOGGLE;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
682 data = DATA((unsigned long)SUB_CLIENT_MODE_FLOAT);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
683 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
684 else if(CHAR2SYM("WindowFull") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
685 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
686 type = SUB_GRAB_WINDOW_TOGGLE;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
687 data = DATA((unsigned long)SUB_CLIENT_MODE_FULL);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
688 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
689 else if(CHAR2SYM("WindowStick") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
690 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
691 type = SUB_GRAB_WINDOW_TOGGLE;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
692 data = DATA((unsigned long)SUB_CLIENT_MODE_STICK);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
693 }
2863
de1a798ab06d Updated #216: Added grab :WindowZaphod
unexist
parents: 2842
diff changeset
694 else if(CHAR2SYM("WindowZaphod") == value)
de1a798ab06d Updated #216: Added grab :WindowZaphod
unexist
parents: 2842
diff changeset
695 {
de1a798ab06d Updated #216: Added grab :WindowZaphod
unexist
parents: 2842
diff changeset
696 type = SUB_GRAB_WINDOW_TOGGLE;
de1a798ab06d Updated #216: Added grab :WindowZaphod
unexist
parents: 2842
diff changeset
697 data = DATA((unsigned long)SUB_CLIENT_MODE_ZAPHOD);
de1a798ab06d Updated #216: Added grab :WindowZaphod
unexist
parents: 2842
diff changeset
698 }
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
699 else if(CHAR2SYM("WindowRaise") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
700 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
701 type = SUB_GRAB_WINDOW_STACK;
2984
db9a39840ff2 Updated #241: Updated due to changes in r2983
unexist
parents: 2977
diff changeset
702 data = DATA((unsigned long)SUB_CLIENT_RESTACK_UP);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
703 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
704 else if(CHAR2SYM("WindowLower") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
705 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
706 type = SUB_GRAB_WINDOW_STACK;
2984
db9a39840ff2 Updated #241: Updated due to changes in r2983
unexist
parents: 2977
diff changeset
707 data = DATA((unsigned long)SUB_CLIENT_RESTACK_DOWN);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
708 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
709 else if(CHAR2SYM("WindowLeft") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
710 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
711 type = SUB_GRAB_WINDOW_SELECT;
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
712 data = DATA((unsigned long)SUB_GRAB_DIRECTION_LEFT);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
713 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
714 else if(CHAR2SYM("WindowDown") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
715 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
716 type = SUB_GRAB_WINDOW_SELECT;
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
717 data = DATA((unsigned long)SUB_GRAB_DIRECTION_DOWN);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
718 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
719 else if(CHAR2SYM("WindowUp") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
720 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
721 type = SUB_GRAB_WINDOW_SELECT;
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
722 data = DATA((unsigned long)SUB_GRAB_DIRECTION_UP);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
723 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
724 else if(CHAR2SYM("WindowRight") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
725 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
726 type = SUB_GRAB_WINDOW_SELECT;
2873
cf4cbe6de0ef Updated #218: Added :WindowResize* and :WindowMove grabs and updated due to changes in r2872
unexist
parents: 2863
diff changeset
727 data = DATA((unsigned long)SUB_GRAB_DIRECTION_RIGHT);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
728 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
729 else if(CHAR2SYM("WindowKill") == value)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
730 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
731 type = SUB_GRAB_WINDOW_KILL;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
732 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
733
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
734 /* Symbols with parameters */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
735 if(-1 == type)
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
736 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
737 const char *name = SYM2CHAR(value);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
738
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
739 /* Numbered grabs */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
740 if(!strncmp(name, "ViewJump", 8))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
741 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
742 if((name = (char *)name + 8))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
743 {
3154
3051728c5e46 Added skip_pointer_warp_option
unexist
parents: 3148
diff changeset
744 type = SUB_GRAB_VIEW_FOCUS;
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
745 data = DATA((unsigned long)(atol(name) - 1));
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
746 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
747 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
748 else if(!strncmp(name, "ViewSwitch", 10))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
749 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
750 if((name = (char *)name + 10))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
751 {
3154
3051728c5e46 Added skip_pointer_warp_option
unexist
parents: 3148
diff changeset
752 type = SUB_GRAB_VIEW_SWAP;
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
753 data = DATA((unsigned long)(atol(name) - 1));
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
754 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
755 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
756 else if(!strncmp(name, "ScreenJump", 10))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
757 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
758 if((name = (char *)name + 10))
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
759 {
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
760 type = SUB_GRAB_SCREEN_JUMP;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
761 data = DATA((unsigned long)(atol(name) - 1));
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
762 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
763 }
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
764 else
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
765 {
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
766 /* Sublet grabs? */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
767 type = SUB_RUBY_DATA;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
768 data = DATA((unsigned long)value);
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
769 }
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
770 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
771 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
772 break; /* }}} */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
773 case T_ARRAY: /* {{{ */
2210
94526fdd6e5a Fixed double free of grab arrays
unexist
parents: 2209
diff changeset
774 type = (SUB_GRAB_WINDOW_GRAVITY|SUB_RUBY_DATA);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
775 data = DATA((unsigned long)value);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
776
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
777 rb_ary_push(shelter, value); ///< Protect from GC
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
778 break; /* }}} */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
779 case T_STRING: /* {{{ */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
780 type = SUB_GRAB_SPAWN;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
781 data = DATA(strdup(RSTRING_PTR(value)));
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
782 break; /* }}} */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
783 case T_DATA: /* {{{ */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
784 type = SUB_GRAB_PROC;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
785 data = DATA(value);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
786
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
787 rb_ary_push(shelter, value); ///< Protect from GC
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
788 break; /* }}} */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
789 default:
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
790 subSubtleLogWarn("Unexpected value type for grab `%s'\n",
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
791 rb_obj_classname(value));
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
792
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
793 return;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
794 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
795
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
796 /* Check value type */
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
797 if(T_STRING == rb_type(keys))
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
798 {
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
799 /* Skip on checking only */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
800 if(!(subtle->flags & SUB_SUBTLE_CHECK))
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
801 {
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
802 int duplicate = False, ntok = 0;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
803 char *tokens = NULL, *tok = NULL, *save = NULL;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
804 SubGrab *prev = NULL, *g = NULL;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
805
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
806 /* Parse keys */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
807 tokens = strdup(RSTRING_PTR(keys));
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
808 tok = strtok_r(tokens, " ", &save);
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
809
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
810 while(tok)
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
811 {
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
812 /* Find or create grab */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
813 if((g = subGrabNew(tok, &duplicate)))
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
814 {
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
815 if(!duplicate)
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
816 {
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
817 subArrayPush(subtle->grabs, (void *)g);
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
818 subArraySort(subtle->grabs, subGrabCompare);
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
819 }
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
820
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
821 /* Assemble chain */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
822 if(0 < ntok)
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
823 {
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
824 /* Init chain array */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
825 if(NULL == prev->keys)
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
826 {
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
827 /* Mark first grab as chain start */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
828 if(1 == ntok) prev->flags |= SUB_GRAB_CHAIN_START;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
829
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
830 prev->keys = subArrayNew();
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
831 }
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
832
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
833 /* Mark grabs w/o action as chain link */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
834 if(0 == (g->flags & ~(SUB_TYPE_GRAB|
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
835 SUB_GRAB_KEY|SUB_GRAB_MOUSE|SUB_GRAB_CHAIN_LINK)))
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
836 g->flags |= SUB_GRAB_CHAIN_LINK;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
837
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
838 subArrayPush(prev->keys, (void *)g);
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
839 }
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
840
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
841 prev = g;
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
842 }
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
843
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
844 tok = strtok_r(NULL, " ", &save);
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
845 ntok++;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
846 }
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
847
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
848 /* Add type/action to new grabs and mark as chain end */
2935
d93a43ae8164 Fixed segfault on invalid grab keysyms
unexist
parents: 2929
diff changeset
849 if(g && !duplicate)
2608
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
850 {
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
851 /* Update flags */
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
852 if(g->flags & SUB_GRAB_CHAIN_LINK)
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
853 g->flags &= ~SUB_GRAB_CHAIN_LINK;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
854 if(1 < ntok) g->flags |= SUB_GRAB_CHAIN_END;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
855
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
856 g->flags |= type;
386bfabbc216 Updated grabs handling of sublets
unexist
parents: 2598
diff changeset
857 g->data = data;
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
858 }
2620
a38c47b9638f Fixed leak on duplicate grabs
unexist
parents: 2619
diff changeset
859 else if(type & SUB_GRAB_SPAWN)
a38c47b9638f Fixed leak on duplicate grabs
unexist
parents: 2619
diff changeset
860 free(data.string);
2609
6f4f06e38dbf Fixed leak on duplicated grab
unexist
parents: 2608
diff changeset
861
6f4f06e38dbf Fixed leak on duplicated grab
unexist
parents: 2608
diff changeset
862 free(tokens);
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
863 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
864 }
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
865 else rb_raise(rb_eArgError, "Unknown value type for grab");
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
866 } /* }}} */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
867
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
868 /* RubyEvalPanel {{{ */
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
869 void
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
870 RubyEvalPanel(VALUE ary,
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
871 int position,
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
872 SubScreen *s)
1541
55d93775f9f1 Refactored code and updated gravity system
unexist
parents: 1510
diff changeset
873 {
1543
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
874 /* Check value type */
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
875 if(T_ARRAY == rb_type(ary))
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
876 {
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
877 int i, j, flags = 0;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
878 Window panel = s->panel1;
2198
3e881efba574 Added panel item centering
unexist
parents: 2191
diff changeset
879 VALUE entry = Qnil, tray = Qnil, spacer = Qnil, separator = Qnil;
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
880 VALUE sublets = Qnil, views = Qnil, title = Qnil, keychain;
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
881 VALUE center = Qnil, subtlext = Qnil;
2198
3e881efba574 Added panel item centering
unexist
parents: 2191
diff changeset
882 SubPanel *p = NULL, *last = NULL;;
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
883
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
884 /* Get syms */
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
885 tray = CHAR2SYM("tray");
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
886 spacer = CHAR2SYM("spacer");
2198
3e881efba574 Added panel item centering
unexist
parents: 2191
diff changeset
887 center = CHAR2SYM("center");
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
888 separator = CHAR2SYM("separator");
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
889 sublets = CHAR2SYM("sublets");
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
890 views = CHAR2SYM("views");
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
891 title = CHAR2SYM("title");
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
892 keychain = CHAR2SYM("keychain");
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1871
diff changeset
893
2198
3e881efba574 Added panel item centering
unexist
parents: 2191
diff changeset
894 /* Set position of panel */
2705
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
895 if(SUB_SCREEN_PANEL2 == position) panel = s->panel2;
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
896
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
897 /* Parse array and assemble panel */
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
898 for(i = 0; Qnil != (entry = rb_ary_entry(ary, i)); ++i)
1298
1c9bab6f8dc3 Added snap and panel parsing and replaced broken down font informations with a font string
unexist
parents: 1287
diff changeset
899 {
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
900 p = NULL;
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
901
2403
e609be6d97a9 Fixed panel center problem
unexist
parents: 2402
diff changeset
902 /* Parse array and assemble panel */
e609be6d97a9 Fixed panel center problem
unexist
parents: 2402
diff changeset
903 if(entry == spacer || entry == center || entry == separator)
1298
1c9bab6f8dc3 Added snap and panel parsing and replaced broken down font informations with a font string
unexist
parents: 1287
diff changeset
904 {
2817
63fc97f4856e Fixed #197: Fixed handling of separator and spacer
unexist
parents: 2816
diff changeset
905 /* Add spacer after panel item */
63fc97f4856e Fixed #197: Fixed handling of separator and spacer
unexist
parents: 2816
diff changeset
906 if(last && flags & SUB_PANEL_SPACER1)
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
907 {
2395
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
908 last->flags |= SUB_PANEL_SPACER2;
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
909 flags &= ~SUB_PANEL_SPACER1;
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
910 }
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
911
2817
63fc97f4856e Fixed #197: Fixed handling of separator and spacer
unexist
parents: 2816
diff changeset
912 /* Add separator after panel item */
63fc97f4856e Fixed #197: Fixed handling of separator and spacer
unexist
parents: 2816
diff changeset
913 if(last && flags & SUB_PANEL_SEPARATOR1)
2395
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
914 {
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
915 last->flags |= SUB_PANEL_SEPARATOR2;
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
916 flags &= ~SUB_PANEL_SEPARATOR1;
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
917 }
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
918
2403
e609be6d97a9 Fixed panel center problem
unexist
parents: 2402
diff changeset
919 /* Add flags */
e609be6d97a9 Fixed panel center problem
unexist
parents: 2402
diff changeset
920 if(entry == spacer) flags |= SUB_PANEL_SPACER1;
e609be6d97a9 Fixed panel center problem
unexist
parents: 2402
diff changeset
921 else if(entry == center) flags |= SUB_PANEL_CENTER;
e609be6d97a9 Fixed panel center problem
unexist
parents: 2402
diff changeset
922 else if(entry == separator) flags |= SUB_PANEL_SEPARATOR1;
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
923 }
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
924 else if(entry == sublets)
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
925 {
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
926 if(0 < subtle->sublets->ndata)
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
927 {
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
928 /* Add dummy panel as entry point for sublets */
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
929 flags |= SUB_PANEL_SUBLETS;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
930 p = PANEL(subSharedMemoryAlloc(1, sizeof(SubPanel)));
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
931 }
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
932 }
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
933 else if(entry == tray)
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
934 {
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
935 /* Prevent multiple use */
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
936 if(!subtle->panels.tray.screen)
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
937 {
2655
43bd0ff549e1 Fixed #184: Updated tray (de)selection to be dependent on usage of the tray panel item
unexist
parents: 2651
diff changeset
938 subtle->flags |= SUB_SUBTLE_TRAY;
43bd0ff549e1 Fixed #184: Updated tray (de)selection to be dependent on usage of the tray panel item
unexist
parents: 2651
diff changeset
939 flags |= (SUB_TYPE_PANEL|SUB_PANEL_TRAY);
43bd0ff549e1 Fixed #184: Updated tray (de)selection to be dependent on usage of the tray panel item
unexist
parents: 2651
diff changeset
940 p = &subtle->panels.tray;
2705
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
941
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
942 XReparentWindow(subtle->dpy, subtle->windows.tray,
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
943 panel, 0, 0);
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
944 }
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
945 }
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
946 else if(entry == views)
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
947 {
2461
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
948 /* Create new panel views */
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
949 p = subPanelNew(SUB_PANEL_VIEWS);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
950 }
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
951 else if(entry == title)
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
952 {
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
953 /* Create new panel title */
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
954 p = subPanelNew(SUB_PANEL_TITLE);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
955 }
2588
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
956 else if(entry == keychain)
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
957 {
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
958 /* Prevent multiple use */
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
959 if(!subtle->panels.keychain.screen)
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
960 {
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
961 flags |= (SUB_TYPE_PANEL|SUB_PANEL_KEYCHAIN);
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
962 p = &subtle->panels.keychain;
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
963 p->keychain = KEYCHAIN(subSharedMemoryAlloc(1,
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
964 sizeof(SubKeychain)));
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
965 }
b0a38d003bfd Updated #168: Added parsing of key chains and keychain panel item
unexist
parents: 2554
diff changeset
966 }
2457
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
967 else if(T_DATA == rb_type(entry))
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
968 {
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
969 if(NIL_P(subtlext))
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
970 subtlext = rb_const_get(rb_mKernel, rb_intern("Subtlext"));
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
971
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
972 if(rb_obj_is_instance_of(entry,
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
973 rb_const_get(subtlext, rb_intern("Icon"))))
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
974 {
2461
f4fb14a34fe6 Updated icon rendering and added icon_only option to views
unexist
parents: 2457
diff changeset
975 /* Create new panel icon */
2457
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
976 p = subPanelNew(SUB_PANEL_ICON);
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
977
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
978 RubyIconToIcon(entry, p->icon);
2457
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
979
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
980 rb_ary_push(shelter, entry); ///< Protect from GC
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
981 }
6eb5aa8ad3c7 Fixed #161: Added icon panel type and updated evaluation of panels
unexist
parents: 2450
diff changeset
982 }
1298
1c9bab6f8dc3 Added snap and panel parsing and replaced broken down font informations with a font string
unexist
parents: 1287
diff changeset
983 else
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
984 {
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
985 /* Check for sublets */
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
986 for(j = 0; j < subtle->sublets->ndata; j++)
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
987 {
2438
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
988 SubPanel *p2 = PANEL(subtle->sublets->data[j]);
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
989
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
990 if(entry == CHAR2SYM(p2->sublet->name))
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
991 {
2798
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
992 /* Check if sublet is already on a panel */
2438
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
993 if(p2->screen)
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
994 {
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
995 /* Clone sublet */
2438
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
996 p = subPanelNew(SUB_PANEL_COPY);
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
997
2705
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
998 p->flags |= (p2->flags & (SUB_PANEL_SUBLET|
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
999 SUB_PANEL_DOWN|SUB_PANEL_OVER|SUB_PANEL_OUT));
2438
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
1000 p->sublet = p2->sublet;
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
1001
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
1002 printf("Cloned sublet (%s)\n", p->sublet->name);
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
1003 }
77971468d8df Added cloning (output multiplexing) of sublets
unexist
parents: 2436
diff changeset
1004 else p = p2;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1005
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1006 break;
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1007 }
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1008 }
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1009 }
1876
59a541aa6a93 Removed trailing whitespaces
unexist
parents: 1871
diff changeset
1010
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1011 /* Finally add to panel */
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1012 if(p)
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1013 {
2798
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
1014 p->flags |= SUB_SCREEN_PANEL2 == position ?
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
1015 (flags|SUB_PANEL_BOTTOM) : flags; ///< Mark for bottom panel
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1016 p->screen = s;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1017 s->flags |= position; ///< Enable this panel
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1018 flags = 0;
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1019 last = p;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1020
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1021 subArrayPush(s->panels, (void *)p);
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1022 }
1298
1c9bab6f8dc3 Added snap and panel parsing and replaced broken down font informations with a font string
unexist
parents: 1287
diff changeset
1023 }
1c9bab6f8dc3 Added snap and panel parsing and replaced broken down font informations with a font string
unexist
parents: 1287
diff changeset
1024
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
1025 /* Add stuff to last item */
2395
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
1026 if(last && flags & SUB_PANEL_SPACER1) last->flags |= SUB_PANEL_SPACER2;
86b10f3f9f33 Fixed panel spacer/separator for last item
unexist
parents: 2393
diff changeset
1027 if(last && flags & SUB_PANEL_SEPARATOR1) last->flags |= SUB_PANEL_SEPARATOR2;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1028
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1029 subRubyRelease(ary);
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
1030 }
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
1031 } /* }}} */
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
1032
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1033 /* RubyEvalConfig {{{ */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1034 static void
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1035 RubyEvalConfig(void)
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
1036 {
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1037 int i;
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1038
3176
f0879d15c5b7 Renamed subStyleInheritance to subStyleUpdate and added font checks
unexist
parents: 3175
diff changeset
1039 /* Update style values */
f0879d15c5b7 Renamed subStyleInheritance to subStyleUpdate and added font checks
unexist
parents: 3175
diff changeset
1040 subStyleUpdate();
2938
69753c886e4e Fixed #237: Added proper cascading: specific (> views) > all
unexist
parents: 2935
diff changeset
1041
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1042 /* Check and update grabs */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1043 if(0 == subtle->grabs->ndata)
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
1044 {
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1045 subSubtleLogWarn("Cannot find any grabs\n");
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1046 subSubtleFinish();
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1047
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1048 exit(-1);
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
1049 }
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1050 else
1994
b3bc5780accd Replaced hash based config by a DSL
unexist
parents: 1983
diff changeset
1051 {
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1052 subArraySort(subtle->grabs, subGrabCompare);
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1053
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1054 /* Update grabs and gravites */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1055 for(i = 0; i < subtle->grabs->ndata; i++)
2087
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1056 {
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1057 SubGrab *g = GRAB(subtle->grabs->data[i]);
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1058
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1059 /* Update gravity grab */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1060 if(g->flags & SUB_GRAB_WINDOW_GRAVITY)
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1061 {
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1062 char *string = NULL;
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1063
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1064 /* Create gravity string */
2778
45656fa009a5 Updated #190: Removed various options and replaced #color by #style in Subtle::Config
unexist
parents: 2772
diff changeset
1065 RubyValueToGravityString(g->data.num, &string);
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1066 subRubyRelease(g->data.num);
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1067 g->data.string = string;
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1068 g->flags &= ~SUB_RUBY_DATA;
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1069 }
2087
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1070 }
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1071 }
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1072
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1073 /* Check gravities */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1074 if(0 == subtle->gravities->ndata)
2087
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1075 {
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1076 subSubtleLogError("Cannot find any gravities\n");
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1077 subSubtleFinish();
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1078
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1079 exit(-1);
2087
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1080 }
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1081
2809
16d25a802925 Updated handling of default gravity
unexist
parents: 2807
diff changeset
1082 /* Get default gravity or use default (-1) */
16d25a802925 Updated handling of default gravity
unexist
parents: 2807
diff changeset
1083 subtle->gravity = RubyValueToGravity(subtle->gravity);
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1084
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1085 subGravityPublish();
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1086
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1087 /* Check and update screens */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1088 for(i = 0; i < subtle->screens->ndata; i++)
2209
de433dd0b336 Fixed window type matching
unexist
parents: 2203
diff changeset
1089 {
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1090 SubScreen *s = SCREEN(subtle->screens->data[i]);
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1091
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1092 /* Check if vid exists */
3154
3051728c5e46 Added skip_pointer_warp_option
unexist
parents: 3148
diff changeset
1093 if(0 > s->viewid || s->viewid >= subtle->views->ndata)
3051728c5e46 Added skip_pointer_warp_option
unexist
parents: 3148
diff changeset
1094 s->viewid = 0;
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1095
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1096 s->flags &= ~SUB_RUBY_DATA;
2209
de433dd0b336 Fixed window type matching
unexist
parents: 2203
diff changeset
1097 }
2087
fbcbb5f18236 Updated parsing of new match format
unexist
parents: 2068
diff changeset
1098
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1099 /* Check and update tags */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1100 for(i = 0; i < subtle->tags->ndata; i++)
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1101 {
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1102 SubTag *t = TAG(subtle->tags->data[i]);
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1103
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1104 /* Update gravities */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1105 if(t->flags & SUB_TAG_GRAVITY)
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1106 {
2809
16d25a802925 Updated handling of default gravity
unexist
parents: 2807
diff changeset
1107 /* Disable tag gravity when gravity can't be found */
3163
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1108 if(-1 == (t->gravityid = RubyValueToGravity(t->gravityid)))
2809
16d25a802925 Updated handling of default gravity
unexist
parents: 2807
diff changeset
1109 t->flags &= ~SUB_TAG_GRAVITY;
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1110 }
3163
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1111
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1112 /* Update screens */
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1113 if(t->flags & SUB_CLIENT_MODE_STICK)
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1114 {
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1115 if(-1 != t->screenid &&
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1116 (0 > t->screenid || subtle->screens->ndata <= t->screenid))
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1117 t->flags &= ~SUB_CLIENT_MODE_STICK;
97650efd5b70 Fixed #274: Added support of fixnum values in stick property to specifiy a screen
unexist
parents: 3161
diff changeset
1118 }
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1119 }
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1120
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1121 subTagPublish();
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1122
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1123 /* Check tag count */
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1124 if(1 == subtle->tags->ndata)
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1125 {
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1126 subSubtleLogWarn("Cannot find any tags\n");
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1127 }
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1128 else if(32 < subtle->tags->ndata)
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1129 subSubtleLogWarn("Cannot handle more than 32 tags\n");
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1130
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1131 /* Check and update views */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1132 if(0 == subtle->views->ndata) ///< Create default view
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1133 {
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1134 SubView *v = subViewNew("subtle", "default");
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1135
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1136 subArrayPush(subtle->views, (void *)v);
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1137 subSubtleLogError("Cannot find any views\n");
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1138 }
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1139 else ///< Check default tag
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1140 {
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1141 SubView *v = NULL;
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1142
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1143 /* Check for view with default tag */
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1144 for(i = subtle->views->ndata - 1; 0 <= i; i--)
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1145 if((v = VIEW(subtle->views->data[i])) && v->tags & DEFAULTTAG)
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1146 {
3087
7bde205f887c Updated log messages
unexist
parents: 3086
diff changeset
1147 subSubtleLogDebugRuby("EvalConfig: default view=%s\n", v->name);
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1148 break;
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1149 }
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1150
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1151 v->tags |= DEFAULTTAG; ///< Set default tag
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1152 }
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1153
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1154 subViewPublish();
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1155 subDisplayPublish();
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1156 } /* }}} */
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1157
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1158 /* RubyEvalStyle {{{ */
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1159 static void
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1160 RubyEvalStyle(VALUE name,
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1161 SubStyle *s,
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1162 VALUE params)
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1163 {
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1164 int bw = -1;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1165 long border = -1;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1166 VALUE value = Qnil;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1167
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1168 /* Special cases */
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1169 if(CHAR2SYM("subtle") == name)
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1170 {
3183
e967fe7b3b33 Fixed background property of subtle style
unexist
parents: 3178
diff changeset
1171 /* Get colors */
e967fe7b3b33 Fixed background property of subtle style
unexist
parents: 3178
diff changeset
1172 RubyHashToColor(params, "background", &s->bg);
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1173 RubyHashToColor(params, "panel_top", &s->top);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1174 RubyHashToColor(params, "panel_bottom", &s->bottom);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1175 RubyHashToColor(params, "stipple", &s->fg);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1176
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1177 /* Set strut */
3200
14c6dc634785 Updated strut/padding config value handling
unexist
parents: 3199
diff changeset
1178 RubyHashToSides(params, "strut", &s->padding);
14c6dc634785 Updated strut/padding config value handling
unexist
parents: 3199
diff changeset
1179 RubyHashToSides(params, "padding", &s->padding);
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1180
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1181 /* Set both panel colors */
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1182 if(!NIL_P(value = rb_hash_lookup(params, CHAR2SYM("panel"))))
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1183 {
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1184 RubyHashToColor(params, "panel", &s->top);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1185 s->bottom = s->top;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1186 }
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1187 }
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1188 else if(CHAR2SYM("clients") == name)
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1189 {
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1190 /* We misuse some style values here:
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1191 * border-top <-> client border
3187
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1192 * border-right <-> title length
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1193 * margin <-> client gap */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1194
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1195 /* Set border color and width */
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1196 RubyHashToBorder(params, "active", &s->fg, &s->border.top);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1197 RubyHashToBorder(params, "inactive", &s->bg, &s->border.top);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1198
3187
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1199 /* Get client margin */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1200 RubyHashToSides(params, "margin", &s->margin);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1201
3061
48288b46f7b3 Updated #258: Added font property to style DSL
unexist
parents: 3055
diff changeset
1202 /* FIXME: Set title width, but that should be a title style, right? */
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1203 if(FIXNUM_P(value = rb_hash_lookup(params, CHAR2SYM("width"))))
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1204 s->right = FIX2INT(value);
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1205 else s->right = 50;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1206 }
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1207 else
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1208 {
3178
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1209 /* Get colors */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1210 RubyHashToColor(params, "foreground", &s->fg);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1211 RubyHashToColor(params, "background", &s->bg);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1212 RubyHashToColor(params, "icon", &s->icon);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1213
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1214 /* Set all borders */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1215 RubyHashToBorder(params, "border", &border, &bw);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1216
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1217 /* Get borders */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1218 RubyHashToBorder(params, "border_top", &s->top, &s->border.top);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1219 RubyHashToBorder(params, "border_right", &s->right, &s->border.right);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1220 RubyHashToBorder(params, "border_bottom", &s->bottom, &s->border.bottom);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1221 RubyHashToBorder(params, "border_left", &s->left, &s->border.left);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1222
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1223 /* Apply catchall values */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1224 if(-1 != border) s->top = s->right = s->bottom = s->left = border;
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1225 if(-1 != bw)
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1226 {
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1227 s->border.top = s->border.right =
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1228 s->border.bottom = s->border.left = bw;
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1229 }
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1230
3187
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1231 /* Get padding/margin */
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1232 RubyHashToSides(params, "padding", &s->padding);
d5ae3c9ebb57 Fixed client margin
unexist
parents: 3183
diff changeset
1233 RubyHashToSides(params, "margin", &s->margin);
3178
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1234
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1235 /* Get min width */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1236 RubyHashToInt(params, "min_width", &s->min);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1237 s->min = MAX(0, s->min);
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1238
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1239 /* Style font */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1240 if(T_STRING == rb_type(value = rb_hash_lookup(params,
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1241 CHAR2SYM("font"))) && !s->font)
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1242 {
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1243 s->flags |= SUB_STYLE_FONT;
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1244 s->font = RubyFont(RSTRING_PTR(value));
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1245
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1246 /* EWMH: Font */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1247 if(CHAR2SYM("all") == name)
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1248 subEwmhSetString(ROOT, SUB_EWMH_SUBTLE_FONT, RSTRING_PTR(value));
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1249 }
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1250
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1251 /* Style separator */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1252 if(T_STRING == rb_type(value = rb_hash_lookup(params,
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1253 CHAR2SYM("separator"))) && !s->separator)
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1254 {
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1255 s->flags |= SUB_STYLE_SEPARATOR;
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1256
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1257 /* Create new separator */
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1258 s->separator = (SubSeparator *)subSharedMemoryAlloc(1,
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1259 sizeof(SubSeparator));
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1260 s->separator->string = strdup(RSTRING_PTR(value));
d9b6c23b2a2a Updated style value eval
unexist
parents: 3176
diff changeset
1261 }
3092
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1262 }
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1263 } /* }}} */
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1264
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1265 /* Foreach */
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1266
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1267 /* RubyForeachMatcher {{{ */
2815
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1268 static int
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1269 RubyForeachMatcher(VALUE key,
2815
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1270 VALUE value,
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1271 VALUE data)
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1272 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1273 int type = 0;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1274 VALUE regex = Qnil, *rargs = (VALUE *)data;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1275
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1276 if(key == Qundef) return ST_CONTINUE;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1277
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1278 /* Check key value type */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1279 switch(rb_type(key))
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1280 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1281 case T_NIL:
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1282 type = SUB_TAG_MATCH_INSTANCE|SUB_TAG_MATCH_CLASS; ///< Defaults
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1283 break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1284 case T_SYMBOL: RubySymbolToFlag(key, &type); break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1285 case T_ARRAY:
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1286 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1287 int i;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1288 VALUE entry = Qnil;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1289
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1290 /* Check flags in array */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1291 for(i = 0; Qnil != (entry = rb_ary_entry(key, i)); i++)
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1292 RubySymbolToFlag(entry, &type);
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1293 }
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1294 break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1295 default: rb_raise(rb_eArgError, "Unknown value type");
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1296 }
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1297
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1298 /* Check value type */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1299 switch(rb_type(value))
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1300 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1301 case T_REGEXP:
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1302 regex = rb_funcall(value, rb_intern("source"), 0, NULL);
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1303 break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1304 case T_SYMBOL: RubySymbolToFlag(value, &type); break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1305 case T_ARRAY:
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1306 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1307 int i;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1308 VALUE entry = Qnil;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1309
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1310 /* Check flags in array */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1311 for(i = 0; Qnil != (entry = rb_ary_entry(value, i)); i++)
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1312 RubySymbolToFlag(entry, &type);
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1313 }
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1314 break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1315 case T_STRING: regex = value; break;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1316 default: rb_raise(rb_eArgError, "Unknown value type");
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1317 }
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1318
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1319 /* Finally create regex if there is any and append additional flags */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1320 if(0 < type)
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1321 {
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1322 subTagMatcherAdd(TAG(rargs[0]), type,
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1323 NIL_P(regex) ? NULL : RSTRING_PTR(regex), 0 < rargs[1]++);
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1324 }
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1325
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1326 return ST_CONTINUE;
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1327 } /* }}} */
2d6d9945e252 Closed #193: Replaced tag exclude by logic AND
unexist
parents: 2809
diff changeset
1328
3021
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1329 /* RubyForeachStyle {{{ */
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1330 static int
3021
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1331 RubyForeachStyle(VALUE key,
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1332 VALUE value,
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1333 VALUE data)
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1334 {
2973
9688ce38ebb6 Updated #240: Added icon style element
unexist
parents: 2967
diff changeset
1335 SubStyle *s = (SubStyle *)data, *style = NULL;
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1336
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1337 if(key == Qundef || NIL_P(value)) return ST_CONTINUE;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1338
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1339 /* Create new state */
2973
9688ce38ebb6 Updated #240: Added icon style element
unexist
parents: 2967
diff changeset
1340 style = subStyleNew();
9688ce38ebb6 Updated #240: Added icon style element
unexist
parents: 2967
diff changeset
1341 style->name = strdup(SYM2CHAR(key));
9688ce38ebb6 Updated #240: Added icon style element
unexist
parents: 2967
diff changeset
1342 RubyEvalStyle(key, style, rb_iv_get(value, "@params"));
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1343
3092
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1344 /* Ease access to sub-styles */
3021
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1345 if(&subtle->styles.views == s)
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1346 {
3092
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1347 if(CHAR2SYM("urgent") == key) subtle->styles.urgent = style;
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1348 else if(CHAR2SYM("occupied") == key) subtle->styles.occupied = style;
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1349 else if(CHAR2SYM("focus") == key) subtle->styles.focus = style;
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1350 else if(CHAR2SYM("visible") == key) subtle->styles.visible = style;
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1351 else if(CHAR2SYM("separator") == key) subtle->styles.viewsep = style;
3089
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1352 else if(CHAR2SYM("unoccupied") == key)
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1353 {
3092
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1354 subSubtleLogDeprecated("The `unoccupied' style is deprecated, "
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1355 "please use the `views' style for normal views instead.\n");
3089
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1356
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1357 subStyleMerge(&subtle->styles.views, style);
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1358 subStyleKill(style);
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1359
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1360 return ST_CONTINUE;
612e9eb9fdf2 Updated #240: Removed unoccupied style in favor of views style
unexist
parents: 3087
diff changeset
1361 }
3021
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1362 }
3092
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1363 else if(&subtle->styles.sublets == s)
e6761de8bfdc Updated #261: Added handling of style separator property
unexist
parents: 3089
diff changeset
1364 if(CHAR2SYM("separator") == key) subtle->styles.subletsep = style;
2973
9688ce38ebb6 Updated #240: Added icon style element
unexist
parents: 2967
diff changeset
1365
9688ce38ebb6 Updated #240: Added icon style element
unexist
parents: 2967
diff changeset
1366 /* Finally add style */
3021
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1367 if(!s->styles) s->styles = subArrayNew();
93158907e861 Updated #247: Removed deprecated style definition syntax and added visible style
unexist
parents: 3000
diff changeset
1368 subArrayPush(s->styles, (void *)style);
2956
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1369
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1370 return ST_CONTINUE;
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1371 } /* }}} */
8532ef11ebd8 Updated #240: Added style state handling
unexist
parents: 2947
diff changeset
1372
1543
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
1373 /* Wrap */
59c001100b3b Refactored code and added sanity stuff to catch errors
unexist
parents: 1541
diff changeset
1374
1220
bcdf6e275c9f Replaced rb_funcall_rescue with rb_protect wrapper for ruby 1.9 (ticket #88)
unexist
parents: 1206
diff changeset
1375 /* RubyWrapLoadSubtlext {{{ */
bcdf6e275c9f Replaced rb_funcall_rescue with rb_protect wrapper for ruby 1.9 (ticket #88)
unexist
parents: 1206
diff changeset
1376 static VALUE
bcdf6e275c9f Replaced rb_funcall_rescue with rb_protect wrapper for ruby 1.9 (ticket #88)
unexist
parents: 1206
diff changeset
1377 RubyWrapLoadSubtlext(VALUE data)
bcdf6e275c9f Replaced rb_funcall_rescue with rb_protect wrapper for ruby 1.9 (ticket #88)
unexist
parents: 1206
diff changeset
1378 {
2257
fcd134138acb Replaced autoload by const_missing dispatcher to ensure compatibility <1.9.2
unexist
parents: 2251
diff changeset
1379 return rb_require("subtle/subtlext");
1220
bcdf6e275c9f Replaced rb_funcall_rescue with rb_protect wrapper for ruby 1.9 (ticket #88)
unexist
parents: 1206
diff changeset
1380 }/* }}} */
bcdf6e275c9f Replaced rb_funcall_rescue with rb_protect wrapper for ruby 1.9 (ticket #88)
unexist
parents: 1206
diff changeset
1381
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1382 /* RubyWrapLoadPanels {{{ */
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1383 static VALUE
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1384 RubyWrapLoadPanels(VALUE data)
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1385 {
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1386 int i;
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1387
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1388 /* Pass 1: Load actual panels */
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1389 for(i = 0; i < subtle->screens->ndata; i++)
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1390 {
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1391 SubScreen *s = SCREEN(subtle->screens->data[i]);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1392
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1393 if(!s->panels) s->panels = subArrayNew();
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1394
2221
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1395 RubyEvalPanel(s->top, SUB_SCREEN_PANEL1, s);
64a261a68fa6 Moved DSL stuff from Kernel into own class, added proper autoloading of subtlext and updated sublet init via config values
unexist
parents: 2216
diff changeset
1396 RubyEvalPanel(s->bottom, SUB_SCREEN_PANEL2, s);
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1397 }
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1398
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1399 /* Pass 2: Add remaining sublets if any */
1625
fe0fb1ffb083 Fixed :sublets panel crash on empty sublet list
unexist
parents: 1623
diff changeset
1400 if(0 < subtle->sublets->ndata)
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1401 {
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1402 int j, k, pos;
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1403
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1404 for(i = 0; i < subtle->screens->ndata; i++)
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1405 {
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1406 SubScreen *s = SCREEN(subtle->screens->data[i]);
2188
54d31d0ab619 Fixed raising sublets over fullscreen windows
unexist
parents: 2180
diff changeset
1407 Window panel = s->panel1;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1408
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1409 for(j = 0; j < s->panels->ndata; j++)
1615
e6739d2ff559 Updated panel parsing and evaluation
unexist
parents: 1610
diff changeset
1410 {
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1411 SubPanel *p = PANEL(s->panels->data[j]);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1412
2705
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
1413 if(panel != s->panel2 && p->flags & SUB_PANEL_BOTTOM)
f0d2e20ceff2 Updated #164: Updated panel parsing and added bottom flags
unexist
parents: 2693
diff changeset
1414 panel = s->panel2;
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1415
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1416 /* Find dummy panel */
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1417 if(p->flags & SUB_PANEL_SUBLETS)
1684
6a864ef6230c Added sublet reloading, updated panel parsing and fixed GC marking of sublets
unexist
parents: 1667
diff changeset
1418 {
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1419 SubPanel *sublet = NULL;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1420
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1421 pos = j;
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1422
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1423 subArrayRemove(s->panels, (void *)p);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1424
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1425 /* Find sublets not on any panel so far */
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1426 for(k = 0; k < subtle->sublets->ndata; k++)
1625
fe0fb1ffb083 Fixed :sublets panel crash on empty sublet list
unexist
parents: 1623
diff changeset
1427 {
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1428 sublet = PANEL(subtle->sublets->data[k]);
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1429
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1430 /* Check if screen is empty */
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1431 if(NULL == sublet->screen)
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1432 {
2432
b9274ae10e06 Fixed screen assignment of catch-all sublets
unexist
parents: 2431
diff changeset
1433 sublet->flags |= SUB_PANEL_SEPARATOR2;
b9274ae10e06 Fixed screen assignment of catch-all sublets
unexist
parents: 2431
diff changeset
1434 sublet->screen = s;
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1435
2798
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
1436 /* Mark for bottom panel */
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
1437 if(p->flags & SUB_PANEL_BOTTOM)
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
1438 sublet->flags |= SUB_PANEL_BOTTOM;
4d6cbb3c2c53 Updated bottom flags for sublets
unexist
parents: 2787
diff changeset
1439
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1440 subArrayInsert(s->panels, pos++, (void *)sublet);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1441 }
1625
fe0fb1ffb083 Fixed :sublets panel crash on empty sublet list
unexist
parents: 1623
diff changeset
1442 }
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1443
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1444 /* Check spacers and separators in first and last sublet */
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1445 if((sublet = PANEL(subArrayGet(s->panels, j))))
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1446 sublet->flags |= (p->flags & (SUB_PANEL_BOTTOM|
2198
3e881efba574 Added panel item centering
unexist
parents: 2191
diff changeset
1447 SUB_PANEL_SPACER1|SUB_PANEL_SEPARATOR1|SUB_PANEL_CENTER));
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1448
2203
36b94d9ad6f3 Added grabs to sublets
unexist
parents: 2198
diff changeset
1449 if((sublet = PANEL(subArrayGet(s->panels, pos - 1))))
2180
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1450 {
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1451 sublet->flags |= (p->flags & SUB_PANEL_SPACER2);
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1452
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166
diff changeset
1453 if(!(p->flags & SUB_PANEL_SEPARATOR2))
7651af15b9d9 Added new screen config, deprecation warnings for old stuff and updated error checking
unexist
parents: 2166