[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: branch: master updated (1.4.0-20080127-90-g55b378f)
The branch, master has been updated
via 55b378f5eddc78f0f3f48c83f401e454323d9bd9 (commit)
via 5681a43743b2ccfdf246679ad78f186b5a7f1f14 (commit)
via 0b0100eefa31acbd56f41ca639856da904645e74 (commit)
from faa7917f687694937baee932ea2efaa6fd16fd26 (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/globals.h | 4 --
gschem/include/prototype.h | 1 +
gschem/src/a_zoom.c | 7 ++-
gschem/src/i_callbacks.c | 116 ++++++++++++++++++++++++++++++++++++--------
gschem/src/x_attribedit.c | 21 +++++++-
gschem/src/x_event.c | 46 +++++++++++++++--
gschem/src/x_preview.c | 39 ++-------------
7 files changed, 164 insertions(+), 70 deletions(-)
=================
Commit Messages
=================
commit 55b378f5eddc78f0f3f48c83f401e454323d9bd9
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri May 23 17:02:51 2008 +0200
gschem: use pointer from drawing area in preview and x_attribedit
The preview widget used in the file dialog and in the component dialog is
now using the pointer from the drawing area, too. The motion event function that tracked the pointer is no longer required.
The attribedit dialog used the mouse_wx/y variables to set the attribute
postion when activated with the hotkey. This usage has been removed.
Removed all mouse_wx/y occurences in x_event and in the global.h file.
This variables are completly gone now.
:100644 100644 2e342b5... acd4ed8... M gschem/include/globals.h
:100644 100644 256972b... 08ccef5... M gschem/src/x_attribedit.c
:100644 100644 2681eb6... d087a57... M gschem/src/x_event.c
:100644 100644 b39fe76... 3e9efd2... M gschem/src/x_preview.c
commit 5681a43743b2ccfdf246679ad78f186b5a7f1f14
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri May 23 16:54:28 2008 +0200
gschem: use pointer from drawing area for all gschem callbacks
The global variable for the pointer mouse_wx/y are no longer used.
The zoom and panning actions have a unsnapped position again.
Note: If the pointer is outside the drawing area and a hotkey action
is triggered the action will be ignored.
:100644 100644 80574ce... 392b264... M gschem/src/a_zoom.c
:100644 100644 ed0e377... 18b40c0... M gschem/src/i_callbacks.c
commit 0b0100eefa31acbd56f41ca639856da904645e74
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri May 23 10:22:25 2008 +0200
gschem: added function to get the pointer from the drawing area
The new function x_event_get_pointer_position() get's the mouse
position from a given GSCHEM_TOPLEVEL object. This function will replace
the global mouse_wx, mouse_wy variables in the following commits.
:100644 100644 93a37ab... 6c7e568... M gschem/include/prototype.h
:100644 100644 8d95464... 2681eb6... M gschem/src/x_event.c
=========
Changes
=========
commit 55b378f5eddc78f0f3f48c83f401e454323d9bd9
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri May 23 17:02:51 2008 +0200
gschem: use pointer from drawing area in preview and x_attribedit
The preview widget used in the file dialog and in the component dialog is
now using the pointer from the drawing area, too. The motion event function that tracked the pointer is no longer required.
The attribedit dialog used the mouse_wx/y variables to set the attribute
postion when activated with the hotkey. This usage has been removed.
Removed all mouse_wx/y occurences in x_event and in the global.h file.
This variables are completly gone now.
diff --git a/gschem/include/globals.h b/gschem/include/globals.h
index 2e342b5..acd4ed8 100644
--- a/gschem/include/globals.h
+++ b/gschem/include/globals.h
@@ -40,10 +40,6 @@ extern int do_logging;
extern int logging_dest;
-/* current mouse location */
-extern int mouse_wx; /* defined in x_event.c */
-extern int mouse_wy;
-
/* command line options */
extern int quiet_mode;
extern int verbose_mode;
diff --git a/gschem/src/x_attribedit.c b/gschem/src/x_attribedit.c
index 256972b..08ccef5 100644
--- a/gschem/src/x_attribedit.c
+++ b/gschem/src/x_attribedit.c
@@ -88,6 +88,7 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
int invocation_flag;
int nsel=0, addto=0, replace=0, addmask=0;
int option_index;
+ gint wx, wy;
i_set_state(w_current, SELECT);
@@ -233,13 +234,18 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
invocation_flag =
GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(w_current->aewindow),
"invocation_flag") );
+ wx = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(w_current->aewindow),
+ "position_wx"));
+ wy = GPOINTER_TO_INT( gtk_object_get_data(GTK_OBJECT(w_current->aewindow),
+ "position_wy"));
#if DEBUG
printf("invocation flag: %d\n", invocation_flag);
#endif
- if (invocation_flag == FROM_HOTKEY) {
- new->text->x = snap_grid(toplevel, mouse_wx);
- new->text->y = snap_grid(toplevel, mouse_wy);
+ if (invocation_flag == FROM_HOTKEY
+ && wx != -1 && wy != -1) {
+ new->text->x = wx;
+ new->text->y = wy;
o_erase_single(w_current, new);
o_text_recreate(toplevel, new);
o_text_draw(w_current, new);
@@ -315,6 +321,7 @@ void attrib_edit_dialog(GSCHEM_TOPLEVEL *w_current, OBJECT * list, int flag)
char *name = NULL;
char *val = NULL;
OBJECT *attrib = NULL;
+ gint wx, wy;
/* gschem specific */
if (w_current->aewindow)
@@ -531,6 +538,14 @@ void attrib_edit_dialog(GSCHEM_TOPLEVEL *w_current, OBJECT * list, int flag)
}
gtk_object_set_data(GTK_OBJECT(aewindow), "invocation_flag",
GINT_TO_POINTER(flag));
+
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy)) {
+ wx = wy = -1;
+ }
+ gtk_object_set_data(GTK_OBJECT(aewindow), "position_wx",
+ GINT_TO_POINTER(wx));
+ gtk_object_set_data(GTK_OBJECT(aewindow), "position_wy",
+ GINT_TO_POINTER(wy));
/* gschem specific */
i = 0;
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 2681eb6..d087a57 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -35,9 +35,6 @@
#include <dmalloc.h>
#endif
-/* used in key_press, since it isn't passed this information */
-/* filled in x_event_motion */
-int mouse_wx, mouse_wy;
/* used by mouse pan */
int start_pan_x, start_pan_y;
@@ -841,9 +838,6 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
w_x = snap_grid(toplevel, unsnapped_wx);
w_y = snap_grid(toplevel, unsnapped_wy);
- mouse_wx = w_x;
- mouse_wy = w_y;
-
if (w_current->cowindow) {
coord_display_update(w_current, (int) event->x, (int) event->y);
}
diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index b39fe76..3e9efd2 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -44,8 +44,6 @@
#define OVER_ZOOM_FACTOR 0.1
-extern int mouse_wx, mouse_wy;
-
enum {
PROP_FILENAME=1,
@@ -163,6 +161,7 @@ preview_callback_button_press (GtkWidget *widget,
{
Preview *preview = PREVIEW (widget);
GSCHEM_TOPLEVEL *preview_w_current = preview->preview_w_current;
+ gint wx, wy;
if (!preview->active) {
return TRUE;
@@ -175,7 +174,9 @@ preview_callback_button_press (GtkWidget *widget,
o_redraw_all (preview_w_current);
break;
case 2: /* middle mouse button: pan */
- a_pan (preview_w_current, mouse_wx, mouse_wy);
+ if (!x_event_get_pointer_position(preview_w_current, FALSE, &wx, &wy))
+ return FALSE;
+ a_pan (preview_w_current, wx, wy);
break;
case 3: /* right mouse button: zoom out */
a_zoom (preview_w_current, ZOOM_OUT, HOTKEY,
@@ -187,37 +188,6 @@ preview_callback_button_press (GtkWidget *widget,
return FALSE;
}
-/*! \brief Handles the displacement of the pointer.
- * \par Function Description
- * This function temporary saves the position of the mouse pointer
- * over the preview widget.
- *
- * This position can be later used when the user press a button of
- * the mouse (see <B>preview_callback_button_press()</B>).
- *
- * \param [in] widget The preview widget.
- * \param [in] event The event structure.
- * \param [in] user_data Unused user data.
- * \returns FALSE to propagate the event further.
- */
-static gboolean
-preview_callback_motion_notify (GtkWidget *widget,
- GdkEventMotion *event,
- gpointer user_data)
-{
- Preview *preview = PREVIEW (widget);
- GSCHEM_TOPLEVEL *preview_w_current = preview->preview_w_current;
- TOPLEVEL *preview_toplevel = preview_w_current->toplevel;
-
- if (!preview->active) {
- return TRUE;
- }
-
- SCREENtoWORLD(preview_toplevel,
- (int) event->x, (int) event->y, &mouse_wx, &mouse_wy);
-
- return FALSE;
-}
/*! \brief Updates the preview widget.
* \par Function Description
@@ -395,7 +365,6 @@ preview_init (Preview *preview)
{ "realize", G_CALLBACK (preview_callback_realize) },
{ "expose_event", G_CALLBACK (preview_callback_expose) },
{ "button_press_event", G_CALLBACK (preview_callback_button_press) },
- { "motion_notify_event", G_CALLBACK (preview_callback_motion_notify) },
{ "configure_event", G_CALLBACK (preview_event_configure) },
{ "scroll_event", G_CALLBACK (preview_event_scroll) },
{ NULL, NULL }
commit 5681a43743b2ccfdf246679ad78f186b5a7f1f14
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri May 23 16:54:28 2008 +0200
gschem: use pointer from drawing area for all gschem callbacks
The global variable for the pointer mouse_wx/y are no longer used.
The zoom and panning actions have a unsnapped position again.
Note: If the pointer is outside the drawing area and a hotkey action
is triggered the action will be ignored.
diff --git a/gschem/src/a_zoom.c b/gschem/src/a_zoom.c
index 80574ce..392b264 100644
--- a/gschem/src/a_zoom.c
+++ b/gschem/src/a_zoom.c
@@ -65,8 +65,11 @@ void a_zoom(GSCHEM_TOPLEVEL *w_current, int dir, int selected_from, int pan_flag
/*calc center: either "mouse_to_world" or center=center */
if (w_current->zoom_with_pan == TRUE && selected_from == HOTKEY) {
- world_pan_center_x = mouse_wx;
- world_pan_center_y = mouse_wy;
+ if (!x_event_get_pointer_position(w_current, FALSE,
+ &start_x, &start_y))
+ return;
+ world_pan_center_x = start_x;
+ world_pan_center_y = start_y;
}
else {
world_pan_center_x = (double) (toplevel->page_current->left +
diff --git a/gschem/src/i_callbacks.c b/gschem/src/i_callbacks.c
index ed0e377..18b40c0 100644
--- a/gschem/src/i_callbacks.c
+++ b/gschem/src/i_callbacks.c
@@ -603,14 +603,18 @@ DEFINE_I_CALLBACK(edit_copy)
DEFINE_I_CALLBACK(edit_copy_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
i_update_middle_button(w_current, i_callback_edit_copy_hotkey, _("Copy"));
if (o_select_return_first_object(w_current)) {
o_redraw_cleanstates(w_current);
w_current->event_state = COPY;
- o_copy_start(w_current, mouse_wx, mouse_wy);
+ o_copy_start(w_current, wx, wy);
w_current->event_state = ENDCOPY;
w_current->inside_action = 1;
}
@@ -644,14 +648,18 @@ DEFINE_I_CALLBACK(edit_mcopy)
DEFINE_I_CALLBACK(edit_mcopy_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
i_update_middle_button(w_current, i_callback_edit_mcopy_hotkey, _("Multiple Copy"));
if (o_select_return_first_object(w_current)) {
o_redraw_cleanstates(w_current);
w_current->event_state = MCOPY;
- o_copy_start(w_current, mouse_wx, mouse_wy);
+ o_copy_start(w_current, wx, wy);
w_current->event_state = ENDMCOPY;
w_current->inside_action = 1;
}
@@ -685,13 +693,17 @@ DEFINE_I_CALLBACK(edit_move)
DEFINE_I_CALLBACK(edit_move_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
i_update_middle_button(w_current, i_callback_edit_move_hotkey, _("Move"));
if (o_select_return_first_object(w_current)) {
o_redraw_cleanstates(w_current);
- o_move_start(w_current, mouse_wx, mouse_wy);
+ o_move_start(w_current, wx, wy);
w_current->event_state = ENDMOVE;
w_current->inside_action = 1;
}
@@ -843,6 +855,7 @@ DEFINE_I_CALLBACK(edit_rotate_90_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
GList *object_list;
+ gint wx, wy;
exit_if_null(w_current);
@@ -855,6 +868,9 @@ DEFINE_I_CALLBACK(edit_rotate_90_hotkey)
return;
}
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
/* If inside a move action, send a button 3 released, so rotating
will be handled by x_event.c */
if ( (w_current->inside_action) &&
@@ -879,7 +895,7 @@ DEFINE_I_CALLBACK(edit_rotate_90_hotkey)
i_callback_edit_rotate_90_hotkey, _("Rotate"));
/* Allow o_rotate_world_update to redraw the objects */
w_current->toplevel->DONT_REDRAW = 0;
- o_rotate_world_update(w_current, mouse_wx, mouse_wy, 90, object_list);
+ o_rotate_world_update(w_current, wx, wy, 90, object_list);
}
w_current->event_state = SELECT;
@@ -911,9 +927,13 @@ DEFINE_I_CALLBACK(edit_mirror_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
GList *object_list;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
object_list = geda_list_get_glist( w_current->toplevel->page_current->selection_list );
@@ -921,7 +941,7 @@ DEFINE_I_CALLBACK(edit_mirror_hotkey)
if (object_list) {
i_update_middle_button(w_current,
i_callback_edit_mirror_hotkey, _("Mirror"));
- o_mirror_world_update(w_current, mouse_wx, mouse_wy, object_list);
+ o_mirror_world_update(w_current, wx, wy, object_list);
}
w_current->event_state = SELECT;
@@ -1424,11 +1444,15 @@ DEFINE_I_CALLBACK(view_zoom_box)
DEFINE_I_CALLBACK(view_zoom_box_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, FALSE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
- a_zoom_box_start(w_current, mouse_wx, mouse_wy);
+ a_zoom_box_start(w_current, wx, wy);
w_current->inside_action = 1;
i_set_state(w_current, ZOOMBOXEND);
@@ -1596,12 +1620,16 @@ DEFINE_I_CALLBACK(view_pan_down)
DEFINE_I_CALLBACK(view_pan_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, FALSE, &wx, &wy))
+ return;
+
i_update_middle_button(w_current, i_callback_view_pan_hotkey, _("Pan"));
- a_pan(w_current, mouse_wx, mouse_wy);
+ a_pan(w_current, wx, wy);
if (w_current->undo_panzoom) {
o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY);
@@ -2136,6 +2164,7 @@ DEFINE_I_CALLBACK(buffer_paste5)
DEFINE_I_CALLBACK(buffer_paste1_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
@@ -2143,7 +2172,10 @@ DEFINE_I_CALLBACK(buffer_paste1_hotkey)
return;
}
- o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 0);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
+ o_buffer_paste_start(w_current, wx, wy, 0);
}
/*! \todo Finish function documentation!!!
@@ -2154,6 +2186,7 @@ DEFINE_I_CALLBACK(buffer_paste1_hotkey)
DEFINE_I_CALLBACK(buffer_paste2_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
@@ -2161,7 +2194,10 @@ DEFINE_I_CALLBACK(buffer_paste2_hotkey)
return;
}
- o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 1);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
+ o_buffer_paste_start(w_current, wx, wy, 1);
}
/*! \todo Finish function documentation!!!
@@ -2172,6 +2208,7 @@ DEFINE_I_CALLBACK(buffer_paste2_hotkey)
DEFINE_I_CALLBACK(buffer_paste3_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
@@ -2179,7 +2216,10 @@ DEFINE_I_CALLBACK(buffer_paste3_hotkey)
return;
}
- o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 2);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
+ o_buffer_paste_start(w_current, wx, wy, 2);
}
/*! \todo Finish function documentation!!!
@@ -2190,6 +2230,7 @@ DEFINE_I_CALLBACK(buffer_paste3_hotkey)
DEFINE_I_CALLBACK(buffer_paste4_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
@@ -2197,7 +2238,10 @@ DEFINE_I_CALLBACK(buffer_paste4_hotkey)
return;
}
- o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 3);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
+ o_buffer_paste_start(w_current, wx, wy, 3);
}
/*! \todo Finish function documentation!!!
@@ -2208,6 +2252,7 @@ DEFINE_I_CALLBACK(buffer_paste4_hotkey)
DEFINE_I_CALLBACK(buffer_paste5_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
@@ -2215,7 +2260,10 @@ DEFINE_I_CALLBACK(buffer_paste5_hotkey)
return;
}
- o_buffer_paste_start(w_current, mouse_wx, mouse_wy, 4);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
+ o_buffer_paste_start(w_current, wx, wy, 4);
}
/*! \section add-menu Add Menu Callback Functions */
@@ -2326,9 +2374,13 @@ DEFINE_I_CALLBACK(add_net)
DEFINE_I_CALLBACK(add_net_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
o_net_reset(w_current);
@@ -2338,7 +2390,7 @@ DEFINE_I_CALLBACK(add_net_hotkey)
i_set_state(w_current, STARTDRAWNET);
i_update_toolbar(w_current);
- o_net_start(w_current, mouse_wx, mouse_wy);
+ o_net_start(w_current, wx, wy);
w_current->event_state=DRAWNET;
w_current->inside_action = 1;
@@ -2394,9 +2446,13 @@ DEFINE_I_CALLBACK(add_bus)
DEFINE_I_CALLBACK(add_bus_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
@@ -2405,7 +2461,7 @@ DEFINE_I_CALLBACK(add_bus_hotkey)
i_set_state(w_current, STARTDRAWBUS);
i_update_toolbar(w_current);
- o_bus_start(w_current, mouse_wx, mouse_wy);
+ o_bus_start(w_current, wx, wy);
w_current->event_state=DRAWBUS;
w_current->inside_action = 1;
@@ -2495,15 +2551,19 @@ DEFINE_I_CALLBACK(add_line)
DEFINE_I_CALLBACK(add_line_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
-
+ gint wx, wy;
+
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
i_update_middle_button(w_current, i_callback_add_line_hotkey, _("Line"));
- o_line_start(w_current, mouse_wx, mouse_wy);
+ o_line_start(w_current, wx, wy);
w_current->inside_action = 1;
i_set_state(w_current, ENDLINE);
@@ -2536,15 +2596,19 @@ DEFINE_I_CALLBACK(add_box)
DEFINE_I_CALLBACK(add_box_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
i_update_middle_button(w_current, i_callback_add_box_hotkey, _("Box"));
- o_box_start(w_current, mouse_wx, mouse_wy);
+ o_box_start(w_current, wx, wy);
w_current->inside_action = 1;
i_set_state(w_current, ENDBOX);
@@ -2611,16 +2675,20 @@ DEFINE_I_CALLBACK(add_circle)
DEFINE_I_CALLBACK(add_circle_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
i_update_middle_button(w_current, i_callback_add_circle_hotkey,
_("Circle"));
- o_circle_start(w_current, mouse_wx, mouse_wy);
+ o_circle_start(w_current, wx, wy);
w_current->inside_action = 1;
i_set_state(w_current, ENDCIRCLE);
@@ -2653,15 +2721,19 @@ DEFINE_I_CALLBACK(add_arc)
DEFINE_I_CALLBACK(add_arc_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
i_update_middle_button(w_current, i_callback_add_arc_hotkey, _("Arc"));
- o_arc_start(w_current, mouse_wx, mouse_wy);
+ o_arc_start(w_current, wx, wy);
w_current->inside_action = 1;
i_set_state(w_current, ENDARC);
@@ -2694,15 +2766,19 @@ DEFINE_I_CALLBACK(add_pin)
DEFINE_I_CALLBACK(add_pin_hotkey)
{
GSCHEM_TOPLEVEL *w_current = (GSCHEM_TOPLEVEL*) data;
+ gint wx, wy;
exit_if_null(w_current);
+ if (!x_event_get_pointer_position(w_current, TRUE, &wx, &wy))
+ return;
+
o_redraw_cleanstates(w_current);
o_erase_rubber(w_current);
i_update_middle_button(w_current, i_callback_add_pin_hotkey, _("Pin"));
- o_pin_start(w_current, mouse_wx, mouse_wy);
+ o_pin_start(w_current, wx, wy);
w_current->inside_action = 1;
i_set_state(w_current, ENDPIN);
commit 0b0100eefa31acbd56f41ca639856da904645e74
Author: Werner Hoch <werner.ho@xxxxxx>
Date: Fri May 23 10:22:25 2008 +0200
gschem: added function to get the pointer from the drawing area
The new function x_event_get_pointer_position() get's the mouse
position from a given GSCHEM_TOPLEVEL object. This function will replace
the global mouse_wx, mouse_wy variables in the following commits.
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 93a37ab..6c7e568 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -792,6 +792,7 @@ 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);
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 */
void x_compselect_open (GSCHEM_TOPLEVEL *w_current);
void x_compselect_close (GSCHEM_TOPLEVEL *w_current);
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 8d95464..2681eb6 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -1344,3 +1344,43 @@ gint x_event_scroll (GtkWidget *widget, GdkEventScroll *event,
return 0;
}
+
+
+/*! \brief get the pointer position of a given GSCHEM_TOPLEVEL
+ * \par Function Description
+ * This function gets the pointer position of the drawing area of the
+ * current workspace <b>GSCHEM_TOPLEVEL</b>. The flag <b>snapped</b> specifies
+ * whether the pointer position should be snapped to the current grid.
+ *
+ * \param [in] w_current The GSCHEM_TOPLEVEL object.
+ * \param [in] snapped An option flag to specify the wished coords
+ * \param [out] wx snapped/unsnapped world x coordinate
+ * \param [out] wy snapped/unsnapped world y coordinate
+ *
+ * \return Returns TRUE if the pointer position is inside the drawing area.
+ *
+ */
+gboolean x_event_get_pointer_position (GSCHEM_TOPLEVEL *w_current,
+ gboolean snapped,
+ gint *wx, gint *wy)
+{
+ TOPLEVEL *toplevel = w_current->toplevel;
+ int sx, sy, x, y;
+
+ gtk_widget_get_pointer(w_current->drawing_area, &sx, &sy);
+
+ /* check if we are inside the drawing area */
+ if (sx < 0 || sx >= w_current->win_width
+ || sy <0 || sy >= w_current->win_height)
+ return FALSE;
+
+ SCREENtoWORLD(toplevel, sx, sy, &x, &y);
+ if (snapped) {
+ x = snap_grid(toplevel, x);
+ y = snap_grid(toplevel, y);
+ }
+ *wx = x;
+ *wy = y;
+
+ return TRUE;
+}
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs