From 3a827476312de6201830502d39a4563a7d72b704 Mon Sep 17 00:00:00 2001 From: Gerald Jay Sussman Date: Fri, 21 Jun 1991 03:40:23 +0000 Subject: [PATCH] Implement primitives to map event coordinates to graphics window coordinates. --- v7/src/microcode/x11graph.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/v7/src/microcode/x11graph.c b/v7/src/microcode/x11graph.c index 140ddad67..b9bbb206d 100644 --- a/v7/src/microcode/x11graph.c +++ b/v7/src/microcode/x11graph.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.9 1991/04/26 05:25:22 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.10 1991/06/21 03:40:23 gjs Exp $ Copyright (c) 1989-91 Massachusetts Institute of Technology @@ -531,3 +531,35 @@ DEFINE_PRIMITIVE ("X-GRAPHICS-SET-DASHES", Prim_x_graphics_set_dashes, 3, 3, 0) } PRIMITIVE_RETURN (UNSPECIFIC); } + +DEFINE_PRIMITIVE ("X-GRAPHICS-MAP-X-COORDINATE", Prim_x_graphics_map_x_coordinate, 2, 2, 0) +{ + PRIMITIVE_HEADER (2); + { + struct xwindow * xw = (x_window_arg (1)); + unsigned int xp = (arg_nonnegative_integer (2)); + int bx = (xp - (XW_INTERNAL_BORDER_WIDTH (xw))); + PRIMITIVE_RETURN + (x_coordinate_map + (xw, + ((bx < 0) ? 0 + : (bx >= (XW_X_SIZE (xw))) ? ((XW_X_SIZE (xw)) - 1) + : bx))); + } +} + +DEFINE_PRIMITIVE ("X-GRAPHICS-MAP-Y-COORDINATE", Prim_x_graphics_map_y_coordinate, 2, 2, 0) +{ + PRIMITIVE_HEADER (2); + { + struct xwindow * xw = (x_window_arg (1)); + unsigned int yp = (arg_nonnegative_integer (2)); + int by = (yp - (XW_INTERNAL_BORDER_WIDTH (xw))); + PRIMITIVE_RETURN + (y_coordinate_map + (xw, + ((by < 0) ? 0 + : (by >= (XW_Y_SIZE (xw))) ? ((XW_Y_SIZE (xw)) - 1) + : by))); + } +} -- 2.25.1