From: Thomas Debesse Date: Tue, 21 Jun 2022 00:17:20 +0000 (+0200) Subject: Merge commit '01a950c3de3ef7f7da23360f925404e2bd385d5d' into master-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8705acc09238c97ba0e79094621f0d6c859a7eb1;p=xonotic%2Fnetradiant.git Merge commit '01a950c3de3ef7f7da23360f925404e2bd385d5d' into master-merge --- 8705acc09238c97ba0e79094621f0d6c859a7eb1 diff --cc libs/gtkutil/cursor.cpp index fd11c779,70a0856b..a58c6cf0 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@@ -27,34 -27,31 +27,37 @@@ #include #include -#if 0 ++// Note: NetRadiantCustom disables them but we still make use of them. ++#if 1 GdkCursor* create_blank_cursor(){ - return gdk_cursor_new( GDK_BLANK_CURSOR ); + return gdk_cursor_new(GDK_BLANK_CURSOR); } -void blank_cursor( ui::Widget widget ){ - GdkCursor* cursor = create_blank_cursor(); +void set_cursor( ui::Widget widget, GdkCursorType cursor_type ){ + GdkCursor* cursor = gdk_cursor_new( cursor_type ); - gdk_window_set_cursor( gtk_widget_get_window( widget ), cursor ); + gdk_window_set_cursor( gtk_widget_get_window(widget), cursor ); gdk_cursor_unref( cursor ); } +void blank_cursor( ui::Widget widget ){ + set_cursor( widget, GDK_BLANK_CURSOR ); +} + void default_cursor( ui::Widget widget ){ - gdk_window_set_cursor( gtk_widget_get_window(widget), 0 ); + gdk_window_set_cursor( gtk_widget_get_window( widget ), NULL ); } + #endif - -void Sys_GetCursorPos( ui::Window window, int *x, int *y ){ - gdk_display_get_pointer( gdk_display_get_default(), 0, x, y, 0 ); +void Sys_GetCursorPos( ui::Widget widget, int *x, int *y ){ + GdkDisplay *display = gtk_widget_get_display( GTK_WIDGET( widget ) ); + // No need to store the screen, it will be recovered from widget again. + gdk_display_get_pointer( display, NULL, x, y, NULL ); } -void Sys_SetCursorPos( ui::Window window, int x, int y ){ - GdkScreen *screen; - gdk_display_get_pointer( gdk_display_get_default(), &screen, 0, 0, 0 ); - gdk_display_warp_pointer( gdk_display_get_default(), screen, x, y ); +void Sys_SetCursorPos( ui::Widget widget, int x, int y ){ + GdkDisplay *display = gtk_widget_get_display( GTK_WIDGET( widget ) ); + GdkScreen *screen = gtk_widget_get_screen( GTK_WIDGET( widget ) ); + gdk_display_warp_pointer( display, screen, x, y ); } gboolean DeferredMotion::gtk_motion(ui::Widget widget, GdkEventMotion *event, DeferredMotion *self) @@@ -214,12 -121,7 +217,13 @@@ void FreezePointer::unfreeze_pointer(ui m_function = 0; m_data = 0; - Sys_SetCursorPos( window, recorded_x, recorded_y ); +#if defined(WORKAROUND_MACOS_GTK2_LAGGYPOINTER) + /* The pointer was visible during all the move operation, + so, keep the current position. */ +#else ++ // Note: NetRadiantCustom still uses window instead of widget. + Sys_SetCursorPos( widget, recorded_x, recorded_y ); +#endif gdk_pointer_ungrab( GDK_CURRENT_TIME ); } diff --cc libs/gtkutil/cursor.h index 77cb7761,3b873db4..db0234d7 --- a/libs/gtkutil/cursor.h +++ b/libs/gtkutil/cursor.h @@@ -30,12 -29,15 +30,15 @@@ typedef struct _GdkCursor GdkCursor; typedef struct _GdkEventMotion GdkEventMotion; -#if 0 ++// Note: NetRadiantCustom disables them but we still make use of them. ++#if 1 GdkCursor* create_blank_cursor(); +void set_cursor( ui::Widget widget, GdkCursorType cursor_type ); void blank_cursor( ui::Widget widget ); void default_cursor( ui::Widget widget ); + #endif -void Sys_GetCursorPos( ui::Window window, int *x, int *y ); -void Sys_SetCursorPos( ui::Window window, int x, int y ); - - +void Sys_GetCursorPos( ui::Widget widget, int *x, int *y ); +void Sys_SetCursorPos( ui::Widget widget, int x, int y ); class DeferredMotion { @@@ -107,7 -109,8 +110,7 @@@ void motion_delta( int x, int y, unsign class FreezePointer { unsigned int handle_motion; - int recorded_x, recorded_y, last_x, last_y; + int recorded_x, recorded_y, last_x, last_y, center_x, center_y; -GtkWidget* weedjet; typedef void ( *MotionDeltaFunction )( int x, int y, unsigned int state, void* data ); MotionDeltaFunction m_function; void* m_data; diff --cc radiant/camwindow.cpp index c17a984d,c96ee2f9..ee6634e6 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@@ -1324,7 -1319,7 +1324,9 @@@ void CamWnd::EnableFreeMove() gtk_window_set_focus( m_parent, m_gl_widget ); m_freemove_handle_focusout = m_gl_widget.connect( "focus_out_event", G_CALLBACK( camwindow_freemove_focusout ), this ); - m_freezePointer.freeze_pointer( m_parent, m_gl_widget, Camera_motionDelta, &m_Camera ); ++ /* Note: We chose to replace m_parent by m_gl_widget but NetRadiantCustom does: ++ m_freezePointer.freeze_pointer( m_parent, m_gl_widget, Camera_motionDelta, &m_Camera ); */ + m_freezePointer.freeze_pointer( m_gl_widget, Camera_motionDelta, &m_Camera ); CamWnd_Update( *this ); } diff --cc radiant/mainframe.cpp index e377c523,0141220b..689d797d --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -3270,62 -3192,14 +3270,62 @@@ void MainFrame::Create() vbox.pack_start( split, TRUE, TRUE, 0 ); { - auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) ); + auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) ); g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() ); -#ifndef GARUX_GTK_WORKAROUND - /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ - g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() ); -#endif + + WORKAROUND_GOBJECT_SET_GLWIDGET( window, TextureBrowser_getGLWidget() ); } } + else // single window + { + m_pCamWnd = NewCamWnd(); + GlobalCamera_setCamWnd( *m_pCamWnd ); + CamWnd_setParent( *m_pCamWnd, window ); + + ui::Widget camera = CamWnd_getWidget( *m_pCamWnd ); + + m_pYZWnd = new XYWnd(); + m_pYZWnd->SetViewType( YZ ); + + ui::Widget yz = m_pYZWnd->GetWidget(); + + m_pXYWnd = new XYWnd(); + m_pXYWnd->SetViewType( XY ); + + ui::Widget xy = m_pXYWnd->GetWidget(); + + m_pXZWnd = new XYWnd(); + m_pXZWnd->SetViewType( XZ ); + + ui::Widget xz = m_pXZWnd->GetWidget(); + + ui::Widget hsplit = ui::HPaned(ui::New); + vbox.pack_start( hsplit, TRUE, TRUE, 0 ); + hsplit.show(); + + ui::Widget split = create_split_views( camera, yz, xy, xz ); + + ui::Widget vsplit = ui::VPaned(ui::New); + vsplit.show(); + + // textures + ui::Widget texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) ); + + // console + ui::Widget console_window = create_framed_widget( Console_constructWindow( window ) ); + + gtk_paned_add1( GTK_PANED( hsplit ), split ); + gtk_paned_add2( GTK_PANED( hsplit ), vsplit ); + + gtk_paned_add1( GTK_PANED( vsplit ), texture_window ); + gtk_paned_add2( GTK_PANED( vsplit ), console_window ); + + hsplit.connect( "size_allocate", G_CALLBACK( hpaned_allocate ), &g_single_hpaned ); + hsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_single_hpaned ); + + vsplit.connect( "size_allocate", G_CALLBACK( vpaned_allocate ), &g_single_vpaned ); + vsplit.connect( "notify::position", G_CALLBACK( paned_position ), &g_single_vpaned ); + } EntityList_constructWindow( window ); PreferencesDialog_constructWindow( window ); diff --cc radiant/texwindow.cpp index 96fe13c2,6f920595..27baf5ed --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@@ -1212,14 -1121,19 +1174,24 @@@ void TextureBrowser_trackingDelta( int } } - void TextureBrowser_Tracking_MouseDown( TextureBrowser& textureBrowser ){ - textureBrowser.m_freezePointer.freeze_pointer( textureBrowser.m_gl_widget, TextureBrowser_trackingDelta, &textureBrowser ); - } - void TextureBrowser_Tracking_MouseUp( TextureBrowser& textureBrowser ){ + textureBrowser.m_move_started = false; - textureBrowser.m_freezePointer.unfreeze_pointer( textureBrowser.m_parent ); ++ /* Note: NetRadiantCustom did this instead: ++ textureBrowser.m_freezePointer.unfreeze_pointer( textureBrowser.m_gl_widget ); */ ++ + textureBrowser.m_freezePointer.unfreeze_pointer( textureBrowser.m_gl_widget ); } + void TextureBrowser_Tracking_MouseDown( TextureBrowser& textureBrowser ){ + if( textureBrowser.m_move_started ){ + TextureBrowser_Tracking_MouseUp( textureBrowser ); + } + textureBrowser.m_move_started = true; - textureBrowser.m_freezePointer.freeze_pointer( textureBrowser.m_parent, textureBrowser.m_gl_widget, TextureBrowser_trackingDelta, &textureBrowser ); ++ /* Note: NetRadiantCustom did this instead: ++ textureBrowser.m_freezePointer.freeze_pointer( textureBrowser.m_parent, textureBrowser.m_gl_widget, TextureBrowser_trackingDelta, &textureBrowser ); */ ++ textureBrowser.m_freezePointer.freeze_pointer( textureBrowser.m_gl_widget, TextureBrowser_trackingDelta, &textureBrowser ); + } + void TextureBrowser_Selection_MouseDown( TextureBrowser& textureBrowser, guint32 flags, int pointx, int pointy ){ SelectTexture( textureBrowser, pointx, textureBrowser.height - 1 - pointy, ( flags & GDK_SHIFT_MASK ) != 0 ); } diff --cc radiant/xywindow.cpp index 3470f861,ae99174b..4c07a7fe --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@@ -824,8 -820,7 +824,8 @@@ XYWnd::XYWnd() m_parent( ui::null ), m_window_observer( NewWindowObserver() ), m_XORRectangle( m_gl_widget ), - m_chasemouse_handler( 0 ) { + m_chasemouse_handler( 0 ){ + m_bActive = false; m_buttonstate = 0; @@@ -1099,11 -1094,11 +1099,11 @@@ void entitycreate_activated( ui::Widge g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name ); } else { - GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), "There's already a worldspawn in your map!" - "", + GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), + "There's already a worldspawn in your map!", - "Info", - eMB_OK, - eMB_ICONDEFAULT ); + "Info", + eMB_OK, + eMB_ICONDEFAULT ); } } @@@ -1215,7 -1210,7 +1215,9 @@@ void XYWnd::Move_Begin() Move_End(); } m_move_started = true; - g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this ); ++ /* Note: NetRadiantCustom did this instead: ++ g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this ); */ + g_xywnd_freezePointer.freeze_pointer( m_gl_widget, XYWnd_moveDelta, this ); m_move_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this ); } @@@ -1260,7 -1255,7 +1262,9 @@@ void XYWnd::Zoom_Begin() } m_zoom_started = true; g_dragZoom = 0; - g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this ); ++ /* Note: NetRadiantCustom did this instead: ++ g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this ); */ + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); m_zoom_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); }