diff --git a/ChangeLog b/ChangeLog index d155096..f60e363 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2008-07-12 Fred Kiefer + + * Source/xlib/GSXftFontInfo.m (-setupAttributes:), + * Source/xlib/XGFontSetFontInfo.m (-setupAttributes:), + * Source/xlib/XGFont.m (-setupAttributes:), + * Source/art/ftfont.m (-setupAttributes:), + * Source/art/ftfont-old.m (-setupAttributes): Correct the sign of + the descender in the bounding box. + +2008-07-12 Fred Kiefer + + * Source/xlib/GSXftFontInfo.m (-setupAttributes:), + * Source/xlib/XGFontSetFontInfo.m (-setupAttributes:), + * Source/xlib/XGFont.m (-setupAttributes:): Correct the setting of + fontBBox, used for boundingRectForFont. + +2008-07-11 Fred Kiefer + + * Source/x11/XGServerWindow.m (-setinputstate:): Disable new code, + as it does not work on KDE 4. + +2008-07-08 Fred Kiefer + + * Source/x11/XGServerWindow.m (-setinputfocus:): For EWMH window + managers set the user time before requesting focus. + * Source/x11/XGServerWindow.m (-setinputstate:): For EWMH window + managers set active window status. + Based on patch by Hubert Chathi . + +2008-06-26 Fred Kiefer + + * Source/cairo/CairoGState.m (-copyWithZone:): Use a runtime + version check and adjust from > to >= 1.6.0. + * Source/cairo/CairoFontInfo.m (-setupAttributes): Slightly better + error checks. + 2008-06-14 Adam Fedor * Version 0.14.0 diff --git a/Source/art/ftfont-old.m b/Source/art/ftfont-old.m index ce186a2..05f2359 100644 --- a/Source/art/ftfont-old.m +++ b/Source/art/ftfont-old.m @@ -246,7 +246,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_ xHeight = ascender * 0.5; /* TODO */ maximumAdvancement = NSMakeSize((size->metrics.max_advance / 64.0), ascender + descender); - fontBBox = NSMakeRect(0, descender, maximumAdvancement.width, ascender + descender); + fontBBox = NSMakeRect(0, -descender, maximumAdvancement.width, ascender + descender); descender = -descender; /* printf("(%@) h=%g a=%g d=%g max=(%g %g) (%g %g)+(%g %g)\n",name, diff --git a/Source/art/ftfont.m b/Source/art/ftfont.m index 1ee62d9..afa772c 100644 --- a/Source/art/ftfont.m +++ b/Source/art/ftfont.m @@ -262,7 +262,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_ maximumAdvancement = NSMakeSize((ft_size->metrics.max_advance / 64.0), 0.0); fontBBox - = NSMakeRect(0, descender, maximumAdvancement.width, ascender + descender); + = NSMakeRect(0, -descender, maximumAdvancement.width, ascender + descender); descender = -descender; /* printf("(%@) h=%g a=%g d=%g max=(%g %g) (%g %g)+(%g %g)\n",name, diff --git a/Source/cairo/CairoFontInfo.m b/Source/cairo/CairoFontInfo.m index cb8d76b..3409567 100644 --- a/Source/cairo/CairoFontInfo.m +++ b/Source/cairo/CairoFontInfo.m @@ -93,25 +93,36 @@ */ cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + //cairo_matrix_scale(&font_matrix, 0.9, 0.9); cairo_matrix_init_identity(&ctm); - // FIXME: Should get default font options from somewhere - options = cairo_font_options_create(); face = [_faceInfo fontFace]; if (!face) { return NO; } - _scaled = cairo_scaled_font_create(face, &font_matrix, &ctm, options); - cairo_font_options_destroy(options); - if (!_scaled) + // Get default font options + options = cairo_font_options_create(); + if (cairo_font_options_status(options) != CAIRO_STATUS_SUCCESS) { return NO; } + + _scaled = cairo_scaled_font_create(face, &font_matrix, &ctm, options); + cairo_font_options_destroy(options); + if (cairo_scaled_font_status(_scaled) != CAIRO_STATUS_SUCCESS) + { + return NO; + } + cairo_scaled_font_extents(_scaled, &font_extents); + if (cairo_scaled_font_status(_scaled) != CAIRO_STATUS_SUCCESS) + { + return NO; + } + ascender = font_extents.ascent; - // The FreeType documentation claims this value is already negative, but it isn't. descender = -font_extents.descent; xHeight = ascender * 0.6; lineHeight = font_extents.height; @@ -119,6 +130,16 @@ font_extents.max_y_advance); fontBBox = NSMakeRect(0, descender, maximumAdvancement.width, ascender - descender); +/* + NSLog(@"Font matrix (%g, %g, %g, %g, %g, %g) type %d", + matrix[0], matrix[1], matrix[2], + matrix[3], matrix[4], matrix[5], cairo_scaled_font_get_type(_scaled)); + NSLog(@"(%@) h=%g a=%g d=%g max=(%g %g) (%g %g)+(%g %g)\n", fontName, + xHeight, ascender, descender, + maximumAdvancement.width, maximumAdvancement.height, + fontBBox.origin.x, fontBBox.origin.y, + fontBBox.size.width, fontBBox.size.height); +*/ return YES; } diff --git a/Source/cairo/CairoGState.m b/Source/cairo/CairoGState.m index 31fe28c..f49c409 100644 --- a/Source/cairo/CairoGState.m +++ b/Source/cairo/CairoGState.m @@ -205,20 +205,32 @@ static float floatToUserSpace(NSAffineTransform *ctm, float f) { int i; - for (i = 0; i < clip_rects->num_rectangles; i++) + if (cairo_version() >= CAIRO_VERSION_ENCODE(1, 6, 0)) { - cairo_rectangle_t rect = clip_rects->rectangles[i]; - NSSize size = [_surface size]; + for (i = 0; i < clip_rects->num_rectangles; i++) + { + cairo_rectangle_t rect = clip_rects->rectangles[i]; - cairo_rectangle(copy->_ct, rect.x, -#if CAIRO_VERSION > CAIRO_VERSION_ENCODE(1, 6, 0) - rect.y, -#else - // This strange computation is due to the device offset. - rect.y + 2*(offset.y - size.height), -#endif - rect.width, rect.height); - cairo_clip(copy->_ct); + cairo_rectangle(copy->_ct, rect.x, rect.y, + rect.width, rect.height); + cairo_clip(copy->_ct); + } + } + else + { + for (i = 0; i < clip_rects->num_rectangles; i++) + { + cairo_rectangle_t rect = clip_rects->rectangles[i]; + NSSize size = [_surface size]; + + cairo_rectangle(copy->_ct, rect.x, + /* This strange computation is due + to the device offset missing for + clip rects in cairo < 1.6.0. */ + rect.y + 2*(offset.y - size.height), + rect.width, rect.height); + cairo_clip(copy->_ct); + } } } cairo_rectangle_list_destroy(clip_rects); diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 94268bb..fc0c729 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -1556,6 +1556,7 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg) pid_atom, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&pid, 1); + // FIXME: Need to set WM_CLIENT_MACHINE as well. } /* We need to determine the offsets between the actual decorated window @@ -2001,12 +2002,15 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg) window->numProtocols = 0; window->protocols[window->numProtocols++] = generic.take_focus_atom; window->protocols[window->numProtocols++] = generic.delete_win_atom; - window->protocols[window->numProtocols++] = generic.net_wm_ping_atom; + // Add ping protocol for EWMH + if ((generic.wm & XGWM_EWMH) != 0) + { + window->protocols[window->numProtocols++] = generic.net_wm_ping_atom; + } if ((generic.wm & XGWM_WINDOWMAKER) != 0) { window->protocols[window->numProtocols++] = generic.miniaturize_atom; } - // FIXME Add ping protocol for EWMH XSetWMProtocols(dpy, window->ident, window->protocols, window->numProtocols); window->exposedRects = [NSMutableArray new]; @@ -3611,7 +3615,22 @@ static BOOL didCreatePixmaps; NSDebugLLog(@"Focus", @"Focus already set on %d", window->number); return; } - + + if ((generic.wm & XGWM_EWMH) != 0) + { + static Atom user_time_atom = None; + Time last = [self lastTime]; + + if (user_time_atom == None) + { + user_time_atom = XInternAtom(dpy, "_NET_WM_USER_TIME", False); + } + + NSDebugLLog(@"Focus", @"Setting user time for %d to %ul", window->ident, last); + XChangeProperty(dpy, window->ident, user_time_atom, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)&last, 1); + } + NSDebugLLog(@"Focus", @"Setting focus to %d", window->number); generic.desiredFocusWindow = win; generic.focusRequestNumber = XNextRequest(dpy); @@ -3646,6 +3665,39 @@ static BOOL didCreatePixmaps; data2: 0 data3: 0]; } +#if 0 + else if ((generic.wm & XGWM_EWMH) != 0) + { + if ((st == GSTitleBarKey) || (st == GSTitleBarMain)) + { + static Atom active_window_atom = None; + gswindow_device_t *window = WINDOW_WITH_TAG(win); + + if (win == 0 || window == 0) + { + return; + } + + if (active_window_atom == None) + { + active_window_atom = XInternAtom(window->display, + "_NET_ACTIVE_WINDOW", False); + } + + /* + * Work around "focus stealing prevention" by first asking for focus + * before we try to take it. + */ + [self _sendRoot: window->root + type: active_window_atom + window: window->ident + data0: 1 + data1: [self lastTime] + data2: 0 + data3: 0]; + } + } +#endif } /** Sets the transparancy value for the whole window */ diff --git a/Source/xlib/GSXftFontInfo.m b/Source/xlib/GSXftFontInfo.m index fa10600..fdcdcd5 100644 --- a/Source/xlib/GSXftFontInfo.m +++ b/Source/xlib/GSXftFontInfo.m @@ -940,7 +940,7 @@ static FT_Outline_Funcs bezierpath_funcs = { xHeight = capHeight*0.6; //Errr... TODO fontBBox = NSMakeRect( (float)(0), - (float)(0 - font_info->ascent), + (float)(-font_info->descent), (float)(font_info->max_advance_width), (float)(font_info->ascent + font_info->descent)); maximumAdvancement = NSMakeSize(font_info->max_advance_width, 0.0); diff --git a/Source/xlib/XGFont.m b/Source/xlib/XGFont.m index ace0473..6b6d883 100644 --- a/Source/xlib/XGFont.m +++ b/Source/xlib/XGFont.m @@ -304,8 +304,8 @@ static BOOL XGInitAtoms(Display *dpy) ascender = font_info->ascent; descender = -(font_info->descent); fontBBox = NSMakeRect( - (float)(0 + font_info->min_bounds.lbearing), - (float)(0 - font_info->max_bounds.ascent), + (float)(font_info->min_bounds.lbearing), + (float)(-font_info->max_bounds.descent), (float)(font_info->max_bounds.rbearing - font_info->min_bounds.lbearing), (float)(font_info->max_bounds.ascent + font_info->max_bounds.descent)); maximumAdvancement = NSMakeSize(font_info->max_bounds.width, 0.0); diff --git a/Source/xlib/XGFontSetFontInfo.m b/Source/xlib/XGFontSetFontInfo.m index 5e38393..335c9a4 100644 --- a/Source/xlib/XGFontSetFontInfo.m +++ b/Source/xlib/XGFontSetFontInfo.m @@ -132,7 +132,7 @@ static BOOL char_struct_for_glyph(NSGlyph glyph, XFontSet font_set, mostCompatibleStringEncoding = NSASCIIStringEncoding; fontBBox = NSMakeRect(base->min_bounds.lbearing, - -base->max_bounds.ascent, + -base->max_bounds.descent, base->max_bounds.rbearing - base->max_bounds.lbearing, base->max_bounds.ascent + base->max_bounds.descent); isFixedPitch = XGFontIsFixedPitch(dpy, base);