summaryrefslogtreecommitdiff
path: root/src/bin/e_manager.c
blob: 917dc7e54fc6d38573ba4c384d53db6c705f831e (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
#include "e.h"

/* local subsystem functions */
static void _e_manager_free(E_Manager *man);

static Eina_Bool _e_manager_cb_window_show_request(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_window_configure(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_key_up(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_key_down(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_frame_extents_request(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_ping(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_screensaver_notify(void *data, int ev_type, void *ev);
static Eina_Bool _e_manager_cb_client_message(void *data, int ev_type, void *ev);

static Eina_Bool _e_manager_frame_extents_free_cb(const Eina_Hash *hash __UNUSED__,
						  const void *key __UNUSED__,
						  void *data, void *fdata __UNUSED__);
static E_Manager *_e_manager_get_for_root(Ecore_X_Window root);
static Eina_Bool _e_manager_clear_timer(void *data);
#if 0 /* use later - maybe */
static int _e_manager_cb_window_destroy(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_hide(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_reparent(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_create(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_configure_request(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_gravity(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_stack(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_stack_request(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_property(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_colormap(void *data, int ev_type, void *ev);
static int _e_manager_cb_window_shape(void *data, int ev_type, void *ev);
static int _e_manager_cb_client_message(void *data, int ev_type, void *ev);
#endif

/* local subsystem globals */

typedef struct _Frame_Extents Frame_Extents;

struct _Frame_Extents
{
   int l, r, t, b;
};

static Eina_List *managers = NULL;
static Eina_Hash *frame_extents = NULL;
static Ecore_Timer *timer_post_screensaver_lock = NULL;

/* externally accessible functions */
EINTERN int
e_manager_init(void)
{
   ecore_x_screensaver_event_listen_set(1);
   frame_extents = eina_hash_string_superfast_new(NULL);
   return 1;
}

EINTERN int
e_manager_shutdown(void)
{
   E_FREE_LIST(managers, e_object_del);

   if (frame_extents)
     {
	eina_hash_foreach(frame_extents, _e_manager_frame_extents_free_cb, NULL);
	eina_hash_free(frame_extents);
	frame_extents = NULL;
     }

   if (timer_post_screensaver_lock)
     {
	ecore_timer_del(timer_post_screensaver_lock);
	timer_post_screensaver_lock = NULL;
     }

   return 1;
}

EAPI Eina_List *
e_manager_list(void)
{
   return managers;
}

EAPI E_Manager *
e_manager_new(Ecore_X_Window root, int num)
{
   E_Manager *man;

   if (!ecore_x_window_manage(root)) return NULL;
   man = E_OBJECT_ALLOC(E_Manager, E_MANAGER_TYPE, _e_manager_free);
   if (!man) return NULL;
   managers = eina_list_append(managers, man);
   man->root = root;
   man->num = num;
   ecore_x_window_size_get(man->root, &(man->w), &(man->h));
   man->win = man->root;

   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW_REQUEST, 
                                              _e_manager_cb_window_show_request, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, 
                                              _e_manager_cb_window_configure, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, 
                                              _e_manager_cb_key_down, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_EVENT_KEY_UP, 
                                              _e_manager_cb_key_up, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_X_EVENT_FRAME_EXTENTS_REQUEST, 
                                              _e_manager_cb_frame_extents_request, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_X_EVENT_PING, 
                                              _e_manager_cb_ping, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_X_EVENT_SCREENSAVER_NOTIFY, 
                                              _e_manager_cb_screensaver_notify, 
                                              man));
   man->handlers = 
     eina_list_append(man->handlers, 
                      ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, 
                                              _e_manager_cb_client_message, 
                                              man));

   man->pointer = e_pointer_window_new(man->root, 1);

   ecore_x_window_background_color_set(man->root, 0, 0, 0);
   
   man->clear_timer = ecore_timer_add(10.0, _e_manager_clear_timer, man);
   return man;
}

EAPI void
e_manager_manage_windows(E_Manager *man)
{
   Ecore_X_Window *windows;
   int wnum;

   /* a manager is designated for each root. lets get all the windows in
      the managers root */
   windows = ecore_x_window_children_get(man->root, &wnum);
   if (windows)
     {
	int i;
	const char *atom_names[] =
	  {
	     "_XEMBED_INFO",
	       "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR",
	       "KWM_DOCKWINDOW"
	  };
	Ecore_X_Atom atoms[3];
        Ecore_X_Atom atom_xmbed, atom_kde_netwm_systray, atom_kwm_dockwindow;
	unsigned char *data = NULL;
	int count;

	ecore_x_atoms_get(atom_names, 3, atoms);
	atom_xmbed = atoms[0];
	atom_kde_netwm_systray = atoms[1];
	atom_kwm_dockwindow = atoms[2];
	for (i = 0; i < wnum; i++)
	  {
	     Ecore_X_Window_Attributes att;
	     unsigned int ret_val, deskxy[2];
	     int ret;

             if (e_border_find_by_client_window(windows[i]))
               continue;
	     ecore_x_window_attributes_get(windows[i], &att);
	     if ((att.override) || (att.input_only))
	       {
		  if (att.override)
		    {
		       char *wname = NULL, *wclass = NULL;

		       ecore_x_icccm_name_class_get(windows[i],
						    &wname, &wclass);
		       if ((wname) && (wclass) &&
			   (!strcmp(wname, "E")) &&
			   (!strcmp(wclass, "Init_Window")))
			 {
			    free(wname);
			    free(wclass);
			    man->initwin = windows[i];
			 }
		       else
			 {
			    if (wname) free(wname);
			    if (wclass) free(wclass);
			    continue;
			 }
		    }
		  else
                    continue;
	       }
	     /* XXX manage xembed windows as long as they are not override_redirect..
	      * if (!ecore_x_window_prop_property_get(windows[i],
	      * 					   atom_xmbed,
	      * 					   atom_xmbed, 32,
	      * 					   &data, &count))
	      *   data = NULL;
	      * if (!data) */
	       {
		  if (!ecore_x_window_prop_property_get(windows[i],
							atom_kde_netwm_systray,
							atom_xmbed, 32,
							&data, &count))
		    data = NULL;
	       }
	     if (!data)
	       {
		  if (!ecore_x_window_prop_property_get(windows[i],
							atom_kwm_dockwindow,
							atom_kwm_dockwindow, 32,
							&data, &count))
		    data = NULL;
	       }
	     if (data)
	       {
		  free(data);
		  data = NULL;
		  continue;
	       }
	     ret = ecore_x_window_prop_card32_get(windows[i],
						  E_ATOM_MANAGED,
						  &ret_val, 1);

	     /* we have seen this window before */
	     if ((ret > -1) && (ret_val == 1))
	       {
		  E_Container  *con = NULL;
		  E_Zone       *zone = NULL;
		  E_Desk       *desk = NULL;
		  E_Border     *bd = NULL;
		  unsigned int  id;
		  char *path;
		  Efreet_Desktop *desktop = NULL;

		  /* get all information from window before it is
		   * reset by e_border_new */
		  ret = ecore_x_window_prop_card32_get(windows[i],
						       E_ATOM_CONTAINER,
						       &id, 1);
		  if (ret == 1)
		    con = e_container_number_get(man, id);
		  if (!con)
		    con = e_container_current_get(man);

		  ret = ecore_x_window_prop_card32_get(windows[i],
						       E_ATOM_ZONE,
						       &id, 1);
		  if (ret == 1)
		    zone = e_container_zone_number_get(con, id);
		  if (!zone)
		    zone = e_zone_current_get(con);
		  ret = ecore_x_window_prop_card32_get(windows[i],
						       E_ATOM_DESK,
						       deskxy, 2);
		  if (ret == 2)
		    desk = e_desk_at_xy_get(zone,
					    deskxy[0],
					    deskxy[1]);

		  path = ecore_x_window_prop_string_get(windows[i],
							E_ATOM_DESKTOP_FILE);
		  if (path)
		    {
		       desktop = efreet_desktop_get(path);
		       free(path);
		    }

		    {
		       bd = e_border_new(con, windows[i], 1, 0);
		       if (bd)
			 {
                            bd->ignore_first_unmap = 1;
			    /* FIXME:
			     * It's enough to set the desk, the zone will
			     * be set according to the desk */
//			    if (zone) e_border_zone_set(bd, zone);
			    if (desk) e_border_desk_set(bd, desk);
			    bd->desktop = desktop;
			 }
		    }
	       }
	     else if ((att.visible) && (!att.override) &&
		      (!att.input_only))
	       {
		  /* We have not seen this window, and X tells us it
		   * should be seen */
		  E_Container *con;
		  E_Border *bd;

		  con = e_container_current_get(man);
		  bd = e_border_new(con, windows[i], 1, 0);
		  if (bd)
                    {
                       bd->ignore_first_unmap = 1;
                       e_border_show(bd);
                    }
	       }
	  }
	free(windows);
     }
}

EAPI void
e_manager_show(E_Manager *man)
{
   Eina_List *l;
   E_Container *con;

   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (man->visible) return;
   EINA_LIST_FOREACH(man->containers, l, con)
     {
	e_container_show(con);
     }
   if (man->root != man->win)
     {
	Ecore_X_Window mwin;

	mwin = e_menu_grab_window_get();
	if (!mwin) mwin = man->initwin;
	if (!mwin)
	  ecore_x_window_raise(man->win);
	else
	  ecore_x_window_configure(man->win,
				   ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
				   ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
				   0, 0, 0, 0, 0,
				   mwin, ECORE_X_WINDOW_STACK_BELOW);
	ecore_x_window_show(man->win);
     }
   man->visible = 1;
}

EAPI void
e_manager_hide(E_Manager *man)
{
   Eina_List *l;
   E_Container *con;

   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (!man->visible) return;
   EINA_LIST_FOREACH(man->containers, l, con)
     {
	e_container_hide(con);
     }
   if (man->root != man->win)
     ecore_x_window_hide(man->win);
   man->visible = 0;
}

EAPI void
e_manager_move(E_Manager *man, int x, int y)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if ((x == man->x) && (y == man->y)) return;
   if (man->root != man->win)
     {
	man->x = x;
	man->y = y;
	ecore_x_window_move(man->win, man->x, man->y);
     }
}

EAPI void
e_manager_resize(E_Manager *man, int w, int h)
{
   Eina_List *l;
   E_Container *con;

   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if ((w == man->w) && (h == man->h)) return;
   man->w = w;
   man->h = h;
   if (man->root != man->win)
     ecore_x_window_resize(man->win, man->w, man->h);

   EINA_LIST_FOREACH(man->containers, l, con)
     {
	e_container_resize(con, man->w, man->h);
     }

   ecore_x_netwm_desk_size_set(man->root, man->w, man->h);
}

EAPI void
e_manager_move_resize(E_Manager *man, int x, int y, int w, int h)
{
   Eina_List *l;
   E_Container *con;

   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if ((x == man->x) && (y == man->y) && (w == man->w) && (h == man->h)) return;
   if (man->root != man->win)
     {
	man->x = x;
	man->y = y;
     }
   man->w = w;
   man->h = h;
   ecore_x_window_move_resize(man->win, man->x, man->y, man->w, man->h);

   EINA_LIST_FOREACH(man->containers, l, con)
     {
	e_container_resize(con, man->w, man->h);
     }
}

EAPI void
e_manager_raise(E_Manager *man)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (man->root != man->win)
     {
	Ecore_X_Window mwin;

	mwin = e_menu_grab_window_get();
	if (!mwin) mwin = man->initwin;
	if (!mwin)
	  ecore_x_window_raise(man->win);
	else
	  ecore_x_window_configure(man->win,
				   ECORE_X_WINDOW_CONFIGURE_MASK_SIBLING |
				   ECORE_X_WINDOW_CONFIGURE_MASK_STACK_MODE,
				   0, 0, 0, 0, 0,
				   mwin, ECORE_X_WINDOW_STACK_BELOW);
     }
}

EAPI void
e_manager_lower(E_Manager *man)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (man->root != man->win)
     ecore_x_window_lower(man->win);
}

EAPI E_Manager *
e_manager_current_get(void)
{
   Eina_List *l;
   E_Manager *man;
   int x, y;

   if (!managers) return NULL;
   EINA_LIST_FOREACH(managers, l, man)
     {
	ecore_x_pointer_xy_get(man->win, &x, &y);
	if (x == -1 && y == -1)
	  continue;
	if (E_INSIDE(x, y, man->x, man->y, man->w, man->h))
	  return man;
     }
   return eina_list_data_get(managers);
}

EAPI E_Manager *
e_manager_number_get(int num)
{
   Eina_List *l;
   E_Manager *man;

   if (!managers) return NULL;
   EINA_LIST_FOREACH(managers, l, man)
     {
	if (man->num == num)
	  return man;
     }
   return NULL;
}

EAPI void
e_managers_keys_grab(void)
{
   Eina_List *l;
   E_Manager *man;

   EINA_LIST_FOREACH(managers, l, man)
     {
	e_bindings_key_grab(E_BINDING_CONTEXT_ANY, man->root);
     }
}

EAPI void
e_managers_keys_ungrab(void)
{
   Eina_List *l;
   E_Manager *man;

   EINA_LIST_FOREACH(managers, l, man)
     {
	e_bindings_key_ungrab(E_BINDING_CONTEXT_ANY, man->root);
     }
}







EAPI void
e_manager_comp_set(E_Manager *man, E_Manager_Comp *comp)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   man->comp = comp;
   e_msg_send("comp.manager", "change.comp", // name + info
              0, // val
              E_OBJECT(man), // obj
              NULL, // msgdata
              NULL, NULL); // afterfunc + afterdata
}

EAPI Evas *
e_manager_comp_evas_get(E_Manager *man)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, NULL);
   if (!man->comp) return NULL;
   return man->comp->func.evas_get(man->comp->data, man);
}

EAPI void
e_manager_comp_evas_update(E_Manager *man)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (!man->comp) return;
   return man->comp->func.update(man->comp->data, man);
}

EAPI const Eina_List *
e_manager_comp_src_list(E_Manager *man)
{
   return man->comp->func.src_list_get(man->comp->data, man);
}

EAPI E_Manager_Comp_Source*
e_manager_comp_src_get(E_Manager *man, Ecore_X_Window win)
{
   return man->comp->func.src_get(man->comp->data, man, win);
}

EAPI Evas_Object *
e_manager_comp_src_image_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_image_get(man->comp->data, man, src);
}

EAPI Evas_Object *
e_manager_comp_src_shadow_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_shadow_get(man->comp->data, man, src);
}

EAPI Evas_Object *
e_manager_comp_src_image_mirror_add(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_image_mirror_add(man->comp->data, man, src);
}

EAPI Eina_Bool
e_manager_comp_src_visible_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_visible_get(man->comp->data, man, src);
}

EAPI void
e_manager_comp_src_hidden_set(E_Manager *man, E_Manager_Comp_Source *src, Eina_Bool hidden)
{
   return man->comp->func.src_hidden_set(man->comp->data, man, src, hidden);
}

EAPI Eina_Bool
e_manager_comp_src_hidden_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_hidden_get(man->comp->data, man, src);
}

EAPI Ecore_X_Window
e_manager_comp_src_window_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_window_get(man->comp->data, man, src);
}

EAPI E_Popup *
e_manager_comp_src_popup_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_popup_get(man->comp->data, man, src);
}

