From 61fc3710932a0ef5f93a0fbefa6c1cfd43654702 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 11 Jul 2002 15:09:45 +0000 Subject: [PATCH] redraw fix 1. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4605 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 3 +-- src/ChangeLog | 4 ++++ src/frontends/xforms/ChangeLog | 5 ++++ src/frontends/xforms/XWorkArea.C | 39 ++++++++++++++++++++------------ src/frontends/xforms/XWorkArea.h | 19 ++++++++-------- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 95bf55f1d7..f2a70a68db 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -929,8 +929,7 @@ void BufferView::Pimpl::workAreaResize() } } - // FIXME: GUII temporarily we always repaint for xforms' benefit - if (1 || widthChange || heightChange) { + if (widthChange || heightChange) { repaint(); } diff --git a/src/ChangeLog b/src/ChangeLog index 0d826b97c3..134668eb67 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2002-07-11 John Levon + + * BufferView_pimpl.C: remove unneeded extra repaint() + 2002-07-10 John Levon * LyXAction.C: allow command-sequence with NoBuffer diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 06af1bf7d7..c5656a15b8 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-07-11 John Levon + + * XWorkArea.h: + * XWorkArea.C: do a copy area on redraw when no geometry change + 2002-07-11 Herbert Voss * FormGraphics.C (input): test also the height for %-value, when diff --git a/src/frontends/xforms/XWorkArea.C b/src/frontends/xforms/XWorkArea.C index 3468047595..b11948732f 100644 --- a/src/frontends/xforms/XWorkArea.C +++ b/src/frontends/xforms/XWorkArea.C @@ -61,7 +61,6 @@ void setXtermCursor(Window win) } -// FIXME ! mouse_button::state x_button_state(unsigned int button) { mouse_button::state b = mouse_button::none; @@ -88,7 +87,6 @@ mouse_button::state x_button_state(unsigned int button) } -// FIXME mouse_button::state x_motion_state(unsigned int state) { mouse_button::state b = mouse_button::none; @@ -182,7 +180,7 @@ XWorkArea::XWorkArea(int x, int y, int w, int h) int const bw = int(abs(fl_get_border_width())); // Create the workarea pixmap - createPixmap(w - 15 - 2 * bw, h - 2 * bw); + // FIXME remove redraw(w - 15 - 2 * bw, h - 2 * bw); if (lyxerr.debugging(Debug::WORKAREA)) lyxerr << "\tfree object: +" @@ -210,11 +208,18 @@ XWorkArea::XWorkArea(int x, int y, int w, int h) fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_XWorkAreaEventCB); fl_unfreeze_all_forms(); + + XGCValues val; + + val.function = GXcopy; + copy_gc = XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0), + GCFunction, &val); } XWorkArea::~XWorkArea() { + XFreeGC(fl_get_display(), copy_gc); if (workareapixmap) XFreePixmap(fl_get_display(), workareapixmap); } @@ -235,31 +240,37 @@ void destroy_object(FL_OBJECT * obj) } // namespace anon -void XWorkArea::createPixmap(int width, int height) +void XWorkArea::redraw(int width, int height) { static int cur_width = -1; static int cur_height = -1; - if (cur_width == width && cur_height == height && workareapixmap) + if (cur_width == width && cur_height == height && workareapixmap) { + XCopyArea(fl_get_display(), + getPixmap(), getWin(), copy_gc, + 0, 0, width, height, xpos(), ypos()); return; + } cur_width = width; cur_height = height; - if (workareapixmap) - XFreePixmap(fl_get_display(), workareapixmap); - - if (lyxerr.debugging(Debug::WORKAREA)) - lyxerr << "Creating pixmap (" + if (lyxerr.debugging(Debug::WORKAREA)) { + lyxerr << "(Re)creating pixmap (" << width << 'x' << height << ")" << endl; + } + + if (workareapixmap) { + XFreePixmap(fl_get_display(), workareapixmap); + } workareapixmap = XCreatePixmap(fl_get_display(), RootWindow(fl_get_display(), 0), width, height, fl_get_visual_depth()); - if (lyxerr.debugging(Debug::WORKAREA)) - lyxerr << "\tpixmap=" << workareapixmap << endl; + + workAreaResize(); } @@ -333,9 +344,7 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event, !area->work_area->form->visible) return 1; lyxerr[Debug::WORKAREA] << "Workarea event: DRAW" << endl; - area->createPixmap(area->workWidth(), area->workHeight()); - area->workAreaResize(); - area->redraw(); + area->redraw(area->workWidth(), area->workHeight()); break; case FL_PUSH: if (!ev || ev->xbutton.button == 0) break; diff --git a/src/frontends/xforms/XWorkArea.h b/src/frontends/xforms/XWorkArea.h index 0b9ba2e6f6..b8a095a5bf 100644 --- a/src/frontends/xforms/XWorkArea.h +++ b/src/frontends/xforms/XWorkArea.h @@ -34,11 +34,6 @@ public: /// virtual int workHeight() const { return work_area->h; } /// - virtual void redraw() const { - //fl_redraw_object(work_area); - //fl_redraw_object(scrollbar); - } - /// Window getWin() const { return work_area->form->window; } /// virtual void setScrollbarParams(int height, int pos, int line_height); @@ -66,18 +61,22 @@ public: /// handles SelectionRequest X Event, to fill the clipboard int event_cb(XEvent * xev); private: - /// - void createPixmap(int, int); + /// generate the pixmap, and copy backing pixmap to it, + /// and send resize event if needed + void redraw(int, int); + /// GC used for copying to the screen + GC copy_gc; + /// FL_OBJECT * backgroundbox; - /// + /// the workarea free object FL_OBJECT * work_area; - /// + /// the scrollbar objcet FL_OBJECT * scrollbar; /// The pixmap overlay on the workarea Pixmap workareapixmap; - /// + /// the xforms-specific painter XPainter painter_; /// if we call redraw with true needed for locking-insets bool screen_cleared; -- 2.39.2