[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-390-gda649f4)
The branch, master has been updated
via da649f4066f8ce35a1717a1d0a298fe82817a8b5 (commit)
from 1d16923d30f2348184675df66e5b67e893d3c519 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
gschem/include/prototype.h | 2 +-
gschem/src/x_event.c | 116 ++++++++++++++++++++++++++++++++++++++++---
gschem/src/x_window.c | 3 +-
3 files changed, 110 insertions(+), 11 deletions(-)
=================
Commit Messages
=================
commit da649f4066f8ce35a1717a1d0a298fe82817a8b5
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Thu Dec 18 18:17:48 2008 +0000
gschem: Make key press / release events update modifier states
If a sensitive action is taking place when a modifier key changes state,
fetch the current mouse pointer and call the action's motion handler.
This allows us to see instant on-screen changes when (say) pressing the
modifier key to switch magnetic net mode off, or between orthogonal /
non-orthogonal constraints mode when copying or moving objects.
Preivously motion was needed after pressing the modifier key to get an
on-screen update.
:100644 100644 a87d5d4... e839e97... M gschem/include/prototype.h
:100644 100644 ea8f1b7... d3662fd... M gschem/src/x_event.c
:100644 100644 1904f20... 0ea2014... M gschem/src/x_window.c
=========
Changes
=========
commit da649f4066f8ce35a1717a1d0a298fe82817a8b5
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Thu Dec 18 18:17:48 2008 +0000
gschem: Make key press / release events update modifier states
If a sensitive action is taking place when a modifier key changes state,
fetch the current mouse pointer and call the action's motion handler.
This allows us to see instant on-screen changes when (say) pressing the
modifier key to switch magnetic net mode off, or between orthogonal /
non-orthogonal constraints mode when copying or moving objects.
Preivously motion was needed after pressing the modifier key to get an
on-screen update.
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index a87d5d4..e839e97 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -804,7 +804,7 @@ void x_manual_resize(GSCHEM_TOPLEVEL *w_current);
void x_event_hschanged(GtkAdjustment *adj, GSCHEM_TOPLEVEL *w_current);
void x_event_vschanged(GtkAdjustment *adj, GSCHEM_TOPLEVEL *w_current);
gint x_event_enter(GtkWidget *widget, GdkEventCrossing *event, GSCHEM_TOPLEVEL *w_current);
-gboolean x_event_key_press(GtkWidget *widget, GdkEventKey *event, GSCHEM_TOPLEVEL *w_current);
+gboolean x_event_key(GtkWidget *widget, GdkEventKey *event, GSCHEM_TOPLEVEL *w_current);
gint x_event_scroll(GtkWidget *widget, GdkEventScroll *event, GSCHEM_TOPLEVEL *w_current);
gboolean x_event_get_pointer_position (GSCHEM_TOPLEVEL *w_current, gboolean snapped, gint *wx, gint *wy);
/* x_compselect.c */
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index ea8f1b7..d3662fd 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -26,6 +26,7 @@
#endif
#include "gschem.h"
+#include <gdk/gdkkeysyms.h>
#ifdef HAVE_LIBDMALLOC
#include <dmalloc.h>
@@ -1128,28 +1129,125 @@ gint x_event_enter(GtkWidget *widget, GdkEventCrossing *event,
return(0);
}
+/*! \brief Get a snapped pointer position in world coordinates
+ *
+ * \par Function Description
+ * Queries GTK for the mouse location in world coordinates,
+ * then snaps it to the grid.
+ *
+ * \param [in] w_current The GSCHEM_TOPLEVEL object.
+ * \param [out] wx Return location for the snapped X coordinate.
+ * \param [out] wy Return location for the snapped Y coordiante.
+ */
+static void get_snapped_pointer (GSCHEM_TOPLEVEL *w_current, int *wx, int *wy)
+{
+ TOPLEVEL *toplevel = w_current->toplevel;
+ int sx, sy;
+ int unsnapped_wx, unsnapped_wy;
+
+ gtk_widget_get_pointer (w_current->drawing_area, &sx, &sy);
+ SCREENtoWORLD (toplevel, sx, sy, &unsnapped_wx, &unsnapped_wy);
+ *wx = snap_grid (toplevel, unsnapped_wx);
+ *wy = snap_grid (toplevel, unsnapped_wy);
+}
+
/*! \todo Finish function documentation!!!
* \brief
* \par Function Description
*
*/
-gboolean x_event_key_press (GtkWidget *widget, GdkEventKey *event,
- GSCHEM_TOPLEVEL *w_current)
+gboolean x_event_key (GtkWidget *widget, GdkEventKey *event,
+ GSCHEM_TOPLEVEL *w_current)
{
- int retval;
-
- retval = FALSE;
+ gboolean retval = FALSE;
+ int wx, wy;
+ int alt_key = 0;
+ int shift_key = 0;
+ int control_key = 0;
+ int pressed;
- exit_if_null(w_current);
global_window_current = w_current;
- if (event) {
#if DEBUG
- printf("x_event_key_pressed: Pressed key %i.\n", event->keyval);
+ printf("x_event_key_pressed: Pressed key %i.\n", event->keyval);
#endif
- retval = g_keys_execute(w_current, event->state, event->keyval) ? TRUE : FALSE;
+
+ /* update the state of the modifiers */
+ w_current->ALTKEY = (event->state & GDK_MOD1_MASK) ? 1 : 0;
+ w_current->SHIFTKEY = (event->state & GDK_SHIFT_MASK) ? 1 : 0;
+ w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
+
+ pressed = (event->type == GDK_KEY_PRESS) ? 1 : 0;
+
+ switch (event->keyval) {
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ alt_key = 1;
+ w_current->ALTKEY = pressed;
+ break;
+
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ shift_key = 1;
+ w_current->SHIFTKEY = pressed;
+ break;
+
+ case GDK_Control_L:
+ case GDK_Control_R:
+ control_key = 1;
+ w_current->CONTROLKEY = pressed;
+ break;
}
+ switch (w_current->event_state) {
+ case ENDLINE:
+ if (control_key) {
+ get_snapped_pointer (w_current, &wx, &wy);
+ o_line_motion (w_current, wx, wy);
+ }
+ break;
+ case STARTDRAWNET:
+ if (control_key) {
+ get_snapped_pointer (w_current, &wx, &wy);
+ o_net_start_magnetic(w_current, wx, wy);
+ }
+ break;
+ case DRAWNET:
+ case NETCONT:
+ if (shift_key || control_key) {
+ get_snapped_pointer (w_current, &wx, &wy);
+ o_net_motion (w_current, wx, wy);
+ }
+ break;
+ case DRAWBUS:
+ case BUSCONT:
+ if (control_key) {
+ get_snapped_pointer (w_current, &wx, &wy);
+ o_bus_motion (w_current, wx, wy);
+ }
+ break;
+ case ENDMOVE:
+ if (control_key) {
+ get_snapped_pointer (w_current, &wx, &wy);
+ o_move_motion (w_current, wx, wy);
+ }
+ break;
+ case ENDCOMP: /* FIXME: This state shouldn't respond to modifier keys */
+ case ENDPASTE: /* FIXME: This state shouldn't respond to modifier keys */
+ case ENDTEXT: /* FIXME: This state shouldn't respond to modifier keys */
+ case ENDCOPY:
+ case ENDMCOPY:
+ if (control_key) {
+ get_snapped_pointer (w_current, &wx, &wy);
+ o_place_motion (w_current, wx, wy);
+ }
+ break;
+ }
+
+ if (pressed)
+ retval = g_keys_execute (w_current, event->state, event->keyval)
+ ? TRUE : FALSE;
+
return retval;
}
diff --git a/gschem/src/x_window.c b/gschem/src/x_window.c
index 1904f20..0ea2014 100644
--- a/gschem/src/x_window.c
+++ b/gschem/src/x_window.c
@@ -191,7 +191,8 @@ void x_window_setup_draw_events(GSCHEM_TOPLEVEL *w_current)
{ "button_release_event", G_CALLBACK(x_event_button_released) },
{ "motion_notify_event", G_CALLBACK(x_event_motion) },
{ "configure_event", G_CALLBACK(x_event_configure) },
- { "key_press_event", G_CALLBACK(x_event_key_press) },
+ { "key_press_event", G_CALLBACK(x_event_key) },
+ { "key_release_event", G_CALLBACK(x_event_key) },
{ NULL, NULL } };
struct event_reg_t main_window_events[] = {
{ "enter_notify_event", G_CALLBACK(x_event_enter) },
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs