SE_event_loop — Central X11 Event Dispatcher & Interactive Command Router
SE_event_loop (code/SE/SE_event_loop.c, 6,498 lines) is the central nervous system of swathed. Authored by John E. Hughes Clarke with extensive additions by Jonathan Beaudoin, Carlos Rubio, Anand, Douglas Bergersen, and Leonardo, it implements process_x_events()—the single top-level X11 event loop that receives every KeyPress, ButtonPress, ButtonRelease, MotionNotify, Expose, EnterNotify, LeaveNotify, ConfigureNotify, and UnmapNotify event across all swathed windows and dispatches them either to modular jX_widget handlers or to built-in editing, filtering, and navigation routines.
Two-Tier Event Dispatch Architecture
When swathed finishes initializing its X11 windows, main() enters process_x_events(), which runs until done is set (or parse_which_widget() returns 999 on clicking the exit icon):
- Event Queue Coalescing:
- Drains intermediate
MotionNotifyevents (XEventsQueued(display, QueuedAlready)) during rubber-band dragging so cursor tracking never lags behind X11 server traffic. - Deduplicates redundant
Exposeevents (XCheckTypedWindowEvent(..., Expose, &event)) before callingrefresh_window()(added by JDB, March 2003).
- Drains intermediate
- Tier 1 — Widget Router (
parse_which_widget):- Checks whether
event.xany.windowbelongs to the main toolbar (manage_ICON_events), main window frame (manage_MAIN_events), Sub-Bottom viewer (manage_SUBBOTTOM_events), or any of the 11jX_widgettoolkits viajX_is_any_win():SE_W_TimeSeries(TimeSeries_widget,TSplot_widget,TSpram_widget)SE_AnandBS(AnandBS_widget,ARC_widget)SE_BDI_DP(BDI_DP_widget) andSE_PDI_LA(PDI_LA_widget)SE_WaterColumn(WaterColumn_widget) andc_wcl_TOOLBOX(target_widget)SE_PhaseBathy(PhaseBathy_widget),SE_Waveforms(Waveform_widget), andSE_3D(SE3D_widget)
- Checks whether
- Tier 2 — Classic Sub-Window & Main Editor Event Loop (
managed == 0):- Handles all keyboard shortcuts, mouse clicks, and rubber-band selections for the 8 core
swathedpanels (graphic_window[0..7]) and classic sub-windows (sub_window[1..61]andREF_OFFSET61..73).
- Handles all keyboard shortcuts, mouse clicks, and rubber-band selections for the 8 core
Toolbar Icon Launcher (manage_ICON_events, icon_window[0..17])
Clicking any of the 18 toolbar icons (icon_window[0..17]) executes manage_ICON_events():
| Icon Index | Label | Action |
|---|---|---|
0 | exit | Calls dump_array(&in_recnum) to save pending flag edits to .merged and returns 999 to exit swathed. |
1 / 2 | fwd / bck | Saves edits (dump_array()) and steps in_recnum forward or backward by SE_NO_SWATHS - 4 (76 pings), calling prime_array(). |
3 | ALL/sel | Toggles all_sel_flag between flagging all 80 swaths in a rubber-band box (ALL) vs. only selected_swath/selected_beam (SEL). |
4 | p-B-s | Cycles psb_flag between viewing Port (P-b-s), Starboard (p-b-S), or Both (p-B-s) half-swaths. |
5 | next | Saves edits and advances current_file to the next loaded .merged survey line (start_file(), prime_array()). |
6 | list | Opens the ASCII ping/beam header inspector (view_list(), plot_list() in SE_listwin). |
7 | ss | Launches SE_sswindow (multibeam sidescan), SE_PhaseBathy (SEA_SwathPlus), or SE_SUBBOTwin (Knudsen_320). |
8 | auto | Opens the automated slope/spike flagging window (SE_AUTOFLAGwin) and runs check_data(1). |
9 | 2D | Opens the 2D sub-area sounding scatterplot editor (SE_2Dwindow) and loads profiles via get_D2_profiles_inarea(). |
10 | Class | Launches SE_AnandBS (make_AnandBS_widget()) or SE_BSwindow (view_BSbox()). |
11 | Patch | Opens the interactive Patch Test toolkit (SE_PATCHwin) and loads corridor swaths via get_Swaths_inarea(). |
12 | Lines | Opens the paginated survey line manager (SE_LineListwin). |
13 | Refr. | Opens the empirical refraction and induced-heave modeling tool (SE_REFTOOLwin). |
14 | geo | Initializes a blank geographic trackline locator window (setup_blank_area() in SE_GEOwindows) when no .r4 grid was provided. |
15 | TS | Maps TimeSeries_widget and TSpram_widget (SE_W_TimeSeries). |
16 | WC / WF | Maps WaterColumn_widget (SE_WaterColumn) or Waveform_widget (SE_Waveforms). |
17 | WGC | Opens the Weekley–Goodrich–Cornman neighbor-depth filter window (SE_Weekley_Goodrich_Cornman). |
Key Interactive Hotkeys in the Main Editing Windows (graphic_window[0..7])
- Rubber-Band Flagging / Unflagging / Zooming:
- Left-drag (
Button1): Flags soundings inside the rubber-band box ingraphic_window[0](along-track),[1](across-track),[4], or[5]; unflags soundings ingraphic_window[2]or[3]. - Middle-drag (
Button2): Zooms the view (lock_view) to the dragged rectangle ingraphic_window[0],[1], or[5]; pressingrunlocks and resets the zoom. - Right-click (
Button3): Selectsselected_beamandselected_swath(highlight_beam()) across all linked views.
- Left-drag (
- Automated Filters & Editing Hotkeys (
SE_filters):u: Undo last flagging operation (undo(), up to 10 levels viashift_undo_flags()).d/D: Toggle linear seafloor detrending (detrend_flag,update_for_detrend()) and phase-only detrend criteria (Detrend_Criteria).f: Run statistical standard-deviation “defluffing” (defluff()) on detrended soundings (F1–F6setSDmultiplier = 1.0..6.0;FcyclesSD_calc_method).m/M/</>/%: Run 2D median filter (compute_median(),median_filter()), toggle auto-premedian (premedian_flag), adjust kernel size (median_filter_size,2..10), and increment depth threshold (median_filter_threshold).e/E/(/): Run nadir/tunnel “detrenching” (detrench()), togglepredetrench, and adjustdetrench_port_sector/detrench_stbd_sector.l: Reject isolated “lonely” soundings (filter_lonely_soundings()).p: Run modal-depth Powell filter (depowell()).w: Run Weekley–Goodrich–Cornman filter (do_weekley_filter()).s/t: Flag entireselected_swath(s) or all 80 swaths in the current block (t).F7–F12: Control CARIS HIPS flag preloading (preload_flags,load_flags()) and ping-offset synchronization (HIPS_ping_offset,guess_flag_offset()).W: Export 80 sequential PPM/GIF animation frames (across_%05d.ppm,along_%05d.ppm,both_%05d.gif) across the current 80-ping block.