summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Bouchaud (yoz) <yoz@efl.so>2020-05-14 11:13:31 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-05-14 11:23:04 +0100
commiteae3cd37e830b82fee160dbc67ea3a75971dffc7 (patch)
tree988629069cdae42695c89634996b21c892505436 /src
parentf4c1ba959e908dde14023aba7c7e55ce3b963d6e (diff)
e_client_volume: Reparent sink if a new window comes and match this one
Summary: This commit avoid multiple windows got the same sink. Like launching rage from terminology, gstreamer sink could be associated with terminology and rage window too. Reviewers: raster, devilhorns Subscribers: cedric, zmike Tags: #enlightenment-git Differential Revision: https://phab.enlightenment.org/D8929
Diffstat (limited to 'src')
-rw-r--r--src/modules/mixer/gadget/backend.c145
1 files changed, 82 insertions, 63 deletions
diff --git a/src/modules/mixer/gadget/backend.c b/src/modules/mixer/gadget/backend.c
index 66ebb2652..3afc0c187 100644
--- a/src/modules/mixer/gadget/backend.c
+++ b/src/modules/mixer/gadget/backend.c
@@ -45,6 +45,7 @@ static int _sink_input_min_get(void *data);
45static int _sink_input_max_get(void *data); 45static int _sink_input_max_get(void *data);
46static const char *_sink_input_name_get(void *data); 46static const char *_sink_input_name_get(void *data);
47static pid_t _get_ppid(pid_t pid); 47static pid_t _get_ppid(pid_t pid);
48static E_Client_Volume_Sink *_sink_input_e_client_volume_sink_find(Emix_Sink_Input *input, pid_t *ret_pid);
48static void _sink_input_event(int type, Emix_Sink_Input *input); 49static void _sink_input_event(int type, Emix_Sink_Input *input);
49static void _events_cb(void *data, enum Emix_Event type, void *event_info); 50static void _events_cb(void *data, enum Emix_Event type, void *event_info);
50static Eina_Bool _desklock_cb(void *data, int type, void *info); 51static Eina_Bool _desklock_cb(void *data, int type, void *info);
@@ -523,51 +524,75 @@ _get_ppid(pid_t pid)
523 return ppid; 524 return ppid;
524} 525}
525 526
526static void 527static E_Client_Volume_Sink *
527_sink_input_event(int type, Emix_Sink_Input *input) 528_sink_input_e_client_volume_sink_find(Emix_Sink_Input *input, pid_t *ret_pid)
528{ 529{
529 Eina_List *clients, *l, *ll; 530 Eina_List *clients, *l;
530 E_Client *ec; 531 E_Client *ec;
531 E_Client_Volume_Sink *sink; 532 E_Client_Volume_Sink *sink = NULL;
532 pid_t pid; 533 pid_t pid;
533 Eina_Bool found = EINA_FALSE; 534 Eina_Bool found = EINA_FALSE;
534 535
536 pid = input->pid;
537
538 EINA_LIST_FOREACH(_client_sinks, l, sink)
539 {
540 if (sink->data == input)
541 break;
542 }
543
544 for (;;)
545 {
546 if ((pid <= 1) || (pid == getpid())) break;
547 clients = e_client_focus_stack_get();
548 EINA_LIST_FOREACH(clients, l, ec)
549 {
550 if ((ec->netwm.pid == pid) && (!ec->parent))
551 {
552 DBG("Sink found the client %s",
553 e_client_util_name_get(ec));
554 if (!sink)
555 {
556 DBG("Create a new client_volume_sink");
557 sink = e_client_volume_sink_new(_sink_input_get,
558 _sink_input_set,
559 _sink_input_min_get,
560 _sink_input_max_get,
561 _sink_input_name_get,
562 input);
563 }
564 e_client_volume_sink_append(ec, sink);
565 _client_sinks = eina_list_append(_client_sinks, sink);
566 found = EINA_TRUE;
567 }
568 }
569 if (found) break;
570 pid = _get_ppid(pid);
571 }
572 if (ret_pid) *ret_pid = pid;
573 return found ? sink : NULL;
574}
575
576static void
577_sink_input_event(int type, Emix_Sink_Input *input)
578{
579 Eina_List *l;
580 E_Client_Volume_Sink *sink;
581
535 switch (type) 582 switch (type)
536 { 583 {
537 case EMIX_SINK_INPUT_ADDED_EVENT: 584 case EMIX_SINK_INPUT_ADDED_EVENT:
538 pid = input->pid; 585 _sink_input_e_client_volume_sink_find(input, NULL);
539 for (;;)
540 {
541 if ((pid <= 1) || (pid == getpid())) return;
542 clients = e_client_focus_stack_get();
543 EINA_LIST_FOREACH(clients, l, ec)
544 {
545 if ((ec->netwm.pid == pid) && (!ec->parent))
546 {
547 DBG("Sink found the client %s",
548 e_client_util_name_get(ec));
549 sink = e_client_volume_sink_new(_sink_input_get,
550 _sink_input_set,
551 _sink_input_min_get,
552 _sink_input_max_get,
553 _sink_input_name_get,
554 input);
555 e_client_volume_sink_append(ec, sink);
556 _client_sinks = eina_list_append(_client_sinks, sink);
557 found = EINA_TRUE;
558 }
559 }
560 if (found) break;
561 pid = _get_ppid(pid);
562 }
563 break; 586 break;
564 case EMIX_SINK_INPUT_REMOVED_EVENT: 587 case EMIX_SINK_INPUT_REMOVED_EVENT:
565 EINA_LIST_FOREACH_SAFE(_client_sinks, l, ll, sink) 588 EINA_LIST_FOREACH(_client_sinks, l, sink)
566 { 589 {
567 if (sink->data == input) 590 if (sink->data == input)
568 { 591 {
592 DBG("Client sink del");
569 e_client_volume_sink_del(sink); 593 e_client_volume_sink_del(sink);
570 _client_sinks = eina_list_remove_list(_client_sinks, l); 594 _client_sinks = eina_list_remove_list(_client_sinks, l);
595 break;
571 } 596 }
572 } 597 }
573 break; 598 break;
@@ -953,39 +978,33 @@ _client_mixer_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
953static Eina_Bool 978static Eina_Bool
954_e_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) 979_e_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
955{ 980{
956 E_Event_Client *ev; 981 E_Event_Client *ev;
957 Eina_List *l; 982 Eina_List *l, *ll;
958 Emix_Sink_Input *input; 983 Emix_Sink_Input *input;
959 pid_t pid; 984 E_Client *ec;
960 E_Client_Volume_Sink *sink; 985 E_Client_Volume_Sink *sink;
961 986 pid_t pid;
962 ev = event; 987
963 988 ev = event;
964 if (ev->ec->parent) return ECORE_CALLBACK_PASS_ON; 989
965 EINA_LIST_FOREACH((Eina_List *)emix_sink_inputs_get(), l, input) 990 if (ev->ec->parent) return ECORE_CALLBACK_PASS_ON;
966 { 991 EINA_LIST_FOREACH((Eina_List *)emix_sink_inputs_get(), l, input)
967 pid = input->pid; 992 {
968 while (42) 993 sink = _sink_input_e_client_volume_sink_find(input, &pid);
969 { 994 if (sink)
970 if (pid <= 1 || pid == getpid()) return ECORE_CALLBACK_PASS_ON; 995 {
971 if (ev->ec->netwm.pid == pid) 996 EINA_LIST_FOREACH_SAFE(sink->clients, l, ll, ec)
972 { 997 {
973 DBG("Client(%s) found a sink input", 998 if (ec->netwm.pid != pid)
974 e_client_util_name_get(ev->ec)); 999 {
975 sink = e_client_volume_sink_new(_sink_input_get, 1000 DBG("Clean invalid client sink %s",
976 _sink_input_set, 1001 e_client_util_name_get(ec));
977 _sink_input_min_get, 1002 e_client_volume_sink_remove(ec, sink);
978 _sink_input_max_get, 1003 }
979 _sink_input_name_get, 1004 }
980 input); 1005 }
981 e_client_volume_sink_append(ev->ec, sink); 1006 }
982 _client_sinks = eina_list_append(_client_sinks, sink); 1007 return ECORE_CALLBACK_PASS_ON;
983 return ECORE_CALLBACK_PASS_ON;
984 }
985 pid = _get_ppid(pid);
986 }
987 }
988 return ECORE_CALLBACK_PASS_ON;
989} 1008}
990 1009
991static Eina_Bool 1010static Eina_Bool