EAPI E_Border *
e_manager_comp_src_border_get(E_Manager *man, E_Manager_Comp_Source *src)
{
   return man->comp->func.src_border_get(man->comp->data, man, src);
}

#ifdef _F_COMP_SCREEN_LOCK_
EAPI void
e_manager_comp_screen_lock(E_Manager *man)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (!man->comp) return;
   return man->comp->func.screen_lock(man->comp->data, man);
}

EAPI void
e_manager_comp_screen_unlock(E_Manager *man)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   if (!man->comp) return;
   return man->comp->func.screen_unlock(man->comp->data, man);
}
#endif

#ifdef _F_COMP_INPUT_REGION_SET_
EAPI Eina_Bool
e_manager_comp_src_input_region_set(E_Manager *man, E_Manager_Comp_Source *src, int x, int y, int w, int h)
{
   E_OBJECT_CHECK_RETURN(man, EINA_FALSE);
   E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, EINA_FALSE);
   if (!man->comp) return EINA_FALSE;
   E_OBJECT_CHECK_RETURN(src, EINA_FALSE);
   return man->comp->func.src_input_region_set(man->comp->data, man, src, x, y, w, h);
}
#endif

#ifdef _F_COMP_MOVE_LOCK_
EAPI Eina_Bool
e_manager_comp_src_move_lock(E_Manager *man, E_Manager_Comp_Source *src)
{
   E_OBJECT_CHECK_RETURN(man, EINA_FALSE);
   E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, EINA_FALSE);
   if (!man->comp) return EINA_FALSE;
   E_OBJECT_CHECK_RETURN(src, EINA_FALSE);
   return man->comp->func.src_move_lock(man->comp->data, man, src);
}

