From: Thomas Debesse Date: Sat, 20 Mar 2021 22:21:03 +0000 (+0100) Subject: radiant/xywindow: make glarea redraw code reusable, force redraw on background selection X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=b5d69f41b4480f1309008333bef98a197c25b31d radiant/xywindow: make glarea redraw code reusable, force redraw on background selection --- diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index a39fed7b..ab1e8ee9 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -529,6 +529,19 @@ void XYWnd_ZoomOut( XYWnd* xy ){ } } +void XYWnd::Redraw() { + if ( glwidget_make_current( m_gl_widget ) != FALSE ) { + if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { + GlobalOpenGL_debugAssertNoErrors(); + XY_Draw(); + GlobalOpenGL_debugAssertNoErrors(); + + m_XORRectangle.set( rectangle_t() ); + } + glwidget_swap_buffers( m_gl_widget ); + } +} + VIEWTYPE GlobalXYWnd_getCurrentViewType(){ ASSERT_NOTNULL( g_pParentWnd ); ASSERT_NOTNULL( g_pParentWnd->ActiveXY() ); @@ -769,20 +782,10 @@ gboolean xywnd_size_allocate( ui::Widget widget, GtkAllocation* allocation, XYWn } gboolean xywnd_expose( ui::Widget widget, GdkEventExpose* event, XYWnd* xywnd ){ - if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) { - if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { - GlobalOpenGL_debugAssertNoErrors(); - xywnd->XY_Draw(); - GlobalOpenGL_debugAssertNoErrors(); - - xywnd->m_XORRectangle.set( rectangle_t() ); - } - glwidget_swap_buffers( xywnd->GetWidget() ); - } + xywnd->Redraw(); return FALSE; } - void XYWnd_CameraMoved( XYWnd& xywnd ){ if ( g_xywindow_globals_private.m_bCamXYUpdate ) { XYWnd_Update( xywnd ); @@ -1501,6 +1504,9 @@ void WXY_BackgroundSelect( void ){ if ( filename ) { g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename ); } + + // Draw the background image immediately (do not wait for user input). + g_pParentWnd->ActiveXY()->Redraw(); } /* diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 0b762d45..ee434833 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -124,6 +124,8 @@ void Zoom_End(); bool m_zoom_started; guint m_zoom_focusOut; +void Redraw(); + void SetActive( bool b ){ m_bActive = b; };