X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fm17n-gui.c;h=c0bd14a51ce4478618d127b32ff759b51c47ec43;hb=0793e3bffb93b37b42eab1223c19ffc70c4ba1ae;hp=7e1e594ce734d40dab9cf051a125645fce432c86;hpb=d67c6bdc38589273d9e86c43719619aec0826bb1;p=m17n%2Fm17n-lib.git diff --git a/src/m17n-gui.c b/src/m17n-gui.c index 7e1e594..c0bd14a 100644 --- a/src/m17n-gui.c +++ b/src/m17n-gui.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU Lesser General Public License along with the m17n library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 02111-1307, USA. */ /***en @@ -88,7 +88,7 @@ typedef struct { /** Name of the dynamic library (e.g. "libm17n-X.so"). */ char *library; - /** Handle fo the dynamic library. */ + /** Handle of the dynamic library. */ void *handle; /** Function to call just after loading the library. */ int (*init) (); @@ -112,7 +112,6 @@ free_frame (void *object) (*frame->driver->close) (frame); M17N_OBJECT_UNREF (frame->face); - free (frame->font); M17N_OBJECT_UNREF (frame->font_driver_list); free (object); } @@ -197,8 +196,8 @@ null_device_fini () mface__free_realized ((MRealizedFace *) MPLIST_VAL (plist)); M17N_OBJECT_UNREF (null_device.realized_face_list); - MPLIST_DO (plist, null_device.realized_font_list) - mfont__free_realized ((MRealizedFont *) MPLIST_VAL (plist)); + if (MPLIST_VAL (null_device.realized_font_list)) + mfont__free_realized (MPLIST_VAL (null_device.realized_font_list)); M17N_OBJECT_UNREF (null_device.realized_font_list); return 0; } @@ -210,6 +209,9 @@ null_device_open (MFrame *frame, MPlist *param) frame->device = NULL; frame->device_type = 0; + frame->dpi = (int) mplist_get (param, Mresolution); + if (frame->dpi == 0) + frame->dpi = 100; frame->driver = &null_driver; frame->font_driver_list = mplist (); mplist_add (frame->font_driver_list, Mfreetype, &mfont__ft_driver); @@ -237,9 +239,9 @@ m17n_init_win (void) { int mdebug_mask = MDEBUG_INIT; + merror_code = MERROR_NONE; if (m17n__gui_initialized++) return; - merror_code = MERROR_NONE; m17n_init (); if (merror_code != MERROR_NONE) { @@ -262,6 +264,7 @@ m17n_init_win (void) Mdrawable = msymbol ("drawable"); Mdepth = msymbol ("depth"); Mwidget = msymbol ("widget"); + Mcolormap = msymbol ("colormap"); MDEBUG_PUSH_TIME (); if (mfont__init () < 0) @@ -314,22 +317,26 @@ m17n_fini_win (void) dlclose (interface->handle); } free (interface->library); + free (interface); } #ifdef HAVE_FREETYPE if (null_interface.handle) - (*null_interface.fini) (); + { + (*null_interface.fini) (); + null_interface.handle = NULL; + } #endif /* not HAVE_FREETYPE */ M17N_OBJECT_UNREF (device_library_list); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input-gui module.")); minput__win_fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize draw module.")); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize input-gui module.")); mdraw__fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize face module.")); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize draw module.")); mface__fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize fontset module.")); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize face module.")); mfont__fontset_fini (); - MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize font module.")); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize fontset module.")); mfont__fini (); + MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize font module.")); mframe_default = NULL; MDEBUG_POP_TIME (); MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the gui modules.")); @@ -648,9 +655,12 @@ mframe (MPlist *plist) if (! interface->handle) { if (! (interface->handle = dlopen (interface->library, RTLD_NOW)) - || ! (interface->init = dlsym (interface->handle, "device_init")) - || ! (interface->open = dlsym (interface->handle, "device_open")) - || ! (interface->fini = dlsym (interface->handle, "device_fini")) + || ! (*(void **) (&interface->init) + = dlsym (interface->handle, "device_init")) + || ! (*(void **) (&interface->open) + = dlsym (interface->handle, "device_open")) + || ! (*(void **) (&interface->fini) + = dlsym (interface->handle, "device_fini")) || (*interface->init) () < 0) { fprintf (stderr, "%s\n", (char *) dlerror ()); @@ -676,7 +686,8 @@ mframe (MPlist *plist) if (MPLIST_KEY (pl) == Mface) mface_merge (frame->face, (MFace *) MPLIST_VAL (pl)); mface__update_frame_face (frame); - + frame->font + = frame->rface->rfont ? (MFont *) frame->rface->rfont : NULL; if (plist_created) M17N_OBJECT_UNREF (plist); return frame; @@ -770,9 +781,9 @@ mframe_get_prop (MFrame *frame, MSymbol key) if (key == Mface) return frame->face; if (key == Mfont) - return &frame->rface->rfont->font; + return frame->font; if (key == Mfont_width) - return (void *) (frame->space_width); + return (void *) (frame->average_width); if (key == Mfont_ascent) return (void *) (frame->ascent); if (key == Mfont_descent)