]> git.lyx.org Git - lyx.git/commitdiff
Make the XForms frontend 'do the right thing' when exposing the work area
authorAngus Leeming <leeming@lyx.org>
Tue, 4 May 2004 16:25:30 +0000 (16:25 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 4 May 2004 16:25:30 +0000 (16:25 +0000)
* if * libforms supports this.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8737 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/XWorkArea.C
src/frontends/xforms/XWorkArea.h
src/frontends/xforms/xscreen.C

index 793197d1946f80eedbcccc1be8aa4870ea11af9a..a85859a7d3b25908bab22059c2fdfd62e6ebc37f 100644 (file)
@@ -1,3 +1,14 @@
+2004-05-04  Angus Leeming  <leeming@lyx.org>
+
+       This is a resurrection of John Levon's June 2002 code.
+
+       * xscreen.C (expose): do the 'right thing' and ouput an XEvent
+       request to expose the work area.
+
+       * XWorkArea.C (updateGeometry, paint): split the old redraw function
+       into two. Use the x, y data.
+       (work_area_handler): if an XEvent * is passed on FL_DRAW, then use it.
+
 2004-05-04  Angus Leeming  <leeming@lyx.org>
 
        * XWorkArea.C (XWorkArea): revert the red color of the frame widget.
index 475bbd6529465d761d89ea34c9c1c0116e360fcd..5a6cc2e89be19d0e6d3c9bfee9ec6ebe8b8a9e56 100644 (file)
@@ -175,8 +175,9 @@ XWorkArea::XWorkArea(LyXView & owner, int w, int h)
        XGCValues val;
 
        val.function = GXcopy;
+       val.graphics_exposures = false;
        copy_gc = XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
-                           GCFunction, &val);
+                           GCFunction | GCGraphicsExposures, &val);
 }
 
 
@@ -188,17 +189,13 @@ XWorkArea::~XWorkArea()
 }
 
 
-void XWorkArea::redraw(int width, int height)
+void XWorkArea::updateGeometry(int width, int height)
 {
        static int cur_width = -1;
        static int cur_height = -1;
 
-       if (cur_width == width && cur_height == height && workareapixmap) {
-               XCopyArea(fl_get_display(),
-                         getPixmap(), getWin(), copy_gc,
-                         0, 0, width, height, xpos(), ypos());
+       if (cur_width == width && cur_height == height && workareapixmap)
                return;
-       }
 
        cur_width = width;
        cur_height = height;
@@ -222,6 +219,20 @@ void XWorkArea::redraw(int width, int height)
 }
 
 
+void XWorkArea::paint(int x, int y, int w, int h)
+{
+       lyxerr[Debug::WORKAREA]
+               << "XWorkarea::paint " << w << 'x' << h
+               << '+' << x << '+' << y << endl;
+
+       updateGeometry(workWidth(), workHeight());
+       XCopyArea(fl_get_display(),
+                 getPixmap(), getWin(),
+                 copy_gc, x, y, w, h,
+                 work_area->x + x, work_area->y + y);
+}
+
+
 void XWorkArea::setScrollbarParams(int height, int pos, int line_height)
 {
        // we need to cache this for scroll_cb
@@ -292,12 +303,35 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
 
        switch (event) {
 
-       case FL_DRAW:
+       case FL_DRAW: {
                if (!area->work_area || !area->work_area->form->visible)
                        return 1;
-               lyxerr[Debug::WORKAREA] << "Workarea event: DRAW" << endl;
-               area->redraw(area->workWidth(), area->workHeight());
+
+               if (ev) {
+                       lyxerr[Debug::WORKAREA]
+                               << "work_area_handler, handling X11 "
+                               "expose event "
+                               << ev->xexpose.width << 'x'
+                               << ev->xexpose.height << '+'
+                               << ev->xexpose.x << '+'
+                               << ev->xexpose.y << endl;
+
+                       // X11 generates XEvents with x, y relative to the
+                       // top left corner of the window.
+                       // XScreen::expose emulates this behaviour.
+                       // We therefore need to remove this offset before
+                       // generating the pixmap.
+                        int const x = ev->xexpose.x - ob->x;
+                        int const y = ev->xexpose.y - ob->y;
+
+                       area->paint(x, y,
+                                   ev->xexpose.width, ev->xexpose.height);
+               } else
+                       area->paint(0, 0,
+                                   area->workWidth(), area->workHeight());
+
                break;
+       }
 
        case FL_PUSH:
                if (!ev || ev->xbutton.button == 0) break;
index 22d6274da46b1ffc56759dced204865ebead9a08..570100df53cb8b8387be5f205f1bac581ac54077 100644 (file)
@@ -65,7 +65,10 @@ public:
 private:
        /// generate the pixmap, and copy backing pixmap to it,
        /// and send resize event if needed
-       void redraw(int, int);
+       void updateGeometry(int, int);
+
+       ///
+       void paint(int x, int y, int w, int h);
 
        /// GC used for copying to the screen
        GC copy_gc;
index 4375e57a423fd6d78da22d50014a5784f739fa1f..6465b5fee3ac60c9197a807250ec31b17f01c7e5 100644 (file)
@@ -79,7 +79,7 @@ void XScreen::setCursorColor()
 
 void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
 {
-       // Update the cursor color. (a little slow dooing it like this ??)
+       // Update the cursor color. (a little slow doing it like this ??)
        setCursorColor();
 
        cursor_x_ = x;
@@ -153,13 +153,21 @@ void XScreen::removeCursor()
 
 void XScreen::expose(int x, int y, int w, int h)
 {
-       lyxerr[Debug::GUI] << "expose " << w << 'x' << h
+       lyxerr[Debug::GUI] << "XScreen::expose " << w << 'x' << h
                << '+' << x << '+' << y << endl;
-       XCopyArea(fl_get_display(),
-                 owner_.getPixmap(),
-                 owner_.getWin(),
-                 gc_copy,
-                 x, y, w, h,
-                 x + owner_.xpos(),
-                 y + owner_.ypos());
+
+       XEvent ev;
+
+       ev.type = Expose;
+       ev.xexpose.window = owner_.getWin();
+       // Adjust the x,y data so that XWorkArea can handle XEvents
+       // received from here in identical fashion to those it receives
+       // direct from X11.
+       ev.xexpose.x = owner_.xpos() + x;
+       ev.xexpose.y = owner_.ypos() + y;
+       ev.xexpose.width = w;
+       ev.xexpose.height = h;
+       ev.xexpose.count = 0;
+
+       XSendEvent(fl_get_display(), owner_.getWin(), False, 0, &ev);
 }