c++ - C++。gtk_window_resize 不调整窗口大小
问题描述
我有类(称为BorderWindow
),实际上是环绕的GtkWidget
。此类表示特定应用程序窗口周围的边框(例如,可以说终端窗口)。在BorderWindow
构造函数内部,我创建了计时器,因此每隔一个BorderWindow::ClockTick
函数就会被调用一次。
在这个函数内部,边框大小(实际上是GtkWidget
)与绑定应用程序的窗口(在我们的例子中为终端)进行比较,如果不同gtk_window_resize
则调用。但是,如果我打电话,那么gtk_window_get_size
它会返回旧值。
gboolean BorderWindow::ClockTick(gpointer data)
{
auto that = reinterpret_cast<BorderWindow*>(data);
int x = 0, y = 0;
GtkWindow* pWindow = GTK_WINDOW(that->m_borderWindowHandle);
gtk_window_get_size(pWindow, &x, &y);
DUMPER_INFO("curr size: %dx%d; new size: %dx%d", x, y, that->m_windowRect.width, that->m_windowRect.height); // added for debug
if(x != that->m_windowRect.width || y != that->m_windowRect.height)
{
gtk_window_resize(pWindow, that->m_windowRect.width, that->m_windowRect.height);
that->CreateBorder();
GtkWindow* pWindow = GTK_WINDOW(that->m_borderWindowHandle); // added for debug
gtk_window_get_size(pWindow, &x, &y); // added for debug
DUMPER_INFO("after resize: %dx%d", x, y); // added for debug
}
gtk_window_get_position(pWindow, &x, &y);
if(x != that->m_windowRect.x || y != that->m_windowRect.y)
{
gtk_window_move(pWindow, that->m_windowRect.x, that->m_windowRect.y);
}
gdk_window_invalidate_rect(gtk_widget_get_window(that->m_borderWindowHandle), nullptr, FALSE);
that->m_highlightFrame = !that->m_highlightFrame;
return TRUE;
}
这是调试输出
20-05-19 11:24:40.294 [139856177248000] INFO 1537 %% - 静态 gboolean LinuxBorderWindow::ClockTick(gpointer):当前大小:734x540;新尺寸:1024x706
20-05-19 11:24:40.295 [139856177248000] INFO 1537 %% - 静态 gboolean LinuxBorderWindow::ClockTick(gpointer):调整大小后:734x540
如您所见,窗口没有调整大小。此代码片段适用于 xfce 和 Unity DE,但不适用于 GNOME(和 GNOME 经典版)。谁能解释我做错了什么以及如何调整 GNOME DE 的窗口大小?谢谢。
解决方案
推荐阅读
- asp.net-mvc - 在 Bootstrap 4 中,文本框表单控件宽度不起作用。文本框不会全角显示。我正在使用 asp.net mvc 5
- c++ - 仅对 QTableView 中的列显示 gridLine
- r - R - 如何在我的 ggplot2 图表中添加双变量图例?
- c# - Win32::OLE 与 C# DLL 和返回的对象
- java - DSpace 最近站点提交返回 0 个项目,而最近社区提交集合工作正常
- r - 我们可以使用 uniroot() 而不是 optimize() 在 R 中进行这种最小化吗?
- java - 连接到 Localhost MySQL 数据库的问题
- ms-word - Ms-Word 邮件合并格式
- vba - vba 逻辑运算符分组
- javascript - 选择表格单元格作为组