summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSeunghun Lee <shiin.lee@samsung.com>2014-12-10 12:12:21 -0500
committerChris Michael <cp.michael@samsung.com>2014-12-10 12:12:21 -0500
commit5720a350f995c017efc1bf5d4472856dc7552962 (patch)
tree50d7b64923e69cba0b6d6e87b21330af5633eb3b /src
parent5d767aff32e42040da0dd6a5c4d70cff7139e1b2 (diff)
ecore-drm: Add event to notify session activation state.
Summary: this event is to notify session activation state to compositor. thus compositor can change composite state by this event. Reviewers: devilhorns Subscribers: torori, cedric Differential Revision: https://phab.enlightenment.org/D1767
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_drm/Ecore_Drm.h10
-rw-r--r--src/lib/ecore_drm/ecore_drm.c21
-rw-r--r--src/lib/ecore_drm/ecore_drm_dbus.c12
-rw-r--r--src/lib/ecore_drm/ecore_drm_logind.c75
-rw-r--r--src/lib/ecore_drm/ecore_drm_private.h2
-rw-r--r--src/lib/ecore_drm/ecore_drm_tty.c4
6 files changed, 85 insertions, 39 deletions
diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index 3238a20adf..7a652735cf 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -108,6 +108,11 @@ struct _Ecore_Drm_Device
108 unsigned int window; 108 unsigned int window;
109}; 109};
110 110
111struct _Ecore_Drm_Event_Activate
112{
113 Eina_Bool active;
114};
115
111/* opaque structure to represent a drm device */ 116/* opaque structure to represent a drm device */
112typedef struct _Ecore_Drm_Device Ecore_Drm_Device; 117typedef struct _Ecore_Drm_Device Ecore_Drm_Device;
113 118
@@ -129,6 +134,11 @@ typedef struct _Ecore_Drm_Seat Ecore_Drm_Seat;
129/* opaque structure to represent a drm sprite */ 134/* opaque structure to represent a drm sprite */
130typedef struct _Ecore_Drm_Sprite Ecore_Drm_Sprite; 135typedef struct _Ecore_Drm_Sprite Ecore_Drm_Sprite;
131 136
137/* sturcture to inform drm activation state */
138typedef struct _Ecore_Drm_Event_Activate Ecore_Drm_Event_Activate;
139
140EAPI extern int ECORE_DRM_EVENT_ACTIVATE;
141
132/** 142/**
133 * @file 143 * @file
134 * @brief Ecore functions for dealing with drm, virtual terminals 144 * @brief Ecore functions for dealing with drm, virtual terminals
diff --git a/src/lib/ecore_drm/ecore_drm.c b/src/lib/ecore_drm/ecore_drm.c
index 6413270a08..1bbd49caa0 100644
--- a/src/lib/ecore_drm/ecore_drm.c
+++ b/src/lib/ecore_drm/ecore_drm.c
@@ -2,6 +2,7 @@
2# include "config.h" 2# include "config.h"
3#endif 3#endif
4 4
5#include "Ecore_Drm.h"
5#include "ecore_drm_private.h" 6#include "ecore_drm_private.h"
6 7
7/* local variables */ 8/* local variables */
@@ -10,6 +11,24 @@ static int _ecore_drm_init_count = 0;
10/* external variables */ 11/* external variables */
11int _ecore_drm_log_dom = -1; 12int _ecore_drm_log_dom = -1;
12 13
14EAPI int ECORE_DRM_EVENT_ACTIVATE = 0;
15
16static void
17_ecore_drm_event_activate_free(void *data EINA_UNUSED, void *event)
18{
19 free(event);
20}
21
22void
23_ecore_drm_event_activate_send(Eina_Bool active)
24{
25 Ecore_Drm_Event_Activate *e;
26
27 e = calloc(1, sizeof(Ecore_Drm_Event_Activate));
28 e->active = active;
29 ecore_event_add(ECORE_DRM_EVENT_ACTIVATE, e, _ecore_drm_event_activate_free, NULL);
30}
31
13/** 32/**
14 * @defgroup Ecore_Drm_Init_Group Drm Library Init and Shutdown Functions 33 * @defgroup Ecore_Drm_Init_Group Drm Library Init and Shutdown Functions
15 * 34 *
@@ -67,6 +86,8 @@ ecore_drm_init(void)
67 /* try to init eeze */ 86 /* try to init eeze */
68 if (!eeze_init()) goto eeze_err; 87 if (!eeze_init()) goto eeze_err;
69 88
89 ECORE_DRM_EVENT_ACTIVATE = ecore_event_type_new();
90
70 /* return init count */ 91 /* return init count */
71 return _ecore_drm_init_count; 92 return _ecore_drm_init_count;
72 93
diff --git a/src/lib/ecore_drm/ecore_drm_dbus.c b/src/lib/ecore_drm/ecore_drm_dbus.c
index bfac33f31b..9eb7570292 100644
--- a/src/lib/ecore_drm/ecore_drm_dbus.c
+++ b/src/lib/ecore_drm/ecore_drm_dbus.c
@@ -68,10 +68,8 @@ _cb_device_paused(void *ctxt EINA_UNUSED, const Eldbus_Message *msg)
68 _ecore_drm_dbus_device_pause_done(maj, min); 68 _ecore_drm_dbus_device_pause_done(maj, min);
69 } 69 }
70 70
71 /* if (maj == DRM_MAJOR) */ 71 if (maj == DRM_MAJOR)
72 /* { */ 72 _ecore_drm_event_activate_send(EINA_FALSE);
73 /* // emit paused to compositor */
74 /* } */
75 } 73 }
76} 74}
77 75
@@ -90,10 +88,8 @@ _cb_device_resumed(void *ctxt EINA_UNUSED, const Eldbus_Message *msg)
90 88
91 if (eldbus_message_arguments_get(msg, "uuh", &maj, &min, &fd)) 89 if (eldbus_message_arguments_get(msg, "uuh", &maj, &min, &fd))
92 { 90 {
93 /* if (maj == DRM_MAJOR) */ 91 if (maj == DRM_MAJOR)
94 /* { */ 92 _ecore_drm_event_activate_send(EINA_TRUE);
95 /* // emit active to compositor */
96 /* } */
97 } 93 }
98} 94}
99 95
diff --git a/src/lib/ecore_drm/ecore_drm_logind.c b/src/lib/ecore_drm/ecore_drm_logind.c
index 45ac877fae..332eccbe00 100644
--- a/src/lib/ecore_drm/ecore_drm_logind.c
+++ b/src/lib/ecore_drm/ecore_drm_logind.c
@@ -10,6 +10,7 @@
10# define KDSKBMUTE 0x4B51 10# define KDSKBMUTE 0x4B51
11#endif 11#endif
12 12
13Ecore_Event_Handler *active_hdl;
13static char *sid; 14static char *sid;
14 15
15static Eina_Bool 16static Eina_Bool
@@ -52,15 +53,40 @@ _ecore_drm_logind_cb_vt_signal(void *data, int type EINA_UNUSED, void *event)
52 53
53 if (ev->number == 1) 54 if (ev->number == 1)
54 { 55 {
55 Ecore_Drm_Input *input; 56 if (!ecore_drm_tty_release(dev))
56 Ecore_Drm_Output *output; 57 ERR("Could not release VT: %m");
57 Ecore_Drm_Sprite *sprite; 58 }
58 Eina_List *l; 59 else if (ev->number == 2)
60 {
61 if (!ecore_drm_tty_acquire(dev))
62 ERR("Could not acquire VT: %m");
63 }
64
65 return ECORE_CALLBACK_PASS_ON;
66}
59 67
60 /* disable inputs (suspends) */ 68static Eina_Bool
61 EINA_LIST_FOREACH(dev->inputs, l, input) 69_ecore_drm_logind_cb_activate(void *data, int type EINA_UNUSED, void *event)
62 ecore_drm_inputs_disable(input); 70{
71 Ecore_Drm_Event_Activate *e;
72 Ecore_Drm_Device *dev;
73 Ecore_Drm_Sprite *sprite;
74 Ecore_Drm_Output *output;
75 Eina_List *l;
76
77
78 if ((!event) || (!data)) return ECORE_CALLBACK_RENEW;
79 e = event;
80 dev = data;
63 81
82 if (e->active)
83 {
84 /* set output mode */
85 EINA_LIST_FOREACH(dev->outputs, l, output)
86 ecore_drm_output_enable(output);
87 }
88 else
89 {
64 /* disable hardware cursor */ 90 /* disable hardware cursor */
65 EINA_LIST_FOREACH(dev->outputs, l, output) 91 EINA_LIST_FOREACH(dev->outputs, l, output)
66 ecore_drm_output_cursor_size_set(output, 0, 0, 0); 92 ecore_drm_output_cursor_size_set(output, 0, 0, 0);
@@ -68,34 +94,12 @@ _ecore_drm_logind_cb_vt_signal(void *data, int type EINA_UNUSED, void *event)
68 /* disable sprites */ 94 /* disable sprites */
69 EINA_LIST_FOREACH(dev->sprites, l, sprite) 95 EINA_LIST_FOREACH(dev->sprites, l, sprite)
70 ecore_drm_sprites_fb_set(sprite, 0, 0); 96 ecore_drm_sprites_fb_set(sprite, 0, 0);
71
72 if (!ecore_drm_tty_release(dev))
73 ERR("Could not release VT: %m");
74 }
75 else if (ev->number == 2)
76 {
77 if (ecore_drm_tty_acquire(dev))
78 {
79 Ecore_Drm_Output *output;
80 Ecore_Drm_Input *input;
81 Eina_List *l;
82
83 /* set output mode */
84 EINA_LIST_FOREACH(dev->outputs, l, output)
85 ecore_drm_output_enable(output);
86
87 /* enable inputs */
88 EINA_LIST_FOREACH(dev->inputs, l, input)
89 ecore_drm_inputs_enable(input);
90 }
91 else
92 ERR("Could not acquire VT: %m");
93 } 97 }
94 98
95 return ECORE_CALLBACK_PASS_ON; 99 return ECORE_CALLBACK_PASS_ON;
96} 100}
97 101
98static Eina_Bool 102static Eina_Bool
99_ecore_drm_logind_tty_setup(Ecore_Drm_Device *dev) 103_ecore_drm_logind_tty_setup(Ecore_Drm_Device *dev)
100{ 104{
101 struct stat st; 105 struct stat st;
@@ -160,7 +164,6 @@ err_kmode:
160 return EINA_FALSE; 164 return EINA_FALSE;
161} 165}
162 166
163
164static Eina_Bool 167static Eina_Bool
165_ecore_drm_logind_vt_open(Ecore_Drm_Device *dev, const char *name) 168_ecore_drm_logind_vt_open(Ecore_Drm_Device *dev, const char *name)
166{ 169{
@@ -222,6 +225,10 @@ _ecore_drm_logind_vt_open(Ecore_Drm_Device *dev, const char *name)
222 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, 225 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
223 _ecore_drm_logind_cb_vt_switch, dev); 226 _ecore_drm_logind_cb_vt_switch, dev);
224 227
228 active_hdl =
229 ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE,
230 _ecore_drm_logind_cb_activate, dev);
231
225 /* set current tty into env */ 232 /* set current tty into env */
226 setenv("ECORE_DRM_TTY", tty, 1); 233 setenv("ECORE_DRM_TTY", tty, 1);
227 234
@@ -278,6 +285,12 @@ _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev)
278{ 285{
279 _ecore_drm_logind_vt_close(dev); 286 _ecore_drm_logind_vt_close(dev);
280 _ecore_drm_dbus_shutdown(); 287 _ecore_drm_dbus_shutdown();
288
289 if (active_hdl)
290 {
291 ecore_event_handler_del(active_hdl);
292 active_hdl = NULL;
293 }
281} 294}
282 295
283Eina_Bool 296Eina_Bool
diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h
index acd61f514b..151303fe53 100644
--- a/src/lib/ecore_drm/ecore_drm_private.h
+++ b/src/lib/ecore_drm/ecore_drm_private.h
@@ -229,6 +229,8 @@ struct _Ecore_Drm_Sprite
229 229
230typedef void (*Ecore_Drm_Open_Cb)(void *data, int fd, Eina_Bool b); 230typedef void (*Ecore_Drm_Open_Cb)(void *data, int fd, Eina_Bool b);
231 231
232void _ecore_drm_event_activate_send(Eina_Bool active);
233
232Eina_Bool _ecore_drm_launcher_device_open(const char *device, Ecore_Drm_Open_Cb callback, void *data, int flags); 234Eina_Bool _ecore_drm_launcher_device_open(const char *device, Ecore_Drm_Open_Cb callback, void *data, int flags);
233int _ecore_drm_launcher_device_open_no_pending(const char *device, int flags); 235int _ecore_drm_launcher_device_open_no_pending(const char *device, int flags);
234void _ecore_drm_launcher_device_close(const char *device, int fd); 236void _ecore_drm_launcher_device_close(const char *device, int fd);
diff --git a/src/lib/ecore_drm/ecore_drm_tty.c b/src/lib/ecore_drm/ecore_drm_tty.c
index 6b3652fbce..5e85a03a71 100644
--- a/src/lib/ecore_drm/ecore_drm_tty.c
+++ b/src/lib/ecore_drm/ecore_drm_tty.c
@@ -78,6 +78,8 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event)
78 } 78 }
79 else 79 else
80 ERR("Could not drop drm master: %m"); 80 ERR("Could not drop drm master: %m");
81
82 _ecore_drm_event_activate_send(EINA_FALSE);
81 } 83 }
82 else if (ev->number == 2) 84 else if (ev->number == 2)
83 { 85 {
@@ -99,6 +101,8 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event)
99 /* enable inputs */ 101 /* enable inputs */
100 EINA_LIST_FOREACH(dev->inputs, l, input) 102 EINA_LIST_FOREACH(dev->inputs, l, input)
101 ecore_drm_inputs_enable(input); 103 ecore_drm_inputs_enable(input);
104
105 _ecore_drm_event_activate_send(EINA_TRUE);
102 } 106 }
103 else 107 else
104 ERR("Could not acquire VT: %m"); 108 ERR("Could not acquire VT: %m");