Module: Mesa
Branch: master
Commit: 30580640f2508e935e667e25f0e0cf4ff0ce55af
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=30580640f2508e935e667e25f0e0cf4ff0ce55af

Author: Tapani Pälli <[email protected]>
Date:   Tue Sep 11 10:32:32 2018 +0300

intel/tools: fix initial position of window in aubinator viewer

Currently position is set before widgets are sized by gtk and
calculation can get wrong results where window is positioned
offscreen. Patch fixes this by setting aubfile window position
as 0,0 only when size_allocate has been called to the widget.

Now window is always positioned to 0,0 if imgui.ini is missing.

Signed-off-by: Tapani Pälli <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>

---

 src/intel/tools/aubinator_viewer.cpp | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/intel/tools/aubinator_viewer.cpp 
b/src/intel/tools/aubinator_viewer.cpp
index e29bccb192..d5d289032e 100644
--- a/src/intel/tools/aubinator_viewer.cpp
+++ b/src/intel/tools/aubinator_viewer.cpp
@@ -1050,8 +1050,7 @@ show_aubfile_window(void)
 
    list_inithead(&window->parent_link);
    window->size = ImVec2(-1, 250);
-   window->position =
-      ImVec2(0, ImGui::GetIO().DisplaySize.y - window->size.y);
+   window->position = ImVec2(0, 0);
    window->opened = true;
    window->display = display_aubfile_window;
    window->destroy = NULL;
@@ -1144,6 +1143,21 @@ unrealize_area(GtkGLArea *area)
 }
 
 static void
+size_allocate_area(GtkGLArea *area,
+                   GdkRectangle *allocation,
+                   gpointer user_data)
+{
+   if (!gtk_widget_get_realized(GTK_WIDGET(area)))
+      return;
+
+   /* We want to catch only initial size allocate. */
+   g_signal_handlers_disconnect_by_func(area,
+                                        (gpointer) size_allocate_area,
+                                        user_data);
+   show_aubfile_window();
+}
+
+static void
 print_help(const char *progname, FILE *file)
 {
    fprintf(file,
@@ -1198,12 +1212,11 @@ int main(int argc, char *argv[])
    g_signal_connect(gl_area, "render", G_CALLBACK(repaint_area), NULL);
    g_signal_connect(gl_area, "realize", G_CALLBACK(realize_area), NULL);
    g_signal_connect(gl_area, "unrealize", G_CALLBACK(unrealize_area), NULL);
+   g_signal_connect(gl_area, "size_allocate", G_CALLBACK(size_allocate_area), 
NULL);
    gtk_container_add(GTK_CONTAINER(context.gtk_window), gl_area);
 
    gtk_widget_show_all(context.gtk_window);
 
-   show_aubfile_window();
-
    gtk_main();
 
    free(context.xml_path);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to