aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/PlatGTK.cxx30
-rw-r--r--include/Platform.h8
-rw-r--r--src/Editor.h2
-rw-r--r--win32/PlatWin.cxx7
4 files changed, 30 insertions, 17 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index cb2e020e4..7ea5fe61a 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -26,16 +26,16 @@
#pragma warning(disable: 4505)
#endif
-static GdkFont *PFont(Font &f) {
- return reinterpret_cast<GdkFont *>(f.GetID());
+static GdkFont *PFont(Font &f) {
+ return reinterpret_cast<GdkFont *>(f.GetID());
}
-static GtkWidget *PWidget(WindowID id) {
- return reinterpret_cast<GtkWidget *>(id);
+static GtkWidget *PWidget(WindowID id) {
+ return reinterpret_cast<GtkWidget *>(id);
}
-static GtkWidget *PWidget(Window &w) {
- return PWidget(w.GetID());
+static GtkWidget *PWidget(Window &w) {
+ return PWidget(w.GetID());
}
Point Point::FromLong(long lpoint) {
@@ -91,7 +91,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
void Palette::Allocate(Window &w) {
if (allocatedPalette) {
gdk_colormap_free_colors(gtk_widget_get_colormap(PWidget(w)),
- reinterpret_cast<GdkColor *>(allocatedPalette),
+ reinterpret_cast<GdkColor *>(allocatedPalette),
allocatedLen);
delete [](reinterpret_cast<GdkColor *>(allocatedPalette));
allocatedPalette = 0;
@@ -298,7 +298,7 @@ void SurfaceImpl::Init(SurfaceID sid) {
Release();
drawable = drawable_;
gc = gdk_gc_new(drawable_);
- //gdk_gc_set_line_attributes(gc, 1,
+ //gdk_gc_set_line_attributes(gc, 1,
// GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
createdGC = true;
inited = true;
@@ -310,7 +310,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_) {
ppixmap = gdk_pixmap_new(static_cast<SurfaceImpl *>(surface_)->drawable, width, height, -1);
drawable = ppixmap;
gc = gdk_gc_new(static_cast<SurfaceImpl *>(surface_)->drawable);
- //gdk_gc_set_line_attributes(gc, 1,
+ //gdk_gc_set_line_attributes(gc, 1,
// GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
createdGC = true;
inited = true;
@@ -369,7 +369,7 @@ void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAlloc
rc.right - rc.left - 2, rc.bottom - rc.top - 2);
PenColour(fore);
- // The subtraction of 1 off the width and height here shouldn't be needed but
+ // The subtraction of 1 off the width and height here shouldn't be needed but
// otherwise a different rectangle is drawn than would be done if the fill parameter == 1
gdk_draw_rectangle(drawable, gc, 0,
rc.left, rc.top,
@@ -679,6 +679,13 @@ void Window::SetFont(Font &) {
void Window::SetCursor(Cursor curs) {
GdkCursor *gdkCurs;
+
+ // We don't set the cursor to same value numerous times under gtk because
+ // it stores the cursor in the window once it's set
+ if (curs == cursorLast)
+ return;
+ cursorLast = curs;
+
switch (curs) {
case cursorText:
gdkCurs = gdk_cursor_new(GDK_XTERM);
@@ -697,9 +704,10 @@ void Window::SetCursor(Cursor curs) {
break;
default:
gdkCurs = gdk_cursor_new(GDK_ARROW);
+ cursorLast = cursorArrow;
break;
}
-
+
gdk_window_set_cursor(PWidget(id)->window, gdkCurs);
gdk_cursor_destroy(gdkCurs);
}
diff --git a/include/Platform.h b/include/Platform.h
index 80f5af2e3..b3cfcfe66 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -310,8 +310,8 @@ class Window {
protected:
WindowID id;
public:
- Window() : id(0) {}
- Window(const Window &source) : id(source.id) {}
+ Window() : id(0), cursorLast(cursorInvalid) {}
+ Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
virtual ~Window();
Window &operator=(WindowID id_) {
id = id_;
@@ -329,9 +329,11 @@ public:
void InvalidateAll();
void InvalidateRectangle(PRectangle rc);
virtual void SetFont(Font &font);
- enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
+ enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
void SetCursor(Cursor curs);
void SetTitle(const char *s);
+private:
+ Cursor cursorLast;
};
/**
diff --git a/src/Editor.h b/src/Editor.h
index 374e2b33f..97cb64329 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -54,6 +54,8 @@ public:
int lines;
enum {maxDisplayLines = 400};
int lineStarts[maxDisplayLines];
+
+ LineLayout() : numCharsInLine(0) {}
};
class SelectionText {
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index a5b632379..9befd3f78 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -723,9 +723,6 @@ void Window::SetCursor(Cursor curs) {
case cursorText:
::SetCursor(::LoadCursor(NULL,IDC_IBEAM));
break;
- case cursorArrow:
- ::SetCursor(::LoadCursor(NULL,IDC_ARROW));
- break;
case cursorUp:
::SetCursor(::LoadCursor(NULL,IDC_UPARROW));
break;
@@ -748,6 +745,10 @@ void Window::SetCursor(Cursor curs) {
::SetCursor(::LoadCursor(hinstPlatformRes, MAKEINTRESOURCE(IDC_MARGIN)));
}
break;
+ case cursorArrow:
+ case cursorInvalid: // Should not occur, but just in case.
+ ::SetCursor(::LoadCursor(NULL,IDC_ARROW));
+ break;
}
}