简体   繁体   English

如何在调整大小和移动属性工作的情况下创建没有标题栏的 gtk+ windows

[英]How to create gtk+ windows without title bar with resize and move properties working

How to create gtk+ windows without title bar with resize and move properties working.如何创建没有标题栏的 gtk+ windows,调整大小和移动属性正常工作。 I checked gtk_window_set_decorated function, but it disable resize and move features of window. I found this answer already , but I don't think it has anything to do with it.我检查了gtk_window_set_decorated function,但它禁用了 window 的调整大小和移动功能。我已经找到了这个答案,但我认为它与它没有任何关系。

I tried to set resizeable true after gtk_window_set_decorated but still not working我尝试在 gtk_window_set_decorated 之后设置 resizeable true 但仍然无法正常工作

Please check code请检查代码

    #include <gtk/gtk.h>
    int main (int argc,
    char *argv[])
    {  
      GtkWidget *window;
      /* Initialize GTK+ and all of its supporting libraries. */
      gtk_init (&argc, &argv);
      /* Create a new window, give it a title and display it to the user. */
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title (GTK_WINDOW (window), "Hello World");
      gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
      gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
      //gtk_window_set_gravity(GTK_WINDOW (window), GDK_GRAVITY_NORTH_EAST);
      //gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
      gtk_widget_show (window);
      /* Hand control over to the main loop. */
      gtk_main ();
      return 0;
    }

So what I found to work is to remove the header with gtk_window_set_decorated set to FALSE. 所以我发现工作是删除标题, gtk_window_set_decorated设置为FALSE。 Then manually change the cursor and call gtk_window_begin_resize_drag() to begin a resize on mousedown. 然后手动更改光标并调用gtk_window_begin_resize_drag()以开始在mousedown上调整大小。

How I implemented this was to check if the mouse was near a border on a mousemove callback and if so change the cursor with gdk_window_set_cursor() . 我如何实现这个是检查鼠标是否接近mousemove回调的边框,如果是这样,用gdk_window_set_cursor()更改光标。

On a mousedown event near a border I call gtk_window_begin_resize_drag() with the appropriate border. 在边界附近的mousedown事件中,我使用适当的边框调用gtk_window_begin_resize_drag()

you can use GTK_WINDOW_POPUP:你可以使用 GTK_WINDOW_POPUP:

#include <gtk/gtk.h>
    int main (int argc,
    char *argv[])
    {  
      GtkWidget *window;
      /* Initialize GTK+ and all of its supporting libraries. */
      gtk_init (&argc, &argv);
      gtk_widget_show (window);
      gtk_main ();
      return 0;
    }

You should not use GTK_WINDOW_POPUP if you only want window manager decorations turned off for the window. Instead, use gtk_window_set_decorated (GtkWindow *window, gboolean show) to turn off window decorations.如果您只想为 window 关闭 window 经理装饰,则不应使用 GTK_WINDOW_POPUP。相反,请使用 gtk_window_set_decorated (GtkWindow *window, gboolean show) 关闭 window 装饰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM