physical.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1986 AT&T
* All Rights Reserved
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.25 */
#include <curses.h>
#include <fcntl.h>
#include "wish.h"
#include "token.h"
#include "message.h"
#include "vt.h"
#include "var_arrays.h"
#include "actrec.h"
#include "moremacros.h"
#include "vtdefs.h"
#ifdef TIME_IT
#endif /* TIME_IT */
extern char Semaphore[];
extern int Coproc_active;
extern int Vflag;
/* #ifdef i386 abs k18 */
/*
* redefine curses mouse position macros
*/
#define SCR_ROW MOUSE_Y_POS
#define SCR_COL MOUSE_X_POS
/*
* Given a screen offset (r, c), PTS_to() will determine whether r,c
* points to a given frame (excluding the frame border).
* (br, bc is the beginning offset of the frame on the screen and
* mr, mc is the maximum rows and columns of the frame)
*/
/*
* ON_border() will evaluate to true if the mouse points to the
* frame border
*/
/*
* Determine the mouse offset within the frame (0,0 based)
* (excluding the frame border).
*/
/* #endif abs k18 */
int Mouse_row;
int Mouse_col;
int Open_mouse_mode = FALSE;
extern long Mail_check;
extern long Interupt_pending;
register token t;
{
int fd;
#ifdef PHYSICAL /* i dont know what this does but since
* it was un-compilable until k17
* it must never have been used. abs */
int lcv1 = 10000;
while ( lcv1-- )
{
#endif /* PHYSICAL */
if (Vflag)
(void) mess_flush(FALSE);
/* new les */
vt_flush();
alarm((int) Mail_check);
if (Coproc_active)
{
/*
* The call to open is to protect "vsig" from
* sending a signal to FACE when the screen
* is being painted ...
* Vsig will block on the semaphore until FACE
* is able to receive signals ..
* This code may be changed if a better solution
* is found ...
* Interupt_pending is definined in main.c and
* set in the interupt handler for a SIGUSR2
* once a signal is encountered ...
*/
if (Interupt_pending)
{
Interupt_pending = 0;
vt_flush(); /* abs k18.2 */
}
t = wgetchar();
}
else
t = wgetchar();
mess_unlock(); /* allow calls to mess_temp and mess_perm */
if (t < 0)
t = TOK_NOP;
/* #ifdef i386 abs k18*/
else if (t == KEY_MOUSE)
{
if (Open_mouse_mode)
t = do_open_mouse();
else
t = do_mouse();
}
/* #endif abs k18 */
(void) mess_flush(TRUE);
return t;
#ifdef PHYSICAL /* abs k17 */
} /* abs k17 */
#endif /* PHYSICAL */ /* abs k17 */
}
/* #ifdef i386 abs k18 */
static token
do_mouse()
{
token t;
return(TOK_NOP); /* only concerned about button 1 events */
/*
* First check to see which frame (if any) the
* the mouse points to ...
*/
t = TOK_NOP;
/*
* Mouse points to the current frame border
*/
t = TOK_BPRESSED;
}
/*
* Mouse points to the current frame
*/
t = TOK_BPRESSED;
}
else {
/*
* Scan the list of VT's to find one that the
* mouse points to ...
*/
v = VT_array;
(v->flags & VT_NOBORDER))
continue; /* don't bother */
savev = v;
}
t = TOK_BPRESSED;
}
savev = v;
}
t = TOK_BPRESSED;
}
}
}
/*
* If the mouse doesn't point to a frame (t != TOK_BPRESSED)
* then return TOK_NOP
*/
if (t != TOK_BPRESSED)
return(TOK_NOP);
v = savev;
if (v != curvt) {
/*
* frame is not current so make it current
*/
vt_flush();
}
/*
* If not on the frame border then
* do object specific action for
* BUTTON PRESS
*/
}
/*
* Perform mouse tracking while the button is
* depressed ... (if the mouse was "clicked" there
* is no need to track)
*
* NOTE: Do not map button release events to SLKS while
* tracking.
*/
map_button(0);
for (; ;) {
/*
* No longer track on BUTTON_RELEASE
*/
break;
}
if (request_mouse_pos() == ERR)
break;
if (mess_flush(FALSE))
}
}
}
}
/*
* If XY points to the current frame return (TOK_BRELEASED)
* otherwise ignore the mouse event (TOK_NOP)
*/
flushinp();
/*
* The mouse points to the right frame border ...
* check to see if it is inside the scroll box
*/
}
/*
* The mouse points to the current frame ...
* Determine the frame offset
*/
t = TOK_BRELEASED;
}
else
t = TOK_NOP;
}
return(t);
}
/*
* DO_OPEN_MOUSE is similar to DO_MOUSE except the mouse doesn't have
* to point inside a frame (e.g., frame management routines move and
* reshape)
*/
static token
{
token t;
return(TOK_NOP); /* only concerned about button 1 events */
t = TOK_NOP;
/*
* Perform mouse tracking while button is depressed
*/
map_button(0);
for (; ;) {
t = TOK_NOP;
/*
* No longer track on BUTTON_RELEASE
*/
t = TOK_BRELEASED;
break;
}
if (request_mouse_pos() == ERR)
break;
if (MOUSE_MOVED) {
vt_flush();
}
}
}
/*
* Button was clicked so don't track ... interpret as
* Button press immediately followed by button release.
*/
vt_flush();
t = TOK_BRELEASED;
}
return(t);
}
/*
* Given that the mouse points to the right frame border,
* PAGE_TOK() returns a page token if the mouse points to
*/
static token
{
else
return(rettok);
}
/*
* Given 2 frames ON_TOP will return TRUE if frame 1 (arg1) is
* "on top of" frame 2 (arg2)
*/
static int
{
return(TRUE);
return(TRUE);
else
return(FALSE);
}
/* #endif abs k18 */