EAPI Eina_Bool
e_manager_comp_src_move_unlock(E_Manager *man, E_Manager_Comp_Source *src)
{
   E_OBJECT_CHECK_RETURN(man, EINA_FALSE);
   E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, EINA_FALSE);
   if (!man->comp) return EINA_FALSE;
   E_OBJECT_CHECK_RETURN(src, EINA_FALSE);
   return man->comp->func.src_move_unlock(man->comp->data, man, src);
}
#endif

#ifdef _F_COMP_COMPOSITE_MODE_
EAPI void
e_manager_comp_composite_mode_set(E_Manager *man, E_Zone *zone, Eina_Bool set)
{
   E_OBJECT_CHECK(man);
   E_OBJECT_CHECK(zone);
   E_OBJECT_TYPE_CHECK(man, E_MANAGER_TYPE);
   E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
   if (!man->comp) return;
   man->comp->func.composite_mode_set(man->comp->data, man, zone, set);
}

EAPI Eina_Bool
e_manager_comp_composite_mode_get(E_Manager *man, E_Zone *zone)
{
   E_OBJECT_CHECK_RETURN(man, EINA_FALSE);
   E_OBJECT_CHECK_RETURN(zone, EINA_FALSE);
   E_OBJECT_TYPE_CHECK_RETURN(man, E_MANAGER_TYPE, EINA_FALSE);
   E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, EINA_FALSE);
   if (!man->comp) return EINA_FALSE;
   return man->comp->func.composite_mode_get(man->comp->data, man, zone);
}
#endif /* _F_COMP_COMPOSITE_MODE_ */

