qemacs: update patch

* cleanup
* count repaints and discard unneeded ones, reduces flicker
* implement mouse suppose (selection doesn't work yet)
* implement window resizing
* fix cursor drawing (map XOR mode for rectangles to B_OP_INVERT)
* Add 1 to the font descent value, now draws text like Pe.
This commit is contained in:
François Revol
2013-03-14 18:54:21 +00:00
parent 43eb4cf39b
commit 0a8b3f9365

View File

@@ -4,7 +4,7 @@ RCS file: /sources/qemacs/qemacs/Makefile,v
retrieving revision 1.50 retrieving revision 1.50
diff -u -r1.50 Makefile diff -u -r1.50 Makefile
--- Makefile 5 Jun 2008 07:14:12 -0000 1.50 --- Makefile 5 Jun 2008 07:14:12 -0000 1.50
+++ Makefile 13 Mar 2013 14:27:53 -0000 +++ Makefile 14 Mar 2013 18:45:07 -0000
@@ -63,7 +63,7 @@ @@ -63,7 +63,7 @@
endif endif
@@ -61,7 +61,7 @@ RCS file: /sources/qemacs/qemacs/cfb.c,v
retrieving revision 1.8 retrieving revision 1.8
diff -u -r1.8 cfb.c diff -u -r1.8 cfb.c
--- cfb.c 8 Apr 2008 06:55:44 -0000 1.8 --- cfb.c 8 Apr 2008 06:55:44 -0000 1.8
+++ cfb.c 13 Mar 2013 14:27:53 -0000 +++ cfb.c 14 Mar 2013 18:45:07 -0000
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
static void cfb16_fill_rectangle(QEditScreen *s, static void cfb16_fill_rectangle(QEditScreen *s,
int x1, int y1, int w, int h, QEColor color) int x1, int y1, int w, int h, QEColor color)
@@ -122,7 +122,7 @@ RCS file: /sources/qemacs/qemacs/configure,v
retrieving revision 1.15 retrieving revision 1.15
diff -u -r1.15 configure diff -u -r1.15 configure
--- configure 17 Apr 2008 15:06:44 -0000 1.15 --- configure 17 Apr 2008 15:06:44 -0000 1.15
+++ configure 13 Mar 2013 14:27:53 -0000 +++ configure 14 Mar 2013 18:45:07 -0000
@@ -45,9 +45,11 @@ @@ -45,9 +45,11 @@
ptsname="yes" ptsname="yes"
gprof="no" gprof="no"
@@ -207,7 +207,7 @@ RCS file: /sources/qemacs/qemacs/display.h,v
retrieving revision 1.11 retrieving revision 1.11
diff -u -r1.11 display.h diff -u -r1.11 display.h
--- display.h 11 Jan 2008 11:29:28 -0000 1.11 --- display.h 11 Jan 2008 11:29:28 -0000 1.11
+++ display.h 13 Mar 2013 14:27:53 -0000 +++ display.h 14 Mar 2013 18:45:07 -0000
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
int refcount; int refcount;
int ascent; int ascent;
@@ -232,7 +232,7 @@ RCS file: /sources/qemacs/qemacs/fbfrender.c,v
retrieving revision 1.10 retrieving revision 1.10
diff -u -r1.10 fbfrender.c diff -u -r1.10 fbfrender.c
--- fbfrender.c 8 Jan 2008 16:37:54 -0000 1.10 --- fbfrender.c 8 Jan 2008 16:37:54 -0000 1.10
+++ fbfrender.c 13 Mar 2013 14:27:54 -0000 +++ fbfrender.c 14 Mar 2013 18:45:07 -0000
@@ -124,7 +124,7 @@ @@ -124,7 +124,7 @@
static GlyphCache *fbf_decode_glyph1(QEFont *font, int code) static GlyphCache *fbf_decode_glyph1(QEFont *font, int code)
@@ -257,7 +257,7 @@ RCS file: /sources/qemacs/qemacs/html2png.c,v
retrieving revision 1.12 retrieving revision 1.12
diff -u -r1.12 html2png.c diff -u -r1.12 html2png.c
--- html2png.c 11 Jan 2008 11:29:28 -0000 1.12 --- html2png.c 11 Jan 2008 11:29:28 -0000 1.12
+++ html2png.c 13 Mar 2013 14:27:54 -0000 +++ html2png.c 14 Mar 2013 18:45:07 -0000
@@ -135,7 +135,7 @@ @@ -135,7 +135,7 @@
/* realloc ppm bitmap */ /* realloc ppm bitmap */
static int ppm_resize(QEditScreen *s, int w, int h) static int ppm_resize(QEditScreen *s, int w, int h)
@@ -319,7 +319,7 @@ RCS file: /sources/qemacs/qemacs/qe.h,v
retrieving revision 1.96 retrieving revision 1.96
diff -u -r1.96 qe.h diff -u -r1.96 qe.h
--- qe.h 4 May 2008 15:54:39 -0000 1.96 --- qe.h 4 May 2008 15:54:39 -0000 1.96
+++ qe.h 13 Mar 2013 14:27:55 -0000 +++ qe.h 14 Mar 2013 18:45:11 -0000
@@ -267,11 +267,11 @@ @@ -267,11 +267,11 @@
int ustristart(const unsigned int *str, const char *val, const unsigned int **ptr); int ustristart(const unsigned int *str, const char *val, const unsigned int **ptr);
static inline unsigned int *umemmove(unsigned int *dest, static inline unsigned int *umemmove(unsigned int *dest,
@@ -340,7 +340,7 @@ RCS file: /sources/qemacs/qemacs/tty.c,v
retrieving revision 1.50 retrieving revision 1.50
diff -u -r1.50 tty.c diff -u -r1.50 tty.c
--- tty.c 23 Apr 2008 15:30:33 -0000 1.50 --- tty.c 23 Apr 2008 15:30:33 -0000 1.50
+++ tty.c 13 Mar 2013 14:27:56 -0000 +++ tty.c 14 Mar 2013 18:45:11 -0000
@@ -118,7 +118,7 @@ @@ -118,7 +118,7 @@
tty_screen = s; tty_screen = s;
@@ -436,7 +436,7 @@ RCS file: /sources/qemacs/qemacs/win32.c,v
retrieving revision 1.15 retrieving revision 1.15
diff -u -r1.15 win32.c diff -u -r1.15 win32.c
--- win32.c 23 Apr 2008 15:29:35 -0000 1.15 --- win32.c 23 Apr 2008 15:29:35 -0000 1.15
+++ win32.c 13 Mar 2013 14:27:56 -0000 +++ win32.c 14 Mar 2013 18:45:11 -0000
@@ -139,7 +139,7 @@ @@ -139,7 +139,7 @@
if (!_hPrev) if (!_hPrev)
init_application(); init_application();
@@ -461,7 +461,7 @@ RCS file: /sources/qemacs/qemacs/x11.c,v
retrieving revision 1.28 retrieving revision 1.28
diff -u -r1.28 x11.c diff -u -r1.28 x11.c
--- x11.c 15 Apr 2008 23:24:04 -0000 1.28 --- x11.c 15 Apr 2008 23:24:04 -0000 1.28
+++ x11.c 13 Mar 2013 14:27:56 -0000 +++ x11.c 14 Mar 2013 18:45:12 -0000
@@ -194,7 +194,7 @@ @@ -194,7 +194,7 @@
QEStyleDef default_style; QEStyleDef default_style;
XGCValues gc_val; XGCValues gc_val;
@@ -566,9 +566,9 @@ diff -u -r1.28 x11.c
l = q - x11_str; l = q - x11_str;
XSetFont(display, gc, xfont->fid); XSetFont(display, gc, xfont->fid);
XDrawString16(display, dbuffer, gc, x_start, y, x11_str, l); XDrawString16(display, dbuffer, gc, x_start, y, x11_str, l);
--- /dev/null 2013-03-13 15:41:16.406936000 +0100 --- /dev/null 2013-03-14 16:10:28.351668000 +0100
+++ haiku.cpp 2013-03-13 15:14:35.549191680 +0100 +++ haiku.cpp 2013-03-14 19:43:57.698351616 +0100
@@ -0,0 +1,680 @@ @@ -0,0 +1,831 @@
+/* +/*
+ * Haiku driver for QEmacs + * Haiku driver for QEmacs
+ * Copyright (c) 2013 François Revol. + * Copyright (c) 2013 François Revol.
@@ -589,10 +589,7 @@ diff -u -r1.28 x11.c
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */ + */
+extern "C" { +extern "C" {
+//XXX:shouldn't be required anymore
+//#define private priv_data
+#include "qe.h" +#include "qe.h"
+//#undef private
+} +}
+ +
+#include <Application.h> +#include <Application.h>
@@ -628,6 +625,10 @@ diff -u -r1.28 x11.c
+static int bapp_ref_count = 0; +static int bapp_ref_count = 0;
+static int events_wr; +static int events_wr;
+ +
+/* count of pending repaints */
+static vint32 repaints = 0;
+//TODO:use double-buffering with a BBitmap
+
+static void haiku_handle_event(void *opaque); +static void haiku_handle_event(void *opaque);
+ +
+static status_t bmessage_input(QEWindow *win, QEView *view, BMessage *message) +static status_t bmessage_input(QEWindow *win, QEView *view, BMessage *message)
@@ -666,17 +667,15 @@ diff -u -r1.28 x11.c
+ QEView(BRect frame, const char *name); + QEView(BRect frame, const char *name);
+ virtual ~QEView(); + virtual ~QEView();
+ +
+#if 0
+virtual void MouseDown(BPoint where); +virtual void MouseDown(BPoint where);
+virtual void MouseUp(BPoint where); +virtual void MouseUp(BPoint where);
+virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message); +virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message);
+#endif
+virtual void KeyDown(const char *bytes, int32 numBytes); +virtual void KeyDown(const char *bytes, int32 numBytes);
+virtual void KeyUp(const char *bytes, int32 numBytes); +virtual void KeyUp(const char *bytes, int32 numBytes);
+virtual void Draw(BRect updateRect); +virtual void Draw(BRect updateRect);
+virtual void FrameResized(float new_width, float new_height);
+#if 0 +#if 0
+virtual void WindowActivated(bool state); +virtual void WindowActivated(bool state);
+virtual void FrameResized(float new_width, float new_height);
+virtual void MessageReceived(BMessage *message); +virtual void MessageReceived(BMessage *message);
+#endif +#endif
+}; +};
@@ -693,6 +692,12 @@ diff -u -r1.28 x11.c
+{ +{
+ uint32 mods; + uint32 mods;
+ switch (message->what) { + switch (message->what) {
+ case B_MOUSE_WHEEL_CHANGED:
+ {
+ BMessage *message = DetachCurrentMessage();
+ bmessage_input(this, NULL, message);
+ }
+ break;
+ case B_KEY_DOWN: + case B_KEY_DOWN:
+ if ((message->FindInt32("modifiers", (int32 *)&mods) == B_OK) && + if ((message->FindInt32("modifiers", (int32 *)&mods) == B_OK) &&
+ (mods & B_COMMAND_KEY)) { + (mods & B_COMMAND_KEY)) {
@@ -716,12 +721,31 @@ diff -u -r1.28 x11.c
+ :BView(frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FRAME_EVENTS) + :BView(frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FRAME_EVENTS)
+{ +{
+ SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR)); + SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
+ //SetViewColor(0, 255, 0);
+} +}
+ +
+QEView::~QEView() +QEView::~QEView()
+{ +{
+} +}
+ +
+void QEView::MouseDown(BPoint where)
+{
+ BMessage *message = Window()->DetachCurrentMessage();
+ bmessage_input(NULL, this, message);
+}
+
+void QEView::MouseUp(BPoint where)
+{
+ BMessage *message = Window()->DetachCurrentMessage();
+ bmessage_input(NULL, this, message);
+}
+
+void QEView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message)
+{
+ BMessage *message = Window()->DetachCurrentMessage();
+ bmessage_input(NULL, this, message);
+}
+
+void QEView::KeyDown(const char *bytes, int32 numBytes) +void QEView::KeyDown(const char *bytes, int32 numBytes)
+{ +{
+ BMessage *message = Window()->DetachCurrentMessage(); + BMessage *message = Window()->DetachCurrentMessage();
@@ -742,9 +766,17 @@ diff -u -r1.28 x11.c
+ BMessage *message; + BMessage *message;
+ message = new BMessage(_UPDATE_); + message = new BMessage(_UPDATE_);
+ message->AddRect("update_rect", updateRect); + message->AddRect("update_rect", updateRect);
+ atomic_add(&repaints, 1);
+ bmessage_input(NULL, this, message); + bmessage_input(NULL, this, message);
+} +}
+ +
+void QEView::FrameResized(float new_width, float new_height)
+{
+ BMessage *message = Window()->DetachCurrentMessage();
+ atomic_set(&repaints, 0);
+ bmessage_input(NULL, this, message);
+ BView::FrameResized(new_width, new_height);
+}
+ +
+ +
+static int haiku_probe(void) +static int haiku_probe(void)
@@ -838,7 +870,7 @@ diff -u -r1.28 x11.c
+ ctx->font.GetHeight(&height); + ctx->font.GetHeight(&height);
+ +
+ font_xsize = (int)ctx->font.StringWidth("n"); + font_xsize = (int)ctx->font.StringWidth("n");
+ font_ysize = (int)(height.ascent + height.descent + height.leading); + font_ysize = (int)(height.ascent + height.descent + height.leading + 1);
+ +
+ if (w == 0) + if (w == 0)
+ w = 80; + w = 80;
@@ -884,6 +916,15 @@ diff -u -r1.28 x11.c
+ +
+static void haiku_flush(QEditScreen *s) +static void haiku_flush(QEditScreen *s)
+{ +{
+ WindowState *ctx = (WindowState *)s->priv_data;
+ //fprintf(stderr, "%s()\n", __FUNCTION__);
+
+ ctx->v->LockLooper();
+
+ // doesn't really help
+ ctx->v->Sync();
+
+ ctx->v->UnlockLooper();
+} +}
+ +
+static int haiku_is_user_input_pending(QEditScreen *s) +static int haiku_is_user_input_pending(QEditScreen *s)
@@ -929,9 +970,103 @@ diff -u -r1.28 x11.c
+ break; + break;
+ +
+ case _UPDATE_: + case _UPDATE_:
+ // TODO: flush queued + // flush queued repaints
+ if (atomic_set(&repaints, 0)) {
+ ev->expose_event.type = QE_EXPOSE_EVENT; + ev->expose_event.type = QE_EXPOSE_EVENT;
+ qe_handle_event(ev); + qe_handle_event(ev);
+ }
+ break;
+
+ case B_VIEW_RESIZED:
+ {
+ int32 width, height;
+ int columns, rows;
+ //event->PrintToStream();
+/*
+ if (event->FindInt32("width", &width) < B_OK)
+ break;
+ if (event->FindInt32("height", &height) < B_OK)
+ break;
+*/
+
+ ctx->v->LockLooper();
+
+ width = ctx->v->Bounds().IntegerWidth() + 1;
+ height = ctx->v->Bounds().IntegerHeight() + 1;
+
+ if (width != s->width || height != s->height)
+ ctx->v->Invalidate(ctx->v->Bounds());
+
+ s->width = width;
+ s->height = height;
+
+ ctx->v->UnlockLooper();
+
+ //ev->expose_event.type = QE_EXPOSE_EVENT;
+ //qe_handle_event(ev);
+ }
+ break;
+
+ case B_MOUSE_MOVED:
+ {
+ BPoint pt;
+
+ ev->button_event.type = QE_MOTION_EVENT;
+ ev->button_event.x = (int)pt.x;
+ ev->button_event.y = (int)pt.y;
+ qe_handle_event(ev);
+ }
+ break;
+
+ case B_MOUSE_DOWN:
+ case B_MOUSE_UP:
+ {
+ BPoint pt;
+ uint32 buttons;
+
+ if (event->what == B_MOUSE_DOWN)
+ ev->button_event.type = QE_BUTTON_PRESS_EVENT;
+ else
+ ev->button_event.type = QE_BUTTON_RELEASE_EVENT;
+
+ if (event->FindPoint("where", &pt) < B_OK)
+ pt = BPoint(0,0);
+ ev->button_event.x = (int)pt.x;
+ ev->button_event.y = (int)pt.y;
+
+ if (event->FindInt32("buttons", (int32 *)&buttons) < B_OK)
+ buttons = (event->what == B_MOUSE_UP)?0:B_PRIMARY_MOUSE_BUTTON;
+
+
+ if (buttons & B_PRIMARY_MOUSE_BUTTON)
+ ev->button_event.button = QE_BUTTON_LEFT;
+ else if (buttons & B_SECONDARY_MOUSE_BUTTON)
+ ev->button_event.button = QE_BUTTON_MIDDLE;
+ else if (buttons & B_TERTIARY_MOUSE_BUTTON)
+ ev->button_event.button = QE_BUTTON_RIGHT;
+
+ qe_handle_event(ev);
+ }
+ break;
+
+ case B_MOUSE_WHEEL_CHANGED:
+ {
+ float delta;
+
+ ev->button_event.type = QE_BUTTON_PRESS_EVENT;
+
+ if (event->FindFloat("be:wheel_delta_y", &delta) < B_OK)
+ delta = 0.0;
+
+ if (delta > 0)
+ ev->button_event.button = QE_WHEEL_DOWN;
+ else if (delta < 0)
+ ev->button_event.button = QE_WHEEL_UP;
+ else
+ break;
+
+ qe_handle_event(ev);
+ }
+ break; + break;
+ +
+ case B_KEY_UP: + case B_KEY_UP:
@@ -1092,10 +1227,7 @@ diff -u -r1.28 x11.c
+{ +{
+ WindowState *ctx = (WindowState *)s->priv_data; + WindowState *ctx = (WindowState *)s->priv_data;
+ //fprintf(stderr, "%s()\n", __FUNCTION__); + //fprintf(stderr, "%s()\n", __FUNCTION__);
+ + drawing_mode oldMode;
+ /* XXX: suppress XOR mode */
+ if (color == QECOLOR_XOR)
+ color = QERGB(0xff, 0xff, 0xff);
+ +
+ BRect r(x1, y1, x1 + w - 1, y1 + h - 1); + BRect r(x1, y1, x1 + w - 1, y1 + h - 1);
+ rgb_color c = {(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, + rgb_color c = {(color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff,
@@ -1103,9 +1235,19 @@ diff -u -r1.28 x11.c
+ +
+ ctx->v->LockLooper(); + ctx->v->LockLooper();
+ +
+ oldMode = ctx->v->DrawingMode();
+
+ /* XXX: suppress XOR mode */
+ if (color == QECOLOR_XOR)
+ ctx->v->SetDrawingMode(B_OP_INVERT);
+ else
+ ctx->v->SetHighColor(c); + ctx->v->SetHighColor(c);
+ ctx->v->FillRect(r); + ctx->v->FillRect(r);
+ +
+ /* XXX: suppress XOR mode */
+ if (color == QECOLOR_XOR)
+ ctx->v->SetDrawingMode(oldMode);
+
+ ctx->v->UnlockLooper(); + ctx->v->UnlockLooper();
+} +}
+ +
@@ -1125,7 +1267,7 @@ diff -u -r1.28 x11.c
+ font_height height; + font_height height;
+ f->GetHeight(&height); + f->GetHeight(&height);
+ font->ascent = (int)height.ascent; + font->ascent = (int)height.ascent;
+ font->descent = (int)(height.descent + height.leading); + font->descent = (int)(height.descent + height.leading + 1);
+ font->priv_data = f; + font->priv_data = f;
+ return font; + return font;
+} +}
@@ -1221,6 +1363,15 @@ diff -u -r1.28 x11.c
+ haiku_set_clip, + haiku_set_clip,
+ NULL, /* no selection handling */ + NULL, /* no selection handling */
+ NULL, /* no selection handling */ + NULL, /* no selection handling */
+ NULL, /* dpy_invalidate */
+ NULL, /* dpy_cursor_at */
+ NULL, /* dpy_bmp_alloc */
+ NULL, /* dpy_bmp_free */
+ NULL, /* dpy_bmp_draw */
+ NULL, /* dpy_bmp_lock */
+ NULL, /* dpy_bmp_unlock */
+ NULL, /* dpy_full_screen */
+ NULL, /* next */
+}; +};
+ +
+static CmdOptionDef cmd_options[] = { +static CmdOptionDef cmd_options[] = {