X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXView.C;h=86316604667a70e7a74d9ada5f8c7166bf83f22c;hb=91a2ea274e9c27f571a3cd4798d2e8ecc1b982a7;hp=129aec0e009ac05626c7908c5713cfcadfe2a83d;hpb=5f3f9ad231bc0c24d34c00e3936e226d9834589a;p=lyx.git diff --git a/src/LyXView.C b/src/LyXView.C index 129aec0e00..8631660466 100644 --- a/src/LyXView.C +++ b/src/LyXView.C @@ -5,7 +5,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. + * Copyright 1995-2000 The LyX Team. * * ====================================================== */ @@ -15,6 +15,9 @@ #pragma implementation #endif +#include +#include + #include "LyXView.h" #include "lyx_main.h" #include "lyxlookup.h" @@ -26,7 +29,6 @@ #include "layout_forms.h" #include "intl.h" #include "lyxrc.h" -#include "lyxscreen.h" #include "support/filetools.h" // OnlyFilename() #include "layout.h" #include "lyxtext.h" @@ -36,7 +38,7 @@ extern FD_form_document * fd_form_document; extern void AutoSave(); extern char updatetimer; extern void QuitLyX(); -int current_layout = 0; +LyXTextClass::size_type current_layout = 0; // This is very temporary BufferView * current_view; @@ -78,10 +80,10 @@ void LyXView::UpdateTimerCB(FL_OBJECT * ob, long) LyXView * view = static_cast(ob->u_vdata); if (!view->view()->available()) return; - if (!view->view()->getScreen() || !updatetimer) + if (!updatetimer) return; - view->view()->getScreen()->HideCursor(); + view->view()->hideCursor(); view->view()->update(-2); /* This update can happen, even when the work area has lost @@ -115,8 +117,8 @@ extern "C" void C_LyXView_AutosaveTimerCB(FL_OBJECT * ob, long data) /// Reset autosave timer void LyXView::resetAutosaveTimer() { - if (lyxrc->autosave) - fl_set_timer(_form_main->timer_autosave, lyxrc->autosave); + if (lyxrc.autosave) + fl_set_timer(_form_main->timer_autosave, lyxrc.autosave); } @@ -183,7 +185,7 @@ void LyXView::create_form_form_main(int width, int height) // TOOLBAR // - toolbar = new Toolbar(lyxrc->toolbar, this, air, 30 + air + bw); + toolbar = new Toolbar(this, air, 30 + air + bw); // Setup the toolbar toolbar->set(true); @@ -255,15 +257,15 @@ void LyXView::init() UpdateDocumentClassChoice(); // Start autosave timer - if (lyxrc->autosave) - fl_set_timer(_form_main->timer_autosave, lyxrc->autosave); + if (lyxrc.autosave) + fl_set_timer(_form_main->timer_autosave, lyxrc.autosave); // Install the raw callback for keyboard events fl_register_raw_callback(_form, KeyPressMask, C_LyXView_KeyPressMask_raw_callback); - intl->InitKeyMapper(lyxrc->use_kbmap); + intl->InitKeyMapper(lyxrc.use_kbmap); } @@ -304,7 +306,7 @@ void LyXView::updateLayoutChoice() // we need to do this. toolbar->combox->Redraw(); - char layout = bufferview->text->cursor.par->GetLayout(); + LyXTextClass::size_type layout = bufferview->text->cursor.par->GetLayout(); if (layout != current_layout){ toolbar->combox->select(layout + 1); @@ -334,14 +336,50 @@ int LyXView::KeyPressMask_raw_callback(FL_FORM * fl, void * xev) LyXView * view = static_cast(fl->u_vdata); int retval = 0; // 0 means XForms should have a look at this event + XKeyEvent * xke = static_cast(xev); + static Time last_time_pressed = 0; + static Time last_time_released = 0; + static unsigned int last_key_pressed = 0; + static unsigned int last_key_released = 0; + static unsigned int last_state_pressed = 0; + static unsigned int last_state_released = 0; + // funny. Even though the raw_callback is registered with KeyPressMask, // also KeyRelease-events are passed through:-( // [It seems that XForms puts them in pairs... (JMarc)] if (static_cast(xev)->type == KeyPress - && view->bufferview->getWorkArea()->focus - && view->bufferview->getWorkArea()->active) + && view->bufferview->focus() + && view->bufferview->active()) + { + last_time_pressed = xke->time; + last_key_pressed = xke->keycode; + last_state_pressed = xke->state; retval = view->getLyXFunc() ->processKeyEvent(static_cast(xev)); + } + else if (static_cast(xev)->type == KeyRelease + && view->bufferview->focus() + && view->bufferview->active()) +{ + last_time_released = xke->time; + last_key_released = xke->keycode; + last_state_released = xke->state; + } + + if (last_key_released == last_key_pressed + && last_state_released == last_state_pressed + && last_time_released == last_time_pressed) { + // When the diff between last_time_released and + // last_time_pressed is 0, that sinifies an autoreapeat + // at least on my system. It like some feedback from + // others, especially from user running LyX remote. + //lyxerr << "Syncing - purging X events." << endl; + XSync(fl_get_display(), 1); + // This purge make f.ex. scrolling stop imidiatly when + // releaseing the PageDown button. The question is if this + // purging of XEvents can cause any harm...after some testing + // I can see no problems, but I'd like other reports too. + } return retval; }