Builtin move-or-lower, move-or-raise, move-or-iconify

(instead of user defined functions in default config file)

- Remove MoveDelta option in favor of a program constant.
- Remove deltastop function. It was part of the mechanism to provide
  move-or-* as custom functions.
This commit is contained in:
Mike Small 2021-02-15 20:10:59 -05:00
parent 63be49b23c
commit 5d1c9ebee6
15 changed files with 257 additions and 197 deletions

View File

@ -1,3 +1,52 @@
2021-02-15 Mike Small <smallm@sdf.org>
* man/twmruined.man: replace a reference to move-or-lower,
etc. as user defined functions with equivalent builtins.
(values): document the new move-or-... builtins.
* src/menus.cc (ExecuteFunction): logic to make f.move-or-lower,
f.move-or-raise, and f.move-or-iconify work correctly as builtins
instead of user defined functions.
2021-02-13 Mike Small <smallm@sdf.org>
* src/lex.l: allow hyphen in identifiers so that f.move-or-lower,
etc. can be the names of builtin functions.
2021-02-03 Mike Small <smallm@sdf.org>
* man/twmruined.man (example): remove move-or-lower and friends
from example.
* src/deftwmrc.c: move-or-lower, etc. from custom to builtin.
2021-02-02 Mike Small <smallm@sdf.org>
* src/parse.c: f.move-or-iconify, f.move-or-lower, f.move-or-raise
keytable entries for new builtins to make up for removal of custom
functions.
* src/events.h: MOVEDELTA constant where menus.cc and events.c
can see it.
* src/menus.cc: Make move delta a local hard coded constant and
stop using f.deltastop. With move delta always non-zero, code
to start the wire frame early is not needed.
* src/deftwmrc.c: remove MoveDelta option, f.deltastop, and some
default custom functions.
* src/system.twmruinedrc: Remove use of f.deltastop
Remove the custom functions entirely. Will remove the ability
to define functions sooner or later anyway (but bring it back
with lisp functions?). Use new builtin functions of same name.
* src/screen.h (struct ScreenInfo): remove MoveDelta option
* src/parse.c: remove MoveDelta option and DeltaStop function
* man/twmruined.man: remove MoveDelta option and DeltaStop function
2021-01-31 Mike Small <smallm@sdf.org>
* src/util.h: Remove zoom option

11
README
View File

@ -3,10 +3,13 @@ A twm fork to suit my preferences.
Features removed...
1. iconmgr feature and icon region (icons always land on the right edge).
2. these configuration options: UsePPosition, SqueezeTitle, RandomPlacement,
2. configuration options: UsePPosition, SqueezeTitle, RandomPlacement,
opaquemove, window highlight, DontIconifyByUnmapping, IconifyByUnmapping,
TitlePadding, title button indent, NoGrabServer (never grab), IconRegion,
Zoom.
Zoom, MoveDelta
2. builtin functions: DeltaStop
3. default user defined functions: move-or-lower, move-or-raise,
and move-or-iconify (changed to builtins).
Changes ...
@ -14,6 +17,10 @@ Changes ...
- icons always land on the right edge if there's space there. xconsole
lands on the bottom right.
Additions ...
1. builtin functions: move-or-lower, move-or-raise, and move-or-iconify.
The master development code repository can be found at:
https://git.sdf.org/smallm/twmruined

View File

