diff options
author | Antenore Gatta (tmow) <antenore@simbiosi.org> | 2021-07-09 00:07:47 +0300 |
---|---|---|
committer | Antenore Gatta (tmow) <antenore@simbiosi.org> | 2021-07-09 00:07:47 +0300 |
commit | fff6f127496c170a82f568d99fa09a0c3b1f3590 (patch) | |
tree | 3870c5739e0795799fad3cbc3987c633c21dfba4 | |
parent | 49488c61f551ebcd9b30b48e4f3e01a106bca4f9 (diff) | |
parent | 5f226986157a5f0cb4df9e2061ecd23d75c2201a (diff) |
Merge branch 'refact/gdkx' into 'master'
Code refactoring - X11 cleanup
See merge request Remmina/Remmina!2294
-rw-r--r-- | plugins/tool_hello_world/plugin.c | 3 | ||||
-rw-r--r-- | src/remmina_public.c | 106 | ||||
-rw-r--r-- | src/remmina_public.h | 2 | ||||
-rw-r--r-- | src/remmina_ssh.c | 92 | ||||
-rw-r--r-- | src/remmina_ssh.h | 8 |
5 files changed, 1 insertions, 210 deletions
diff --git a/plugins/tool_hello_world/plugin.c b/plugins/tool_hello_world/plugin.c index 05dfd2e36..56171e971 100644 --- a/plugins/tool_hello_world/plugin.c +++ b/plugins/tool_hello_world/plugin.c @@ -38,9 +38,6 @@ #include "common/remmina_plugin.h" -#include <gtk/gtkx.h> -#include <gdk/gdkx.h> - static RemminaPluginService *remmina_plugin_service = NULL; #define REMMINA_PLUGIN_DEBUG(fmt, ...) remmina_plugin_service->_remmina_debug(__func__, fmt, ##__VA_ARGS__) diff --git a/src/remmina_public.c b/src/remmina_public.c index dd0e0983c..5b635c9c8 100644 --- a/src/remmina_public.c +++ b/src/remmina_public.c @@ -523,111 +523,6 @@ gint remmina_public_open_xdisplay(const gchar *disp) return sock; } -/* This function was copied from GEdit (gedit-utils.c). */ -guint remmina_public_get_current_workspace(GdkScreen *screen) -{ - TRACE_CALL(__func__); -#ifdef GDK_WINDOWING_X11 -#if GTK_CHECK_VERSION(3, 10, 0) - g_return_val_if_fail(GDK_IS_SCREEN(screen), 0); - if (GDK_IS_X11_DISPLAY(gdk_screen_get_display(screen))) - return gdk_x11_screen_get_current_desktop(screen); - else - return 0; - -#else - GdkWindow *root_win; - GdkDisplay *display; - Atom type; - gint format; - gulong nitems; - gulong bytes_after; - guint *current_desktop; - gint err, result; - guint ret = 0; - - g_return_val_if_fail(GDK_IS_SCREEN(screen), 0); - - root_win = gdk_screen_get_root_window(screen); - display = gdk_screen_get_display(screen); - - gdk_error_trap_push(); - result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XID(root_win), - gdk_x11_get_xatom_by_name_for_display(display, "_NET_CURRENT_DESKTOP"), - 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, - &bytes_after, (gpointer) & current_desktop); - err = gdk_error_trap_pop(); - - if (err != Success || result != Success) - return ret; - - if (type == XA_CARDINAL && format == 32 && nitems > 0) - ret = current_desktop[0]; - - XFree(current_desktop); - return ret; -#endif -#else - /* FIXME: on mac etc probably there are native APIs - * to get the current workspace etc */ - return 0; -#endif -} - -/* This function was copied from GEdit (gedit-utils.c). */ -guint remmina_public_get_window_workspace(GtkWindow *gtkwindow) -{ - TRACE_CALL(__func__); -#ifdef GDK_WINDOWING_X11 -#if GTK_CHECK_VERSION(3, 10, 0) - GdkWindow *window; - g_return_val_if_fail(GTK_IS_WINDOW(gtkwindow), 0); - g_return_val_if_fail(gtk_widget_get_realized(GTK_WIDGET(gtkwindow)), 0); - window = gtk_widget_get_window(GTK_WIDGET(gtkwindow)); - if (GDK_IS_X11_DISPLAY(gdk_window_get_display(window))) - return gdk_x11_window_get_desktop(window); - else - return 0; -#else - GdkWindow *window; - GdkDisplay *display; - Atom type; - gint format; - gulong nitems; - gulong bytes_after; - guint *workspace; - gint err, result; - guint ret = 0; - - g_return_val_if_fail(GTK_IS_WINDOW(gtkwindow), 0); - g_return_val_if_fail(gtk_widget_get_realized(GTK_WIDGET(gtkwindow)), 0); - - window = gtk_widget_get_window(GTK_WIDGET(gtkwindow)); - display = gdk_window_get_display(window); - - gdk_error_trap_push(); - result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XID(window), - gdk_x11_get_xatom_by_name_for_display(display, "_NET_WM_DESKTOP"), - 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, - &bytes_after, (gpointer) & workspace); - err = gdk_error_trap_pop(); - - if (err != Success || result != Success) - return ret; - - if (type == XA_CARDINAL && format == 32 && nitems > 0) - ret = workspace[0]; - - XFree(workspace); - return ret; -#endif -#else - /* FIXME: on mac etc probably there are native APIs - * to get the current workspace etc */ - return 0; -#endif -} - /* Find hardware keycode for the requested keyval */ guint16 remmina_public_get_keycode_for_keyval(GdkKeymap *keymap, guint keyval) { @@ -686,7 +581,6 @@ GtkBuilder* remmina_public_gtk_builder_new_from_resource(gchar *resource) return builder; } - /* Change parent container for a widget * If possible use this function instead of the deprecated gtk_widget_reparent */ void remmina_public_gtk_widget_reparent(GtkWidget *widget, GtkContainer *container) diff --git a/src/remmina_public.h b/src/remmina_public.h index 9707c1d44..c91fb324d 100644 --- a/src/remmina_public.h +++ b/src/remmina_public.h @@ -102,8 +102,6 @@ void remmina_public_get_server_port(const gchar *server, gint defaultport, gchar /* X */ gboolean remmina_public_get_xauth_cookie(const gchar *display, gchar **msg); gint remmina_public_open_xdisplay(const gchar *disp); -guint remmina_public_get_current_workspace(GdkScreen *screen); -guint remmina_public_get_window_workspace(GtkWindow *gtkwindow); /* Find hardware keycode for the requested keyval */ guint16 remmina_public_get_keycode_for_keyval(GdkKeymap *keymap, guint keyval); diff --git a/src/remmina_ssh.c b/src/remmina_ssh.c index 7d5514246..fe33b82d5 100644 --- a/src/remmina_ssh.c +++ b/src/remmina_ssh.c @@ -44,7 +44,6 @@ #include <errno.h> #define LIBSSH_STATIC 1 #include <libssh/libssh.h> -#include <gdk/gdkx.h> #include <gtk/gtk.h> #include <glib/gi18n.h> #include <stdlib.h> @@ -1611,7 +1610,6 @@ remmina_ssh_tunnel_new_from_file(RemminaFile *remminafile) tunnel->socketbuffers = NULL; tunnel->num_channels = 0; tunnel->max_channels = 0; - tunnel->x11_channel = NULL; tunnel->thread = 0; tunnel->running = FALSE; tunnel->server_sock = -1; @@ -1653,13 +1651,6 @@ remmina_ssh_tunnel_close_all_channels(RemminaSSHTunnel *tunnel) tunnel->num_channels = 0; tunnel->max_channels = 0; - - if (tunnel->x11_channel) { - ssh_channel_close(tunnel->x11_channel); - ssh_channel_send_eof(tunnel->x11_channel); - ssh_channel_free(tunnel->x11_channel); - tunnel->x11_channel = NULL; - } } static void @@ -1801,47 +1792,6 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) remmina_ssh_tunnel_add_channel(tunnel, channel, sock); break; - case REMMINA_SSH_TUNNEL_X11: - if ((tunnel->x11_channel = ssh_channel_new(tunnel->ssh.session)) == NULL) { - // TRANSLATORS: The placeholder %s is an error message - remmina_ssh_set_error(REMMINA_SSH(tunnel), _("Could not create channel. %s")); - tunnel->thread = 0; - return NULL; - } - if (!remmina_public_get_xauth_cookie(tunnel->localdisplay, &ptr)) { - remmina_ssh_set_application_error(REMMINA_SSH(tunnel), "%s", ptr); - g_free(ptr); - tunnel->thread = 0; - return NULL; - } - if (ssh_channel_open_session(tunnel->x11_channel) || - ssh_channel_request_x11(tunnel->x11_channel, TRUE, NULL, ptr, - gdk_x11_screen_get_screen_number(gdk_screen_get_default()))) { - g_free(ptr); - // TRANSLATORS: The placeholder %s is an error message - remmina_ssh_set_error(REMMINA_SSH(tunnel), _("Could not open channel. %s")); - tunnel->thread = 0; - return NULL; - } - g_free(ptr); - if (ssh_channel_request_exec(tunnel->x11_channel, tunnel->dest)) { - ptr = g_strdup_printf(_("Could not run %s on SSH server."), tunnel->dest); - remmina_ssh_set_error(REMMINA_SSH(tunnel), ptr); - g_free(ptr); - tunnel->thread = 0; - return NULL; - } - - if (tunnel->init_func && - !(*tunnel->init_func)(tunnel, tunnel->callback_data)) { - if (tunnel->disconnect_func) - (*tunnel->disconnect_func)(tunnel, tunnel->callback_data); - tunnel->thread = 0; - return NULL; - } - - break; - case REMMINA_SSH_TUNNEL_XPORT: /* Detect the next available port starting from 6010 on the server */ for (i = 10; i <= MAX_X_DISPLAY_NUMBER; i++) { @@ -1918,15 +1868,10 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) /* Start the tunnel data transmission */ while (tunnel->running) { if (tunnel->tunnel_type == REMMINA_SSH_TUNNEL_XPORT || - tunnel->tunnel_type == REMMINA_SSH_TUNNEL_X11 || tunnel->tunnel_type == REMMINA_SSH_TUNNEL_REVERSE) { if (first) { first = FALSE; - /* Wait for a period of time for the first incoming connection */ - if (tunnel->tunnel_type == REMMINA_SSH_TUNNEL_X11) - channel = ssh_channel_accept_x11(tunnel->x11_channel, 15000); - else - channel = ssh_channel_accept_forward(REMMINA_SSH(tunnel)->session, 15000, &tunnel->port); + channel = ssh_channel_accept_forward(REMMINA_SSH(tunnel)->session, 15000, &tunnel->port); if (!channel) { remmina_ssh_set_application_error(REMMINA_SSH(tunnel), _("The server did not respond.")); if (tunnel->disconnect_func) @@ -1952,9 +1897,6 @@ remmina_ssh_tunnel_main_thread_proc(gpointer data) + g_date_time_difference(t1, t2) / 100000; if (diff > 1) { REMMINA_DEBUG("Polling tunnel channels"); - if (tunnel->tunnel_type == REMMINA_SSH_TUNNEL_X11) - channel = ssh_channel_accept_x11(tunnel->x11_channel, 0); - else channel = ssh_channel_accept_forward(REMMINA_SSH(tunnel)->session, 0, &tunnel->port); if (channel == NULL) t2 = t1; @@ -2216,23 +2158,6 @@ remmina_ssh_tunnel_open(RemminaSSHTunnel *tunnel, const gchar *host, gint port, } gboolean -remmina_ssh_tunnel_x11(RemminaSSHTunnel *tunnel, const gchar *cmd) -{ - TRACE_CALL(__func__); - tunnel->tunnel_type = REMMINA_SSH_TUNNEL_X11; - tunnel->dest = g_strdup(cmd); - tunnel->running = TRUE; - - if (pthread_create(&tunnel->thread, NULL, remmina_ssh_tunnel_main_thread, tunnel)) { - // TRANSLATORS: Do not translate pthread - remmina_ssh_set_application_error(REMMINA_SSH(tunnel), _("Could not start pthread.")); - tunnel->thread = 0; - return FALSE; - } - return TRUE; -} - -gboolean remmina_ssh_tunnel_xport(RemminaSSHTunnel *tunnel, gboolean bindlocalhost) { TRACE_CALL(__func__); @@ -2458,21 +2383,6 @@ remmina_ssh_shell_thread(gpointer data) ssh_channel_request_pty(channel); - /* ssh_channel_request_x11 works but I do not know yet how to use the - * channel. At the moment I leave the code here, commented, for future - * investigations. - */ - //screen = gdk_x11_screen_get_screen_number(gdk_screen_get_default()); - //ret = ssh_channel_request_x11 (channel, FALSE, NULL, NULL, screen); - /* TODO: We should have a callback that intercept an x11 request to use - * ssh_channel_accept_x11 */ - //if ( ret != SSH_OK ) { - //g_print ("[SSH] X11 channel error: %d\n", ret); - //}else { - //ssh_channel_accept_x11 ( channel, 50); - //} - - if (shell->exec && shell->exec[0]) ret = ssh_channel_request_exec(channel, shell->exec); else diff --git a/src/remmina_ssh.h b/src/remmina_ssh.h index 9c50aa1d2..997e83ff8 100644 --- a/src/remmina_ssh.h +++ b/src/remmina_ssh.h @@ -139,7 +139,6 @@ typedef gboolean (*RemminaSSHTunnelCallback) (RemminaSSHTunnel *, gpointer); enum { REMMINA_SSH_TUNNEL_OPEN, - REMMINA_SSH_TUNNEL_X11, REMMINA_SSH_TUNNEL_XPORT, REMMINA_SSH_TUNNEL_REVERSE }; @@ -156,8 +155,6 @@ struct _RemminaSSHTunnel { gint num_channels; gint max_channels; - ssh_channel x11_channel; - pthread_t thread; gboolean running; @@ -198,11 +195,6 @@ gboolean remmina_ssh_tunnel_open(RemminaSSHTunnel *tunnel, const gchar *host, gi */ void remmina_ssh_tunnel_cancel_accept(RemminaSSHTunnel *tunnel); -/* Accept the X11 tunnel. A new thread will be started and connect to local display. - * cmd: The remote X11 application to be executed - */ -gboolean remmina_ssh_tunnel_x11(RemminaSSHTunnel *tunnel, const gchar *cmd); - /* start X Port Forwarding */ gboolean remmina_ssh_tunnel_xport(RemminaSSHTunnel *tunnel, gboolean bindlocalhost); |