47 sub = strstr(haystack, needle);
51 return sub - haystack;
74 gboolean has_custom_monitors = FALSE;
76 gboolean primary_found = FALSE;
83 static gchar buffer[256];
84 gint buffer_offset = 0;
86 GdkRectangle geometry = { 0, 0, 0, 0 };
87 GdkRectangle tempgeom = { 0, 0, 0, 0 };
88 GdkRectangle destgeom = { 0, 0, 0, 0 };
89 rdpSettings* settings;
95 *maxwidth = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
96 *maxheight = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
98 display = gdk_display_get_default ();
99 n_monitors = gdk_display_get_n_monitors(display);
108 has_custom_monitors = TRUE;
110 rdpMonitor* base = (rdpMonitor *)freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray);
111 for (gint i = 0; i < n_monitors; ++i) {
113 if (has_custom_monitors) {
114 REMMINA_PLUGIN_DEBUG(
"We have custom monitors");
116 snprintf(itoc,
sizeof(itoc),
"%d", i);
118 REMMINA_PLUGIN_DEBUG(
"Monitor n %d it's out of the provided list", i);
124 monitor = gdk_display_get_monitor(display, i);
125 if (monitor == NULL) {
126 REMMINA_PLUGIN_DEBUG(
"Monitor n %d does not exist or is not active", i);
131 monitor = gdk_display_get_monitor(display, index);
132 current = &base[index];
133 REMMINA_PLUGIN_DEBUG(
"Monitor n %d", index);
137 gdk_monitor_get_geometry (monitor, &geometry);
138 current->x = geometry.x;
139 REMMINA_PLUGIN_DEBUG(
"Monitor n %d x: %d", index, geometry.x);
140 current->y = geometry.y;
141 REMMINA_PLUGIN_DEBUG(
"Monitor n %d y: %d", index, geometry.y);
144 scale = gdk_monitor_get_scale_factor (monitor);
145 REMMINA_PLUGIN_DEBUG(
"Monitor n %d scale: %d", index, scale);
148 geometry.width *= scale;
149 geometry.height *= scale;
150 REMMINA_PLUGIN_DEBUG(
"Monitor n %d width: %d", index, geometry.width);
151 REMMINA_PLUGIN_DEBUG(
"Monitor n %d height: %d", index, geometry.height);
152 current->width = geometry.width;
153 current->height = geometry.height;
154 current->attributes.physicalHeight = gdk_monitor_get_height_mm (monitor);
155 REMMINA_PLUGIN_DEBUG(
"Monitor n %d physical height: %d", i, current->attributes.physicalHeight);
156 current->attributes.physicalWidth = gdk_monitor_get_width_mm (monitor);
157 REMMINA_PLUGIN_DEBUG(
"Monitor n %d physical width: %d", i, current->attributes.physicalWidth);
158 current->orig_screen = index;
159 if (!primary_found) {
160 freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, current->x);
161 freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, current->y);
163 if (gdk_monitor_is_primary(monitor)) {
164 REMMINA_PLUGIN_DEBUG (
"Primary monitor found with id: %d", index);
165 current->is_primary = TRUE;
166 primary_found = TRUE;
167 if (current->x != 0 || current->y != 0)
169 REMMINA_PLUGIN_DEBUG (
"Primary monitor not at 0,0 coordinates: %d", index);
170 freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, current->x);
171 freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, current->y);
174 if (!primary_found && current->x == 0 &&
177 REMMINA_PLUGIN_DEBUG (
"Monitor %d has 0,0 coordinates", index);
178 current->is_primary = TRUE;
179 freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, current->x);
180 freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, current->y);
181 primary_found = TRUE;
182 REMMINA_PLUGIN_DEBUG (
"Primary monitor set to id: %d", index);
185 REMMINA_PLUGIN_DEBUG (
"Local X Shift: %d", freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftX));
186 REMMINA_PLUGIN_DEBUG (
"Local Y Shift: %d", freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftY));
194 if (buffer_offset == 0)
195 buffer_offset = g_sprintf(buffer + buffer_offset,
"%d", i);
197 buffer_offset = g_sprintf(buffer + buffer_offset,
",%d", i);
198 REMMINA_PLUGIN_DEBUG(
"Monitor IDs buffer: %s", buffer);
199 gdk_rectangle_union(&tempgeom, &geometry, &destgeom);
200 memcpy(&tempgeom, &destgeom,
sizeof tempgeom);
205 freerdp_settings_set_uint32(settings, FreeRDP_MonitorCount, index);
213 for (gint i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++)
215 rdpMonitor* current = &base[i];
217 current->x - freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftX);
218 REMMINA_PLUGIN_DEBUG(
"Monitor n %d calculated x: %d", i, current->x);
220 current->y - freerdp_settings_get_uint32(settings, FreeRDP_MonitorLocalShiftY);
221 REMMINA_PLUGIN_DEBUG(
"Monitor n %d calculated y: %d", i, current->y);
224 REMMINA_PLUGIN_DEBUG(
"%d monitors on %d have been configured", freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount), count);
225 *maxwidth = destgeom.width;
226 *maxheight = destgeom.height;
227 REMMINA_PLUGIN_DEBUG(
"maxw and maxh: %ux%u", *maxwidth, *maxheight);
229 freerdp_settings_set_bool(rfi->
settings, FreeRDP_SupportMonitorLayoutPdu, TRUE);
230 *monitorids = g_strdup(buffer);
gint remmina_rdp_utils_strpos(const gchar *haystack, const gchar *needle)
Utility functions should be moved somewhere else
void remmina_rdp_monitor_get(rfContext *rfi, gchar **monitorids, guint32 *maxwidth, guint32 *maxheight)
Set the MonitorIDs, the maxwidth and maxheight.