gboolean ghid_port_button_release_cb (GtkWidget * drawing_area, GdkEventButton * ev, GtkUIManager * ui) { ModifierKeysState mk; gboolean drag; GdkModifierType state; ghid_note_event_location (ev); state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); drag = have_crosshair_attachments (); if (drag) HideCrosshair (TRUE); do_mouse_action(ev->button, mk + M_Release); if (drag) { AdjustAttachedObjects (); ghid_invalidate_all (); RestoreCrosshair (TRUE); ghid_screen_update (); } ghid_set_status_line_label (); g_idle_add (ghid_idle_cb, NULL); return TRUE; }
/* Mouse scroll wheel events */ gint ghid_port_window_mouse_scroll_cb (GtkWidget * widget, GdkEventScroll * ev, GHidPort * out) { ModifierKeysState mk; GdkModifierType state; int button; state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); /* X11 gtk hard codes buttons 4, 5, 6, 7 as below in * gtk+/gdk/x11/gdkevents-x11.c:1121, but quartz and windows have * special mouse scroll events, so this may conflict with a mouse * who has buttons 4 - 7 that aren't the scroll wheel? */ switch(ev->direction) { case GDK_SCROLL_UP: button = 4; break; case GDK_SCROLL_DOWN: button = 5; break; case GDK_SCROLL_LEFT: button = 6; break; case GDK_SCROLL_RIGHT: button = 7; break; default: button = -1; } do_mouse_action(button, mk); return TRUE; }
gboolean ghid_port_button_press_cb (GtkWidget * drawing_area, GdkEventButton * ev, GtkUIManager * ui) { ModifierKeysState mk; gboolean drag; GdkModifierType state; /* Reject double and triple click events */ if (ev->type != GDK_BUTTON_PRESS) return TRUE; ghid_note_event_location (ev); state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); ghid_show_crosshair (FALSE); HideCrosshair (TRUE); drag = have_crosshair_attachments (); do_mouse_action(ev->button, mk); ghid_invalidate_all (); RestoreCrosshair (TRUE); ghid_set_status_line_label (); ghid_show_crosshair (TRUE); if (!gport->panning) g_idle_add (ghid_idle_cb, NULL); return TRUE; }
gboolean ghid_port_button_release_cb (GtkWidget * drawing_area, GdkEventButton * ev, gpointer data) { ModifierKeysState mk; GdkModifierType state; ghid_note_event_location (ev); state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); do_mouse_action(ev->button, mk + M_Release); AdjustAttachedObjects (); ghid_invalidate_all (); ghid_window_set_name_label (PCB->Name); ghid_set_status_line_label (); g_idle_add (ghid_idle_cb, NULL); return TRUE; }
gboolean ghid_port_button_press_cb (GtkWidget * drawing_area, GdkEventButton * ev, gpointer data) { ModifierKeysState mk; GdkModifierType state; /* Reject double and triple click events */ if (ev->type != GDK_BUTTON_PRESS) return TRUE; ghid_note_event_location (ev); state = (GdkModifierType) (ev->state); mk = ghid_modifier_keys_state (&state); do_mouse_action(ev->button, mk); ghid_invalidate_all (); ghid_window_set_name_label (PCB->Name); ghid_set_status_line_label (); if (!gport->panning) g_idle_add (ghid_idle_cb, NULL); return TRUE; }
gboolean ghid_port_key_press_cb (GtkWidget * drawing_area, GdkEventKey * kev, gpointer data) { ModifierKeysState mk; gint ksym = kev->keyval; gboolean handled; extern void ghid_hotkey_cb (int); GdkModifierType state; if (ghid_is_modifier_key_sym (ksym)) ghid_note_event_location (NULL); state = (GdkModifierType) (kev->state); mk = ghid_modifier_keys_state (&state); handled = TRUE; /* Start off assuming we handle it */ switch (ksym) { case GDK_Alt_L: case GDK_Alt_R: case GDK_Control_L: case GDK_Control_R: case GDK_Shift_L: case GDK_Shift_R: case GDK_Shift_Lock: case GDK_ISO_Level3_Shift: break; case GDK_Up: ghid_hotkey_cb (GHID_KEY_UP); break; case GDK_Down: ghid_hotkey_cb (GHID_KEY_DOWN); break; case GDK_Left: ghid_hotkey_cb (GHID_KEY_LEFT); break; case GDK_Right: ghid_hotkey_cb (GHID_KEY_RIGHT); break; case GDK_ISO_Left_Tab: case GDK_3270_BackTab: switch (mk) { case NONE_PRESSED: ghid_hotkey_cb (GHID_KEY_SHIFT | GHID_KEY_TAB); break; case CONTROL_PRESSED: ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); break; case MOD1_PRESSED: ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); break; case SHIFT_PRESSED: ghid_hotkey_cb (GHID_KEY_SHIFT | GHID_KEY_TAB); break; case SHIFT_CONTROL_PRESSED: ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); break; case SHIFT_MOD1_PRESSED: ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); break; default: handled = FALSE; break; } break; case GDK_Tab: switch (mk) { case NONE_PRESSED: ghid_hotkey_cb (GHID_KEY_TAB); break; case CONTROL_PRESSED: ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_TAB); break; case MOD1_PRESSED: ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_TAB); break; case SHIFT_PRESSED: ghid_hotkey_cb (GHID_KEY_SHIFT | GHID_KEY_TAB); break; case SHIFT_CONTROL_PRESSED: ghid_hotkey_cb (GHID_KEY_CONTROL | GHID_KEY_SHIFT | GHID_KEY_TAB); break; case SHIFT_MOD1_PRESSED: ghid_hotkey_cb (GHID_KEY_ALT | GHID_KEY_SHIFT | GHID_KEY_TAB); break; default: handled = FALSE; break; } break; default: handled = FALSE; } return handled; }
/* If user hits a key instead of the mouse button, we'll abort unless | it's one of the cursor keys. Move the layout if a cursor key. */ static gboolean loop_key_press_cb (GtkWidget * drawing_area, GdkEventKey * kev, GMainLoop ** loop) { ModifierKeysState mk; GdkModifierType state; gint ksym = kev->keyval; if (ghid_is_modifier_key_sym (ksym)) return TRUE; state = (GdkModifierType) (kev->state); mk = ghid_modifier_keys_state (&state); /* Duplicate the cursor key actions in gui-output-events.c */ switch (ksym) { case GDK_Up: if (mk == CONTROL_PRESSED) { hid_actionl ("Display", "Scroll", "8", NULL); hid_actionl ("Display", "Scroll", "0", NULL); } else if (mk == SHIFT_PRESSED) hid_actionl ("MovePointer", "0", "-10", NULL); else if (mk == NONE_PRESSED) hid_actionl ("MovePointer", "0", "-1", NULL); break; case GDK_Down: if (mk == CONTROL_PRESSED) { hid_actionl ("Display", "Scroll", "2", NULL); hid_actionl ("Display", "Scroll", "0", NULL); } else if (mk == SHIFT_PRESSED) hid_actionl ("MovePointer", "0", "10", NULL); else if (mk == NONE_PRESSED) hid_actionl ("MovePointer", "0", "1", NULL); break; case GDK_Left: if (mk == CONTROL_PRESSED) { hid_actionl ("Display", "Scroll", "4", NULL); hid_actionl ("Display", "Scroll", "0", NULL); } else if (mk == SHIFT_PRESSED) hid_actionl ("MovePointer", "-10", "0", NULL); else if (mk == NONE_PRESSED) hid_actionl ("MovePointer", "-1", "0", NULL); break; case GDK_Right: if (mk == CONTROL_PRESSED) { hid_actionl ("Display", "Scroll", "6", NULL); hid_actionl ("Display", "Scroll", "0", NULL); } else if (mk == SHIFT_PRESSED) hid_actionl ("MovePointer", "10", "0", NULL); else if (mk == NONE_PRESSED) hid_actionl ("MovePointer", "1", "0", NULL); break; case GDK_Return: /* Accept cursor location */ if (g_main_loop_is_running (*loop)) g_main_loop_quit (*loop); break; default: /* Abort */ got_location = FALSE; if (g_main_loop_is_running (*loop)) g_main_loop_quit (*loop); break; } return TRUE; }