From 72db8e927d0b53bb405e8157af1e5eeebb7f9231 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 5 Jun 2001 22:08:31 +0000 Subject: [PATCH] * key.c [HAVE_TEXTMODE_X11_SUPPORT]: Rename `display' to `x11_display' and `w' to `x11_window'. Make them static. (init_textmode_x11_support): Include into init_key(). (done_textmode_x11_support): Include into done_key(). (k_dispose): Make static. (s_dispose): Likewise. * key.h: Remove init_textmode_x11_support() and done_textmode_x11_support(). * main.c: Don't call init_textmode_x11_support() and done_textmode_x11_support(). --- src/ChangeLog | 11 +++++++++++ src/key.c | 47 ++++++++++++++++++----------------------------- src/key.h | 2 -- src/main.c | 8 -------- 4 files changed, 29 insertions(+), 39 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 363d45e46..a357d23d7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,16 @@ 2001-06-05 Pavel Roskin + * key.c [HAVE_TEXTMODE_X11_SUPPORT]: Rename `display' to + `x11_display' and `w' to `x11_window'. Make them static. + (init_textmode_x11_support): Include into init_key(). + (done_textmode_x11_support): Include into done_key(). + (k_dispose): Make static. + (s_dispose): Likewise. + * key.h: Remove init_textmode_x11_support() and + done_textmode_x11_support(). + * main.c: Don't call init_textmode_x11_support() and + done_textmode_x11_support(). + * achown.c: Make global variables static if possible. Remove now useless preprocessor directives, since this file is now used in the text edition only. diff --git a/src/key.c b/src/key.c index 8d066578a..8fcf5ee6b 100644 --- a/src/key.c +++ b/src/key.c @@ -223,17 +223,9 @@ define_sequences (key_define_t *kd) } #ifdef HAVE_TEXTMODE_X11_SUPPORT -Display *display; -Window w; - -void -init_textmode_x11_support (void) -{ - display = XOpenDisplay (0); - if (display) - w = DefaultRootWindow (display); -} -#endif +static Display *x11_display; +static Window x11_window; +#endif /* HAVE_TEXTMODE_X11_SUPPORT */ /* This has to be called before slang_init or whatever routine calls any define_sequence */ @@ -272,6 +264,12 @@ void init_key (void) use_8th_bit_as_meta = 0; } #endif /* __QNX__ */ + +#ifdef HAVE_TEXTMODE_X11_SUPPORT + x11_display = XOpenDisplay (0); + if (x11_display) + x11_window = DefaultRootWindow (x11_display); +#endif /* HAVE_TEXTMODE_X11_SUPPORT */ } /* This has to be called after SLang_init_tty/slint_init */ @@ -943,7 +941,7 @@ int get_modifier (void) { #ifdef HAVE_TEXTMODE_X11_SUPPORT - if (display) { + if (x11_display) { Window root, child; int root_x, root_y; int win_x, win_y; @@ -951,7 +949,7 @@ get_modifier (void) Bool b; int result = 0; - b = XQueryPointer(display, w, &root, &child, + b = XQueryPointer(x11_display, x11_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); @@ -990,8 +988,7 @@ ctrl_pressed () } #ifdef HAVE_MAD - -void k_dispose (key_def *k) +static void k_dispose (key_def *k) { if (!k) return; @@ -1000,7 +997,7 @@ void k_dispose (key_def *k) g_free (k); } -void s_dispose (SelectList *sel) +static void s_dispose (SelectList *sel) { if (!sel) return; @@ -1008,25 +1005,17 @@ void s_dispose (SelectList *sel) s_dispose (sel->next); g_free (sel); } +#endif /* HAVE_MAD */ void done_key () { +#ifdef HAVE_MAD k_dispose (keys); s_dispose (select_list); -} - -#else -void done_key () -{ -} - #endif /* HAVE_MAD */ #ifdef HAVE_TEXTMODE_X11_SUPPORT -void -done_textmode_x11_support (void) -{ - if (display) - XCloseDisplay (display); -} + if (x11_display) + XCloseDisplay (x11_display); #endif /* HAVE_TEXTMODE_X11_SUPPORT */ +} diff --git a/src/key.h b/src/key.h index 1f517cf6f..558f1c14b 100644 --- a/src/key.h +++ b/src/key.h @@ -4,8 +4,6 @@ void init_key (void); void init_key_input_fd (void); void done_key (void); -void init_textmode_x11_support (void); -void done_textmode_x11_support (void); int get_event (Gpm_Event *event, int redo_event, int block); int is_idle (void); diff --git a/src/main.c b/src/main.c index 2981a6d3d..bf8668ef7 100644 --- a/src/main.c +++ b/src/main.c @@ -3051,10 +3051,6 @@ main (int argc, char *argv []) calls any define_sequence */ init_key (); -#ifdef HAVE_TEXTMODE_X11_SUPPORT - init_textmode_x11_support (); -#endif - handle_args (argc, argv); #endif /* HAVE_X */ @@ -3244,10 +3240,6 @@ main (int argc, char *argv []) done_key (); #endif -#if defined (HAVE_TEXTMODE_X11_SUPPORT) && !defined (HAVE_X) - done_textmode_x11_support (); -#endif - mad_finalize (__FILE__, __LINE__); #ifdef HAVE_X xtoolkit_end ();