misc...
* fix: texbro m2 drag in 2x2 layout
* fix: crash in (texbro + freezePointer)
* fix: all sorts of problems with freezePointer drags near widget borders
#include <gdk/gdkcursor.h>
#include <gdk/gdkpixmap.h>
-
+#if 0
GdkCursor* create_blank_cursor(){
GdkPixmap *pixmap;
GdkBitmap *mask;
void default_cursor( GtkWidget* widget ){
gdk_window_set_cursor( widget->window, 0 );
}
+#endif
void Sys_GetCursorPos( GtkWindow* window, int *x, int *y ){
#include <gdk/gdkevents.h>
#include <gtk/gtkwidget.h>
#include <gtk/gtkwindow.h>
+#include <gtk/gtkmain.h>
#include "debugging/debugging.h"
typedef struct _GtkWidget GtkWidget;
typedef struct _GtkWindow GtkWindow;
+#if 0
GdkCursor* create_blank_cursor();
void blank_cursor( GtkWidget* widget );
void default_cursor( GtkWidget* widget );
+#endif
void Sys_GetCursorPos( GtkWindow* window, int *x, int *y );
void Sys_SetCursorPos( GtkWindow* window, int x, int y );
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;
Sys_GetCursorPos( GTK_WINDOW( widget ), ¤t_x, ¤t_y );
int dx = current_x - self->last_x;
int dy = current_y - self->last_y;
- int ddx = current_x - self->recorded_x;
- int ddy = current_y - self->recorded_y;
+ int ddx = current_x - self->center_x;
+ int ddy = current_y - self->center_y;
self->last_x = current_x;
self->last_y = current_y;
if ( dx != 0 || dy != 0 ) {
//globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n";
if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) {
- Sys_SetCursorPos( GTK_WINDOW( widget ), self->recorded_x, self->recorded_y );
- self->last_x = self->recorded_x;
- self->last_y = self->recorded_y;
+ Sys_SetCursorPos( GTK_WINDOW( widget ), self->center_x, self->center_y );
+ self->last_x = self->center_x;
+ self->last_y = self->center_y;
}
self->m_function( dx, dy, event->state, self->m_data );
}
return FALSE;
}
-void freeze_pointer( GtkWindow* window, MotionDeltaFunction function, void* data ){
+void freeze_pointer( GtkWindow* window, GtkWidget* widget, MotionDeltaFunction function, void* data ){
ASSERT_MESSAGE( m_function == 0, "can't freeze pointer" );
const GdkEventMask mask = static_cast<GdkEventMask>( GDK_POINTER_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK
| GDK_VISIBILITY_NOTIFY_MASK );
- GdkCursor* cursor = create_blank_cursor();
+ GdkCursor* cursor = gdk_cursor_new( GDK_BLANK_CURSOR );
+ //GdkCursor* cursor = create_blank_cursor();
//GdkGrabStatus status =
+ /* fixes cursor runaways during srsly quick drags in camera
+ drags with pressed buttons have no problem at all w/o this */
gdk_pointer_grab( GTK_WIDGET( window )->window, TRUE, mask, 0, cursor, GDK_CURRENT_TIME );
+ //gdk_window_set_cursor ( GTK_WIDGET( window )->window, cursor );
+ /* is needed to fix activating neighbour widgets, that happens, if using upper one */
+ gtk_grab_add( widget );
+ weedjet = widget;
+
gdk_cursor_unref( cursor );
Sys_GetCursorPos( window, &recorded_x, &recorded_y );
- Sys_SetCursorPos( window, recorded_x, recorded_y );
+ /* using center for tracking for max safety */
+ gdk_window_get_origin( widget->window, ¢er_x, ¢er_y );
+ center_y += widget->allocation.height / 2;
+ center_x += widget->allocation.width / 2;
+
+ Sys_SetCursorPos( window, center_x, center_y );
- last_x = recorded_x;
- last_y = recorded_y;
+ last_x = center_x;
+ last_y = center_y;
m_function = function;
m_data = data;
Sys_SetCursorPos( window, recorded_x, recorded_y );
+// gdk_window_set_cursor( GTK_WIDGET( window )->window, 0 );
gdk_pointer_ungrab( GDK_CURRENT_TIME );
+ gtk_grab_remove( weedjet );
}
};
gtk_window_set_focus( m_parent, m_gl_widget );
m_freemove_handle_focusout = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( camwindow_freemove_focusout ), this );
- m_freezePointer.freeze_pointer( m_parent, Camera_motionDelta, &m_Camera );
+ m_freezePointer.freeze_pointer( m_parent, m_gl_widget, Camera_motionDelta, &m_Camera );
CamWnd_Update( *this );
}
ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", path.c_str(), 0, 0, SW_SHOW );
}
else{
- globalOutputStream() << "Failed to open '" << filename << "\n";
+ globalOutputStream() << "Failed to open '" << filename << "'\nOne sits in .pk3 most likely!\n";
}
return;
}
DoGtkTextEditor( path.c_str(), cursorpos, length );
}
else{
- globalOutputStream() << "Failed to open '" << filename << "\n";
+ globalOutputStream() << "Failed to open '" << filename << "'\nOne sits in .pk3 most likely!\n";
}
return;
}
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 );
{
- GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
+ GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
g_object_set_data( G_OBJECT( GroupDialog_getWindow() ), "glwidget", TextureBrowser_getGLWidget() );
bool m_rmbSelected;
bool m_searchedTags;
bool m_tags;
+bool m_move_started;
// The uniform size (in pixels) that textures are resized to when m_resizeTextures is true.
int m_uniformTextureSize;
int m_uniformTextureMinSize;
// Return the display width of a texture in the texture browser
-/*void getTextureWH( qtexture_t* tex, int *width, int *height ){
- if ( !g_TextureBrowser_fixedSize ) {
- // Don't use uniform size
- *width = (int)( tex->width * ( (float)m_textureScale / 100 ) );
- *height = (int)( tex->height * ( (float)m_textureScale / 100 ) );
-
- }
- else if ( tex->width >= tex->height ) {
- // Texture is square, or wider than it is tall
- if ( tex->width >= m_uniformTextureSize ){
- *width = m_uniformTextureSize;
- *height = (int)( m_uniformTextureSize * ( (float)tex->height / tex->width ) );
- }
- else if ( tex->width <= m_uniformTextureMinSize ){
- *width = m_uniformTextureMinSize;
- *height = (int)( m_uniformTextureMinSize * ( (float)tex->height / tex->width ) );
- }
- else {
- *width = tex->width;
- *height = tex->height;
- }
- }
- else {
- // Texture taller than it is wide
- if ( tex->height >= m_uniformTextureSize ){
- *height = m_uniformTextureSize;
- *width = (int)( m_uniformTextureSize * ( (float)tex->width / tex->height ) );
- }
- else if ( tex->height <= m_uniformTextureMinSize ){
- *height = m_uniformTextureMinSize;
- *width = (int)( m_uniformTextureMinSize * ( (float)tex->width / tex->height ) );
- }
- else {
- *width = tex->width;
- *height = tex->height;
- }
- }
-}
-*/
void getTextureWH( qtexture_t* tex, int &W, int &H ){
// Don't use uniform size
W = (int)( tex->width * ( (float)m_textureScale / 100 ) );
m_searchedTags( false ),
m_tags( false ),
m_uniformTextureSize( 160 ),
- m_uniformTextureMinSize( 48 ){
+ m_uniformTextureMinSize( 48 ),
+ m_move_started( false ){
}
};
}
}
-void TextureBrowser_Tracking_MouseDown( TextureBrowser& textureBrowser ){
- textureBrowser.m_freezePointer.freeze_pointer( textureBrowser.m_parent, TextureBrowser_trackingDelta, &textureBrowser );
-}
-
void TextureBrowser_Tracking_MouseUp( TextureBrowser& textureBrowser ){
+ textureBrowser.m_move_started = false;
textureBrowser.m_freezePointer.unfreeze_pointer( textureBrowser.m_parent );
}
+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 );
+}
+
void TextureBrowser_Selection_MouseDown( TextureBrowser& textureBrowser, guint32 flags, int pointx, int pointy ){
SelectTexture( textureBrowser, pointx, textureBrowser.height - 1 - pointy, ( flags & GDK_SHIFT_MASK ) != 0 );
}
Move_End();
}
m_move_started = true;
- g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this );
+ g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this );
m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this );
}
}
m_zoom_started = true;
g_dragZoom = 0;
- g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this );
+ g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this );
m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this );
}