mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-23 16:10:52 +00:00
Focus fixes. Update passing of colorspaces, fonts
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@14680 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
802e8e9997
commit
f6429ce1fc
11 changed files with 85 additions and 98 deletions
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2002-10-08 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Update for front-end passing colorspaces and fonts
|
||||
in overridable way.
|
||||
* Headers/gsc/GSGStateOps.h: Update changed methods.
|
||||
* Source/art/ARTContext.m: Font ivar is now a GSFontInfo
|
||||
class, so use 'font' instead of '[font fontInfo]'.
|
||||
* Source/gsc/GSContext.m (-GSSetFont): Idem.
|
||||
(-GSSetFillColorspace:): Implement.
|
||||
(-GSSetStrokeColorspace:): Idem.
|
||||
(-GSSetFillColor:): Idem.
|
||||
(-GSSetStrokeColor:): Idem.
|
||||
* Source/gsc/GSGState.m: Update font ivar handling.
|
||||
* Source/gsc/GSStreamContext.m: Idem.
|
||||
* Source/winlib/WIN32GState.m: Idem.
|
||||
* Source/xlib/XGGState.m: Idem.
|
||||
|
||||
* Window focus fixes
|
||||
* Source/x11/XGServerEvent.m ([XGServer
|
||||
-receivedEvent:type:extra:forMode:](ClientMessage/TAKE_FOCUS)):
|
||||
Use given window as focus window, not one under mouse.
|
||||
* Source/x11/XGServerWindow.m ([XGServer -setinputfocus:]): Don't
|
||||
reset focus if we already requested it on this window.
|
||||
|
||||
2002-09-28 22:04 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/art/ftfont.m: Add .font package handling again.
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef enum {
|
|||
NSAffineTransform *ctm;
|
||||
NSPoint offset; /* Offset from Drawable origin */
|
||||
NSBezierPath *path; /* Current path */
|
||||
NSFont *font; /* Current font */
|
||||
GSFontInfo *font; /* Current font reference */
|
||||
NSColor *fillColorS; /* Color(space) used for fill drawing */
|
||||
NSColor *strokeColorS; /* Color(space) used for stroke drawing */
|
||||
device_color_t fillColor; /* fill color */
|
||||
|
|
|
@ -40,10 +40,10 @@
|
|||
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b;
|
||||
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b;
|
||||
|
||||
- (void) GSSetFillColorspace: (NSDictionary *)dict;
|
||||
- (void) GSSetStrokeColorspace: (NSDictionary *)dict;
|
||||
- (void) GSSetFillColor: (float *)values;
|
||||
- (void) GSSetStrokeColor: (float *)values;
|
||||
- (void) GSSetFillColorspace: (void *)spaceref;
|
||||
- (void) GSSetStrokeColorspace: (void *)spaceref;
|
||||
- (void) GSSetFillColor: (const float *)values;
|
||||
- (void) GSSetStrokeColor: (const float *)values;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Text operations */
|
||||
|
@ -59,7 +59,7 @@
|
|||
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size;
|
||||
|
||||
- (void) GSSetCharacterSpacing: (float)extra;
|
||||
- (void) GSSetFont: (NSFont*)font;
|
||||
- (void) GSSetFont: (GSFontInfo *)fontref;
|
||||
- (void) GSSetFontSize: (float)size;
|
||||
- (NSAffineTransform *) GSGetTextCTM;
|
||||
- (NSPoint) GSGetTextPosition;
|
||||
|
|
|
@ -202,7 +202,7 @@ very expensive
|
|||
if ([path isEmpty]) return;
|
||||
p=[self currentPoint];
|
||||
|
||||
[(id<FTFontInfo>)[font fontInfo]
|
||||
[(id<FTFontInfo>)font
|
||||
outlineString: s
|
||||
at: p.x:p.y
|
||||
gstate: self];
|
||||
|
@ -223,7 +223,7 @@ very expensive
|
|||
|
||||
x = p.x;
|
||||
y = wi->sy - p.y;
|
||||
[(id<FTFontInfo>)[font fontInfo]
|
||||
[(id<FTFontInfo>)font
|
||||
drawString: s
|
||||
at: x:y
|
||||
to: clip_x0:clip_y0:clip_x1:clip_y1 : CLIP_DATA : wi->bytes_per_line
|
||||
|
@ -252,7 +252,7 @@ very expensive
|
|||
|
||||
x = p.x;
|
||||
y = wi->sy - p.y;
|
||||
[(id<FTFontInfo>)[font fontInfo]
|
||||
[(id<FTFontInfo>)font
|
||||
drawString: s
|
||||
at: x:y
|
||||
to: clip_x0:clip_y0:clip_x1:clip_y1 : CLIP_DATA : wi->bytes_per_line
|
||||
|
@ -276,7 +276,7 @@ very expensive
|
|||
|
||||
x = p.x;
|
||||
y = wi->sy - p.y;
|
||||
[(id<FTFontInfo>)[font fontInfo]
|
||||
[(id<FTFontInfo>)font
|
||||
drawString: s
|
||||
at: x:y
|
||||
to: clip_x0:clip_y0:clip_x1:clip_y1 : CLIP_DATA : wi->bytes_per_line
|
||||
|
@ -300,7 +300,7 @@ very expensive
|
|||
|
||||
x = p.x;
|
||||
y = wi->sy - p.y;
|
||||
[(id<FTFontInfo>)[font fontInfo]
|
||||
[(id<FTFontInfo>)font
|
||||
drawString: s
|
||||
at: x:y
|
||||
to: clip_x0:clip_y0:clip_x1:clip_y1 : CLIP_DATA : wi->bytes_per_line
|
||||
|
|
|
@ -255,24 +255,24 @@ static unsigned int unique_index = 0;
|
|||
[gstate DPSsetrgbcolor:r :g :b];
|
||||
}
|
||||
|
||||
- (void) GSSetFillColorspace: (NSDictionary *)dict
|
||||
- (void) GSSetFillColorspace: (void *)spaceref
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
[gstate GSSetFillColorspace: spaceref];
|
||||
}
|
||||
|
||||
- (void) GSSetStrokeColorspace: (NSDictionary *)dict
|
||||
- (void) GSSetStrokeColorspace: (void *)spaceref
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
[gstate GSSetStrokeColorspace: spaceref];
|
||||
}
|
||||
|
||||
- (void) GSSetFillColor: (float *)values
|
||||
- (void) GSSetFillColor: (const float *)values
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
[gstate GSSetFillColor: values];
|
||||
}
|
||||
|
||||
- (void) GSSetStrokeColor: (float *)values
|
||||
- (void) GSSetStrokeColor: (const float *)values
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
[gstate GSSetStrokeColor: values];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
@ -323,9 +323,9 @@ static unsigned int unique_index = 0;
|
|||
[gstate GSSetCharacterSpacing: extra];
|
||||
}
|
||||
|
||||
- (void) GSSetFont: (NSFont*)font
|
||||
- (void) GSSetFont: (void *)fontref
|
||||
{
|
||||
[gstate GSSetFont: font];
|
||||
[gstate GSSetFont: fontref];
|
||||
}
|
||||
|
||||
- (void) GSSetFontSize: (float)size
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <AppKit/NSAffineTransform.h>
|
||||
#include <AppKit/NSBezierPath.h>
|
||||
#include <AppKit/NSColor.h>
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/GSFontInfo.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include "gsc/GSContext.h"
|
||||
#include "gsc/GSGState.h"
|
||||
|
@ -41,11 +41,11 @@
|
|||
|
||||
/* Just temporary until we improve NSColor */
|
||||
@interface NSColor (PrivateColor)
|
||||
+ colorWithValues: (float *)values colorSpaceName: colorSpace;
|
||||
+ colorWithValues: (const float *)values colorSpaceName: colorSpace;
|
||||
@end
|
||||
|
||||
@implementation NSColor (PrivateColor)
|
||||
+ colorWithValues: (float *)values colorSpaceName: colorSpace
|
||||
+ colorWithValues: (const float *)values colorSpaceName: colorSpace
|
||||
{
|
||||
NSColor *color = nil;
|
||||
if ([colorSpace isEqual: NSDeviceWhiteColorSpace])
|
||||
|
@ -278,10 +278,11 @@
|
|||
}
|
||||
|
||||
|
||||
- (void) GSSetFillColorspace: (NSDictionary *)dict
|
||||
- (void) GSSetFillColorspace: (void *)spaceref
|
||||
{
|
||||
device_color_t col;
|
||||
float values[6];
|
||||
NSDictionary *dict = (NSDictionary *)spaceref;
|
||||
NSString *colorSpace = [dict objectForKey: GSColorSpaceName];
|
||||
if (fillColorS)
|
||||
RELEASE(fillColorS);
|
||||
|
@ -292,10 +293,11 @@
|
|||
[self setColor: &col state: COLOR_FILL];
|
||||
}
|
||||
|
||||
- (void) GSSetStrokeColorspace: (NSDictionary *)dict
|
||||
- (void) GSSetStrokeColorspace: (void *)spaceref
|
||||
{
|
||||
device_color_t col;
|
||||
float values[6];
|
||||
NSDictionary *dict = (NSDictionary *)spaceref;
|
||||
NSString *colorSpace = [dict objectForKey: GSColorSpaceName];
|
||||
if (strokeColorS)
|
||||
RELEASE(strokeColorS);
|
||||
|
@ -306,7 +308,7 @@
|
|||
[self setColor: &col state: COLOR_STROKE];
|
||||
}
|
||||
|
||||
- (void) GSSetFillColor: (float *)values
|
||||
- (void) GSSetFillColor: (const float *)values
|
||||
{
|
||||
device_color_t dcolor;
|
||||
NSColor *color;
|
||||
|
@ -329,7 +331,7 @@
|
|||
[self setColor: &dcolor state: COLOR_FILL];
|
||||
}
|
||||
|
||||
- (void) GSSetStrokeColor: (float *)values
|
||||
- (void) GSSetStrokeColor: (const float *)values
|
||||
{
|
||||
device_color_t dcolor;
|
||||
NSColor *color;
|
||||
|
@ -401,20 +403,15 @@
|
|||
charSpacing = extra;
|
||||
}
|
||||
|
||||
- (void) GSSetFont: (NSFont*)newFont
|
||||
- (void) GSSetFont: (GSFontInfo *)fontref
|
||||
{
|
||||
if (font == newFont)
|
||||
if (font == fontref)
|
||||
return;
|
||||
ASSIGN(font, newFont);
|
||||
ASSIGN(font, fontref);
|
||||
}
|
||||
|
||||
- (void) GSSetFontSize: (float)size
|
||||
{
|
||||
NSFont *newFont;
|
||||
if (font == nil)
|
||||
return;
|
||||
newFont = [NSFont fontWithName: [font fontName] size: size];
|
||||
[self GSSetFont: newFont];
|
||||
}
|
||||
|
||||
- (NSAffineTransform *) GSGetTextCTM
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "gsc/GSContext.h"
|
||||
#include "gsc/GSStreamContext.h"
|
||||
#include "gsc/GSStreamGState.h"
|
||||
#include <AppKit/GSFontInfo.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
|
@ -121,12 +122,12 @@
|
|||
fprintf(gstream, "%g %g %g setrgbcolor\n", r, g, b);
|
||||
}
|
||||
|
||||
- (void) GSSetFillColor: (float *)values
|
||||
- (void) GSSetFillColor: (const float *)values
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (void) GSSetStrokeColor: (float *)values
|
||||
- (void) GSSetStrokeColor: (const float *)values
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
@ -191,10 +192,10 @@
|
|||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (void) GSSetFont: (NSFont*)font
|
||||
- (void) GSSetFont: (void *)fontref
|
||||
{
|
||||
const float *m = [font matrix];
|
||||
fprintf(gstream, "/%s findfont ", [[font fontName] cString]);
|
||||
const float *m = [(GSFontInfo *)fontref matrix];
|
||||
fprintf(gstream, "/%s findfont ", [[(GSFontInfo *)fontref fontName] cString]);
|
||||
fprintf(gstream, "[%g %g %g %g %g %g] ", m[0], m[1], m[2], m[3], m[4], m[5]);
|
||||
fprintf(gstream, " makefont setfont\n");
|
||||
}
|
||||
|
|
|
@ -710,7 +710,7 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
|
|||
}
|
||||
|
||||
p = GSWindowPointToMS(self, current);
|
||||
[(WIN32FontInfo*)[font fontInfo] draw: s lenght: strlen(s)
|
||||
[(WIN32FontInfo*)font draw: s lenght: strlen(s)
|
||||
onDC: hDC at: p];
|
||||
[self releaseHDC: hDC];
|
||||
}
|
||||
|
|
|
@ -493,37 +493,10 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
|
|||
else if (xEvent.xclient.data.l[0]
|
||||
== generic.take_focus_atom)
|
||||
{
|
||||
int win;
|
||||
NSPoint p;
|
||||
gswindow_device_t *w = 0;
|
||||
|
||||
/*
|
||||
* WM is asking us to take the keyboard focus
|
||||
*/
|
||||
NSDebugLLog(@"Focus", @"check focus: %d",
|
||||
cWin->number);
|
||||
p = [self mouseLocationOnScreen: -1 window:(void *)&win];
|
||||
if (win == 0)
|
||||
{
|
||||
/*
|
||||
* If we can't locate the window under the mouse,
|
||||
* assume an existing window.
|
||||
*/
|
||||
nswin = [NSApp keyWindow];
|
||||
if (nswin == nil)
|
||||
{
|
||||
nswin = [NSApp mainWindow];
|
||||
}
|
||||
if (nswin != nil)
|
||||
{
|
||||
win = [nswin windowNumber];
|
||||
}
|
||||
}
|
||||
w = [XGServer _windowWithTag: win];
|
||||
if (w != 0)
|
||||
{
|
||||
cWin = w;
|
||||
}
|
||||
NSDebugLLog(@"Focus", @"check focus: %d", cWin->number);
|
||||
nswin = [NSApp keyWindow];
|
||||
if (nswin == nil
|
||||
|| [nswin windowNumber] != cWin->number)
|
||||
|
@ -541,8 +514,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
|
|||
data1: 0
|
||||
data2: 0];
|
||||
}
|
||||
if (nswin != nil
|
||||
&& [nswin windowNumber] == cWin->number)
|
||||
else if (generic.desiredFocusWindow != 0)
|
||||
{
|
||||
/*
|
||||
* We reassert our desire to have input
|
||||
|
@ -929,6 +901,7 @@ static inline int check_modifier (XEvent *xEvent, KeyCode key_code)
|
|||
{
|
||||
nswin = GSWindowWithNumber(cWin->number);
|
||||
}
|
||||
NSDebugLLog(@"Focus", @"Focus went to %p\n", nswin);
|
||||
if (nswin == nil)
|
||||
{
|
||||
[NSApp deactivate];
|
||||
|
|
|
@ -2216,12 +2216,11 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number,
|
|||
*/
|
||||
if (win == generic.desiredFocusWindow && generic.focusRequestNumber != 0)
|
||||
{
|
||||
NSDebugLLog(@"Focus", @"Resetting focus to %d", window->number);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDebugLLog(@"Focus", @"Setting focus to %d", window->number);
|
||||
NSDebugLLog(@"Focus", @"Focus already set on %d", window->number);
|
||||
return;
|
||||
}
|
||||
|
||||
NSDebugLLog(@"Focus", @"Setting focus to %d", window->number);
|
||||
generic.desiredFocusWindow = win;
|
||||
generic.focusRequestNumber = XNextRequest(dpy);
|
||||
XSetInputFocus(dpy, window->ident, RevertToParent, generic.lastTime);
|
||||
|
|
|
@ -356,9 +356,6 @@ static Region emptyRegion;
|
|||
NSRect flushRect;
|
||||
Drawable from;
|
||||
|
||||
flushRect.size = aRect.size;
|
||||
flushRect.origin = aPoint;
|
||||
|
||||
CHECK_GC;
|
||||
if (draw == 0)
|
||||
{
|
||||
|
@ -373,6 +370,8 @@ static Region emptyRegion;
|
|||
}
|
||||
|
||||
src = XGViewRectToX(source, aRect);
|
||||
flushRect.size = aRect.size;
|
||||
flushRect.origin = aPoint;
|
||||
dst = XGViewRectToX(self, flushRect);
|
||||
NSDebugLLog(@"XGGraphics", @"Copy area from %@ to %@",
|
||||
NSStringFromRect(aRect), NSStringFromPoint(aPoint));
|
||||
|
@ -1195,10 +1194,9 @@ typedef enum {
|
|||
int len;
|
||||
int width;
|
||||
NSSize scale;
|
||||
XGFontInfo *font_info = [font fontInfo];
|
||||
NSPoint point = [path currentPoint];
|
||||
|
||||
if (font_info == nil)
|
||||
if (font == nil)
|
||||
{
|
||||
NSLog(@"DPS (xgps): no font set\n");
|
||||
return;
|
||||
|
@ -1225,10 +1223,10 @@ typedef enum {
|
|||
// FIXME: We should put this line before the loop
|
||||
// and do all computation in display space.
|
||||
xp = XGWindowPointToX(self, point);
|
||||
width = [font_info widthOf: s+i lenght: 1];
|
||||
width = [(XGFontInfo *)font widthOf: s+i lenght: 1];
|
||||
// Hack: Only draw when alpha is not zero
|
||||
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||
[font_info draw: s+i lenght: 1
|
||||
[(XGFontInfo *)font draw: s+i lenght: 1
|
||||
onDisplay: XDPY drawable: draw
|
||||
with: xgcntxt at: xp];
|
||||
|
||||
|
@ -1237,7 +1235,7 @@ typedef enum {
|
|||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||
|
||||
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||
[font_info draw: s+i lenght: 1
|
||||
[(XGFontInfo *)font draw: s+i lenght: 1
|
||||
onDisplay: XDPY drawable: alpha_buffer
|
||||
with: agcntxt at: xp];
|
||||
}
|
||||
|
@ -1264,7 +1262,7 @@ typedef enum {
|
|||
if (relative == YES)
|
||||
{
|
||||
delta.x += width * scale.width;
|
||||
delta.y += [font_info ascender] * scale.height;
|
||||
delta.y += [font ascender] * scale.height;
|
||||
}
|
||||
if (c && *(s+i) == c)
|
||||
{
|
||||
|
@ -1306,9 +1304,8 @@ typedef enum {
|
|||
int width;
|
||||
NSSize scale;
|
||||
XPoint xp;
|
||||
XGFontInfo *font_info = [font fontInfo];
|
||||
|
||||
if (font_info == nil)
|
||||
if (font == nil)
|
||||
{
|
||||
NSLog(@"DPS (xgps): no font set\n");
|
||||
return;
|
||||
|
@ -1325,11 +1322,11 @@ typedef enum {
|
|||
[self setColor: &fillColor state: COLOR_FILL];
|
||||
|
||||
len = strlen(s);
|
||||
width = [font_info widthOf: s lenght: len];
|
||||
width = [(XGFontInfo *)font widthOf: s lenght: len];
|
||||
xp = XGWindowPointToX(self, [path currentPoint]);
|
||||
// Hack: Only draw when alpha is not zero
|
||||
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
|
||||
[font_info draw: s lenght: len
|
||||
[(XGFontInfo *)font draw: s lenght: len
|
||||
onDisplay: XDPY drawable: draw
|
||||
with: xgcntxt at: xp];
|
||||
|
||||
|
@ -1338,7 +1335,7 @@ typedef enum {
|
|||
NSAssert(alpha_buffer, NSInternalInconsistencyException);
|
||||
|
||||
[self setAlphaColor: fillColor.field[AINDEX]];
|
||||
[font_info draw: s lenght: len
|
||||
[(XGFontInfo *)font draw: s lenght: len
|
||||
onDisplay: XDPY drawable: alpha_buffer
|
||||
with: agcntxt at: xp];
|
||||
}
|
||||
|
@ -1381,21 +1378,17 @@ typedef enum {
|
|||
isRelative: NO];
|
||||
}
|
||||
|
||||
- (void) GSSetFont: (NSFont*)newFont
|
||||
- (void) GSSetFont: (GSFontInfo *)newFont
|
||||
{
|
||||
XGFontInfo *font_info;
|
||||
|
||||
if (font == newFont)
|
||||
return;
|
||||
|
||||
ASSIGN(font, newFont);
|
||||
[super GSSetFont: newFont];
|
||||
|
||||
COPY_GC_ON_CHANGE;
|
||||
if (xgcntxt == 0)
|
||||
return;
|
||||
|
||||
font_info = (XGFontInfo *)[font fontInfo];
|
||||
[font_info setActiveFor: XDPY gc: xgcntxt];
|
||||
[(XGFontInfo *)font setActiveFor: XDPY gc: xgcntxt];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in a new issue