efl

Форк
0
/
edje-dynamic-multiseat.c 
136 строк · 3.4 Кб
1
/**
2
 * Edje example demonstrating how to use multiseat features following
3
 * a dynamic approach.
4
 *
5
 * It's an example of how themes can be implemented even if the number
6
 * of seats using the UI is unknown.
7
 *
8
 * You'll need at least one Evas engine built for it (excluding the
9
 * buffer one) that supports multiseat. It may be wayland or
10
 * X11 with VNC support. Using other engines will lead you to a
11
 * situation where all seats are reported as the same one ("default").
12
 *
13
 * @verbatim
14
 * edje_cc dynamic-multiseat.edc && gcc -o edje-dynamic-multiseat edje-dynamic-multiseat.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
15
 * @endverbatim
16
 */
17

18
#ifdef HAVE_CONFIG_H
19
# include "config.h"
20
#else
21
# define EINA_UNUSED
22
#endif
23

24
#ifndef PACKAGE_DATA_DIR
25
#define PACKAGE_DATA_DIR "."
26
#endif
27

28
#include <Ecore.h>
29
#include <Ecore_Evas.h>
30
#include <Edje.h>
31

32
#define WIDTH 400
33
#define HEIGHT 400
34

35
static const char *GROUPNAME = "example/main";
36
static const char *EDJE_FILE = PACKAGE_DATA_DIR"/dynamic_multiseat.edj";
37

38
static void
39
_on_destroy(Ecore_Evas *ee EINA_UNUSED)
40
{
41
   ecore_main_loop_quit();
42
}
43

44
static void
45
_on_canvas_resize(Ecore_Evas *ee)
46
{
47
   Evas_Object *bg;
48
   Evas_Object *edje_obj;
49
   int w, h;
50

51
   bg = ecore_evas_data_get(ee, "background");
52
   edje_obj = ecore_evas_data_get(ee, "edje_obj");
53

54
   ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
55
   evas_object_resize(bg, w, h);
56
   evas_object_resize(edje_obj, w, h);
57
}
58

59
static void
60
_edje_seat_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, const char *emission, const char *source EINA_UNUSED)
61
{
62
   const char *sig;
63

64
   sig = emission + strlen("seat,");
65
   printf("Device %s\n", sig);
66
}
67

68
static void
69
_print_msg_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, const char *emission, const char *source EINA_UNUSED)
70
{
71
   printf("Info: %s\n", emission);
72
}
73

74
int
75
main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
76
{
77
   Evas_Object *edje_obj, *bg;
78
   Ecore_Evas *ee;
79
   Evas *evas;
80

81
   if (!ecore_evas_init())
82
     return EXIT_FAILURE;
83

84
   if (!edje_init())
85
     goto shutdown_ecore_evas;
86

87
   ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
88
   if (!ee) goto shutdown_edje;
89

90
   ecore_evas_callback_destroy_set(ee, _on_destroy);
91
   ecore_evas_callback_resize_set(ee, _on_canvas_resize);
92
   ecore_evas_title_set(ee, "Edje Dynamic Multiseat Example");
93

94
   evas = ecore_evas_get(ee);
95

96
   bg = evas_object_rectangle_add(evas);
97
   evas_object_color_set(bg, 255, 255, 255, 255);
98
   evas_object_resize(bg, WIDTH, HEIGHT);
99
   evas_object_show(bg);
100
   ecore_evas_data_set(ee, "background", bg);
101

102
   edje_obj = edje_object_add(evas);
103

104
   if (!edje_object_file_set(edje_obj, EDJE_FILE, GROUPNAME))
105
     printf("failed to set file %s.\n", EDJE_FILE);
106

107
   evas_object_move(edje_obj, 0, 0);
108
   evas_object_resize(edje_obj, WIDTH, HEIGHT);
109
   evas_object_show(edje_obj);
110
   ecore_evas_data_set(ee, "edje_obj", edje_obj);
111

112
   edje_object_signal_callback_add(edje_obj, "seat,*", "",
113
                                   _edje_seat_cb, NULL);
114
   edje_object_signal_callback_add(edje_obj, "*", "theme",
115
                                   _print_msg_cb, NULL);
116

117
   printf("Running example on evas engine %s\n",
118
          ecore_evas_engine_name_get(ee));
119

120
   ecore_evas_show(ee);
121

122
   ecore_main_loop_begin();
123

124
   ecore_evas_free(ee);
125
   ecore_evas_shutdown();
126
   edje_shutdown();
127

128
   return EXIT_SUCCESS;
129

130
shutdown_edje:
131
   edje_shutdown();
132
shutdown_ecore_evas:
133
   ecore_evas_shutdown();
134

135
   return EXIT_FAILURE;
136
}
137

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.