@ -447,10 +447,6 @@ can only be specified inside of a
.IP "\fBMonochrome\fP { \fIcolors\fP }" 8
This variable specifies a list of color assignments that should be made if
the screen has a depth of 1. See the description of \fBColors\fP.
.IP "\fBMoveDelta\fP \fIpixels\fP" 8
This variable specifies the number of pixels the pointer
must move before the \fBf.move\fP function starts working. Also
see the \fBf.deltastop\fP function. The default is zero pixels.
.IP "\fBNoBackingStore\fP" 8
This variable indicates that \fItwmruined\fP's menus should not request backing
store to minimize repainting of menus. This is typically
@ -599,7 +595,7 @@ will be deiconified and raised.
.SH BINDINGS
.PP
After the desired variables have been set, functions may be attached
titlebuttons and key and pointer buttons. Titlebuttons may be added
to titlebuttons and key and pointer buttons. Titlebuttons may be added
from the left or right side and appear in the titlebar from left-to-right
according to the
order in which they are specified. Key and pointer button
@ -645,12 +641,12 @@ keywords described below. For example, the default startup
file contains the following bindings:
.EX 0
Button1 = : root : f.menu "TwmWindows"
Button1 = m : window | icon : f.function "move-or-lower"
Button1 = m : window | icon : f.move-or-lower
Button2 = m : window | icon : f.iconify
Button3 = m : window | icon : f.function "move-or-raise"
Button1 = : title : f.function "move-or-raise"
Button3 = m : window | icon : f.move-or-raise
Button1 = : title : f.move-or-raise
Button2 = : title : f.raiselower
Button1 = : icon : f.function "move-or-iconify"
Button1 = : icon : f.move-or-iconify
Button2 = : icon : f.iconify
.EE
A user who wanted to be able to manipulate windows from the keyboard could
@ -678,9 +674,6 @@ User-defined functions contain the name by which they are referenced in
calls to \fBf.function\fP and a list of other functions to execute. For
example:
.EX 0
Function "move-or-lower" { f.move f.deltastop f.lower }
Function "move-or-raise" { f.move f.deltastop f.raise }
Function "move-or-iconify" { f.move f.deltastop f.iconify }
Function "restore-colormap" { f.colormap "default" f.lower }
.EE
The function name must be used in \fBf.function\fP exactly as it appears in
@ -726,10 +719,6 @@ WM_DELETE_WINDOW messages, the keyboard bell will be rung indicating that
the user should choose an alternative method. Note this is very different
from f.destroy. The intent here is to delete a single window, not
necessarily the entire application.
.IP "\fBf.deltastop\fP" 8
This function allows a user-defined function to be aborted if the pointer has
been moved more than \fIMoveDelta\fP pixels. See the example definition
given for \fBFunction "move-or-raise"\fP at the beginning of the section.
.IP "\fBf.destroy\fP" 8
This function instructs the X server to close the display connection of the
client that created the selected window. This should only be used as a last
@ -791,6 +780,12 @@ constrains the move to be either horizontal or vertical depending on which
grid line is crossed.
To abort a move, press another button before releasing the
first button.
.IP "\fBf.move-or-iconfiy\fP" 8
Like f.move if you drag the window. Like f.iconify if you do not.
.IP "\fBf.move-or-lower\fP" 8
Like f.move if you drag the window. Like f.lower if you do not.
.IP "\fBf.move-or-raise\fP" 8
Like f.move if you drag the window. Like f.raise if you do not.
.IP "\fBf.nop\fP" 8
This function does nothing and is typically used with the \fBDefaultFunction\fP
or \fBWindowFunction\fP variables or to introduce blank lines in menus.

View File

@ -627,7 +627,7 @@ MappedNotOverride(Window w)
* attach default bindings so that naive users don't get messed up if they
* provide a minimal twmrc.
*/
static void do_add_binding (int button, int context, int modifier, int func)
static void do_add_binding(int button, int context, int modifier, int func)
{
MouseButton *mb = &Scr->Mouse[button][context][modifier];
@ -647,11 +647,11 @@ AddDefaultBindings(void)
#define NoModifierMask 0
do_add_binding (Button1, C_TITLE, NoModifierMask, F_MOVE);
do_add_binding (Button1, C_ICON, NoModifierMask, F_ICONIFY);
do_add_binding(Button1, C_TITLE, NoModifierMask, F_MOVE);
do_add_binding(Button1, C_ICON, NoModifierMask, F_ICONIFY);
do_add_binding (Button2, C_TITLE, NoModifierMask, F_RAISELOWER);
do_add_binding (Button2, C_ICON, NoModifierMask, F_ICONIFY);
do_add_binding(Button2, C_TITLE, NoModifierMask, F_RAISELOWER);
do_add_binding(Button2, C_ICON, NoModifierMask, F_ICONIFY);
#undef NoModifierMask
}

View File

@ -29,21 +29,16 @@ unsigned char *defTwmrc[] = {
(unsigned char *) " IconBorderColor \"gray85\"",
(unsigned char *) "}",
(unsigned char *) "",
(unsigned char *) "MoveDelta 3",
(unsigned char *) "Function \"move-or-lower\" { f.move f.deltastop f.lower }",
(unsigned char *) "Function \"move-or-raise\" { f.move f.deltastop f.raise }",
(unsigned char *) "Function \"move-or-iconify\" { f.move f.deltastop f.iconify }",
(unsigned char *) "",
(unsigned char *) "Button1 = : root : f.menu \"defops\"",
(unsigned char *) "",
(unsigned char *) "Button1 = m : window|icon : f.function \"move-or-lower\"",
(unsigned char *) "Button1 = m : window|icon : f.move-or-lower",
(unsigned char *) "Button2 = m : window|icon : f.iconify",
(unsigned char *) "Button3 = m : window|icon : f.function \"move-or-raise\"",
(unsigned char *) "Button3 = m : window|icon : f.move-or-raise",
(unsigned char *) "",
(unsigned char *) "Button1 = : title : f.function \"move-or-raise\"",
(unsigned char *) "Button1 = : title : f.move-or-raise",
(unsigned char *) "Button2 = : title : f.raiselower",
(unsigned char *) "",
(unsigned char *) "Button1 = : icon : f.function \"move-or-iconify\"",
(unsigned char *) "Button1 = : icon : f.move-or-iconify",
(unsigned char *) "Button2 = : icon : f.iconify",
(unsigned char *) "",
(unsigned char *) "menu \"defops\"",

View File

@ -1426,8 +1426,8 @@ HandleMotionNotify(void)
/* Set WindowMoved appropriately so that f.deltastop will
work with resize as well as move. */
if (abs (Event.xmotion.x - ResizeOrigX) >= Scr->MoveDelta
|| abs (Event.xmotion.y - ResizeOrigY) >= Scr->MoveDelta)
if (abs (Event.xmotion.x - ResizeOrigX) >= MOVEDELTA
|| abs (Event.xmotion.y - ResizeOrigY) >= MOVEDELTA)
WindowMoved = TRUE;
if (XFindContext(dpy, ResizeWindow, TwmContext, &context_data) == 0)

View File

@ -70,6 +70,8 @@ in this Software without prior written authorization from The Open Group.
#define EXTERN extern
#endif
#define MOVEDELTA 3
typedef void (*event_proc)(void);
extern Time lastTimestamp;

231
src/lex.c
View File

@ -7,8 +7,8 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 0
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@ -53,7 +53,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@ -84,6 +83,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@ -140,7 +141,15 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@ -152,7 +161,12 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
extern int yyleng;
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t yyleng;
extern FILE *yyin, *yyout;
@ -161,6 +175,7 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
@ -178,11 +193,6 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@ -200,7 +210,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
int yy_n_chars;
yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@ -270,8 +280,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int yyleng;
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@ -299,7 +309,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@ -342,11 +352,17 @@ extern int yylineno;
int yylineno = 1;
extern char *yytext;
#ifdef yytext_ptr
#undef yytext_ptr
#endif
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
#if defined(__GNUC__) && __GNUC__ >= 3
__attribute__((__noreturn__))
#endif
static void yy_fatal_error (yyconst char msg[] );
/* Done after the current pattern has been matched and before the
@ -376,7 +392,7 @@ static yyconst flex_int16_t yy_accept[33] =
0, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
static yyconst YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
@ -408,18 +424,18 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[20] =
static yyconst YY_CHAR yy_meta[20] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1
} ;
static yyconst flex_int16_t yy_base[36] =
static yyconst flex_uint16_t yy_base[36] =
{ 0,
0, 0, 39, 58, 58, 58, 58, 15, 35, 58,
58, 58, 58, 26, 24, 58, 58, 58, 58, 58,
58, 16, 58, 29, 26, 58, 17, 15, 18, 20,
42, 58, 25, 23, 21
0, 0, 43, 62, 62, 62, 62, 15, 39, 62,
62, 62, 11, 13, 28, 62, 62, 62, 62, 62,
62, 20, 62, 33, 34, 62, 16, 22, 24, 26,
46, 62, 32, 31, 27
} ;
static yyconst flex_int16_t yy_def[36] =
@ -430,28 +446,30 @@ static yyconst flex_int16_t yy_def[36] =
35, 0, 32, 32, 32
} ;
static yyconst flex_int16_t yy_nxt[78] =
static yyconst flex_uint16_t yy_nxt[82] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 4, 18, 19, 20, 21, 23,
23, 29, 23, 25, 23, 22, 28, 27, 26, 24,
24, 22, 24, 30, 24, 28, 27, 26, 32, 32,
32, 32, 32, 31, 22, 32, 30, 32, 32, 32,
32, 32, 32, 32, 32, 32, 31, 3, 32, 32,
27, 27, 27, 27, 23, 27, 27, 29, 23, 24,
23, 25, 22, 28, 24, 22, 26, 30, 24, 28,
24, 26, 32, 32, 32, 32, 32, 31, 22, 32,
30, 32, 32, 32, 32, 32, 32, 32, 32, 32,
31, 3, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32
32
} ;
static yyconst flex_int16_t yy_chk[78] =
static yyconst flex_int16_t yy_chk[82] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 8,
22, 35, 29, 34, 30, 33, 28, 27, 25, 8,
22, 24, 29, 24, 30, 15, 14, 9, 3, 0,
0, 0, 0, 24, 31, 0, 31, 0, 0, 0,
0, 0, 0, 0, 0, 0, 31, 32, 32, 32,
13, 13, 14, 14, 22, 27, 27, 35, 29, 8,
30, 34, 33, 28, 22, 24, 25, 24, 29, 15,
30, 9, 3, 0, 0, 0, 0, 24, 31, 0,
31, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32
32
} ;
static yy_state_type yy_last_accepting_state;
@ -559,7 +577,7 @@ static int doinput (char *buf, int size)
#define YY_NO_UNPUT
#endif
#line 563 "lex.c"
#line 581 "lex.c"
#define INITIAL 0
@ -592,19 +610,19 @@ void yyset_extra (YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
void yyset_in (FILE * in_str );
void yyset_in (FILE * _in_str );
FILE *yyget_out (void );
void yyset_out (FILE * out_str );
void yyset_out (FILE * _out_str );
int yyget_leng (void );
yy_size_t yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
void yyset_lineno (int line_number );
void yyset_lineno (int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -618,8 +636,12 @@ extern int yywrap (void );
#endif
#endif
#ifndef YY_NO_UNPUT
static void yyunput (int c,char *buf_ptr );
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
@ -640,7 +662,12 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@ -648,7 +675,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
#define ECHO fwrite( yytext, yyleng, 1, yyout )
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@ -659,7 +686,7 @@ static int input (void );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
int n; \
size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@ -727,7 +754,7 @@ extern int yylex (void);
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK break;
#define YY_BREAK /*LINTED*/break;
#endif
#define YY_RULE_SETUP \
@ -737,14 +764,10 @@ extern int yylex (void);
*/
YY_DECL
{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
#line 95 "lex.l"
#line 747 "lex.c"
if ( !(yy_init) )
{
(yy_init) = 1;
@ -771,7 +794,12 @@ YY_DECL
yy_load_buffer_state( );
}
while ( 1 ) /* loops until end-of-file is reached */
{
#line 95 "lex.l"
#line 801 "lex.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
@ -787,7 +815,7 @@ YY_DECL
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -802,7 +830,7 @@ yy_match:
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 58 );
while ( yy_base[yy_current_state] != 62 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@ -937,7 +965,7 @@ YY_RULE_SETUP
#line 134 "lex.l"
ECHO;
YY_BREAK
#line 941 "lex.c"
#line 969 "lex.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -1068,6 +1096,7 @@ case YY_STATE_EOF(INITIAL):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
@ -1079,9 +1108,9 @@ case YY_STATE_EOF(INITIAL):
*/
static int yy_get_next_buffer (void)
{
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = (yytext_ptr);
register int number_to_move, i;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
yy_size_t number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@ -1110,7 +1139,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@ -1123,21 +1152,21 @@ static int yy_get_next_buffer (void)
else
{
int num_to_read =
yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
int new_size = b->yy_buf_size * 2;
yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -1168,7 +1197,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), (size_t) num_to_read );
(yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@ -1213,14 +1242,14 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_get_previous_state (void)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_state_type yy_current_state;
char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1245,10 +1274,10 @@ static int yy_get_next_buffer (void)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
register int yy_is_jam;
register char *yy_cp = (yy_c_buf_p);
int yy_is_jam;
char *yy_cp = (yy_c_buf_p);
register YY_CHAR yy_c = 1;
YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -1263,12 +1292,14 @@ static int yy_get_next_buffer (void)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 32);
return yy_is_jam ? 0 : yy_current_state;
return yy_is_jam ? 0 : yy_current_state;
}
static void yyunput (int c, register char * yy_bp )
#ifndef YY_NO_UNPUT
static void yyunput (int c, char * yy_bp )
{
register char *yy_cp;
char *yy_cp;
yy_cp = (yy_c_buf_p);
@ -1278,10 +1309,10 @@ static int yy_get_next_buffer (void)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
yy_size_t number_to_move = (yy_n_chars) + 2;
char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
char *source =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
@ -1303,6 +1334,8 @@ static int yy_get_next_buffer (void)
(yy_c_buf_p) = yy_cp;
}
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
@ -1327,7 +1360,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
int offset = (yy_c_buf_p) - (yytext_ptr);
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@ -1452,7 +1485,7 @@ static void yy_load_buffer_state (void)
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = size;
b->yy_buf_size = (yy_size_t)size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
@ -1487,10 +1520,6 @@ static void yy_load_buffer_state (void)
yyfree((void *) b );
}
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
@ -1603,7 +1632,7 @@ void yypop_buffer_state (void)
*/
static void yyensure_buffer_stack (void)
{
int num_to_alloc;
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@ -1611,7 +1640,7 @@ static void yyensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1;
num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
@ -1628,7 +1657,7 @@ static void yyensure_buffer_stack (void)
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */;
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@ -1695,17 +1724,17 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param bytes the byte buffer to scan
* @param len the number of bytes in the buffer pointed to by @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@ -1736,7 +1765,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
static void yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@ -1787,7 +1816,7 @@ FILE *yyget_out (void)
/** Get the length of the current token.
*
*/
int yyget_leng (void)
yy_size_t yyget_leng (void)
{
return yyleng;
}
@ -1802,29 +1831,29 @@ char *yyget_text (void)
}
/** Set the current line number.
* @param line_number
* @param _line_number line number
*
*/
void yyset_lineno (int line_number )
void yyset_lineno (int _line_number )
{
yylineno = line_number;
yylineno = _line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param in_str A readable stream.
* @param _in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * in_str )
void yyset_in (FILE * _in_str )
{
yyin = in_str ;
yyin = _in_str ;
}
void yyset_out (FILE * out_str )
void yyset_out (FILE * _out_str )
{
yyout = out_str ;
yyout = _out_str ;
}
int yyget_debug (void)
@ -1832,9 +1861,9 @@ int yyget_debug (void)
return yy_flex_debug;
}
void yyset_debug (int bdebug )
void yyset_debug (int _bdebug )
{
yy_flex_debug = bdebug ;
yy_flex_debug = _bdebug ;
}
static int yy_init_globals (void)
@ -1894,7 +1923,8 @@ int yylex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
register int i;
int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@ -1903,7 +1933,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
register int n;
int n;
for ( n = 0; s[n]; ++n )
;
@ -1913,11 +1943,12 @@ static int yy_flex_strlen (yyconst char * s )
void *yyalloc (yy_size_t size )
{
return (void *) malloc( size );
return (void *) malloc( size );
}
void *yyrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@ -1930,7 +1961,7 @@ void *yyrealloc (void * ptr, yy_size_t size )
void yyfree (void * ptr )
{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"

View File

@ -103,7 +103,7 @@ number [0-9]+
"-" { return MINUS; }
"|" { return OR; }
[a-zA-Z\.]+ { int token = parse_keyword ((char *)yytext,
[a-zA-Z\.-]+ { int token = parse_keyword ((char *)yytext,
&yylval.num);
if (token == ERRORTOKEN) {
twmrc_error_prefix();

View File

@ -88,7 +88,6 @@ in this Software without prior written authorization from The Open Group.
constexpr Pixel UNUSED_PIXEL{~0UL};
const int SHADOWWIDTH{5}; /* in pixels */
int RootFunction{0};
MenuRoot *ActiveMenu{nullptr}; /**< the active menu */
MenuItem *ActiveItem{nullptr}; /**< the active menu item */
@ -1270,7 +1269,6 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
{
case F_NOP:
case F_TITLE:
case F_DELTASTOP:
case F_RAISELOWER:
case F_WARPTOSCREEN:
case F_WARPTO:
@ -1293,10 +1291,6 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_TITLE:
break;
case F_DELTASTOP:
if (WindowMoved) do_next_action = FALSE;
break;
case F_RESTART:
{
XSync (dpy, 0);
@ -1422,6 +1416,9 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_MOVE:
case F_FORCEMOVE:
case F_MOVE_OR_ICONIFY:
case F_MOVE_OR_LOWER:
case F_MOVE_OR_RAISE:
if (DeferExecution(context, func, Scr->MoveCursor))
return true;
@ -1500,29 +1497,6 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
last_time = eventp->xbutton.time;
InstallRootColormap();
if (!Scr->MoveDelta)
{
/*
* Draw initial outline. This was previously done the
* first time though the outer loop by dropping out of
* the XCheckMaskEvent inner loop down to one of the
* MoveOutline's below.
*/
MoveOutline(rootw,
origDragX - JunkBW, origDragY - JunkBW,
DragWidth + 2 * JunkBW, DragHeight + 2 * JunkBW,
tmp_win->frame_bw,
moving_icon ? 0 : tmp_win->title_height);
/*
* This next line causes HandleReleaseNotify to call
* XRaiseWindow(). This is solely to preserve the
* previous behaviour that raises a window being moved
* on button release even if you never actually moved
* any distance (unless you move less than MoveDelta or
* NoRaiseMove is set).
*/
DragWindow = w;
}
/*
* see if this is being done from the titlebar
@ -1590,10 +1564,30 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
if (Event.type == releaseEvent)
{
MoveOutline(rootw, 0, 0, 0, 0, 0, 0);
if (!WindowMoved) {
if (MoveFunction == F_MOVE_OR_ICONIFY
&& moving_icon) {
ExecuteFunction(F_DEICONIFY, action, w, tmp_win,
eventp, context, pulldown);
break;
}
if (MoveFunction == F_MOVE_OR_RAISE) {
ExecuteFunction(F_RAISE, action, w, tmp_win,
eventp, context, pulldown);
break;
}
if (MoveFunction == F_MOVE_OR_LOWER) {
ExecuteFunction(F_LOWER, action, w, tmp_win,
eventp, context, pulldown);
break;
}
}
if (moving_icon &&
((CurrentDragX != origDragX ||
CurrentDragY != origDragY)))
tmp_win->icon_moved = TRUE;
if (menuFromFrameOrWindowOrTitlebar)
XMoveWindow(dpy, DragWindow,
Event.xbutton.x_root - DragWidth / 2,
@ -1610,8 +1604,8 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
&JunkX, &JunkY, &JunkMask);
if (DragWindow == None &&
abs(eventp->xmotion.x_root - origX) < Scr->MoveDelta &&
abs(eventp->xmotion.y_root - origY) < Scr->MoveDelta)
abs(eventp->xmotion.x_root - origX) < MOVEDELTA &&
abs(eventp->xmotion.y_root - origY) < MOVEDELTA)
continue;
WindowMoved = true;
@ -1710,11 +1704,9 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
tmp_win->frame_bw,
moving_icon ? 0 : tmp_win->title_height);
}
}
MovedFromKeyPress = False;
if (DragWindow == None)
UninstallRootColormap();

View File

@ -335,7 +335,6 @@ typedef struct _TwmKeyword {
#define kws_MaxWindowSize 9
#define kwn_ConstrainedMoveTime 1
#define kwn_MoveDelta 2
#define kwn_XorValue 3
#define kwn_FramePadding 4
#define kwn_ButtonIndent 6
@ -363,9 +362,9 @@ typedef struct _TwmKeyword {
/*
* The following is sorted alphabetically according to name (which must be
* in lowercase and only contain the letters a-z). It is fed to a binary
* search to parse keywords.
* The following is sorted alphabetically according to name (which
* must be in lowercase). It is fed to a binary search to parse
* keywords.
*/
static TwmKeyword keytable[] = {
{ "all", ALL, 0 },
@ -400,7 +399,6 @@ static TwmKeyword keytable[] = {
{ "f.cutfile", FKEYWORD, F_CUTFILE },
{ "f.deiconify", FKEYWORD, F_DEICONIFY },
{ "f.delete", FKEYWORD, F_DELETE },
{ "f.deltastop", FKEYWORD, F_DELTASTOP },
{ "f.destroy", FKEYWORD, F_DESTROY },
{ "f.exec", FSKEYWORD, F_EXEC },
{ "f.file", FSKEYWORD, F_FILE },
@ -418,6 +416,9 @@ static TwmKeyword keytable[] = {
{ "f.lower", FKEYWORD, F_LOWER },
{ "f.menu", FSKEYWORD, F_MENU },
{ "f.move", FKEYWORD, F_MOVE },
{ "f.move-or-iconify", FKEYWORD, F_MOVE_OR_ICONIFY },
{ "f.move-or-lower", FKEYWORD, F_MOVE_OR_LOWER },
{ "f.move-or-raise", FKEYWORD, F_MOVE_OR_RAISE },
{ "f.nop", FKEYWORD, F_NOP },
{ "f.priority", FSKEYWORD, F_PRIORITY },
{ "f.quit", FKEYWORD, F_QUIT },
@ -478,7 +479,6 @@ static TwmKeyword keytable[] = {
{ "mod", META, 0 }, /* fake it */
{ "monochrome", MONOCHROME, 0 },
{ "move", MOVE, 0 },
{ "movedelta", NKEYWORD, kwn_MoveDelta },
{ "nobackingstore", KEYWORD, kw0_NoBackingStore },
{ "nodefaults", KEYWORD, kw0_NoDefaults },
{ "nomenushadows", KEYWORD, kw0_NoMenuShadows },
@ -525,17 +525,17 @@ static TwmKeyword keytable[] = {
{ "xorvalue", NKEYWORD, kwn_XorValue },
};
static int numkeywords = (sizeof(keytable)/sizeof(keytable[0]));
const int numkeywords = (sizeof(keytable)/sizeof(keytable[0]));
int parse_keyword (char *s, int *nump)
int parse_keyword(char *s, int *nump)
{
register int lower = 0, upper = numkeywords - 1;
XmuCopyISOLatin1Lowered (s, s);
XmuCopyISOLatin1Lowered(s, s);
while (lower <= upper) {
int middle = (lower + upper) / 2;
TwmKeyword *p = &keytable[middle];
int res = strcmp (p->name, s);
int res = strcmp(p->name, s);
if (res < 0) {
lower = middle + 1;
@ -680,17 +680,13 @@ int do_string_keyword (int keyword, char *s)
}
int do_number_keyword (int keyword, int num)
int do_number_keyword(int keyword, int num)
{
switch (keyword) {
case kwn_ConstrainedMoveTime:
ConstrainedMoveTime = num;
return 1;
case kwn_MoveDelta:
Scr->MoveDelta = num;
return 1;
case kwn_XorValue:
if (Scr->FirstTime) Scr->XORvalue = num;
return 1;

View File

@ -119,6 +119,9 @@ extern int mods;
#define F_CUTFILE 43
#define F_SHOWLIST 44
#define F_HIDELIST 45
#define F_MOVE_OR_ICONIFY 46
#define F_MOVE_OR_LOWER 47
#define F_MOVE_OR_RAISE 48
#define F_MENU 101 /* string */
#define F_WARPNEXT 112 /* string */

View File

@ -204,7 +204,6 @@ typedef struct ScreenInfo
short BackingStore; /* use backing store for menus */
short SaveUnder; /* use save under's for menus */
short StackMode; /* should we honor stack mode requests */
short MoveDelta; /* number of pixels before f.move starts */
short Shadow; /* show the menu shadow */
short InterpolateMenuColors;/* make pretty menus */
short HaveFonts; /* set if fonts have been loaded */

View File

@ -32,27 +32,19 @@ Color
IconBorderColor "gray85"
}
#
# Define some useful functions for motion-based actions.
#
MoveDelta 3
Function "move-or-lower" { f.move f.deltastop f.lower }
Function "move-or-raise" { f.move f.deltastop f.raise }
Function "move-or-iconify" { f.move f.deltastop f.iconify }
#
# Set some useful bindings. Sort of uwm-ish, sort of simple-button-ish
#
Button1 = : root : f.menu "defops"
Button1 = m : window|icon : f.function "move-or-lower"
Button1 = m : window|icon : f.move-or-lower
Button2 = m : window|icon : f.iconify
Button3 = m : window|icon : f.function "move-or-raise"
Button3 = m : window|icon : f.move-or-raise
Button1 = : title : f.function "move-or-raise"
Button1 = : title : f.move-or-raise
Button2 = : title : f.raiselower
Button1 = : icon : f.function "move-or-iconify"
Button1 = : icon : f.move-or-iconify
Button2 = : icon : f.iconify
#

View File

@ -714,7 +714,6 @@ InitVariables(void)
Scr->BackingStore = TRUE;
Scr->SaveUnder = TRUE;
Scr->StackMode = TRUE;
Scr->MoveDelta = 1; /* so that f.deltastop will work */
Scr->Shadow = TRUE;
Scr->InterpolateMenuColors = FALSE;
Scr->FirstTime = TRUE;