summaryrefslogtreecommitdiff
path: root/src/drivers/Xlib
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2016-04-17 14:22:02 +0000
committerMatthias Melcher <fltk@matthiasm.com>2016-04-17 14:22:02 +0000
commitcc57af841a11ee314efca6a434ff14bed51706e4 (patch)
treef3080908a464e23d2c24c3643a049afc4f449708 /src/drivers/Xlib
parenta4e5dc0267bf972b5897aec0f167b3e2d9488a8c (diff)
virtualizes fl_set_spot and fl_reset_spot
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11640 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Xlib')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H2
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx75
2 files changed, 77 insertions, 0 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index 808900677..ff037c3e1 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
@@ -129,6 +129,8 @@ protected:
void color(uchar r, uchar g, uchar b);
virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s);
virtual float scale_bitmap_for_PostScript();
+ virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
+ virtual void reset_spot();
};
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
index 44d0ad1a5..717718cb4 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
@@ -118,6 +118,81 @@ void Fl_Xlib_Graphics_Driver::fixloop() { // remove equal points from closed pa
while (n>2 && p[n-1].x == p[0].x && p[n-1].y == p[0].y) n--;
}
+// FIXME: should be members of Fl_Xlib_Graphics_Driver
+static XRectangle spot;
+static int spotf = -1;
+static int spots = -1;
+
+void Fl_Xlib_Graphics_Driver::reset_spot(void)
+{
+ spot.x = -1;
+ spot.y = -1;
+ //if (fl_xim_ic) XUnsetICFocus(fl_xim_ic);
+}
+
+void Fl_Xlib_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win)
+{
+ int change = 0;
+ XVaNestedList preedit_attr;
+ static XFontSet fs = NULL;
+ char **missing_list;
+ int missing_count;
+ char *def_string;
+ char *fnt = NULL;
+ bool must_free_fnt =true;
+
+ static XIC ic = NULL;
+
+ if (!fl_xim_ic || !fl_is_over_the_spot) return;
+ //XSetICFocus(fl_xim_ic);
+ if (X != spot.x || Y != spot.y) {
+ spot.x = X;
+ spot.y = Y;
+ spot.height = H;
+ spot.width = W;
+ change = 1;
+ }
+ if (font != spotf || size != spots) {
+ spotf = font;
+ spots = size;
+ change = 1;
+ if (fs) {
+ XFreeFontSet(fl_display, fs);
+ }
+#if USE_XFT
+
+#if defined(__GNUC__)
+ // FIXME: warning XFT support here
+#endif /*__GNUC__*/
+
+ fnt = NULL; // fl_get_font_xfld(font, size);
+ if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
+ fs = XCreateFontSet(fl_display, fnt, &missing_list,
+ &missing_count, &def_string);
+#else
+ fnt = fl_get_font_xfld(font, size);
+ if (!fnt) {fnt = (char*)"-misc-fixed-*";must_free_fnt=false;}
+ fs = XCreateFontSet(fl_display, fnt, &missing_list,
+ &missing_count, &def_string);
+#endif
+ }
+ if (fl_xim_ic != ic) {
+ ic = fl_xim_ic;
+ change = 1;
+ }
+
+ if (fnt && must_free_fnt) free(fnt);
+ if (!change) return;
+
+
+ preedit_attr = XVaCreateNestedList(0,
+ XNSpotLocation, &spot,
+ XNFontSet, fs, NULL);
+ XSetICValues(fl_xim_ic, XNPreeditAttributes, preedit_attr, NULL);
+ XFree(preedit_attr);
+}
+
+
//
// End of "$Id$".
//