changeset 1013:d5b8853767e7 refine_backend_if

Add flush function to mb_backend_t
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 22 Nov 2010 00:42:30 +0800
parents 914add76c210
children f7bf372a85a3
files include/mb_backend.h src/X_supp.c
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/include/mb_backend.h	Mon Nov 22 00:42:30 2010 +0800
+++ b/include/mb_backend.h	Mon Nov 22 00:42:30 2010 +0800
@@ -46,6 +46,7 @@
     mb_rt_t *(*new_with_win)(MB_DISPLAY display, MB_WINDOW win);
     
     void (*free)(mb_rt_t *rt);
+    void (*free_keep_win)(mb_rt_t *rt);
     /*! \brief Request the backend to start monitoring a file descriptor.
      *
      * This is used only when the backend is responsible for event loop.
@@ -64,6 +65,9 @@
      * mb_IO_factory_t) with the backend.
      */
     void (*event_loop)(mb_rt_t *rt);
+
+    /*! \brief Flush requests to screen server if existed */
+    int (*flush)(mb_rt_t *rt);
     
     subject_t *(*kbevents)(mb_rt_t *rt);
     redraw_man_t *(*rdman)(mb_rt_t *rt);
--- a/src/X_supp.c	Mon Nov 22 00:42:30 2010 +0800
+++ b/src/X_supp.c	Mon Nov 22 00:42:30 2010 +0800
@@ -1188,13 +1188,24 @@
     io_man->unreg(io_man, hdl);
 }
 
+static int
+_x_mb_flush(mb_rt_t *rt) {
+    X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *) rt;
+    int r;
+
+    r = XFlush(xmb_rt->display);
+    return r == 0? ERR: OK;
+}
+
 mb_backend_t backend = { X_MB_new,
 			 X_MB_new_with_win,
 			 
 			 X_MB_free,
+			 X_MB_free_keep_win,
 			 X_MB_add_event,
 			 X_MB_remove_event,
 			 _x_mb_event_loop,
+			 _x_mb_flush,
 			 
 			 X_MB_kbevents,
 			 X_MB_rdman,