This repository has been archived by the owner on Dec 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
winmin-viewer-multimonitor.c
148 lines (110 loc) · 3.36 KB
/
winmin-viewer-multimonitor.c
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
//WIP for winmin-viewer multimonitor support
#include <gtk/gtk.h>
#include <spice-client-gtk-3.0/spice-client-gtk.h>
#include <stdio.h>
#include <glib-object.h>
#include <spice-client.h>
#include <signal.h>
SpiceSession * session;
char** name;
char** sock;
int id;
int windowcount;
GtkWidget * window[2];
SpiceChannel * mainchannel;
gboolean resize_done (gpointer data)
{
guint *gid = data;
*gid = 0;
resize();
return FALSE;
}
gboolean on_configure_event (GdkEvent *event, gpointer data)
{
static guint gid = 0;
if (gid)
g_source_remove (gid);
gid = g_timeout_add (250, resize_done, &gid);
return FALSE;
}
void resize() {
printf("Resize!\n");
for (int i = 0; i < windowcount; ++i) {
int width, height;
gtk_window_get_size(window[i], &width, &height);
spice_main_set_display_enabled(mainchannel,i,TRUE);
spice_main_set_display(mainchannel,i, 0, 0, width, height);
}
//spice_main_channel_update_display(mainchannel, 1, 0, 0, 500, 500, TRUE);
printf("Send!\n");
spice_main_send_monitor_config(mainchannel);
//spice_main_set_display_enabled(mainchannel,-1,TRUE);
}
void setup_spice() {
session = spice_session_new();
g_object_set(session,"uri",sock);
printf("test\n");
char** test;
g_object_get(session,"uri",&test);
printf("test: %s\n",test);
mainchannel = spice_channel_new(session,1,0);
spice_session_connect(session);
if (SPICE_IS_MAIN_CHANNEL(mainchannel)) {
printf("Good\n");
}
else {
printf("Bad\n");
}
}
static void
activate (GtkApplication* app,
gpointer user_data)
{
window[windowcount] = gtk_application_window_new (app);
SpiceDisplay * display = spice_display_new(session, windowcount);
GtkWidget * displaywidget = GTK_WIDGET(display);
gtk_container_add(GTK_CONTAINER(window[windowcount]),displaywidget);
gtk_window_set_title (GTK_WINDOW(window[windowcount]), name);
gtk_window_set_default_size (GTK_WINDOW (window[windowcount]), 900, 800);
gtk_window_set_position(GTK_WINDOW(window[windowcount]), GTK_WIN_POS_CENTER);
gtk_widget_show_all (window[windowcount]);
resize();
g_signal_connect(G_OBJECT(window[windowcount]), "configure-event",
G_CALLBACK(on_configure_event), NULL);
windowcount += 1;
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
name = argv[1];
sock = argv[2];
id = (int)strtol(argv[3], NULL, 10);
app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE);
setup_spice();
windowcount = 0;
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), NULL, NULL);
g_object_unref (app);
return status;
}
/*static void
activateaux (GtkApplication* app,
gpointer user_data)
{
window[1] = gtk_application_window_new (app);
SpiceDisplay * display2 = spice_display_new(session,1);
GtkWidget * displaywidget = GTK_WIDGET(display2);
gtk_container_add(GTK_CONTAINER(window[1]),displaywidget);
gtk_window_set_title (GTK_WINDOW(window[1]), name);
gtk_window_set_default_size (GTK_WINDOW (window[1]), 900, 800);
gtk_window_set_position(GTK_WINDOW(window[1]), GTK_WIN_POS_CENTER);
gtk_widget_show_all (window[1]);
resize();
g_signal_connect(G_OBJECT(window[1]), "configure-event",
G_CALLBACK(on_configure_event), NULL);
}
*/