Reputation: 321
I'm trying to automatically move the window to the focused workspace. That is, when I change the workspace, the Gtkwindow will automatically move to that workspace. I tried the script below but it is not working. Can anybody check it?
#include <gtk/gtk.h>
#include <gdk/x11/gdkx.h>
int update (gpointer user_data){
printf ("Timer\n");
GtkNative *native = gtk_widget_get_native ((GtkWidget* )user_data);
GdkSurface *surface = gtk_native_get_surface ((GtkNative *)native);
//current desktop id
guint32 desktopId = gdk_x11_surface_get_desktop (surface);
printf ("Desktop Id %d\n", desktopId);
gdk_x11_surface_move_to_current_desktop ((GdkSurface*)surface);
//gdk_x11_surface_move_to_desktop (( GdkSurface *)surface, desktopId);
}
static void
activate (GtkApplication* app,
gpointer user_data)
{
GtkWidget *window;
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "ColorPicker");
gtk_window_set_default_size (GTK_WINDOW (window), 415, 300);
gtk_window_present (GTK_WINDOW (window));
g_timeout_add(512, (GSourceFunc)update, window);
gtk_widget_show (window);
}
int
main (int argc,
char **argv)
{
GtkApplication *app;
int status;
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
Upvotes: 1
Views: 46
Reputation: 474
It's unlikely that you'll be able to do this using GTK/GDK, window position control has been fully delegated to the window manager/composer in GTK4, even using X11. To do what you want, the way forward is to write an extension for gnome-shell.
Upvotes: 1