EAPI void
e_manager_comp_event_resize_send(E_Manager *man)
{
   e_msg_send("comp.manager", "resize.comp", // name + info
              0, // val
              E_OBJECT(man), // obj
              NULL, // msgdata
              NULL, NULL); // afterfunc + afterdata
}

EAPI void
e_manager_comp_event_src_add_send(E_Manager *man, E_Manager_Comp_Source *src,
                                  void (*afterfunc) (void *data, E_Manager *man, E_Manager_Comp_Source *src),
                                  void *data)
{
   e_msg_send("comp.manager", "add.src", // name + info
              0, // val
              E_OBJECT(man), // obj
              src, // msgdata
              (void (*)(void *, E_Object *, void *))afterfunc, data); // afterfunc + afterdata
}

EAPI void
e_manager_comp_event_src_del_send(E_Manager *man, E_Manager_Comp_Source *src,
                                  void (*afterfunc) (void *data, E_Manager *man, E_Manager_Comp_Source *src),
                                  void *data)
{
   e_msg_send("comp.manager", "del.src", // name + info
              0, // val
              E_OBJECT(man), // obj
              src, // msgdata
              (void (*)(void *, E_Object *, void *))afterfunc, data); // afterfunc + afterdata
}

EAPI void
e_manager_comp_event_src_config_send(E_Manager *man, E_Manager_Comp_Source *src,
                                     void (*afterfunc) (void *data, E_Manager *man, E_Manager_Comp_Source *src),
                                     void *data)
{
   e_msg_send("comp.manager", "config.src", // name + info
              0, // val
              E_OBJECT(man), // obj
              src, // msgdata
              (void (*)(void *, E_Object *, void *))afterfunc, data); // afterfunc + afterdata
}

