-// Callback for cursor timer
-void BufferView::cursorToggleCB(FL_OBJECT * ob, long)
-{
- BufferView * view = static_cast<BufferView*>(ob->u_vdata);
-
- // Quite a nice place for asyncron Inset updating, isn't it?
- // Actually no! This is run even if no buffer exist... so (Lgb)
- if (view && !view->pimpl_->buffer_) {
- goto set_timer_and_return;
- }
-
- // NOTE:
- // On my quest to solve the gs render hangups I am now
- // disabling the SIGHUP completely, and will do a wait
- // now and then instead. If the guess that xforms somehow
- // destroys something is true, this is likely (hopefully)
- // to solve the problem...at least I hope so. Lgb
-
- // ...Ok this seems to work...at least it does not make things
- // worse so far. However I still see gs processes that hangs.
- // I would really like to know _why_ they are hanging. Anyway
- // the solution without the SIGCHLD handler seems to be easier
- // to debug.
-
- // When attaching gdb to a a running gs that hangs it shows
- // that it is waiting for input(?) Is it possible for us to
- // provide that input somehow? Or figure what it is expecing
- // to read?
-
- // One solution is to, after some time, look if there are some
- // old gs processes still running and if there are: kill them
- // and re render.
-
- // Another solution is to provide the user an option to rerender
- // a picture. This would, for the picture in question, check if
- // there is a gs running for it, if so kill it, and start a new
- // rendering process.
-
- // these comments posted to lyx@via
- {
- int status = 1;
- int pid = waitpid(static_cast<pid_t>(0), &status, WNOHANG);
- if (pid == -1) // error find out what is wrong
- ; // ignore it for now.
- else if (pid > 0)
- sigchldhandler(pid, &status);
- }
-
- view->pimpl_->updatelist.update(view);
-
- if (view && !view->pimpl_->screen) {
- goto set_timer_and_return;
- }
-
- if (view->pimpl_->lyx_focus && view->pimpl_->work_area_focus) {
- if (!view->the_locking_inset) {
- view->pimpl_->screen->CursorToggle();
- } else {
- view->the_locking_inset->
- ToggleInsetCursor(view);
- }
- goto set_timer_and_return;
- } else {
- // Make sure that the cursor is visible.
- if (!view->the_locking_inset) {
- view->pimpl_->screen->ShowCursor();
- } else {
- if (!view->the_locking_inset->isCursorVisible())
- view->the_locking_inset->
- ToggleInsetCursor(view);
- }
- // This is only run when work_area_focus or lyx_focus is false.
- Window tmpwin;
- int tmp;
- XGetInputFocus(fl_display, &tmpwin, &tmp);
- // Commenting this out, we have not had problems with this
- // for a long time. We will probably work on this code later
- // and we can reenable this debug code then. Now it only
- // anoying when debugging. (Lgb)
- //if (lyxerr.debugging(Debug::INFO)) {
- // lyxerr << "tmpwin: " << tmpwin
- // << "\nwindow: " << view->owner_->getForm()->window
- // << "\nwork_area_focus: " << view->work_area_focus
- // << "\nlyx_focus : " << view->lyx_focus
- // << endl;
- //}
- if (tmpwin != view->pimpl_->owner_->getForm()->window) {
- view->pimpl_->lyx_focus = false;
- goto skip_timer;
- } else {
- view->pimpl_->lyx_focus = true;
- if (!view->pimpl_->work_area_focus)
- goto skip_timer;
- else
- goto set_timer_and_return;
- }
- }
-
- set_timer_and_return:
- fl_set_timer(ob, 0.4);
- skip_timer:
- return;
-}
-
-
-void BufferView::workAreaSelectionNotify(Window win, XEvent * event)
-{
- pimpl_->workAreaSelectionNotify(win, event);
-}
-
-
-void BufferView::cursorPrevious()
-{
- if (!text->cursor.row->previous) return;
-
- long y = pimpl_->screen->first;
- Row * cursorrow = text->cursor.row;
- text->SetCursorFromCoordinates(text->cursor.x_fix, y);
- text->FinishUndo();
- // This is to allow jumping over large insets
- if ((cursorrow == text->cursor.row))
- text->CursorUp();
-
- if (text->cursor.row->height < pimpl_->workarea->height())
- pimpl_->screen->Draw(text->cursor.y
- - text->cursor.row->baseline
- + text->cursor.row->height
- - pimpl_->workarea->height() + 1 );
-}
-
-
-void BufferView::cursorNext()
-{
- if (!text->cursor.row->next) return;
-
- long y = pimpl_->screen->first;
- text->GetRowNearY(y);
- Row * cursorrow = text->cursor.row;
- text->SetCursorFromCoordinates(text->cursor.x_fix, y
- + pimpl_->workarea->height());
- text->FinishUndo();
- // This is to allow jumping over large insets
- if ((cursorrow == text->cursor.row))
- text->CursorDown();
-
- if (text->cursor.row->height < pimpl_->workarea->height())
- pimpl_->screen->Draw(text->cursor.y
- - text->cursor.row->baseline);