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
|
/*
* Qt UI
*
* Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact:
* SeokYeon Hwang <syeon.hwang@samsung.com>
* Sangho Park <sangho1206.park@samsung.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* Contributors:
* - S-Core Co., Ltd
*
*/
#include "ui/console.h"
#include "emul_state.h"
#include "maru_display.h"
#include "qt5_supplement.h"
extern QemuMutex sdl_mutex;
extern QemuCond sdl_cond;
/* static Notifier mouse_mode_notifier; */
static int qt5_num_outputs;
static struct qt5_state {
DisplayChangeListener dcl;
DisplaySurface *surface;
int idx;
} *qt5_console;
void qt5_graphic_hw_invalidate(void)
{
graphic_hw_invalidate(NULL);
}
int qt5_graphic_hw_display(void)
{
console_ch_t displayed = 0;
graphic_hw_text_update(NULL, &displayed);
return displayed;
}
static void qt5_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
DisplaySurface *surf = qemu_console_surface(dcl->con);
if (!surf) {
return;
}
qt5_update_internal(surface_data(surf),
surface_width(surf),
surface_height(surf));
}
static void qt5_switch(DisplayChangeListener *dcl,
DisplaySurface *new_surface)
{
}
static void qt5_refresh(DisplayChangeListener *dcl)
{
graphic_hw_update(dcl->con);
qt5_refresh_internal();
}
static void qt5_mouse_warp(DisplayChangeListener *dcl,
int x, int y, int on)
{
}
static void qt5_mouse_define(DisplayChangeListener *dcl,
QEMUCursor *c)
{
}
static const DisplayChangeListenerOps dcl_ops = {
.dpy_name = "qt5",
.dpy_gfx_update = qt5_update,
.dpy_gfx_switch = qt5_switch,
.dpy_refresh = qt5_refresh,
.dpy_mouse_set = qt5_mouse_warp,
.dpy_cursor_define = qt5_mouse_define,
};
#ifdef CONFIG_DARWIN
void ns_run_in_event_loop(void (*func)());
void set_application_icon(char *path);
#endif
void maru_qt5_display_early_init(void)
{
#ifdef CONFIG_DARWIN
ns_run_in_event_loop(&qt5_early_prepare);
/* set emulator icon */
#define ICON_RESOURCE_PATH "../icons/"
#define ICON_FILE_NAME "emulator_icon.ico"
const int path_len = strlen(get_bin_path()) +
strlen(ICON_RESOURCE_PATH) + strlen(ICON_FILE_NAME) + 1;
char *icon_path = g_malloc0(sizeof(char) * path_len);
snprintf(icon_path, path_len, "%s%s%s",
get_bin_path(), ICON_RESOURCE_PATH, ICON_FILE_NAME);
fprintf(stdout, "application icon path : %s\n", icon_path);
set_application_icon(icon_path);
g_free(icon_path);
#else
qt5_early_prepare();
#endif
}
void maru_qt5_display_quit(void)
{
qt5_destroy();
if (qt5_console) {
g_free(qt5_console);
qt5_console = NULL;
}
}
void maru_qt5_display_init(MaruDisplayChangeListener *mdcl, int full_screen)
{
int i;
#ifdef SDL_THREAD
qemu_mutex_init(&sdl_mutex);
qemu_cond_init(&sdl_cond);
#endif
/* prepare gui */
#ifdef CONFIG_DARWIN
ns_run_in_event_loop(&qt5_prepare);
#else
qt5_prepare();
#endif
for (i = 0;; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
if (!con || !qemu_console_is_graphic(con)) {
break;
}
}
qt5_num_outputs = i;
qt5_console = g_new0(struct qt5_state, qt5_num_outputs);
for (i = 0; i < qt5_num_outputs; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
qt5_console[i].dcl.ops = &dcl_ops;
qt5_console[i].dcl.con = con;
register_displaychangelistener(&qt5_console[i].dcl);
qt5_console[i].idx = i;
}
mdcl->fini = maru_qt5_display_quit;
if (full_screen) {
/* TODO */
}
/* TODO
mouse_mode_notifier.notify = qt2_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
*/
/* TODO: cursor control */
}
|