EAPI void
e_manager_comp_event_src_visibility_send(E_Manager *man, E_Manager_Comp_Source *src,
                                         void (*afterfunc) (void *data, E_Manager *man, E_Manager_Comp_Source *src),
                                         void *data)
{
   e_msg_send("comp.manager", "visibility.src", // name + info
              0, // val
              E_OBJECT(man), // obj
              src, // msgdata
              (void (*)(void *, E_Object *, void *))afterfunc, data); // afterfunc + afterdata
}





/* local subsystem functions */
static void
_e_manager_free(E_Manager *man)
{
   Eina_List *l;

   E_FREE_LIST(man->handlers, ecore_event_handler_del);
   l = man->containers;
   man->containers = NULL;
   E_FREE_LIST(l, e_object_del);
   if (man->root != man->win)
     {
	ecore_x_window_free(man->win);
     }
   if (man->pointer) e_object_del(E_OBJECT(man->pointer));
   managers = eina_list_remove(managers, man);
   if (man->clear_timer) ecore_timer_del(man->clear_timer);
   free(man);
}

static Eina_Bool
_e_manager_cb_window_show_request(void *data, int ev_type __UNUSED__, void *ev)
{
   E_Manager *man;
   Ecore_X_Event_Window_Show_Request *e;

   man = data;
   e = ev;
   if (e_stolen_win_get(e->win)) return 1;
   if (ecore_x_window_parent_get(e->win) != man->root)
     return ECORE_CALLBACK_PASS_ON;  /* try other handlers for this */

     {
	E_Container *con;
	E_Border *bd;

	con = e_container_current_get(man);
	if (!e_border_find_by_client_window(e->win))
	  {
	     bd = e_border_new(con, e->win, 0, 0);
	     if (!bd)
	       ecore_x_window_show(e->win);
	  }
     }
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_cb_window_configure(void *data, int ev_type __UNUSED__, void *ev)
{
   E_Manager *man;
   Ecore_X_Event_Window_Configure *e;

   man = data;
   e = ev;
   if (e->win != man->root) return ECORE_CALLBACK_PASS_ON;
   e_manager_resize(man, e->w, e->h);
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_cb_key_down(void *data, int ev_type __UNUSED__, void *ev)
{
   E_Manager *man;
   Ecore_Event_Key *e;

   man = data;
   e = ev;

   if (e->event_window != man->root) return ECORE_CALLBACK_PASS_ON;
   if (e->root_window != man->root) man = _e_manager_get_for_root(e->root_window);
   if (e_bindings_key_down_event_handle(E_BINDING_CONTEXT_MANAGER, E_OBJECT(man), ev))
     return ECORE_CALLBACK_DONE;
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_cb_key_up(void *data, int ev_type __UNUSED__, void *ev)
{
   E_Manager *man;
   Ecore_Event_Key *e;

   man = data;
   e = ev;

   if (e->event_window != man->root) return ECORE_CALLBACK_PASS_ON;
   if (e->root_window != man->root) man = _e_manager_get_for_root(e->root_window);
   if (e_bindings_key_up_event_handle(E_BINDING_CONTEXT_MANAGER, E_OBJECT(man), ev))
     return ECORE_CALLBACK_DONE;
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_cb_frame_extents_request(void *data, int ev_type __UNUSED__, void *ev)
{
   E_Manager *man;
   E_Container *con;
   Ecore_X_Event_Frame_Extents_Request *e;
   Ecore_X_Window_Type type;
   Ecore_X_MWM_Hint_Decor decor;
   Ecore_X_Window_State *state;
   Frame_Extents *extents;
   const char *border, *signal, *key;
   int ok;
   unsigned int i, num;

   man = data;
   con = e_container_current_get(man);
   e = ev;

   if (ecore_x_window_parent_get(e->win) != man->root) return ECORE_CALLBACK_PASS_ON;

   /* TODO:
    * * We need to check if we remember this window, and border locking is set
    */
   border = "default";
   key = border;
   ok = ecore_x_mwm_hints_get(e->win, NULL, &decor, NULL);
   if ((ok) &&
       (!(decor & ECORE_X_MWM_HINT_DECOR_ALL)) &&
       (!(decor & ECORE_X_MWM_HINT_DECOR_TITLE)) &&
       (!(decor & ECORE_X_MWM_HINT_DECOR_BORDER)))
     {
	border = "borderless";
	key = border;
     }

   ok = ecore_x_netwm_window_type_get(e->win, &type);
   if ((ok) &&
       ((type == ECORE_X_WINDOW_TYPE_DESKTOP) ||
	(type == ECORE_X_WINDOW_TYPE_DOCK)))
     {
	border = "borderless";
	key = border;
     }

   signal = NULL;
   ecore_x_netwm_window_state_get(e->win, &state, &num);
   if (state)
     {
	int maximized = 0;

	for (i = 0; i < num; i++)
	  {
	     switch (state[i])
	       {
		case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
		  maximized++;
		  break;
		case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
		  maximized++;
		  break;
		case ECORE_X_WINDOW_STATE_FULLSCREEN:
		  border = "borderless";
		  key = border;
		  break;
		case ECORE_X_WINDOW_STATE_SHADED:
		case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
		case ECORE_X_WINDOW_STATE_SKIP_PAGER:
		case ECORE_X_WINDOW_STATE_HIDDEN:
		case ECORE_X_WINDOW_STATE_ICONIFIED:
		case ECORE_X_WINDOW_STATE_MODAL:
		case ECORE_X_WINDOW_STATE_STICKY:
		case ECORE_X_WINDOW_STATE_ABOVE:
		case ECORE_X_WINDOW_STATE_BELOW:
		case ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION:
		case ECORE_X_WINDOW_STATE_UNKNOWN:
		  break;
	       }
	  }
	if ((maximized == 2) &&
	    (e_config->maximize_policy == E_MAXIMIZE_FULLSCREEN))
	  {
	     signal = "e,action,maximize,fullscreen";
	     key = "maximize,fullscreen";
	  }
	free(state);
     }

   extents = eina_hash_find(frame_extents, key);
   if (!extents)
     {
	extents = E_NEW(Frame_Extents, 1);
	if (extents)
	  {
	     Evas_Object *o;
	     char buf[1024];

	     o = edje_object_add(con->bg_evas);
	     snprintf(buf, sizeof(buf), "e/widgets/border/%s/border", border);
	     ok = e_theme_edje_object_set(o, "base/theme/borders", buf);
	     if (ok)
	       {
		  Evas_Coord x, y, w, h;

		  if (signal)
		    {
		       edje_object_signal_emit(o, signal, "e");
		       edje_object_message_signal_process(o);
		    }

		  evas_object_resize(o, 1000, 1000);
		  edje_object_calc_force(o);
		  edje_object_part_geometry_get(o, "e.swallow.client",
						&x, &y, &w, &h);
		  extents->l = x;
		  extents->r = 1000 - (x + w);
		  extents->t = y;
		  extents->b = 1000 - (y + h);
	       }
	     else
	       {
		  extents->l = 0;
		  extents->r = 0;
		  extents->t = 0;
		  extents->b = 0;
	       }
	     evas_object_del(o);
	     eina_hash_add(frame_extents, key, extents);
	  }
     }

   if (extents)
     ecore_x_netwm_frame_size_set(e->win, extents->l, extents->r, extents->t, extents->b);

   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_cb_ping(void *data, int ev_type __UNUSED__, void *ev)
{
   E_Manager *man;
   E_Border *bd;
   Ecore_X_Event_Ping *e;

   man = data;
   e = ev;

   if (e->win != man->root) return ECORE_CALLBACK_PASS_ON;

   bd = e_border_find_by_client_window(e->event_win);
   if (!bd) return ECORE_CALLBACK_PASS_ON;

   bd->ping_ok = 1;
   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_cb_timer_post_screensaver_lock(void *data __UNUSED__)
{
   e_desklock_show_autolocked();
   timer_post_screensaver_lock = NULL;
   return ECORE_CALLBACK_CANCEL;
}

static Eina_Bool
_e_manager_cb_screensaver_notify(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
{
   Ecore_X_Event_Screensaver_Notify *e = ev;

   if (timer_post_screensaver_lock)
     {
	ecore_timer_del(timer_post_screensaver_lock);
	timer_post_screensaver_lock = NULL;
     }

   if (e->on)
     {
	if (e_config->desklock_autolock_screensaver)
	  {
	     if (e_config->desklock_post_screensaver_time <= 1.0)
	       {
		  e_desklock_show_autolocked();
	       }
	     else
	       {
		  timer_post_screensaver_lock = ecore_timer_add
		    (e_config->desklock_post_screensaver_time,
		     _e_manager_cb_timer_post_screensaver_lock, NULL);
	       }
	  }
     }
   return ECORE_CALLBACK_PASS_ON;
}


#ifdef _F_WINDOW_GROUP_RAISE_
static void
_e_manager_windows_group_raise (E_Border* bd)
{
   Ecore_X_Window leader_win;
   
   if (!bd) return;

   if ((e_config->focus_setting == E_FOCUS_NEW_WINDOW) ||
      (e_config->focus_setting == E_FOCUS_NEW_WINDOW_IF_TOP_STACK) ||
      ((bd->parent) && 
      ((e_config->focus_setting == E_FOCUS_NEW_DIALOG) ||
      ((bd->parent->focused) &&
      (e_config->focus_setting == E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED)))))
     {
        leader_win = bd->client.icccm.client_leader;
        if (leader_win)
          {
             Eina_List* restack_list;
             E_Border *temp_bd;
             E_Border *top_bd;
             E_Border_List *bl;

             restack_list = NULL;
             top_bd = NULL;
             bl = e_container_border_list_last(bd->zone->container);
             while ((temp_bd = e_container_border_list_prev(bl)))
               {
                  if (temp_bd->client.icccm.client_leader == leader_win)
                    {
                       restack_list = eina_list_prepend(restack_list, temp_bd);
                    }
               }
             e_container_border_list_free(bl);

             if (restack_list)
               {
                  EINA_LIST_FREE (restack_list, temp_bd)
                    {
                       if (temp_bd->iconic)
                         {
                            if (e_config->clientlist_warp_to_iconified_desktop == 1)
                               e_desk_show(temp_bd->desk);

                            if (!temp_bd->lock_user_iconify)
                               e_border_uniconify(temp_bd);
                         }

                       if (!temp_bd->iconic) e_desk_show(temp_bd->desk);
                       if (!temp_bd->lock_user_stacking) e_border_raise(temp_bd);

                       // set focus to top window
                       if (!temp_bd->lock_focus_out)
                         {
                            top_bd = temp_bd;

                            if (e_config->focus_policy != E_FOCUS_CLICK)
                               ecore_x_pointer_warp(top_bd->zone->container->win, top_bd->x + (top_bd->w / 2), top_bd->y + (top_bd->h / 2));
                            
                            if (e_config->focus_setting != E_FOCUS_NEW_WINDOW_IF_TOP_STACK)
                               e_border_focus_set(top_bd, 1, 1);
                            else
                              {
                                 Eina_List* l2;
                                 E_Border* temp_bd2;
                                 l2 = NULL;
                                 temp_bd2 = NULL;

                                 bl = e_container_border_list_last(bd->zone->container);
                                 while ((temp_bd2 = e_container_border_list_prev(bl)))
                                   {
                                      if ((!temp_bd2->iconic) && (temp_bd2->visible) && (temp_bd2->desk == top_bd->desk) &&
                                         (temp_bd2->client.icccm.accepts_focus || temp_bd2->client.icccm.take_focus) &&
                                         (temp_bd2->client.netwm.type != ECORE_X_WINDOW_TYPE_DOCK) &&
                                         (temp_bd2->client.netwm.type != ECORE_X_WINDOW_TYPE_TOOLBAR) &&
                                         (temp_bd2->client.netwm.type != ECORE_X_WINDOW_TYPE_MENU) &&
                                         (temp_bd2->client.netwm.type != ECORE_X_WINDOW_TYPE_SPLASH) &&
                                         (temp_bd2->client.netwm.type != ECORE_X_WINDOW_TYPE_DESKTOP))
                                        {
                                           if (top_bd == temp_bd2)
                                             {
                                                e_border_focus_set(top_bd, 1, 1);
                                             }
                                            break;
                                        }
                                   }
                                 e_container_border_list_free(bl);
                              }
                         }
                    }
               }
          }
     }
}
#endif // group raise

static Eina_Bool
_e_manager_cb_client_message(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
{
   Ecore_X_Event_Client_Message *e;
   E_Border *bd;

   e = ev;

   if (e->message_type == ECORE_X_ATOM_NET_ACTIVE_WINDOW)
     {
	bd = e_border_find_by_client_window(e->win);
	if ((bd) && (!bd->focused))
	  {
#if 0 /* notes */
	     if (e->data.l[0] == 0 /* 0 == old, 1 == client, 2 == pager */)
	       {
		  // FIXME: need config for the below - what to do given each
		  //  request (either do nothng, make app look urgent/want
		  //  attention or actiually flip to app as below is the
		  //  current default)
		  // if 0 == just make app demand attention somehow
		  // if 1 == just make app demand attention somehow
		  // if 2 == activate window as below
	       }
	     timestamp = e->data.l[1];
	     requestor_id e->data.l[2];
#endif

#ifdef _F_WINDOW_GROUP_RAISE_
             if (e->data.l[0] == 3) // 'e->data.l[0] == 3' means group raise
               {
                  if (bd->client.icccm.client_leader)
                    {
                       _e_manager_windows_group_raise (bd);
                       return ECORE_CALLBACK_PASS_ON;
                    }
               }
#endif


#ifdef _F_FOCUS_WINDOW_IF_TOP_STACK_
             if ((e_config->focus_setting == E_FOCUS_NEW_WINDOW) ||
                 (e_config->focus_setting == E_FOCUS_NEW_WINDOW_IF_TOP_STACK) ||
                 ((bd->parent) &&
                  ((e_config->focus_setting == E_FOCUS_NEW_DIALOG) ||
                   ((bd->parent->focused) &&
		            (e_config->focus_setting == E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED)))))
#else // original
             if ((e_config->focus_setting == E_FOCUS_NEW_WINDOW) ||
		 ((bd->parent) &&
		  ((e_config->focus_setting == E_FOCUS_NEW_DIALOG) ||
		   ((bd->parent->focused) &&
		    (e_config->focus_setting == E_FOCUS_NEW_DIALOG_IF_OWNER_FOCUSED)))))
#endif
	       {
		  if (bd->iconic)
		    {
		       if (e_config->clientlist_warp_to_iconified_desktop == 1)
			 e_desk_show(bd->desk);

		       if (!bd->lock_user_iconify)
			 e_border_uniconify(bd);
		    }
		  if ((!bd->iconic) && (!bd->sticky))
		    e_desk_show(bd->desk);
		  if (!bd->lock_user_stacking) e_border_raise(bd);
		  if (!bd->lock_focus_out)
		    {
		       /* XXX ooffice does send this request for
		       config dialogs when the main window gets focus.
		       causing the pointer to jump back and forth.  */
		       if ((e_config->focus_policy != E_FOCUS_CLICK) &&
			   !(bd->client.icccm.name && !strcmp(bd->client.icccm.name, "VCLSalFrame")))
		       	 ecore_x_pointer_warp(bd->zone->container->win,
					      bd->x + (bd->w / 2), bd->y + (bd->h / 2));
#ifdef _F_FOCUS_WINDOW_IF_TOP_STACK_
                       if (e_config->focus_setting != E_FOCUS_NEW_WINDOW_IF_TOP_STACK)
                         e_border_focus_set(bd, 1, 1);
                       else
                         {
                            E_Border* temp_bd = NULL;
                            E_Border_List *bl;

                            bl = e_container_border_list_last(bd->zone->container);
                            while ((temp_bd = e_container_border_list_prev(bl)))
                              {
                                 if ((temp_bd->x >= bd->zone->w) || (temp_bd->y >= bd->zone->h)) continue;
                                 if (((temp_bd->x + temp_bd->w) <= 0) || ((temp_bd->y + temp_bd->h) <= 0)) continue;
                                 if (temp_bd->client.illume.win_state.state == ECORE_X_ILLUME_WINDOW_STATE_FLOATING) continue;

                                 if ((!temp_bd->iconic) && (temp_bd->visible) && (temp_bd->desk == bd->desk) &&
                                     (temp_bd->client.icccm.accepts_focus || temp_bd->client.icccm.take_focus) &&
                                     (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DOCK) &&
                                     (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_TOOLBAR) &&
                                     (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_MENU) &&
                                     (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_SPLASH) &&
                                     (temp_bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DESKTOP))
                                   {
                                      e_border_focus_set(temp_bd, 1, 1);
                                      break;
                                   }
                              }
                            e_container_border_list_free(bl);
                         }
#else // original
		       e_border_focus_set(bd, 1, 1);
#endif
		    }
	       }
	  }
     }

   return ECORE_CALLBACK_PASS_ON;
}

static Eina_Bool
_e_manager_frame_extents_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
				 void *data, void *fdata __UNUSED__)
{
   free(data);
   return EINA_TRUE;
}

static E_Manager *
_e_manager_get_for_root(Ecore_X_Window root)
{
   Eina_List *l;
   E_Manager *man;

   if (!managers) return NULL;
   EINA_LIST_FOREACH(managers, l, man)
     {
	if (man->root == root)
	  return man;
     }
   return eina_list_data_get(managers);
}

static Eina_Bool
_e_manager_clear_timer(void *data)
{
   E_Manager *man = data;
   ecore_x_window_background_color_set(man->root, 0, 0, 0);
   man->clear_timer = NULL;
   return EINA_FALSE;
}

#if 0 /* use later - maybe */
static int _e_manager_cb_window_destroy(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_hide(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_reparent(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_create(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_configure_request(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_configure(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_gravity(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_stack(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_stack_request(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_property(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_colormap(void *data, int ev_type, void *ev){return 1;}
static int _e_manager_cb_window_shape(void *data, int ev_type, void *ev){return 1;}
#endif