-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathregion.c
1073 lines (774 loc) · 22.3 KB
/
region.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* ion/ioncore/region.c
*
* Copyright (c) Tuomo Valkonen 1999-2007.
*
* See the included file LICENSE for details.
*/
#include <string.h>
#include <X11/Xatom.h>
#include <libtu/objp.h>
#include <libextl/extl.h>
#include <libmainloop/defer.h>
#include "property.h"
#include "common.h"
#include "global.h"
#include "region.h"
#include "focus.h"
#include "regbind.h"
#include "names.h"
#include "resize.h"
#include "manage.h"
#include "extlconv.h"
#include "activity.h"
#include "region-iter.h"
#include "return.h"
#include "log.h"
#include "screen-notify.h"
#define D2(X)
WHook *region_notify_hook=NULL;
static void region_notify_change_(WRegion *reg, WRegionNotify how);
/*{{{ Init & deinit */
void region_init(WRegion *reg, WWindow *par, const WFitParams *fp)
{
if(fp->g.w<0 || fp->g.h<0)
warn(TR("Creating region with negative width or height!"));
reg->geom=fp->g;
reg->flags=0;
reg->bindings=NULL;
reg->rootwin=NULL;
reg->children=NULL;
reg->parent=NULL;
reg->p_next=NULL;
reg->p_prev=NULL;
reg->active_sub=NULL;
reg->active_prev=NULL;
reg->active_next=NULL;
reg->ni.name=NULL;
reg->ni.inst_off=0;
reg->ni.node=NULL;
reg->manager=NULL;
reg->submapstat=NULL;
reg->mgd_activity=FALSE;
if(par!=NULL){
reg->rootwin=((WRegion*)par)->rootwin;
region_set_parent(reg, par);
}else{
assert(OBJ_IS(reg, WRootWin));
}
}
static void destroy_children(WRegion *reg)
{
WRegion *sub, *prev=NULL;
bool complained=FALSE;
/* destroy children */
while(1){
sub=reg->children;
if(sub==NULL)
break;
assert(!OBJ_IS_BEING_DESTROYED(sub));
assert(sub!=prev);
if(ioncore_g.opmode!=IONCORE_OPMODE_DEINIT && !complained && OBJ_IS(reg, WClientWin)){
warn(TR("Destroying object \"%s\" with client windows as "
"children."), region_name(reg));
complained=TRUE;
}
prev=sub;
destroy_obj((Obj*)sub);
}
}
void region_deinit(WRegion *reg)
{
region_notify_change(reg, ioncore_g.notifies.deinit);
destroy_children(reg);
if(ioncore_g.focus_next==reg){
D(warn("Region to be focused next destroyed[1]."));
ioncore_g.focus_next=NULL;
}
region_detach_manager(reg);
region_unset_return(reg);
region_unset_parent(reg);
region_remove_bindings(reg);
region_unregister(reg);
region_focus_deinit(reg);
if(ioncore_g.focus_next==reg){
D(warn("Region to be focused next destroyed[2]."));
ioncore_g.focus_next=NULL;
}
}
/*}}}*/
/*{{{ Dynfuns */
bool region_fitrep(WRegion *reg, WWindow *par, const WFitParams *fp)
{
bool ret=FALSE;
CALL_DYN_RET(ret, bool, region_fitrep, reg, (reg, par, fp));
return ret;
}
void region_updategr(WRegion *reg)
{
CALL_DYN(region_updategr, reg, (reg));
}
void region_map(WRegion *reg)
{
CALL_DYN(region_map, reg, (reg));
region_notify_change_(reg, ioncore_g.notifies.map);
}
void region_unmap(WRegion *reg)
{
CALL_DYN(region_unmap, reg, (reg));
region_notify_change_(reg, ioncore_g.notifies.unmap);
}
void region_notify_rootpos(WRegion *reg, int x, int y)
{
CALL_DYN(region_notify_rootpos, reg, (reg, x, y));
}
Window region_xwindow(const WRegion *reg)
{
Window ret=None;
CALL_DYN_RET(ret, Window, region_xwindow, reg, (reg));
return ret;
}
void region_activated(WRegion *reg)
{
CALL_DYN(region_activated, reg, (reg));
}
void region_inactivated(WRegion *reg)
{
CALL_DYN(region_inactivated, reg, (reg));
}
void region_do_set_focus(WRegion *reg, bool warp)
{
CALL_DYN(region_do_set_focus, reg, (reg, warp));
}
/*{{{ Manager region dynfuns */
static bool region_managed_prepare_focus_default(WRegion *mgr, WRegion *reg,
int flags,
WPrepareFocusResult *res)
{
if(!region_prepare_focus(mgr, flags, res))
return FALSE;
res->reg=reg;
res->flags=flags;
return TRUE;
}
bool region_managed_prepare_focus(WRegion *mgr, WRegion *reg,
int flags,
WPrepareFocusResult *res)
{
bool ret=TRUE;
CALL_DYN_RET(ret, bool, region_managed_prepare_focus, mgr,
(mgr, reg, flags, res));
return ret;
}
void region_managed_notify(WRegion *mgr, WRegion *reg, WRegionNotify how)
{
CALL_DYN(region_managed_notify, mgr, (mgr, reg, how));
}
void region_managed_remove(WRegion *mgr, WRegion *reg)
{
CALL_DYN(region_managed_remove, mgr, (mgr, reg));
}
/*EXTL_DOC
* Return the object, if any, that is considered ''currently active''
* within the objects managed by \var{mplex}.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
WRegion *region_current(WRegion *mgr)
{
WRegion *ret=NULL;
CALL_DYN_RET(ret, WRegion*, region_current, mgr, (mgr));
return ret;
}
WRegion *region_current_default(WRegion *reg)
{
return reg->active_sub;
}
void region_child_removed(WRegion *reg, WRegion *sub)
{
CALL_DYN(region_child_removed, reg, (reg, sub));
}
/*}}}*/
/*{{{ Dynfun defaults */
void region_updategr_default(WRegion *reg)
{
WRegion *sub=NULL;
FOR_ALL_CHILDREN(reg, sub){
region_updategr(sub);
}
}
/*}}}*/
/*}}}*/
/*{{{ Goto */
bool region_prepare_focus(WRegion *reg, int flags,
WPrepareFocusResult *res)
{
if(!REGION_IS_ACTIVE(reg) || !REGION_IS_MAPPED(reg)){
WRegion *mgr=REGION_MANAGER(reg);
WRegion *par=REGION_PARENT_REG(reg);
if(mgr!=NULL){
return region_managed_prepare_focus(mgr, reg, flags, res);
}else if(par!=NULL){
if(!region_prepare_focus(par, flags, res))
return FALSE;
/* Just focus reg, if it has no manager, and parent can be
* focused.
*/
}else if(!REGION_IS_MAPPED(reg)){
region_map(reg);
}
}
res->reg=reg;
res->flags=flags;
return TRUE;
}
bool region_goto_flags(WRegion *reg, int flags)
{
WPrepareFocusResult res;
bool ret;
ret=region_prepare_focus(reg, flags, &res);
if(res.reg!=NULL){
if(res.flags®ION_GOTO_FOCUS)
region_maybewarp(res.reg, !(res.flags®ION_GOTO_NOWARP));
}
return ret;
}
/*EXTL_DOC
* Attempt to display \var{reg}, save region activity status and then
* warp to (or simply set focus to if warping is disabled) \var{reg}.
*
* Note that this function is asynchronous; the region will not
* actually have received the focus when this function returns.
*/
EXTL_EXPORT_MEMBER
bool region_goto_focus(WRegion *reg)
{
return region_goto_flags(reg, REGION_GOTO_FOCUS);
}
/*EXTL_DOC
* Deprecated in favour of \fnref{WRegion.goto_focus} because 'goto' is a
* keyword since Lua 5.2.
*/
EXTL_EXPORT_MEMBER
bool region_goto(WRegion *reg)
{
return region_goto_focus(reg);
}
/*
* Kept for backwards compatibility
*/
EXTL_EXPORT_MEMBER
bool region_goto_(WRegion *reg)
{
return region_goto_focus(reg);
}
/*
* Kept for backwards compatibility
*/
EXTL_EXPORT_MEMBER
bool region_display(WRegion *reg)
{
return region_goto_focus(reg);
}
/*}}}*/
/*{{{ Fit/reparent */
void region_fit(WRegion *reg, const WRectangle *geom, WRegionFitMode mode)
{
WFitParams fp;
fp.g=*geom;
fp.mode=mode&~REGION_FIT_GRAVITY;
fp.gravity=ForgetGravity;
region_fitrep(reg, NULL, &fp);
}
bool region_reparent(WRegion *reg, WWindow *par,
const WRectangle *geom, WRegionFitMode mode)
{
WFitParams fp;
fp.g=*geom;
fp.mode=mode;
return region_fitrep(reg, par, &fp);
}
/*}}}*/
/*{{{ Close */
static void region_rqclose_default(WRegion *reg, bool relocate)
{
if(relocate || region_may_dispose(reg))
region_defer_rqdispose(reg);
}
/*EXTL_DOC
* Attempt to close/destroy \var{reg}. Whether this operation works
* depends on whether the particular type of region in question has
* implemented the feature and, in case of client windows, whether
* the client supports the \code{WM_DELETE} protocol (see also
* \fnref{WClientWin.kill}). The region will not be destroyed when
* this function returns. To find out if and when it is destroyed,
* use the "deinit" notification. If \var{relocate} is not set, and
* \var{reg} manages other regions, it will not be closed. Otherwise
* the managed regions will be attempted to be relocated.
*/
EXTL_EXPORT_MEMBER
void region_rqclose(WRegion *reg, bool relocate)
{
CALL_DYN(region_rqclose, reg, (reg, relocate));
}
static WRegion *region_rqclose_propagate_default(WRegion *reg,
WRegion *maybe_sub)
{
if(maybe_sub==NULL)
maybe_sub=region_current(reg);
if(maybe_sub!=NULL){
return region_rqclose_propagate(maybe_sub, NULL);
}else{
region_rqclose(reg, FALSE);
return reg;
}
}
/*EXTL_DOC
* Recursively attempt to close a region or one of the regions managed by
* it. If \var{sub} is set, it will be used as the managed region, otherwise
* \fnref{WRegion.current}\code{(reg)}. The object to be closed is
* returned, or NULL if nothing can be closed. For further details, see
* notes for \fnref{WRegion.rqclose}.
*/
EXTL_EXPORT_MEMBER
WRegion *region_rqclose_propagate(WRegion *reg, WRegion *maybe_sub)
{
WRegion *ret=NULL;
CALL_DYN_RET(ret, WRegion*, region_rqclose_propagate, reg,
(reg, maybe_sub));
return ret;
}
bool region_may_dispose_default(WRegion *reg)
{
bool res=region_rescue_needed(reg);
if(res){
const char *name=region_name(reg);
warn(TR("Can not destroy %s: contains client windows."),
(name!=NULL ? name : TR("(unknown)")));
}
return !res;
}
bool region_may_dispose(WRegion *reg)
{
bool ret=TRUE;
CALL_DYN_RET(ret, bool, region_may_dispose, reg, (reg));
return ret;
}
static WRegion *region_managed_disposeroot_default(WRegion *UNUSED(mgr), WRegion *reg)
{
return reg;
}
WRegion *region_managed_disposeroot(WRegion *mgr, WRegion *reg)
{
WRegion *ret=NULL;
CALL_DYN_RET(ret, WRegion*, region_managed_disposeroot, mgr, (mgr, reg));
return ret;
}
WRegion *region_disposeroot(WRegion *reg)
{
WRegion *mgr=REGION_MANAGER(reg);
return (mgr!=NULL
? region_managed_disposeroot(mgr, reg)
: reg);
}
bool region_rqdispose(WRegion *reg)
{
WRegion *root;
if(!region_may_dispose(reg))
return FALSE;
root=region_disposeroot(reg);
if(root==NULL)
return FALSE;
return region_dispose(root);
}
bool region_dispose_(WRegion *reg, bool not_simple)
{
bool rescue=not_simple;
bool was_mcf=(not_simple && region_may_control_focus(reg));
WPHolder *ph=NULL;
if(rescue){
if(!region_rescue(reg, NULL)){
warn(TR("Failed to rescue some client windows - not closing."));
return FALSE;
}
}
if(was_mcf)
ph=region_unset_get_return(reg);
destroy_obj((Obj*)reg);
if(ph!=NULL){
pholder_goto(ph);
destroy_obj((Obj*)ph);
}
return TRUE;
}
bool region_dispose(WRegion *reg)
{
return region_dispose_(reg, TRUE);
}
void region_defer_rqdispose(WRegion *reg)
{
mainloop_defer_action((Obj*)reg, (WDeferredAction*)region_rqdispose);
}
/*}}}*/
/*{{{ Manager/parent stuff */
/* Routine to call to unmanage a region */
void region_detach_manager(WRegion *reg)
{
WRegion *mgr=REGION_MANAGER(reg);
if(mgr==NULL)
return;
region_managed_remove(mgr, reg);
assert(REGION_MANAGER(reg)==NULL);
}
void region_unset_manager_pseudoactivity(WRegion *reg)
{
WRegion *mgr=reg->manager, *par=REGION_PARENT_REG(reg);
if(mgr==NULL || mgr==par || !REGION_IS_PSEUDOACTIVE(mgr))
return;
mgr->flags&=~REGION_PSEUDOACTIVE;
region_notify_change(mgr, ioncore_g.notifies.pseudoinactivated);
region_unset_manager_pseudoactivity(mgr);
}
void region_set_manager_pseudoactivity(WRegion *reg)
{
WRegion *mgr=reg->manager, *par=REGION_PARENT_REG(reg);
if(!REGION_IS_ACTIVE(reg) && !REGION_IS_PSEUDOACTIVE(reg))
return;
if(mgr==NULL || mgr==par || REGION_IS_PSEUDOACTIVE(mgr))
return;
mgr->flags|=REGION_PSEUDOACTIVE;
region_notify_change(mgr, ioncore_g.notifies.pseudoactivated);
region_set_manager_pseudoactivity(mgr);
}
/* This should only be called within region_managed_remove,
* _after_ any managed lists and other essential structures
* of mgr have been broken.
*/
void region_unset_manager(WRegion *reg, WRegion *mgr)
{
if(reg->manager!=mgr)
return;
region_notify_change_(reg, ioncore_g.notifies.unset_manager);
region_unset_manager_pseudoactivity(reg);
reg->manager=NULL;
if(region_is_activity_r(reg))
region_clear_mgd_activity(mgr);
region_unset_return(reg);
}
/* This should be called within region attach routines,
* _after_ any managed lists and other essential structures
* of mgr have been set up.
*/
void region_set_manager(WRegion *reg, WRegion *mgr)
{
assert(reg->manager==NULL);
reg->manager=mgr;
region_set_manager_pseudoactivity(reg);
if(region_is_activity_r(reg))
region_mark_mgd_activity(mgr);
region_notify_change_(reg, ioncore_g.notifies.set_manager);
}
void region_set_parent(WRegion *reg, WWindow *parent)
{
assert(reg->parent==NULL && parent!=NULL);
LINK_ITEM(((WRegion*)parent)->children, reg, p_next, p_prev);
reg->parent=parent;
}
void region_unset_parent(WRegion *reg)
{
WRegion *p=REGION_PARENT_REG(reg);
if(p==NULL || p==reg)
return;
UNLINK_ITEM(p->children, reg, p_next, p_prev);
reg->parent=NULL;
if(p->active_sub==reg){
p->active_sub=NULL;
region_update_owned_grabs(p);
}
region_child_removed(p, reg);
}
/*EXTL_DOC
* Returns the region that manages \var{reg}.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
WRegion *region_manager(WRegion *reg)
{
return reg->manager;
}
/*EXTL_DOC
* Returns the parent region of \var{reg}.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
WWindow *region_parent(WRegion *reg)
{
return reg->parent;
}
WRegion *region_manager_or_parent(WRegion *reg)
{
if(reg->manager!=NULL)
return reg->manager;
else
return (WRegion*)(reg->parent);
}
WRegion *region_get_manager_chk(WRegion *p, const ClassDescr *descr)
{
WRegion *mgr=NULL;
if(p!=NULL){
mgr=REGION_MANAGER(p);
if(obj_is((Obj*)mgr, descr))
return mgr;
}
return NULL;
}
/*}}}*/
/*{{{ Stacking and ordering */
static void region_stacking_default(WRegion *reg,
Window *bottomret, Window *topret)
{
Window win=region_xwindow(reg);
*bottomret=win;
*topret=win;
}
void region_stacking(WRegion *reg, Window *bottomret, Window *topret)
{
CALL_DYN(region_stacking, reg, (reg, bottomret, topret));
}
void region_restack(WRegion *reg, Window other, int mode)
{
CALL_DYN(region_restack, reg, (reg, other, mode));
}
bool region_managed_rqorder(WRegion *reg, WRegion *sub, WRegionOrder order)
{
bool ret=FALSE;
CALL_DYN_RET(ret, bool, region_managed_rqorder, reg, (reg, sub, order));
return ret;
}
bool region_rqorder(WRegion *reg, WRegionOrder order)
{
WRegion *mgr=REGION_MANAGER(reg);
if(mgr==NULL)
return FALSE;
else
return region_managed_rqorder(mgr, reg, order);
}
/*EXTL_DOC
* Request ordering. Currently supported values for \var{ord}
* are 'front' and 'back'.
*/
EXTL_EXPORT_AS(WRegion, rqorder)
bool region_rqorder_extl(WRegion *reg, const char *ord)
{
WRegionOrder order;
if(strcmp(ord, "front")==0){
order=REGION_ORDER_FRONT;
}else if(strcmp(ord, "back")==0){
order=REGION_ORDER_BACK;
}else{
return FALSE;
}
return region_rqorder(reg, order);
}
/*}}}*/
/*{{{ Misc. */
/*EXTL_DOC
* Returns the root window \var{reg} is on.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
WRootWin *region_rootwin_of(const WRegion *reg)
{
WRootWin *rw;
assert(reg!=NULL); /* Lua interface should not pass NULL reg. */
rw=(WRootWin*)(reg->rootwin);
assert(rw!=NULL);
return rw;
}
/*EXTL_DOC
* Returns the screen \var{reg} is on.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
WScreen *region_screen_of(WRegion *reg)
{
while(reg!=NULL){
if(OBJ_IS(reg, WScreen))
return (WScreen*)reg;
reg=REGION_PARENT_REG(reg);
}
return NULL;
}
Window region_root_of(const WRegion *reg)
{
return WROOTWIN_ROOT(region_rootwin_of(reg));
}
bool region_same_rootwin(const WRegion *reg1, const WRegion *reg2)
{
return (reg1->rootwin==reg2->rootwin);
}
/*EXTL_DOC
* Is \var{reg} visible/is it and all it's ancestors mapped?
*/
EXTL_SAFE
EXTL_EXPORT_AS(WRegion, is_mapped)
bool region_is_fully_mapped(WRegion *reg)
{
for(; reg!=NULL; reg=REGION_PARENT_REG(reg)){
if(!REGION_IS_MAPPED(reg))
return FALSE;
}
return TRUE;
}
void region_rootpos(WRegion *reg, int *xret, int *yret)
{
WRegion *par;
par=REGION_PARENT_REG(reg);
if(par==NULL || par==reg){
*xret=0;
*yret=0;
return;
}
region_rootpos(par, xret, yret);
*xret+=REGION_GEOM(reg).x;
*yret+=REGION_GEOM(reg).y;
}
typedef struct{
WRegion *reg;
WRegionNotify how;
} MRSHP;
static bool mrsh_notify_change(WHookDummy *fn, void *p_)
{
MRSHP *p=(MRSHP*)p_;
fn(p->reg, p->how);
return TRUE;
}
static bool mrshe_notify_change(ExtlFn fn, void *p_)
{
MRSHP *p=(MRSHP*)p_;
extl_call(fn, "os", NULL, p->reg, stringstore_get(p->how));
return TRUE;
}
static void region_notify_change_(WRegion *reg, WRegionNotify how)
{
MRSHP p;
p.reg=reg;
p.how=how;
extl_protect(NULL);
hook_call(region_notify_hook, &p, mrsh_notify_change, mrshe_notify_change),
extl_unprotect(NULL);
}
void region_notify_change(WRegion *reg, WRegionNotify how)
{
WRegion *mgr=REGION_MANAGER(reg);
if(mgr!=NULL)
region_managed_notify(mgr, reg, how);
region_notify_change_(reg, how);
}
/*EXTL_DOC
* Returns the geometry of \var{reg} within its parent; a table with fields
* \var{x}, \var{y}, \var{w} and \var{h}.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
ExtlTab region_geom(WRegion *reg)
{
return extl_table_from_rectangle(®ION_GEOM(reg));
}
bool region_handle_drop(WRegion *reg, int x, int y, WRegion *dropped)
{
bool ret=FALSE;
CALL_DYN_RET(ret, bool, region_handle_drop, reg, (reg, x, y, dropped));
return ret;
}
WRegion *region_managed_within(WRegion *reg, WRegion *mgd)
{
while(mgd!=NULL &&
(REGION_PARENT_REG(mgd)==reg ||
REGION_PARENT_REG(mgd)==REGION_PARENT_REG(reg))){
if(REGION_MANAGER(mgd)==reg)
return mgd;
mgd=REGION_MANAGER(mgd);
}
return NULL;
}
void ioncore_region_notify(WRegion *reg, WRegionNotify how)
{
const char *p[1];
if(how==ioncore_g.notifies.name && obj_is((Obj*)reg, &CLASSDESCR(WWindow))){
p[0] = region_name(reg);
xwindow_set_text_property(((WWindow*)reg)->win, XA_WM_NAME, p, 1);
}
}
/*}}}*/
/*{{{ Debug printers */
#define REGION_DEBUGPRINT( what, next ) \
do { \
int indent = 1; \
char line_indent[24]; \
line_indent[0] = ' '; \
line_indent[1] = '\0'; \
\
LOG(DEBUG, GENERAL, what " list start ========:"); \
while( reg != NULL ) \
{ \
LOG(DEBUG, GENERAL, "%s%p (%s)", line_indent, (void*)reg, reg->ni.name); \
\
if( indent == sizeof(line_indent )-1 ) \
{ \
LOG(DEBUG, GENERAL, "too long. cut off"); \
break; \
} \
\
reg = next; \
line_indent[indent] = ' '; \
indent++; \
line_indent[indent] = '\0'; \
} \
LOG(DEBUG, GENERAL, what " list end =========="); \