I'd like to get all windows running on a Linux Mint 21.2 XFCE desktop.I am a newbie in GTK. I followed instruction and wrote following codes. However, the codes cannot be complied. Appreciated much in advance for your kind help!
我想让所有的Windows都运行在Linux Mint 21.2 XFCE台式机上。我是GTK的新手。我按照说明编写了以下代码。然而,这些代码不能被遵守。非常感谢您的帮助!
edited on 11th Sep.
Stop using GdkScreen
GdkScreen has been removed from GTK4! Thereafter, how to get all windows of all applications with GTK4? I cannot find a way from GTK website or google or stackoverflow.
9月11日编辑。停止使用GdkScreen GdkScreen已从GTK4中删除!此后,如何使用GTK4获取所有应用程序的所有窗口?我无法从GTK网站、Google或Stackoverflow找到方法。
#include <gtk/gtk.h>
#include <gdk/gdk.h>
static void
func_button1_clicked(GtkWidget *widget,
gpointer data)
{
GdkDisplayManager *display_manger = gdk_display_manager_get();
GSList *displays = gdk_display_manager_list_displays(display_manger);
while (displays != NULL)
{
// Below line is OK.
GdkDisplay *_display = displays->data;
// Below line is NG!
GdkScreen* screen = gdk_display_get_screen(_display, 0);
// Below line is NG!
GList* windows = gdk_screen_get_toplevel_windows (screen);
// Todo. Iterate windows and do something for each window
g_list_free(windows);
displays = displays->next;
}
g_slist_free(displays);
}
Howerver, following error messages were got from vscode terminal.
然而,从vscode终端收到以下错误消息。
unknown type name ‘GdkScreen’
implicit declaration of function ‘gdk_display_get_screen’; did you mean ‘gdk_display_get_setting’? [-Wimplicit-function-declaration]
c_cpp_properties.json is as follows.
c_cpp_properties.json如下所示。
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/gtk-4.0",
"/usr/include/gio-unix-2.0",
"/usr/include/cairo",
"/usr/include/pango-1.0",
"/usr/include/harfbuzz",
"/usr/include/pango-1.0",
"/usr/include/fribidi",
"/usr/include/harfbuzz",
"/usr/include/gdk-pixbuf-2.0",
"/usr/include/x86_64-linux-gnu",
"/usr/include/cairo",
"/usr/include/pixman-1",
"/usr/include/uuid",
"/usr/include/freetype2",
"/usr/include/libpng16",
"/usr/include/graphene-1.0",
"/usr/lib/x86_64-linux-gnu/graphene-1.0/include",
"/usr/include/libmount",
"/usr/include/blkid",
"/usr/include/glib-2.0",
"/usr/lib/x86_64-linux-gnu/glib-2.0/include"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
更多回答
我是一名优秀的程序员,十分优秀!