mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Support middle mouse button on Linux.
This commit is contained in:
parent
f602408f6a
commit
3a2b6551b9
2 changed files with 131 additions and 132 deletions
|
@ -335,7 +335,7 @@ int lcGetBrickLinkColor(int ColorIndex)
|
||||||
|
|
||||||
const char* Name = gColorList[ColorIndex].Name;
|
const char* Name = gColorList[ColorIndex].Name;
|
||||||
|
|
||||||
for (int Color = 0; Color < sizeof(BrickLinkColors) / sizeof(BrickLinkColors[0]); Color++)
|
for (unsigned int Color = 0; Color < sizeof(BrickLinkColors) / sizeof(BrickLinkColors[0]); Color++)
|
||||||
if (!strcmp(Name, BrickLinkColors[Color].Name))
|
if (!strcmp(Name, BrickLinkColors[Color].Name))
|
||||||
return BrickLinkColors[Color].Code;
|
return BrickLinkColors[Color].Code;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ static GdkVisual* WindowGdkVisual = NULL;
|
||||||
static XVisualInfo* WindowXVisualInfo = NULL;
|
static XVisualInfo* WindowXVisualInfo = NULL;
|
||||||
static bool WindowMultisample = false;
|
static bool WindowMultisample = false;
|
||||||
static GLXContext WindowContext;
|
static GLXContext WindowContext;
|
||||||
int WindowContextCount;
|
static int WindowContextCount;
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// static functions
|
// static functions
|
||||||
|
@ -56,21 +56,19 @@ static gint button_press_event(GtkWidget *widget, GdkEventButton *event, gpointe
|
||||||
if (event->type == GDK_BUTTON_PRESS)
|
if (event->type == GDK_BUTTON_PRESS)
|
||||||
{
|
{
|
||||||
if (event->button == 1)
|
if (event->button == 1)
|
||||||
wnd->OnLeftButtonDown (x, y, (event->state & GDK_CONTROL_MASK) != 0,
|
wnd->OnLeftButtonDown(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
(event->state & GDK_SHIFT_MASK) != 0);
|
else if (event->button == 2)
|
||||||
|
wnd->OnMiddleButtonDown(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
else if (event->button == 3)
|
else if (event->button == 3)
|
||||||
wnd->OnRightButtonDown (x, y, (event->state & GDK_CONTROL_MASK) != 0,
|
wnd->OnRightButtonDown(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
(event->state & GDK_SHIFT_MASK) != 0);
|
|
||||||
}
|
}
|
||||||
else if (event->type == GDK_2BUTTON_PRESS)
|
else if (event->type == GDK_2BUTTON_PRESS)
|
||||||
{
|
{
|
||||||
wnd->OnLeftButtonDoubleClick (x, y, (event->state & GDK_CONTROL_MASK) != 0,
|
wnd->OnLeftButtonDoubleClick(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
(event->state & GDK_SHIFT_MASK) != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(widget)), widget);
|
gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(widget)), widget);
|
||||||
gdk_pointer_grab (widget->window, FALSE, (GdkEventMask)(GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|
|
gdk_pointer_grab(widget->window, FALSE, (GdkEventMask)(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK),
|
||||||
GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK),
|
|
||||||
NULL, NULL, GDK_CURRENT_TIME);
|
NULL, NULL, GDK_CURRENT_TIME);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -87,11 +85,11 @@ static gint button_release_event (GtkWidget *widget, GdkEventButton *event, gpoi
|
||||||
gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
gdk_pointer_ungrab(GDK_CURRENT_TIME);
|
||||||
|
|
||||||
if (event->button == 1)
|
if (event->button == 1)
|
||||||
wnd->OnLeftButtonUp (x, y, (event->state & GDK_CONTROL_MASK) != 0,
|
wnd->OnLeftButtonUp(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
(event->state & GDK_SHIFT_MASK) != 0);
|
else if (event->button == 2)
|
||||||
|
wnd->OnMiddleButtonUp(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
else if (event->button == 3)
|
else if (event->button == 3)
|
||||||
wnd->OnRightButtonUp (x, y, (event->state & GDK_CONTROL_MASK) != 0,
|
wnd->OnRightButtonUp(x, y, (event->state & GDK_CONTROL_MASK) != 0, (event->state & GDK_SHIFT_MASK) != 0);
|
||||||
(event->state & GDK_SHIFT_MASK) != 0);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -232,8 +230,7 @@ bool GLWindow::CreateFromWindow(void *data)
|
||||||
|
|
||||||
GTK_WIDGET_SET_FLAGS(prv->widget, GTK_CAN_FOCUS);
|
GTK_WIDGET_SET_FLAGS(prv->widget, GTK_CAN_FOCUS);
|
||||||
|
|
||||||
gtk_widget_set_events(GTK_WIDGET(prv->widget), GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
|
gtk_widget_set_events(GTK_WIDGET(prv->widget), GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
|
||||||
GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
|
|
||||||
|
|
||||||
// Connect signal handlers
|
// Connect signal handlers
|
||||||
gtk_signal_connect(GTK_OBJECT(prv->widget), "expose_event", GTK_SIGNAL_FUNC(expose_event), this);
|
gtk_signal_connect(GTK_OBJECT(prv->widget), "expose_event", GTK_SIGNAL_FUNC(expose_event), this);
|
||||||
|
@ -331,6 +328,7 @@ static void create_bitmap_and_mask_from_xpm (GdkBitmap **bitmap, GdkBitmap **mas
|
||||||
black_color = '.';
|
black_color = '.';
|
||||||
|
|
||||||
for (y = 0; y < 32; y++)
|
for (y = 0; y < 32; y++)
|
||||||
|
{
|
||||||
for (x = 0; x < 32;)
|
for (x = 0; x < 32;)
|
||||||
{
|
{
|
||||||
char value = 0, maskv = 0;
|
char value = 0, maskv = 0;
|
||||||
|
@ -347,6 +345,7 @@ static void create_bitmap_and_mask_from_xpm (GdkBitmap **bitmap, GdkBitmap **mas
|
||||||
pixmap_buffer [(y * 4 + x/8)-1] = value;
|
pixmap_buffer [(y * 4 + x/8)-1] = value;
|
||||||
mask_buffer [(y * 4 + x/8)-1] = maskv;
|
mask_buffer [(y * 4 + x/8)-1] = maskv;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*bitmap = gdk_bitmap_create_from_data(NULL, pixmap_buffer, 32, 32);
|
*bitmap = gdk_bitmap_create_from_data(NULL, pixmap_buffer, 32, 32);
|
||||||
*mask = gdk_bitmap_create_from_data(NULL, mask_buffer, 32, 32);
|
*mask = gdk_bitmap_create_from_data(NULL, mask_buffer, 32, 32);
|
||||||
|
|
Loading…
Add table
Reference in a new issue