summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhandyande <handyande>2005-01-22 01:06:22 +0000
committerhandyande <handyande@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2005-01-22 01:06:22 +0000
commit6697521787ff5731f196adf18ba86c0a35a25212 (patch)
tree90ea2474c29ee4002a0c16f4f47877683254e56e
parentbe260964a25db6ffd8e7d5c706a2fd021123a33f (diff)
OK, pager moved to gadman now, others tomorrow - note that pager still needs work for multiple zones
SVN revision: 13049
-rw-r--r--src/modules/pager/e_mod_main.c296
-rw-r--r--src/modules/pager/e_mod_main.h18
2 files changed, 97 insertions, 217 deletions
diff --git a/src/modules/pager/e_mod_main.c b/src/modules/pager/e_mod_main.c
index f1e8db7f4..959f79d0d 100644
--- a/src/modules/pager/e_mod_main.c
+++ b/src/modules/pager/e_mod_main.c
@@ -36,10 +36,7 @@ static Pager_Win *_pager_window_find(Pager *e, E_Border *border);
36static E_Manager *_pager_manager_current_get(Pager *e); 36static E_Manager *_pager_manager_current_get(Pager *e);
37 37
38static void _pager_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info); 38static void _pager_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
39static void _pager_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info); 39static void _pager_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
40static void _pager_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
41static int _pager_cb_event_container_resize(void *data, int type, void *event);
42
43static int _pager_cb_event_border_resize(void *data, int type, void *event); 40static int _pager_cb_event_border_resize(void *data, int type, void *event);
44static int _pager_cb_event_border_move(void *data, int type, void *event); 41static int _pager_cb_event_border_move(void *data, int type, void *event);
45static int _pager_cb_event_border_add(void *data, int type, void *event); 42static int _pager_cb_event_border_add(void *data, int type, void *event);
@@ -49,11 +46,6 @@ static int _pager_cb_event_border_show(void *data, int type, void *event
49static int _pager_cb_event_border_desk_set(void *data, int type, void *event); 46static int _pager_cb_event_border_desk_set(void *data, int type, void *event);
50static int _pager_cb_event_zone_desk_count_set(void *data, int type, void *event); 47static int _pager_cb_event_zone_desk_count_set(void *data, int type, void *event);
51 48
52static void _pager_reconfigure(Pager *e);
53
54#define PAGER_MIN_W 10
55#define PAGER_MIN_H 7
56
57/* public module routines. all modules must have these */ 49/* public module routines. all modules must have these */
58void * 50void *
59init(E_Module *m) 51init(E_Module *m)
@@ -102,7 +94,7 @@ save(E_Module *m)
102 Pager *e; 94 Pager *e;
103 95
104 e = m->data; 96 e = m->data;
105 e_config_domain_save("module.pager", e->conf_edd, e->conf); 97/* e_config_domain_save("module.pager", e->conf_edd, e->conf); */
106 return 1; 98 return 1;
107} 99}
108 100
@@ -136,29 +128,17 @@ _pager_init(E_Module *m)
136 e = calloc(1, sizeof(Pager)); 128 e = calloc(1, sizeof(Pager));
137 if (!e) return NULL; 129 if (!e) return NULL;
138 130
139 e->conf_edd = E_CONFIG_DD_NEW("Pager_Config", Config); 131/* e->conf_edd = E_CONFIG_DD_NEW("Pager_Config", Config);
140#undef T 132#undef T
141#undef D 133#undef D
142#define T Config 134#define T Config
143#define D e->conf_edd 135#define D e->conf_edd */
144 E_CONFIG_VAL(D, T, width, INT);
145 E_CONFIG_VAL(D, T, height, INT);
146 E_CONFIG_VAL(D, T, x, DOUBLE);
147 E_CONFIG_VAL(D, T, y, DOUBLE);
148 136
149 e->conf = e_config_domain_load("module.pager", e->conf_edd); 137/* e->conf = e_config_domain_load("module.pager", e->conf_edd);
150 if (!e->conf) 138 if (!e->conf)
151 { 139 {
152 e->conf = E_NEW(Config, 1); 140 e->conf = E_NEW(Config, 1);
153 e->conf->width = 50; 141 } */
154 e->conf->height = 30;
155 e->conf->x = 0.0;
156 e->conf->y = 0.0;
157 }
158 E_CONFIG_LIMIT(e->conf->x, 0.0, 1.0);
159 E_CONFIG_LIMIT(e->conf->y, 0.0, 1.0);
160 E_CONFIG_LIMIT(e->conf->width, PAGER_MIN_W, 1000);
161 E_CONFIG_LIMIT(e->conf->height, PAGER_MIN_H, 1000);
162 142
163 managers = e_manager_list(); 143 managers = e_manager_list();
164 e->managers = managers; 144 e->managers = managers;
@@ -173,6 +153,7 @@ _pager_init(E_Module *m)
173 153
174 con = l2->data; 154 con = l2->data;
175 e->evas = con->bg_evas; 155 e->evas = con->bg_evas;
156 e->con = con;
176 } 157 }
177 } 158 }
178 159
@@ -182,8 +163,6 @@ _pager_init(E_Module *m)
182 evas_object_pass_events_set(o, 0); 163 evas_object_pass_events_set(o, 0);
183 evas_object_repeat_events_set(o, 0); 164 evas_object_repeat_events_set(o, 0);
184 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _pager_cb_down, e); 165 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _pager_cb_down, e);
185 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _pager_cb_up, e);
186 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _pager_cb_move, e);
187 evas_object_show(o); 166 evas_object_show(o);
188 167
189 o = edje_object_add(e->evas); 168 o = edje_object_add(e->evas);
@@ -194,10 +173,6 @@ _pager_init(E_Module *m)
194 "modules/pager/screen"); 173 "modules/pager/screen");
195 evas_object_show(o); 174 evas_object_show(o);
196 175
197 e->ev_handler_container_resize =
198 ecore_event_handler_add(E_EVENT_CONTAINER_RESIZE,
199 _pager_cb_event_container_resize, e);
200
201 e->ev_handler_border_resize = 176 e->ev_handler_border_resize =
202 ecore_event_handler_add(E_EVENT_BORDER_RESIZE, 177 ecore_event_handler_add(E_EVENT_BORDER_RESIZE,
203 _pager_cb_event_border_resize, e); 178 _pager_cb_event_border_resize, e);
@@ -224,9 +199,22 @@ _pager_init(E_Module *m)
224 _pager_cb_event_zone_desk_count_set, e); 199 _pager_cb_event_zone_desk_count_set, e);
225 200
226 _pager_container_set(e); 201 _pager_container_set(e);
227 _pager_reconfigure(e); 202
228 evas_object_resize(e->screen, e->fw, e->fh); 203 e->gmc = e_gadman_client_new(e->con->gadman);
229 evas_object_move(e->base, e->fx, e->fy); 204 e_gadman_client_domain_set(e->gmc, "module.pager", 0);
205 e_gadman_client_policy_set(e->gmc,
206 E_GADMAN_POLICY_ANYWHERE |
207 E_GADMAN_POLICY_HMOVE |
208 E_GADMAN_POLICY_VMOVE |
209 E_GADMAN_POLICY_HSIZE |
210 E_GADMAN_POLICY_VSIZE);
211 e_gadman_client_min_size_set(e->gmc, 8, 8);
212 e_gadman_client_max_size_set(e->gmc, 256, 256);
213 e_gadman_client_auto_size_set(e->gmc, 64, 64);
214 e_gadman_client_align_set(e->gmc, 0.0, 0.5);
215 e_gadman_client_resize(e->gmc, 80, 60);
216 e_gadman_client_change_func_set(e->gmc, _pager_cb_gmc_change, e);
217 e_gadman_client_load(e->gmc);
230 return e; 218 return e;
231} 219}
232 220
@@ -234,14 +222,13 @@ static void
234_pager_shutdown(Pager *e) 222_pager_shutdown(Pager *e)
235{ 223{
236 free(e->conf); 224 free(e->conf);
237 E_CONFIG_DD_FREE(e->conf_edd); 225/* E_CONFIG_DD_FREE(e->conf_edd);*/
238 226
239 if (e->base) evas_object_del(e->base); 227 if (e->base) evas_object_del(e->base);
240 if (e->screen) evas_object_del(e->screen); 228 if (e->screen) evas_object_del(e->screen);
229 e_object_del(E_OBJECT(e->gmc));
241 230
242 _pager_zone_leave(e); 231 _pager_zone_leave(e);
243 ecore_event_handler_del(e->ev_handler_container_resize);
244
245 ecore_event_handler_del(e->ev_handler_border_resize); 232 ecore_event_handler_del(e->ev_handler_border_resize);
246 ecore_event_handler_del(e->ev_handler_border_move); 233 ecore_event_handler_del(e->ev_handler_border_move);
247 ecore_event_handler_del(e->ev_handler_border_add); 234 ecore_event_handler_del(e->ev_handler_border_add);
@@ -379,7 +366,6 @@ _pager_window_create(Pager *e, E_Border *border, Pager_Desk *owner)
379 evas_object_show(o); 366 evas_object_show(o);
380 app = e_app_window_name_class_find(border->client.icccm.name, 367 app = e_app_window_name_class_find(border->client.icccm.name,
381 border->client.icccm.class); 368 border->client.icccm.class);
382 /* FIXME: here we do not get the info, the app has not populated the icccm */
383 if (app) 369 if (app)
384 { 370 {
385 o = edje_object_add(e->evas); 371 o = edje_object_add(e->evas);
@@ -548,28 +534,6 @@ _pager_desk_set(Pager *p, E_Desk *desk)
548} 534}
549 535
550static void 536static void
551_pager_reconfigure(Pager *e)
552{
553 Evas_Coord ww, hh;
554 E_Zone *zone;
555 int xcount, ycount;
556
557 evas_output_viewport_get(e->evas, NULL, NULL, &ww, &hh);
558 e->fx = e->conf->x * (ww - e->conf->width);
559 e->fy = e->conf->y * (hh - e->conf->height);
560 e->fw = e->conf->width;
561 e->fh = e->conf->height;
562
563 zone = e_zone_current_get(e_container_current_get(_pager_manager_current_get(e)));
564 e_zone_desk_count_get(zone, &xcount, &ycount);
565 e->tw = e->fw * xcount;
566 e->th = e->fh * ycount;
567
568 _pager_container_leave(e);
569 _pager_container_set(e);
570}
571
572static void
573_pager_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info) 537_pager_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
574{ 538{
575 Evas_Event_Mouse_Down *ev; 539 Evas_Event_Mouse_Down *ev;
@@ -586,17 +550,44 @@ _pager_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
586 E_MENU_POP_DIRECTION_DOWN); 550 E_MENU_POP_DIRECTION_DOWN);
587 e_util_container_fake_mouse_up_all_later(con); 551 e_util_container_fake_mouse_up_all_later(con);
588 } 552 }
589 else if (ev->button == 2)
590 {
591 p->resize = 1;
592 }
593 else if (ev->button == 1) 553 else if (ev->button == 1)
594 { 554 {
595 p->move = 1; 555 int xcount, ycount;
556 Evas_Coord xx, yy, x, y;
557 E_Zone *zone;
558 E_Desk *desk;
559 E_Container *con;
560
561 con = e_container_current_get(_pager_manager_current_get(p));
562 zone = e_zone_current_get(con);
563 e_zone_desk_count_get(zone, &xcount, &ycount);
564 evas_pointer_canvas_xy_get(p->evas, &xx, &yy);
565
566 for (x = 0; x < xcount; x++)
567 for (y = 0; y < ycount; y++)
568 {
569 int left, right, top, bottom;
570 left = p->fx + x * p->fw;
571 right = left + p->fw;
572 top = p->fy + y * p->fh;
573 bottom = top + p->fh;
574
575 if (left <= xx && xx < right && top <= yy && yy < bottom)
576 {
577 desk = e_desk_at_xy_get(zone, x, y);
578 if (desk)
579 {
580 e_desk_show(desk);
581 _pager_desk_set(p, desk);
582 }
583 else
584 {
585 printf("PAGER ERROR - %d, %d seems to be out of bounds\n", x, y);
586 }
587 }
588 }
589
596 } 590 }
597 evas_pointer_canvas_xy_get(con->bg_evas, &p->xx, &p->yy);
598 p->clickhackx = p->xx;
599 p->clickhacky = p->yy;
600} 591}
601 592
602static Pager_Desk * 593static Pager_Desk *
@@ -678,71 +669,11 @@ _pager_window_find(Pager *e, E_Border *border)
678} 669}
679 670
680static void 671static void
681_pager_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info) 672_pager_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
682{
683 Evas_Event_Mouse_Up *ev;
684 Pager *p;
685 Evas_Coord xx, yy, ww, hh;
686 E_Container *con = NULL;
687
688 ev = event_info;
689 p = data;
690
691 con = e_container_current_get(_pager_manager_current_get(p));
692 evas_output_viewport_get(con->bg_evas, NULL, NULL, &ww, &hh);
693 /* if we clicked, not moved - FIXME, this is a hack */
694 if (p->move && (p->xx == p->clickhackx) && (p->yy == p->clickhacky))
695 {
696 int x, y, w, h, xcount, ycount;
697 E_Zone *zone;
698 E_Desk *desk;
699
700 zone = e_zone_current_get(con);
701 e_zone_desk_count_get(zone, &xcount, &ycount);
702
703 w = p->fw;
704 h = p->fh;
705 for (x = 0; x < xcount; x++)
706 for (y = 0; y < ycount; y++)
707 {
708 int left, right, top, bottom;
709 left = p->fx + x * w;
710 right = left + w;
711 top = p->fy + y * h;
712 bottom = top + h;
713
714 if (left <= p->xx && p->xx < right && top <= p->yy && p->yy < bottom)
715 {
716 desk = e_desk_at_xy_get(zone, x, y);
717 if (desk)
718 {
719 e_desk_show(desk);
720 _pager_desk_set(p, desk);
721 }
722 else
723 {
724 printf("PAGER ERROR - %d, %d seems to be out of bounds\n", x, y);
725 }
726 }
727 }
728 }
729 p->move = 0;
730 p->resize = 0;
731
732 p->conf->width = p->fw;
733 p->conf->height = p->fh;
734 p->conf->x = (double)p->fx / (double)(ww - p->fw);
735 p->conf->y = (double)p->fy / (double)(hh - p->fh);
736 e_config_save_queue();
737
738}
739
740static void
741_pager_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
742{ 673{
743 Evas_Event_Mouse_Move *ev;
744 Pager *p; 674 Pager *p;
745 Evas_Coord cx, cy, sw, sh, tw, th, dx, dy, xx, yy, ww, hh; 675 Evas_Coord x, y, w, h;
676 Evas_Coord xx, yy, ww, hh, deskw, deskh;
746 E_Zone *zone; 677 E_Zone *zone;
747 int xcount, ycount; 678 int xcount, ycount;
748 Evas_List *desks, *wins; 679 Evas_List *desks, *wins;
@@ -750,117 +681,72 @@ _pager_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
750 Pager_Win *win; 681 Pager_Win *win;
751 E_Container *con; 682 E_Container *con;
752 683
753 evas_pointer_canvas_xy_get(e, &cx, &cy);
754 evas_output_viewport_get(e, NULL, NULL, &sw, &sh);
755
756 ev = event_info;
757 p = data; 684 p = data;
758
759 con = e_container_current_get(_pager_manager_current_get(p)); 685 con = e_container_current_get(_pager_manager_current_get(p));
760 zone = e_zone_current_get(con); 686 zone = e_zone_current_get(con);
761 e_zone_desk_count_get(zone, &xcount, &ycount); 687 e_zone_desk_count_get(zone, &xcount, &ycount);
762 /* note that these are not the same as p->tw, as that could be slightly 688
763 larger (rounding etc) these will vie exactly the right result */ 689 e_gadman_client_geometry_get(p->gmc, &x, &y, &w, &h);
764 tw = p->fw * xcount; 690 deskw = w / xcount;
765 th = p->fh * ycount; 691 deskh = h / ycount;
766 dx = cx - p->xx; 692
767 dy = cy - p->yy; 693 p->fx = x;
768 if (p->move) 694 p->fy = y;
695 p->fw = deskw;
696 p->fh = deskh;
697 if (change == E_GADMAN_CHANGE_MOVE_RESIZE)
769 { 698 {
770 if (p->fx + dx < 0) dx = 0 - p->fx; 699 evas_object_move(p->base, x, y);
771 if (p->fx + dx + tw > sw) dx = sw - (p->fx + tw); 700 evas_object_resize(p->base, w, h);
772 if (p->fy + dy < 0) dy = 0 - p->fy; 701 evas_object_resize(p->screen, deskw, deskh);
773 if (p->fy + dy + th > sh) dy = sh - (p->fy + th);
774 p->fx += dx;
775 p->fy += dy;
776
777 evas_object_move(p->base, p->fx, p->fy);
778 702
779 desks = p->desks; 703 desks = p->desks;
780 while (desks) 704 while (desks)
781 { 705 {
782 desk = desks->data; 706 desk = desks->data;
783 707 evas_object_resize(desk->obj, deskw, deskh);
784 evas_object_geometry_get(desk->obj, &xx, &yy, &ww, &hh); 708 evas_object_move(desk->obj, x + (deskw * desk->xpos),
785 evas_object_move(desk->obj, xx + dx, yy + dy); 709 y + (deskh * desk->ypos));
786 710 if (desk->current)
711 evas_object_move(p->screen, x + (deskw * desk->xpos),
712 y + (deskh * desk->ypos));
713
787 wins = desk->wins; 714 wins = desk->wins;
788 while (wins) 715 while (wins)
789 { 716 {
790 win = wins->data; 717 win = wins->data;
791 718 _pager_window_move(p, win);
792 evas_object_geometry_get(win->obj, &xx, &yy, &ww, &hh);
793 evas_object_move(win->obj, xx + dx, yy + dy);
794 719
795 wins = wins->next; 720 wins = wins->next;
796 } 721 }
797
798 desks = desks->next; 722 desks = desks->next;
799 } 723 }
800
801 evas_object_geometry_get(p->screen, &xx, &yy, &ww, &hh);
802 evas_object_move(p->screen, xx + dx, yy + dy);
803 } 724 }
804 else if (p->resize) 725 else if (change == E_GADMAN_CHANGE_RAISE)
805 { 726 {
806 p->tw += dx; 727 evas_object_raise(p->base);
807 p->th += dy;
808 p->fw = p->tw / xcount;
809 p->fh = p->th / ycount;
810 if (p->fw < PAGER_MIN_W) p->fw = PAGER_MIN_W;
811 if (p->fh < PAGER_MIN_H) p->fh = PAGER_MIN_H;
812 if (p->fx + p->tw > sw)
813 {
814 p->tw = sw - p->fx;
815 p->fw = p->tw / xcount;
816 }
817 if (p->fy + p->th > sh)
818 {
819 p->th = sh - p->fy;
820 p->fh = p->th / ycount;
821 }
822
823 evas_object_resize(p->base, p->fw * xcount, p->fh * ycount);
824 evas_object_resize(p->screen, p->fw, p->fh);
825 728
826 desks = p->desks; 729 desks = p->desks;
827 while (desks) 730 while (desks)
828 { 731 {
829 desk = desks->data; 732 desk = desks->data;
830 evas_object_resize(desk->obj, p->fw, p->fh); 733 evas_object_raise(desk->obj);
831 evas_object_move(desk->obj, p->fx + (desk->xpos * p->fw),
832 p->fy + (desk->ypos * p->fh));
833 if (desk->current)
834 evas_object_move(p->screen, p->fx + (p->fw * desk->xpos),
835 p->fy + (p->fh * desk->ypos));
836 734
837 wins = desk->wins; 735 wins = desk->wins;
838 while (wins) 736 while (wins)
839 { 737 {
840 win = wins->data; 738 win = wins->data;
841 _pager_window_move(p, win); 739 evas_object_raise(win->obj);
842 740
843 wins = wins->next; 741 wins = wins->next;
844 } 742 }
845
846 desks = desks->next; 743 desks = desks->next;
847 } 744 }
848 745
849 } 746 evas_object_raise(p->screen);
850 p->xx = ev->cur.canvas.x; 747 }
851 p->yy = ev->cur.canvas.y;
852} 748}
853 749
854static int
855_pager_cb_event_container_resize(void *data, int type, void *event)
856{
857 Pager *e;
858
859 e = data;
860 _pager_reconfigure(e);
861 return 1;
862}
863
864static int 750static int
865_pager_cb_event_border_resize(void *data, int type, void *event) 751_pager_cb_event_border_resize(void *data, int type, void *event)
866{ 752{
@@ -1022,7 +908,7 @@ _pager_cb_event_zone_desk_count_set(void *data, int type, void *event)
1022 E_Event_Zone_Desk_Count_Set *ev; 908 E_Event_Zone_Desk_Count_Set *ev;
1023 909
1024 e = data; 910 e = data;
1025 _pager_reconfigure(e); 911 // FIXME need to update display with sizes etc
1026 return 1; 912 return 1;
1027} 913}
1028 914
diff --git a/src/modules/pager/e_mod_main.h b/src/modules/pager/e_mod_main.h
index ba01754a4..6c3c3ab47 100644
--- a/src/modules/pager/e_mod_main.h
+++ b/src/modules/pager/e_mod_main.h
@@ -8,23 +8,23 @@ typedef struct _Pager_Win Pager_Win;
8 8
9struct _Config 9struct _Config
10{ 10{
11 int width, height; 11 int dummy; /* space holder */
12 double x, y;
13}; 12};
14 13
15struct _Pager 14struct _Pager
16{ 15{
17 Evas_List *managers; 16 Evas_List *managers;
18 E_Menu *config_menu; 17 E_Menu *config_menu;
18 E_Container *con;
19 Evas *evas; 19 Evas *evas;
20 Evas_Object *base, *screen; 20 Evas_Object *base, *screen;
21 Evas_List *desks; 21 Evas_List *desks;
22 22
23 E_Config_DD *conf_edd; 23/* E_Config_DD *conf_edd;*/
24 Config *conf; 24 Config *conf;
25 unsigned char move : 1; 25
26 unsigned char resize : 1; 26 Evas_Coord fx, fy, fw, fh;
27 Ecore_Event_Handler *ev_handler_container_resize; 27 E_Gadman_Client *gmc;
28 28
29 Ecore_Event_Handler *ev_handler_border_resize; 29 Ecore_Event_Handler *ev_handler_border_resize;
30 Ecore_Event_Handler *ev_handler_border_move; 30 Ecore_Event_Handler *ev_handler_border_move;
@@ -34,12 +34,6 @@ struct _Pager
34 Ecore_Event_Handler *ev_handler_border_show; 34 Ecore_Event_Handler *ev_handler_border_show;
35 Ecore_Event_Handler *ev_handler_border_desk_set; 35 Ecore_Event_Handler *ev_handler_border_desk_set;
36 Ecore_Event_Handler *ev_handler_zone_desk_count_set; 36 Ecore_Event_Handler *ev_handler_zone_desk_count_set;
37
38 Evas_Coord fx, fy, fw, fh, tw, th;
39 Evas_Coord xx, yy;
40
41 /* FIXME: want to fix click detection once leftdrag is not used */
42 Evas_Coord clickhackx, clickhacky;
43}; 37};
44 38
45struct _Pager_Desk 39struct _Pager_Desk