mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
- Added xdnd v3 support in WINGs (Sylvain Reynal <sreynal@nerim.net>)
- CVS should compile again
This commit is contained in:
@@ -122,6 +122,7 @@ Changes since version 0.80.2:
|
||||
- Added workaround in global WMWindowAttributes, to avoid creating a second
|
||||
appicon when a KDE3 application opens a config panel.
|
||||
- Updated slovak translation (Jan Tomka <judas@linux.sk>)
|
||||
- Added xdnd v3 support in WINGs (Sylvain Reynal <sreynal@nerim.net>)
|
||||
|
||||
|
||||
Changes since version 0.80.1:
|
||||
|
||||
@@ -47,13 +47,14 @@ Changes since wmaker 0.80.1:
|
||||
- Fixed small memory leak in the font panel code.
|
||||
- Fixed call to qsort in WMSortArray.
|
||||
- Fixed a memleak in the file panel.
|
||||
- Double/triple-click selection in text widgets (Vitaly Ovtchinnikov
|
||||
<ov@rbcmail.ru>)
|
||||
- fixed bug in tableview (clicked row callback got incorrect row) (Carlos Torres
|
||||
<vlaadbrain@operamail.com>)
|
||||
- Double/triple-click selection in text widgets
|
||||
(Vitaly Ovtchinnikov <ov@rbcmail.ru>)
|
||||
- fixed bug in tableview (clicked row callback got incorrect row)
|
||||
(Carlos Torres <vlaadbrain@operamail.com>)
|
||||
- Fixed bug in resizing a scrollview
|
||||
- Fixed bug with wrong text wrapping (Alexey Voinov <voins@voins.program.ru>)
|
||||
- Added wmkrect()
|
||||
- Added xdnd v3 support (Sylvain Reynal <sreynal@nerim.net>)
|
||||
|
||||
|
||||
Changes since wmaker 0.80.0:
|
||||
|
||||
@@ -27,6 +27,7 @@ libWINGs_a_SOURCES = \
|
||||
configuration.c \
|
||||
connection.c \
|
||||
data.c \
|
||||
dragcommon.c \
|
||||
dragdestination.c \
|
||||
dragsource.c \
|
||||
error.c \
|
||||
|
||||
@@ -16,6 +16,7 @@ wtest_DEPENDENCIES = $(top_builddir)/WINGs/libWINGs.a
|
||||
EXTRA_DIST = logo.xpm upbtn.xpm wm.html wm.png
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/WINGs -I$(top_srcdir)/wrlib -I$(top_srcdir)/src \
|
||||
-DRESOURCE_PATH=\"$(datadir)/WINGs\" @HEADER_SEARCH_PATH@ -DDEBUG
|
||||
-DRESOURCE_PATH=\"$(datadir)/WINGs\" @XFTFLAGS@ @HEADER_SEARCH_PATH@ \
|
||||
-DDEBUG
|
||||
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ Display *dpy;
|
||||
int windowCount = 0;
|
||||
|
||||
void
|
||||
closeAction(WMWidget *self, void *data)
|
||||
closeAction(WMWidget *self, void *data)
|
||||
{
|
||||
WMDestroyWidget(self);
|
||||
windowCount--;
|
||||
printf("window closed, window count = %d\n", windowCount);
|
||||
if (windowCount < 1)
|
||||
exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ testFontPanel(WMScreen *scr)
|
||||
|
||||
WMShowFontPanel(panel);
|
||||
|
||||
/* WMFreeFontPanel(panel);*/
|
||||
/*WMFreeFontPanel(panel);*/
|
||||
}
|
||||
|
||||
|
||||
@@ -78,15 +78,15 @@ testFrame(WMScreen *scr)
|
||||
WMFrame *frame;
|
||||
int i;
|
||||
static char* titles[] = {
|
||||
"AboveTop",
|
||||
"AtTop",
|
||||
"BelowTop",
|
||||
"AboveBottom",
|
||||
"AtBottom",
|
||||
"BelowBottom"
|
||||
"AboveTop",
|
||||
"AtTop",
|
||||
"BelowTop",
|
||||
"AboveBottom",
|
||||
"AtBottom",
|
||||
"BelowBottom"
|
||||
};
|
||||
static WMTitlePosition pos[] = {
|
||||
WTPAboveTop,
|
||||
WTPAboveTop,
|
||||
WTPAtTop,
|
||||
WTPBelowTop,
|
||||
WTPAboveBottom,
|
||||
@@ -102,11 +102,11 @@ testFrame(WMScreen *scr)
|
||||
WMResizeWidget(win, 400, 300);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
frame = WMCreateFrame(win);
|
||||
WMMoveWidget(frame, 8+(i%3)*130, 8+(i/3)*130);
|
||||
WMResizeWidget(frame, 120, 120);
|
||||
frame = WMCreateFrame(win);
|
||||
WMMoveWidget(frame, 8+(i%3)*130, 8+(i/3)*130);
|
||||
WMResizeWidget(frame, 120, 120);
|
||||
WMSetFrameTitle(frame, titles[i]);
|
||||
WMSetFrameTitlePosition(frame, pos[i]);
|
||||
WMSetFrameTitlePosition(frame, pos[i]);
|
||||
}
|
||||
|
||||
WMRealizeWidget(win);
|
||||
@@ -147,10 +147,10 @@ testBox(WMScreen *scr)
|
||||
|
||||
/*WMSetBoxHorizontal(box, True);*/
|
||||
for (i = 0; i < 4; i++) {
|
||||
btn = WMCreateCommandButton(box);
|
||||
WMSetButtonText(btn, "bla");
|
||||
WMMapWidget(btn);
|
||||
WMAddBoxSubview(box, WMWidgetView(btn), i&1, True, 20, 0, 5);
|
||||
btn = WMCreateCommandButton(box);
|
||||
WMSetButtonText(btn, "bla");
|
||||
WMMapWidget(btn);
|
||||
WMAddBoxSubview(box, WMWidgetView(btn), i&1, True, 20, 0, 5);
|
||||
}
|
||||
|
||||
pop = WMCreatePopUpButton(box);
|
||||
@@ -165,10 +165,10 @@ testBox(WMScreen *scr)
|
||||
WMMapWidget(hbox);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
btn = WMCreateCommandButton(hbox);
|
||||
WMSetButtonText(btn, "bla");
|
||||
WMMapWidget(btn);
|
||||
WMAddBoxSubview(hbox, WMWidgetView(btn), 1, True, 60, 0, i<3?5:0);
|
||||
btn = WMCreateCommandButton(hbox);
|
||||
WMSetButtonText(btn, "bla");
|
||||
WMMapWidget(btn);
|
||||
WMAddBoxSubview(hbox, WMWidgetView(btn), 1, True, 60, 0, i<3?5:0);
|
||||
}
|
||||
|
||||
|
||||
@@ -242,16 +242,16 @@ testList(WMScreen *scr)
|
||||
/*WMSetListAllowEmptySelection(list, True);*/
|
||||
WMMoveWidget(list, 10, 40);
|
||||
for (i=0; i<105; i++) {
|
||||
sprintf(text, "Item %i", i);
|
||||
WMAddListItem(list, text);
|
||||
sprintf(text, "Item %i", i);
|
||||
WMAddListItem(list, text);
|
||||
}
|
||||
mlist = WMCreateList(win);
|
||||
WMSetListAllowMultipleSelection(mlist, True);
|
||||
/*WMSetListAllowEmptySelection(mlist, True);*/
|
||||
WMMoveWidget(mlist, 210, 40);
|
||||
for (i=0; i<135; i++) {
|
||||
sprintf(text, "Item %i", i);
|
||||
WMAddListItem(mlist, text);
|
||||
sprintf(text, "Item %i", i);
|
||||
WMAddListItem(mlist, text);
|
||||
}
|
||||
|
||||
label = WMCreateLabel(win);
|
||||
@@ -272,9 +272,9 @@ testList(WMScreen *scr)
|
||||
WMSetListDoubleAction(mlist, doubleClick, mlabel);
|
||||
|
||||
WMAddNotificationObserver(listSelectionObserver, label,
|
||||
WMListSelectionDidChangeNotification, list);
|
||||
WMListSelectionDidChangeNotification, list);
|
||||
WMAddNotificationObserver(listSelectionObserver, mlabel,
|
||||
WMListSelectionDidChangeNotification, mlist);
|
||||
WMListSelectionDidChangeNotification, mlist);
|
||||
|
||||
|
||||
WMRealizeWidget(win);
|
||||
@@ -289,14 +289,14 @@ testButton(WMScreen *scr)
|
||||
WMWindow *win;
|
||||
int i;
|
||||
char *types[] = {
|
||||
"MomentaryPush",
|
||||
"PushOnPushOff",
|
||||
"Toggle",
|
||||
"Switch",
|
||||
"Radio",
|
||||
"MomentaryChange",
|
||||
"OnOff",
|
||||
"MomentaryLigh"
|
||||
"MomentaryPush",
|
||||
"PushOnPushOff",
|
||||
"Toggle",
|
||||
"Switch",
|
||||
"Radio",
|
||||
"MomentaryChange",
|
||||
"OnOff",
|
||||
"MomentaryLigh"
|
||||
};
|
||||
|
||||
windowCount++;
|
||||
@@ -308,11 +308,11 @@ testButton(WMScreen *scr)
|
||||
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||
|
||||
for (i = 1; i < 9; i++) {
|
||||
WMButton *b;
|
||||
b = WMCreateButton(win, i);
|
||||
WMResizeWidget(b, 150, 24);
|
||||
WMMoveWidget(b, 20, i*30);
|
||||
WMSetButtonText(b, types[i-1]);
|
||||
WMButton *b;
|
||||
b = WMCreateButton(win, i);
|
||||
WMResizeWidget(b, 150, 24);
|
||||
WMMoveWidget(b, 20, i*30);
|
||||
WMSetButtonText(b, types[i-1]);
|
||||
}
|
||||
|
||||
WMRealizeWidget(win);
|
||||
@@ -404,7 +404,7 @@ testGradientButtons(WMScreen *scr)
|
||||
WMSetButtonTextColor(btn, color);
|
||||
|
||||
WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!",
|
||||
WMWidgetView(btn));
|
||||
WMWidgetView(btn));
|
||||
|
||||
WMReleaseColor(color);
|
||||
WMReleaseColor(altColor);
|
||||
@@ -450,12 +450,12 @@ testScrollView(WMScreen *scr)
|
||||
WMSetFrameRelief(f, WRFlat);
|
||||
|
||||
for (i=0; i<20; i++) {
|
||||
l = WMCreateLabel(f);
|
||||
WMResizeWidget(l, 50, 18);
|
||||
WMMoveWidget(l, 10, 20*i);
|
||||
sprintf(buffer, "Label %i", i);
|
||||
WMSetLabelText(l, buffer);
|
||||
WMSetLabelRelief(l, WRSimple);
|
||||
l = WMCreateLabel(f);
|
||||
WMResizeWidget(l, 50, 18);
|
||||
WMMoveWidget(l, 10, 20*i);
|
||||
sprintf(buffer, "Label %i", i);
|
||||
WMSetLabelText(l, buffer);
|
||||
WMSetLabelRelief(l, WRSimple);
|
||||
}
|
||||
WMMapSubwidgets(f);
|
||||
WMMapWidget(f);
|
||||
@@ -509,10 +509,10 @@ testColorPanel(WMScreen *scr)
|
||||
WMColorPanel *panel = WMGetColorPanel(scr);
|
||||
|
||||
/*if (colorname) {
|
||||
startcolor = WMCreateNamedColor(scr, colorname, False);
|
||||
WMSetColorPanelColor(panel, startcolor);
|
||||
WMReleaseColor(startcolor);
|
||||
}*/
|
||||
startcolor = WMCreateNamedColor(scr, colorname, False);
|
||||
WMSetColorPanelColor(panel, startcolor);
|
||||
WMReleaseColor(startcolor);
|
||||
}*/
|
||||
|
||||
WMShowColorPanel(panel);
|
||||
}
|
||||
@@ -609,7 +609,7 @@ testText(WMScreen *scr)
|
||||
WMFont *font, *ifont;
|
||||
|
||||
font = WMDefaultSystemFont(scr);
|
||||
ifont = WMCopyFontWithChanges(scr, font, WFAEmphasized);
|
||||
ifont = WMCopyFontWithStyle(scr, font, WFSEmphasized);
|
||||
if (ifont) {
|
||||
WMSetTextDefaultFont(text, ifont);
|
||||
WMReleaseFont(ifont);
|
||||
@@ -804,21 +804,21 @@ testTabView(WMScreen *scr)
|
||||
|
||||
void
|
||||
splitViewConstrainProc(WMSplitView *sPtr, int indView,
|
||||
int *minSize, int *maxSize)
|
||||
int *minSize, int *maxSize)
|
||||
{
|
||||
switch (indView) {
|
||||
case 0:
|
||||
*minSize = 20;
|
||||
break;
|
||||
*minSize = 20;
|
||||
break;
|
||||
case 1:
|
||||
*minSize = 40;
|
||||
*maxSize = 80;
|
||||
break;
|
||||
*minSize = 40;
|
||||
*maxSize = 80;
|
||||
break;
|
||||
case 2:
|
||||
*maxSize = 60;
|
||||
break;
|
||||
*maxSize = 60;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,14 +829,14 @@ resizeSplitView(XEvent *event, void *data)
|
||||
WMSplitView *sPtr = (WMSplitView*)data;
|
||||
|
||||
if (event->type == ConfigureNotify) {
|
||||
int width = event->xconfigure.width - 10;
|
||||
int width = event->xconfigure.width - 10;
|
||||
|
||||
if (width < WMGetSplitViewDividerThickness(sPtr))
|
||||
width = WMGetSplitViewDividerThickness(sPtr);
|
||||
if (width < WMGetSplitViewDividerThickness(sPtr))
|
||||
width = WMGetSplitViewDividerThickness(sPtr);
|
||||
|
||||
if (width != WMWidgetWidth(sPtr) ||
|
||||
if (width != WMWidgetWidth(sPtr) ||
|
||||
event->xconfigure.height != WMWidgetHeight(sPtr))
|
||||
WMResizeWidget(sPtr, width, event->xconfigure.height - 55);
|
||||
WMResizeWidget(sPtr, width, event->xconfigure.height - 55);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,9 +862,9 @@ removeSubviewButtonAction(WMWidget *self, void *data)
|
||||
int count = WMGetSplitViewSubviewsCount(sPtr);
|
||||
|
||||
if (count > 2) {
|
||||
WMView *view = WMGetSplitViewSubviewAt(sPtr, count-1);
|
||||
WMDestroyWidget(WMWidgetOfView(view));
|
||||
WMRemoveSplitViewSubviewAt(sPtr, count-1);
|
||||
WMView *view = WMGetSplitViewSubviewAt(sPtr, count-1);
|
||||
WMDestroyWidget(WMWidgetOfView(view));
|
||||
WMRemoveSplitViewSubviewAt(sPtr, count-1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,275 +969,6 @@ testSplitView(WMScreen *scr)
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
int x, y;
|
||||
Bool mouseDown;
|
||||
char *filename;
|
||||
} DNDStuff;
|
||||
|
||||
WMPixmap*
|
||||
getImage(WMScreen *scr, char *file)
|
||||
{
|
||||
char buffer[1000];
|
||||
WMPixmap *pix;
|
||||
|
||||
sprintf(buffer, "../../WindowMaker/Icons/%s", file);
|
||||
pix = WMCreatePixmapFromFile(scr, buffer);
|
||||
|
||||
return pix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
iconMouseStuff(XEvent *event, void *cdata)
|
||||
{
|
||||
WMLabel *label = (WMLabel*)cdata;
|
||||
DNDStuff *stuff = WMGetHangedData(label);
|
||||
WMPoint where;
|
||||
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
stuff->x = event->xbutton.x;
|
||||
stuff->y = event->xbutton.y;
|
||||
stuff->mouseDown = True;
|
||||
break;
|
||||
case ButtonRelease:
|
||||
stuff->mouseDown = False;
|
||||
break;
|
||||
case MotionNotify:
|
||||
if (!stuff->mouseDown)
|
||||
break;
|
||||
|
||||
if (abs(stuff->x - event->xmotion.x)>4
|
||||
|| abs(stuff->y - event->xmotion.y)>4) {
|
||||
|
||||
where = WMGetViewScreenPosition(WMWidgetView(label));
|
||||
|
||||
WMDragImageFromView(WMWidgetView(label),
|
||||
WMGetLabelImage(label),
|
||||
NULL, /* XXX */
|
||||
where,
|
||||
wmksize(stuff->x, stuff->y),
|
||||
event, True);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
endedDragImage(WMView *self, WMPixmap *image, WMPoint point, Bool deposited)
|
||||
{
|
||||
DNDStuff *stuff = WMGetHangedData(WMWidgetOfView(self));
|
||||
|
||||
if (deposited) {
|
||||
WMDestroyWidget(WMWidgetOfView(self));
|
||||
}
|
||||
|
||||
stuff->mouseDown = False;
|
||||
}
|
||||
|
||||
|
||||
static WMData*
|
||||
fetchDragData(WMView *self, char *type)
|
||||
{
|
||||
DNDStuff *stuff = WMGetHangedData(WMWidgetOfView(self));
|
||||
|
||||
return WMCreateDataWithBytes(stuff->filename, strlen(stuff->filename)+1);
|
||||
}
|
||||
|
||||
|
||||
WMDragSourceProcs dragSourceProcs = {
|
||||
NULL,
|
||||
NULL,
|
||||
endedDragImage,
|
||||
fetchDragData
|
||||
};
|
||||
|
||||
|
||||
/************************/
|
||||
|
||||
|
||||
unsigned
|
||||
draggingEntered(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
|
||||
unsigned
|
||||
draggingUpdated(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
/*
|
||||
void (*draggingExited)(WMView *self, WMDraggingInfo *info);
|
||||
*/
|
||||
char*
|
||||
prepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return "application/X-WINGs-Bla";
|
||||
}
|
||||
|
||||
|
||||
WMLabel* makeDraggableLabel(WMWidget *w, char *file, int x, int y);
|
||||
|
||||
Bool
|
||||
performDragOperation(WMView *self, WMDraggingInfo *info, WMData *data)
|
||||
{
|
||||
char *file = (char*)WMDataBytes(data);
|
||||
WMPoint pos;
|
||||
|
||||
pos = WMGetDraggingInfoImageLocation(info);
|
||||
|
||||
if (file!=NULL) {
|
||||
WMLabel *label;
|
||||
WMPoint pos2 = WMGetViewScreenPosition(self);
|
||||
|
||||
|
||||
label = makeDraggableLabel(WMWidgetOfView(self), file,
|
||||
pos.x-pos2.x, pos.y-pos2.y);
|
||||
WMRealizeWidget(label);
|
||||
WMMapWidget(label);
|
||||
}
|
||||
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
concludeDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
WMDragDestinationProcs dragDestProcs = {
|
||||
draggingEntered,
|
||||
draggingUpdated,
|
||||
NULL,
|
||||
prepareForDragOperation,
|
||||
performDragOperation,
|
||||
concludeDragOperation
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
WMLabel*
|
||||
makeDraggableLabel(WMWidget *w, char *file, int x, int y)
|
||||
{
|
||||
DNDStuff *stuff;
|
||||
WMLabel *label;
|
||||
WMPixmap *image = getImage(WMWidgetScreen(w), file);
|
||||
|
||||
stuff = wmalloc(sizeof(DNDStuff));
|
||||
stuff->mouseDown = False;
|
||||
|
||||
stuff->filename = wstrdup(file);
|
||||
|
||||
label = WMCreateLabel(w);
|
||||
WMResizeWidget(label, 48, 48);
|
||||
WMMoveWidget(label, x, y);
|
||||
|
||||
WMSetViewDragSourceProcs(WMWidgetView(label), &dragSourceProcs);
|
||||
|
||||
WMHangData(label, stuff);
|
||||
|
||||
WMCreateEventHandler(WMWidgetView(label),
|
||||
ButtonPressMask|ButtonReleaseMask|ButtonMotionMask,
|
||||
iconMouseStuff, label);
|
||||
|
||||
|
||||
if (image != NULL) {
|
||||
WMSetLabelImagePosition(label, WIPImageOnly);
|
||||
WMSetLabelImage(label, image);
|
||||
WMReleasePixmap(image);
|
||||
} else puts(file);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
testDragAndDrop(WMScreen *scr)
|
||||
{
|
||||
WMWindow *win;
|
||||
WMFrame *frame;
|
||||
WMLabel *label;
|
||||
int i, j;
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
char *types[] = {
|
||||
"application/X-WINGs-Bla",
|
||||
NULL
|
||||
};
|
||||
|
||||
windowCount++;
|
||||
|
||||
win = WMCreateWindow(scr, "dragDrop");
|
||||
WMResizeWidget(win, 300, 300);
|
||||
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||
WMSetWindowTitle(win, "Drag and Drop");
|
||||
|
||||
|
||||
frame = WMCreateFrame(win);
|
||||
WMSetFrameRelief(frame, WRSunken);
|
||||
WMResizeWidget(frame, 250, 250);
|
||||
WMMoveWidget(frame, 25, 25);
|
||||
|
||||
WMRegisterViewForDraggedTypes(WMWidgetView(frame), types);
|
||||
WMSetViewDragDestinationProcs(WMWidgetView(frame), &dragDestProcs);
|
||||
|
||||
dir = opendir("../../WindowMaker/Icons");
|
||||
if (!dir) {
|
||||
perror("../../WindowMaker/Icons");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0, j=0; j < 8; i++) {
|
||||
ent = readdir(dir);
|
||||
if (!ent)
|
||||
break;
|
||||
|
||||
if (strstr(ent->d_name, ".xpm")==NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
label = makeDraggableLabel(frame, ent->d_name,4+(j/4)*64, 4+(j%4)*64);
|
||||
|
||||
j++;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
WMMapSubwidgets(frame);
|
||||
|
||||
WMMapSubwidgets(win);
|
||||
WMRealizeWidget(win);
|
||||
WMMapWidget(win);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
void
|
||||
testUD()
|
||||
{
|
||||
@@ -1271,8 +1002,8 @@ main(int argc, char **argv)
|
||||
dpy = XOpenDisplay("");
|
||||
|
||||
if (!dpy) {
|
||||
puts("could not open display");
|
||||
exit(1);
|
||||
puts("could not open display");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* This is used to disable buffering of X protocol requests.
|
||||
@@ -1295,7 +1026,10 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Makes the logo be used in standard dialog panels.
|
||||
*/
|
||||
WMSetApplicationIconPixmap(scr, pixmap); WMReleasePixmap(pixmap);
|
||||
if (pixmap) {
|
||||
WMSetApplicationIconPixmap(scr, pixmap);
|
||||
WMReleasePixmap(pixmap);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do some test stuff.
|
||||
@@ -1303,12 +1037,13 @@ main(int argc, char **argv)
|
||||
* Put the testSomething() function you want to test here.
|
||||
*/
|
||||
|
||||
|
||||
testText(scr);
|
||||
testFontPanel(scr);
|
||||
|
||||
testColorPanel(scr);
|
||||
|
||||
#if 0
|
||||
|
||||
testBox(scr);
|
||||
testButton(scr);
|
||||
testColorPanel(scr);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <WINGs/WUtil.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#define WINGS_H_VERSION 20021124
|
||||
#define WINGS_H_VERSION 20040406
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -223,7 +223,7 @@ enum {
|
||||
|
||||
/* drag operations */
|
||||
typedef enum {
|
||||
WDOperationNone,
|
||||
WDOperationNone = 0,
|
||||
WDOperationCopy,
|
||||
WDOperationMove,
|
||||
WDOperationLink,
|
||||
@@ -427,33 +427,13 @@ typedef struct WMInputPanel {
|
||||
} WMInputPanel;
|
||||
|
||||
|
||||
|
||||
#define WFAUnchanged (NULL)
|
||||
/* Struct for font change operations */
|
||||
typedef struct WMFontAttributes {
|
||||
char *foundry;
|
||||
char *family;
|
||||
char *weight;
|
||||
char *slant;
|
||||
char *setWidth;
|
||||
char *addStyle;
|
||||
char *pixelSize;
|
||||
char *pointSize;
|
||||
char *resolutionX;
|
||||
char *resolutionY;
|
||||
char *spacing;
|
||||
char *averageWidth;
|
||||
char *registry;
|
||||
char *encoding;
|
||||
} WMFontAttributes;
|
||||
|
||||
/* A few useful constant font attributes masks */
|
||||
extern const WMFontAttributes *WFANormal;
|
||||
extern const WMFontAttributes *WFABold;
|
||||
extern const WMFontAttributes *WFANotBold;
|
||||
extern const WMFontAttributes *WFAEmphasized;
|
||||
extern const WMFontAttributes *WFANotEmphasized;
|
||||
extern const WMFontAttributes *WFABoldEmphasized;
|
||||
/* Basic font styles. Used to easily get one style from another */
|
||||
typedef enum WMFontStyle {
|
||||
WFSNormal = 0,
|
||||
WFSBold = 1,
|
||||
WFSEmphasized = 2,
|
||||
WFSBoldEmphasized = 3
|
||||
} WMFontStyle;
|
||||
|
||||
|
||||
/* WMRuler: */
|
||||
@@ -480,11 +460,9 @@ typedef void WMAction(WMWidget *self, void *clientData);
|
||||
typedef void WMAction2(void *self, void *clientData);
|
||||
|
||||
|
||||
typedef void WMDropDataCallback(WMView *view, WMData *data);
|
||||
|
||||
/* delegate method like stuff */
|
||||
typedef void WMListDrawProc(WMList *lPtr, int index, Drawable d, char *text,
|
||||
int state, WMRect *rect);
|
||||
int state, WMRect *rect);
|
||||
|
||||
/*
|
||||
typedef void WMSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
@@ -493,7 +471,7 @@ typedef void WMSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
*/
|
||||
|
||||
typedef void WMSplitViewConstrainProc(WMSplitView *sPtr, int dividerIndex,
|
||||
int *minSize, int *maxSize);
|
||||
int *minSize, int *maxSize);
|
||||
|
||||
typedef WMWidget* WMMatrixCreateCellProc(WMMatrix *mPtr);
|
||||
|
||||
@@ -504,10 +482,10 @@ typedef struct WMBrowserDelegate {
|
||||
void *data;
|
||||
|
||||
void (*createRowsForColumn)(struct WMBrowserDelegate *self,
|
||||
WMBrowser *sender, int column, WMList *list);
|
||||
WMBrowser *sender, int column, WMList *list);
|
||||
|
||||
char* (*titleOfColumn)(struct WMBrowserDelegate *self, WMBrowser *sender,
|
||||
int column);
|
||||
int column);
|
||||
|
||||
void (*didScroll)(struct WMBrowserDelegate *self, WMBrowser *sender);
|
||||
|
||||
@@ -539,7 +517,7 @@ typedef struct WMTextDelegate {
|
||||
void *data;
|
||||
|
||||
Bool (*didDoubleClickOnPicture)(struct WMTextDelegate *self,
|
||||
void *description);
|
||||
void *description);
|
||||
|
||||
} WMTextDelegate;
|
||||
|
||||
@@ -549,7 +527,7 @@ typedef struct WMTabViewDelegate {
|
||||
void *data;
|
||||
|
||||
void (*didChangeNumberOfItems)(struct WMTabViewDelegate *self,
|
||||
WMTabView *tabView);
|
||||
WMTabView *tabView);
|
||||
|
||||
void (*didSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView,
|
||||
WMTabViewItem *item);
|
||||
@@ -565,26 +543,32 @@ typedef struct WMTabViewDelegate {
|
||||
|
||||
|
||||
typedef void WMSelectionCallback(WMView *view, Atom selection, Atom target,
|
||||
Time timestamp, void *cdata, WMData *data);
|
||||
Time timestamp, void *cdata, WMData *data);
|
||||
|
||||
|
||||
typedef struct WMSelectionProcs {
|
||||
WMData* (*convertSelection)(WMView *view, Atom selection, Atom target,
|
||||
void *cdata, Atom *type);
|
||||
void *cdata, Atom *type);
|
||||
void (*selectionLost)(WMView *view, Atom selection, void *cdata);
|
||||
void (*selectionDone)(WMView *view, Atom selection, Atom target,
|
||||
void *cdata);
|
||||
void *cdata);
|
||||
} WMSelectionProcs;
|
||||
|
||||
|
||||
typedef struct W_DraggingInfo WMDraggingInfo;
|
||||
|
||||
|
||||
/* links a label to a dnd operation. */
|
||||
typedef struct W_DragOperationtItem WMDragOperationItem;
|
||||
|
||||
|
||||
typedef struct W_DragSourceProcs {
|
||||
unsigned (*draggingSourceOperation)(WMView *self, Bool local);
|
||||
void (*beganDragImage)(WMView *self, WMPixmap *image, WMPoint point);
|
||||
void (*endedDragImage)(WMView *self, WMPixmap *image, WMPoint point,
|
||||
Bool deposited);
|
||||
WMArray* (*dropDataTypes)(WMView *self);
|
||||
WMDragOperationType (*wantedDropOperation)(WMView *self);
|
||||
WMArray* (*askedOperations)(WMView *self);
|
||||
Bool (*acceptDropOperation)(WMView *self, WMDragOperationType operation);
|
||||
void (*beganDrag)(WMView *self, WMPoint *point);
|
||||
void (*endedDrag)(WMView *self, WMPoint *point, Bool deposited);
|
||||
WMData* (*fetchDragData)(WMView *self, char *type);
|
||||
/* Bool (*ignoreModifierKeysWhileDragging)(WMView *view);*/
|
||||
} WMDragSourceProcs;
|
||||
@@ -592,16 +576,19 @@ typedef struct W_DragSourceProcs {
|
||||
|
||||
|
||||
typedef struct W_DragDestinationProcs {
|
||||
unsigned (*draggingEntered)(WMView *self, WMDraggingInfo *info);
|
||||
unsigned (*draggingUpdated)(WMView *self, WMDraggingInfo *info);
|
||||
void (*draggingExited)(WMView *self, WMDraggingInfo *info);
|
||||
Bool (*prepareForDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
Bool (*performDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
void (*concludeDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
void (*prepareForDragOperation)(WMView *self);
|
||||
WMArray* (*requiredDataTypes)(WMView *self, WMDragOperationType request,
|
||||
WMArray *sourceDataTypes);
|
||||
WMDragOperationType (*allowedOperation)(WMView *self,
|
||||
WMDragOperationType request,
|
||||
WMArray *sourceDataTypes);
|
||||
Bool (*inspectDropData)(WMView *self, WMArray *dropData);
|
||||
void (*performDragOperation)(WMView *self, WMArray *dropData,
|
||||
WMArray *operations, WMPoint *dropLocation);
|
||||
void (*concludeDragOperation)(WMView *self);
|
||||
} WMDragDestinationProcs;
|
||||
|
||||
|
||||
|
||||
/* ...................................................................... */
|
||||
|
||||
|
||||
@@ -707,24 +694,44 @@ extern char *WMSelectionOwnerDidChangeNotification;
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
WMArray* WMCreateDragOperationArray(int initialSize);
|
||||
|
||||
WMDragOperationItem* WMCreateDragOperationItem(WMDragOperationType type,
|
||||
char* text);
|
||||
|
||||
WMDragOperationType WMGetDragOperationItemType(WMDragOperationItem* item);
|
||||
|
||||
char* WMGetDragOperationItemText(WMDragOperationItem* item);
|
||||
|
||||
void WMSetViewDragImage(WMView* view, WMPixmap *dragImage);
|
||||
|
||||
void WMReleaseViewDragImage(WMView* view);
|
||||
|
||||
void WMSetViewDragSourceProcs(WMView *view, WMDragSourceProcs *procs);
|
||||
|
||||
void WMDragImageFromView(WMView *view, WMPixmap *image, char *dataTypes[],
|
||||
WMPoint atLocation, WMSize mouseOffset, XEvent *event,
|
||||
Bool slideBack);
|
||||
Bool WMIsDraggingFromView(WMView *view);
|
||||
|
||||
void WMRegisterViewForDraggedTypes(WMView *view, char *acceptedTypes[]);
|
||||
void WMDragImageFromView(WMView *view, XEvent *event);
|
||||
|
||||
/* Create a drag handler, associating drag event masks with dragEventProc */
|
||||
void WMCreateDragHandler(WMView *view, WMEventProc *dragEventProc, void *clientData);
|
||||
|
||||
void WMDeleteDragHandler(WMView *view, WMEventProc *dragEventProc, void *clientData);
|
||||
|
||||
/* set default drag handler for view */
|
||||
void WMSetViewDraggable(WMView *view, WMDragSourceProcs *procs, WMPixmap *dragImage);
|
||||
|
||||
void WMUnsetViewDraggable(WMView *view);
|
||||
|
||||
void WMRegisterViewForDraggedTypes(WMView *view, WMArray *acceptedTypes);
|
||||
|
||||
void WMUnregisterViewDraggedTypes(WMView *view);
|
||||
|
||||
void WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs);
|
||||
|
||||
|
||||
WMPoint WMGetDraggingInfoImageLocation(WMDraggingInfo *info);
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
Bool WMHasAntialiasingSupport(WMScreen *scrPtr);
|
||||
//Bool WMHasAntialiasingSupport(WMScreen *scrPtr);
|
||||
|
||||
Bool WMIsAntialiasingEnabled(WMScreen *scrPtr);
|
||||
|
||||
@@ -732,12 +739,7 @@ Bool WMIsAntialiasingEnabled(WMScreen *scrPtr);
|
||||
|
||||
WMFont* WMCreateFont(WMScreen *scrPtr, char *fontName);
|
||||
|
||||
//??
|
||||
WMFont* WMCreateFontWithAttributes(WMScreen *scrPtr, char *fontName,
|
||||
WMFontAttributes *attribs);
|
||||
|
||||
WMFont* WMCopyFontWithChanges(WMScreen *scrPtr, WMFont *font,
|
||||
const WMFontAttributes *changes);
|
||||
WMFont* WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style);
|
||||
|
||||
WMFont* WMRetainFont(WMFont *font);
|
||||
|
||||
@@ -766,14 +768,14 @@ WMPixmap* WMRetainPixmap(WMPixmap *pixmap);
|
||||
void WMReleasePixmap(WMPixmap *pixmap);
|
||||
|
||||
WMPixmap* WMCreatePixmap(WMScreen *scrPtr, int width, int height, int depth,
|
||||
Bool masked);
|
||||
Bool masked);
|
||||
|
||||
WMPixmap* WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap,
|
||||
Pixmap mask, int width, int height,
|
||||
int depth);
|
||||
Pixmap mask, int width, int height,
|
||||
int depth);
|
||||
|
||||
WMPixmap* WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image,
|
||||
int threshold);
|
||||
int threshold);
|
||||
|
||||
WMPixmap* WMCreatePixmapFromXPMData(WMScreen *scrPtr, char **data);
|
||||
|
||||
@@ -785,7 +787,7 @@ WMPixmap* WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image,
|
||||
RColor *color);
|
||||
|
||||
WMPixmap* WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName,
|
||||
RColor *color);
|
||||
RColor *color);
|
||||
|
||||
void WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y);
|
||||
|
||||
@@ -813,15 +815,15 @@ GC WMColorGC(WMColor *color);
|
||||
WMPixel WMColorPixel(WMColor *color);
|
||||
|
||||
void WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y,
|
||||
unsigned int width, unsigned int height);
|
||||
unsigned int width, unsigned int height);
|
||||
|
||||
void WMReleaseColor(WMColor *color);
|
||||
|
||||
WMColor* WMRetainColor(WMColor *color);
|
||||
|
||||
WMColor* WMCreateRGBColor(WMScreen *scr, unsigned short red,
|
||||
unsigned short green, unsigned short blue,
|
||||
Bool exact);
|
||||
unsigned short green, unsigned short blue,
|
||||
Bool exact);
|
||||
|
||||
WMColor* WMCreateRGBAColor(WMScreen *scr, unsigned short red,
|
||||
unsigned short green, unsigned short blue,
|
||||
@@ -908,7 +910,7 @@ void WMRedisplayWidget(WMWidget *w);
|
||||
void WMSetViewNotifySizeChanges(WMView *view, Bool flag);
|
||||
|
||||
void WMSetViewExpandsToParent(WMView *view, int topOffs, int leftOffs,
|
||||
int rightOffs, int bottomOffs);
|
||||
int rightOffs, int bottomOffs);
|
||||
|
||||
WMSize WMGetViewSize(WMView *view);
|
||||
|
||||
@@ -952,7 +954,7 @@ WMWindow* WMCreateWindow(WMScreen *screen, char *name);
|
||||
WMWindow* WMCreateWindowWithStyle(WMScreen *screen, char *name, int style);
|
||||
|
||||
WMWindow* WMCreatePanelWithStyleForWindow(WMWindow *owner, char *name,
|
||||
int style);
|
||||
int style);
|
||||
|
||||
WMWindow* WMCreatePanelForWindow(WMWindow *owner, char *name);
|
||||
|
||||
@@ -971,7 +973,7 @@ void WMSetWindowInitialPosition(WMWindow *win, int x, int y);
|
||||
void WMSetWindowUserPosition(WMWindow *win, int x, int y);
|
||||
|
||||
void WMSetWindowAspectRatio(WMWindow *win, int minX, int minY,
|
||||
int maxX, int maxY);
|
||||
int maxX, int maxY);
|
||||
|
||||
void WMSetWindowMaxSize(WMWindow *win, unsigned width, unsigned height);
|
||||
|
||||
@@ -1137,7 +1139,7 @@ extern char *WMTextDidEndEditingNotification;
|
||||
WMScroller* WMCreateScroller(WMWidget *parent);
|
||||
|
||||
void WMSetScrollerParameters(WMScroller *sPtr, float floatValue,
|
||||
float knobProportion);
|
||||
float knobProportion);
|
||||
|
||||
float WMGetScrollerKnobProportion(WMScroller *sPtr);
|
||||
|
||||
@@ -1276,7 +1278,7 @@ WMArray* WMGetBrowserPaths(WMBrowser *bPtr);
|
||||
void WMSetBrowserAction(WMBrowser *bPtr, WMAction *action, void *clientData);
|
||||
|
||||
void WMSetBrowserDoubleAction(WMBrowser *bPtr, WMAction *action,
|
||||
void *clientData);
|
||||
void *clientData);
|
||||
|
||||
WMListItem* WMGetBrowserSelectedItemInColumn(WMBrowser *bPtr, int column);
|
||||
|
||||
@@ -1368,14 +1370,14 @@ Bool WMGetMenuItemHasSubmenu(WMMenuItem *item);
|
||||
WMPopUpButton* WMCreatePopUpButton(WMWidget *parent);
|
||||
|
||||
void WMSetPopUpButtonAction(WMPopUpButton *sPtr, WMAction *action,
|
||||
void *clientData);
|
||||
void *clientData);
|
||||
|
||||
void WMSetPopUpButtonPullsDown(WMPopUpButton *bPtr, Bool flag);
|
||||
|
||||
WMMenuItem* WMAddPopUpButtonItem(WMPopUpButton *bPtr, char *title);
|
||||
|
||||
WMMenuItem* WMInsertPopUpButtonItem(WMPopUpButton *bPtr, int index,
|
||||
char *title);
|
||||
char *title);
|
||||
|
||||
void WMRemovePopUpButtonItem(WMPopUpButton *bPtr, int index);
|
||||
|
||||
@@ -1394,7 +1396,6 @@ char* WMGetPopUpButtonItem(WMPopUpButton *bPtr, int index);
|
||||
|
||||
WMMenuItem* WMGetPopUpButtonMenuItem(WMPopUpButton *bPtr, int index);
|
||||
|
||||
|
||||
int WMGetPopUpButtonNumberOfItems(WMPopUpButton *bPtr);
|
||||
|
||||
void WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag);
|
||||
@@ -1457,7 +1458,7 @@ extern char *WMColorWellDidChangeNotification;
|
||||
WMScrollView* WMCreateScrollView(WMWidget *parent);
|
||||
|
||||
void WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width,
|
||||
unsigned int height);
|
||||
unsigned int height);
|
||||
|
||||
void WMSetScrollViewHasHorizontalScroller(WMScrollView *sPtr, Bool flag);
|
||||
|
||||
@@ -1525,7 +1526,7 @@ void WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview);
|
||||
void WMAdjustSplitViewSubviews(WMSplitView *sPtr);
|
||||
|
||||
void WMSetSplitViewConstrainProc(WMSplitView *sPtr,
|
||||
WMSplitViewConstrainProc *proc);
|
||||
WMSplitViewConstrainProc *proc);
|
||||
|
||||
/*
|
||||
void WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
@@ -1713,7 +1714,7 @@ void WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item);
|
||||
void WMRemoveTabViewItem(WMTabView *tPtr, WMTabViewItem *item);
|
||||
|
||||
WMTabViewItem* WMAddTabViewItemWithView(WMTabView *tPtr, WMView *view,
|
||||
int identifier, char *label);
|
||||
int identifier, char *label);
|
||||
|
||||
WMTabViewItem* WMTabViewItemAtPoint(WMTabView *tPtr, int x, int y);
|
||||
|
||||
@@ -1758,10 +1759,10 @@ WMBox* WMCreateBox(WMWidget *parent);
|
||||
void WMSetBoxBorderWidth(WMBox *box, unsigned width);
|
||||
|
||||
void WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
int minSize, int maxSize, int space);
|
||||
int minSize, int maxSize, int space);
|
||||
|
||||
void WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
int minSize, int maxSize, int space);
|
||||
int minSize, int maxSize, int space);
|
||||
|
||||
void WMRemoveBoxSubview(WMBox *bPtr, WMView *view);
|
||||
|
||||
@@ -1775,20 +1776,20 @@ int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||
|
||||
/* you can free the returned string */
|
||||
char* WMRunInputPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||
char *defaultText, char *okButton, char *cancelButton);
|
||||
char *defaultText, char *okButton, char *cancelButton);
|
||||
|
||||
WMAlertPanel* WMCreateAlertPanel(WMScreen *app, WMWindow *owner, char *title,
|
||||
char *msg, char *defaultButton,
|
||||
char *alternateButton, char *otherButton);
|
||||
char *msg, char *defaultButton,
|
||||
char *alternateButton, char *otherButton);
|
||||
|
||||
WMInputPanel* WMCreateInputPanel(WMScreen *app, WMWindow *owner, char *title,
|
||||
char *msg, char *defaultText, char *okButton,
|
||||
char *cancelButton);
|
||||
char *msg, char *defaultText, char *okButton,
|
||||
char *cancelButton);
|
||||
|
||||
|
||||
WMGenericPanel* WMCreateGenericPanel(WMScreen *scrPtr, WMWindow *owner,
|
||||
char *title, char *defaultButton,
|
||||
char *alternateButton);
|
||||
char *title, char *defaultButton,
|
||||
char *alternateButton);
|
||||
|
||||
void WMDestroyAlertPanel(WMAlertPanel *panel);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <WINGs/WINGs.h>
|
||||
|
||||
#if WINGS_H_VERSION < 20021124
|
||||
#if WINGS_H_VERSION < 20040406
|
||||
#error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
|
||||
#endif
|
||||
|
||||
@@ -97,6 +97,53 @@ typedef struct W_FocusInfo {
|
||||
|
||||
|
||||
|
||||
typedef void* W_DndState(WMView *destView, XClientMessageEvent *event,
|
||||
WMDraggingInfo *info);
|
||||
|
||||
|
||||
typedef struct W_DragOperationItem {
|
||||
WMDragOperationType type;
|
||||
char* text;
|
||||
} W_DragOperationItem;
|
||||
|
||||
|
||||
typedef struct W_DragSourceInfo {
|
||||
WMView *sourceView;
|
||||
Window destinationWindow;
|
||||
W_DndState *state;
|
||||
WMSelectionProcs *selectionProcs;
|
||||
Window icon;
|
||||
WMPoint imageLocation;
|
||||
WMPoint mouseOffset; /* mouse pos in icon */
|
||||
Cursor dragCursor;
|
||||
WMRect noPositionMessageZone;
|
||||
Atom firstThreeTypes[3];
|
||||
} W_DragSourceInfo;
|
||||
|
||||
|
||||
typedef struct W_DragDestinationInfo {
|
||||
WMView *destView;
|
||||
Window sourceWindow;
|
||||
W_DndState *state;
|
||||
WMArray *sourceTypes;
|
||||
WMArray *requiredTypes;
|
||||
Bool typeListAvailable;
|
||||
WMArray *dropDatas;
|
||||
} W_DragDestinationInfo;
|
||||
|
||||
|
||||
struct W_DraggingInfo {
|
||||
unsigned char protocolVersion;
|
||||
Time timestamp;
|
||||
|
||||
Atom sourceAction;
|
||||
Atom destinationAction;
|
||||
|
||||
W_DragSourceInfo* sourceInfo; /* infos needed by source */
|
||||
W_DragDestinationInfo* destInfo; /* infos needed by destination */
|
||||
} W_DraggingInfo;
|
||||
|
||||
/* original
|
||||
struct W_DraggingInfo {
|
||||
Window destinationWindow;
|
||||
Window sourceWindow;
|
||||
@@ -113,12 +160,13 @@ struct W_DraggingInfo {
|
||||
|
||||
int protocolVersion;
|
||||
|
||||
/* should be treated as internal data */
|
||||
// should be treated as internal data
|
||||
WMView *sourceView;
|
||||
WMView *destView;
|
||||
WMSize mouseOffset;
|
||||
unsigned finished:1;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
typedef struct W_Screen {
|
||||
@@ -286,6 +334,8 @@ typedef struct W_Screen {
|
||||
Atom xdndDropAtom;
|
||||
Atom xdndFinishedAtom;
|
||||
Atom xdndTypeListAtom;
|
||||
Atom xdndActionListAtom;
|
||||
Atom xdndActionDescriptionAtom;
|
||||
Atom xdndStatusAtom;
|
||||
|
||||
Atom xdndActionCopy;
|
||||
@@ -366,33 +416,34 @@ typedef struct W_View {
|
||||
Cursor cursor;
|
||||
|
||||
Atom *droppableTypes;
|
||||
struct W_DragSourceProcs *dragSourceProcs;
|
||||
struct W_DragSourceProcs *dragSourceProcs;
|
||||
struct W_DragDestinationProcs *dragDestinationProcs;
|
||||
WMPixmap *dragImage;
|
||||
int helpContext;
|
||||
|
||||
|
||||
struct {
|
||||
unsigned int realized:1;
|
||||
unsigned int mapped:1;
|
||||
unsigned int parentDying:1;
|
||||
unsigned int dying:1; /* the view is being destroyed */
|
||||
unsigned int topLevel:1; /* is a top level window */
|
||||
unsigned int root:1; /* is the root window */
|
||||
unsigned int mapWhenRealized:1;/* map the view when it's realized */
|
||||
unsigned int alreadyDead:1; /* view was freed */
|
||||
unsigned int realized:1;
|
||||
unsigned int mapped:1;
|
||||
unsigned int parentDying:1;
|
||||
unsigned int dying:1; /* the view is being destroyed */
|
||||
unsigned int topLevel:1; /* is a top level window */
|
||||
unsigned int root:1; /* is the root window */
|
||||
unsigned int mapWhenRealized:1; /* map the view when it's realized */
|
||||
unsigned int alreadyDead:1; /* view was freed */
|
||||
|
||||
unsigned int dontCompressMotion:1; /* motion notify event compress */
|
||||
unsigned int notifySizeChanged:1;
|
||||
unsigned int dontCompressExpose:1; /* will compress all expose
|
||||
events into one */
|
||||
/* toplevel only */
|
||||
unsigned int worksWhenModal:1;
|
||||
unsigned int pendingRelease1:1;
|
||||
unsigned int pendingRelease2:1;
|
||||
unsigned int pendingRelease3:1;
|
||||
unsigned int pendingRelease4:1;
|
||||
unsigned int pendingRelease5:1;
|
||||
unsigned int xdndHintSet:1;
|
||||
unsigned int dontCompressMotion:1; /* motion notify event compress */
|
||||
unsigned int notifySizeChanged:1;
|
||||
unsigned int dontCompressExpose:1; /* expose event compress */
|
||||
|
||||
/* toplevel only */
|
||||
unsigned int worksWhenModal:1;
|
||||
unsigned int pendingRelease1:1;
|
||||
unsigned int pendingRelease2:1;
|
||||
unsigned int pendingRelease3:1;
|
||||
unsigned int pendingRelease4:1;
|
||||
unsigned int pendingRelease5:1;
|
||||
unsigned int xdndHintSet:1;
|
||||
} flags;
|
||||
|
||||
int refCount;
|
||||
@@ -492,19 +543,19 @@ void W_SetViewBackgroundColor(W_View *view, WMColor *color);
|
||||
void W_SetViewCursor(W_View *view, Cursor cursor);
|
||||
|
||||
void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
unsigned int height, WMReliefType relief);
|
||||
unsigned int height, WMReliefType relief);
|
||||
|
||||
void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
|
||||
unsigned int width, unsigned int height,
|
||||
WMReliefType relief,
|
||||
GC black, GC dark, GC light, GC white);
|
||||
unsigned int width, unsigned int height,
|
||||
WMReliefType relief,
|
||||
GC black, GC dark, GC light, GC white);
|
||||
|
||||
void W_CallDestroyHandlers(W_View *view);
|
||||
|
||||
void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
|
||||
W_Font *font, WMReliefType relief, char *text,
|
||||
WMAlignment alignment, W_Pixmap *image,
|
||||
WMImagePosition position, WMColor *backColor, int ofs);
|
||||
WMAlignment alignment, W_Pixmap *image,
|
||||
WMImagePosition position, WMColor *backColor, int ofs);
|
||||
|
||||
void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
|
||||
int width, WMAlignment alignment, WMColor *color,
|
||||
@@ -560,6 +611,44 @@ void W_CheckTimerHandlers(void);
|
||||
|
||||
Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
|
||||
|
||||
/* XDnD */
|
||||
Atom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
|
||||
|
||||
WMDragOperationType W_ActionToOperation(WMScreen *scr, Atom action);
|
||||
|
||||
void W_FreeDragOperationItem(void* item);
|
||||
|
||||
Bool W_SendDnDClientMessage(Display *dpy, Window win, Atom message,
|
||||
unsigned long data1, unsigned long data2,
|
||||
unsigned long data3, unsigned long data4,
|
||||
unsigned long data5);
|
||||
|
||||
void W_DragSourceStartTimer(WMDraggingInfo *info);
|
||||
|
||||
void W_DragSourceStopTimer();
|
||||
|
||||
void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
|
||||
|
||||
void W_DragDestinationStartTimer(WMDraggingInfo *info);
|
||||
|
||||
void W_DragDestinationStopTimer();
|
||||
|
||||
void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
|
||||
XClientMessageEvent *event);
|
||||
|
||||
void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
|
||||
WMView *toplevel,
|
||||
XClientMessageEvent *event);
|
||||
|
||||
void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info);
|
||||
|
||||
void W_DragDestinationStateHandler(WMDraggingInfo *info,
|
||||
XClientMessageEvent *event);
|
||||
|
||||
void W_DragDestinationInfoClear(WMDraggingInfo *info);
|
||||
|
||||
void W_FreeViewXdndPart(WMView *view);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -98,48 +98,48 @@ W_ReadConfigurations(void)
|
||||
if (defaults) {
|
||||
char *buttonName;
|
||||
unsigned button;
|
||||
char *str;
|
||||
char *str;
|
||||
|
||||
WINGsConfiguration.systemFont =
|
||||
WMGetUDStringForKey(defaults, "SystemFont");
|
||||
WINGsConfiguration.systemFont =
|
||||
WMGetUDStringForKey(defaults, "SystemFont");
|
||||
|
||||
WINGsConfiguration.boldSystemFont =
|
||||
WMGetUDStringForKey(defaults, "BoldSystemFont");
|
||||
WINGsConfiguration.boldSystemFont =
|
||||
WMGetUDStringForKey(defaults, "BoldSystemFont");
|
||||
|
||||
#ifdef XFT
|
||||
WINGsConfiguration.antialiasedText =
|
||||
WINGsConfiguration.antialiasedText =
|
||||
WMGetUDBoolForKey(defaults, "AntialiasedText");
|
||||
#else
|
||||
WINGsConfiguration.antialiasedText = False;
|
||||
#endif
|
||||
|
||||
WINGsConfiguration.useMultiByte = False;
|
||||
str = WMGetUDStringForKey(defaults, "MultiByteText");
|
||||
if (str) {
|
||||
if (strcasecmp(str, "YES") == 0) {
|
||||
WINGsConfiguration.useMultiByte = True;
|
||||
} else if (strcasecmp(str, "AUTO") == 0) {
|
||||
char *locale;
|
||||
WINGsConfiguration.useMultiByte = False;
|
||||
str = WMGetUDStringForKey(defaults, "MultiByteText");
|
||||
if (str) {
|
||||
if (strcasecmp(str, "YES") == 0) {
|
||||
WINGsConfiguration.useMultiByte = True;
|
||||
} else if (strcasecmp(str, "AUTO") == 0) {
|
||||
char *locale;
|
||||
|
||||
/* if it's a multibyte language (japanese, chinese or korean)
|
||||
* then set it to True */
|
||||
locale = setlocale(LC_CTYPE, NULL);
|
||||
if (locale != NULL
|
||||
&& (strncmp(locale, "ja", 2) == 0
|
||||
|| strncmp(locale, "zh", 2) == 0
|
||||
|| strncmp(locale, "ru", 2) == 0
|
||||
|| strncmp(locale, "ko", 2) == 0)) {
|
||||
/* if it's a multibyte language (japanese, chinese or korean)
|
||||
* then set it to True */
|
||||
locale = setlocale(LC_CTYPE, NULL);
|
||||
if (locale != NULL
|
||||
&& (strncmp(locale, "ja", 2) == 0
|
||||
|| strncmp(locale, "zh", 2) == 0
|
||||
|| strncmp(locale, "ru", 2) == 0
|
||||
|| strncmp(locale, "ko", 2) == 0)) {
|
||||
|
||||
WINGsConfiguration.useMultiByte = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
WINGsConfiguration.useMultiByte = True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WINGsConfiguration.doubleClickDelay =
|
||||
WMGetUDIntegerForKey(defaults, "DoubleClickTime");
|
||||
WINGsConfiguration.doubleClickDelay =
|
||||
WMGetUDIntegerForKey(defaults, "DoubleClickTime");
|
||||
|
||||
WINGsConfiguration.floppyPath =
|
||||
WMGetUDStringForKey(defaults, "FloppyPath");
|
||||
WINGsConfiguration.floppyPath =
|
||||
WMGetUDStringForKey(defaults, "FloppyPath");
|
||||
|
||||
buttonName = WMGetUDStringForKey(defaults, "MouseWheelUp");
|
||||
if (buttonName) {
|
||||
@@ -164,7 +164,7 @@ W_ReadConfigurations(void)
|
||||
WINGsConfiguration.mouseWheelDown = Button5;
|
||||
}
|
||||
|
||||
WINGsConfiguration.defaultFontSize =
|
||||
WINGsConfiguration.defaultFontSize =
|
||||
WMGetUDIntegerForKey(defaults, "DefaultFontSize");
|
||||
}
|
||||
|
||||
@@ -172,22 +172,22 @@ W_ReadConfigurations(void)
|
||||
WINGsConfiguration.systemFont = SYSTEM_FONT;
|
||||
}
|
||||
if (missingOrInvalidXLFD(WINGsConfiguration.boldSystemFont)) {
|
||||
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
|
||||
WINGsConfiguration.boldSystemFont = BOLD_SYSTEM_FONT;
|
||||
}
|
||||
if (!WINGsConfiguration.floppyPath) {
|
||||
WINGsConfiguration.floppyPath = FLOPPY_PATH;
|
||||
WINGsConfiguration.floppyPath = FLOPPY_PATH;
|
||||
}
|
||||
if (WINGsConfiguration.doubleClickDelay == 0) {
|
||||
WINGsConfiguration.doubleClickDelay = 250;
|
||||
WINGsConfiguration.doubleClickDelay = 250;
|
||||
}
|
||||
if (WINGsConfiguration.mouseWheelUp == 0) {
|
||||
WINGsConfiguration.mouseWheelUp = Button4;
|
||||
WINGsConfiguration.mouseWheelUp = Button4;
|
||||
}
|
||||
if (WINGsConfiguration.mouseWheelDown == 0) {
|
||||
WINGsConfiguration.mouseWheelDown = Button5;
|
||||
WINGsConfiguration.mouseWheelDown = Button5;
|
||||
}
|
||||
if (WINGsConfiguration.defaultFontSize == 0) {
|
||||
WINGsConfiguration.defaultFontSize = 12;
|
||||
WINGsConfiguration.defaultFontSize = 12;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2281
WINGs/dragsource.c
2281
WINGs/dragsource.c
File diff suppressed because it is too large
Load Diff
@@ -865,7 +865,7 @@ getPropList(PLData *pldata)
|
||||
break;
|
||||
|
||||
case '(':
|
||||
DPUT("Getting PropList srrsy");
|
||||
DPUT("Getting PropList array");
|
||||
plist = getPLArray(pldata);
|
||||
break;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "WINGsP.h"
|
||||
|
||||
#define XDND_COLOR_DATA_TYPE "application/X-color"
|
||||
|
||||
char *WMColorWellDidChangeNotification = "WMColorWellDidChangeNotification";
|
||||
|
||||
@@ -22,9 +23,11 @@ typedef struct W_ColorWell {
|
||||
WMPoint ipoint;
|
||||
|
||||
struct {
|
||||
unsigned int active:1;
|
||||
unsigned int bordered:1;
|
||||
unsigned int active:1;
|
||||
unsigned int bordered:1;
|
||||
} flags;
|
||||
|
||||
WMArray *xdndTypes;
|
||||
} ColorWell;
|
||||
|
||||
static char *_ColorWellActivatedNotification = "_ColorWellActivatedNotification";
|
||||
@@ -53,33 +56,36 @@ W_ViewDelegate _ColorWellViewDelegate = {
|
||||
};
|
||||
|
||||
|
||||
static unsigned draggingSourceOperation(WMView *self, Bool local);
|
||||
|
||||
static WMArray* dropDataTypes(WMView *self);
|
||||
static WMDragOperationType wantedDropOperation(WMView *self);
|
||||
static Bool acceptDropOperation(WMView *self, WMDragOperationType operation);
|
||||
static WMData* fetchDragData(WMView *self, char *type);
|
||||
|
||||
static WMDragSourceProcs _DragSourceProcs = {
|
||||
draggingSourceOperation,
|
||||
dropDataTypes,
|
||||
wantedDropOperation,
|
||||
NULL,
|
||||
acceptDropOperation,
|
||||
NULL,
|
||||
NULL,
|
||||
fetchDragData
|
||||
};
|
||||
|
||||
|
||||
static unsigned draggingEntered(WMView *self, WMDraggingInfo *info);
|
||||
static unsigned draggingUpdated(WMView *self, WMDraggingInfo *info);
|
||||
static void draggingExited(WMView *self, WMDraggingInfo *info);
|
||||
static char *prepareForDragOperation(WMView *self, WMDraggingInfo *info);
|
||||
static Bool performDragOperation(WMView *self, WMDraggingInfo *info,
|
||||
WMData *data);
|
||||
static void concludeDragOperation(WMView *self, WMDraggingInfo *info);
|
||||
static WMArray* requiredDataTypes(WMView *self,
|
||||
WMDragOperationType requestedOperation, WMArray *sourceDataTypes);
|
||||
static WMDragOperationType allowedOperation(WMView *self,
|
||||
WMDragOperationType requestedOperation, WMArray *sourceDataTypes);
|
||||
static void performDragOperation(WMView *self, WMArray *dropDatas,
|
||||
WMArray *operationsList, WMPoint* dropLocation);
|
||||
|
||||
static WMDragDestinationProcs _DragDestinationProcs = {
|
||||
draggingEntered,
|
||||
draggingUpdated,
|
||||
draggingExited,
|
||||
prepareForDragOperation,
|
||||
performDragOperation,
|
||||
concludeDragOperation
|
||||
NULL,
|
||||
requiredDataTypes,
|
||||
allowedOperation,
|
||||
NULL,
|
||||
performDragOperation ,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -100,7 +106,7 @@ colorChangedObserver(void *data, WMNotification *notification)
|
||||
WMColor *color;
|
||||
|
||||
if (!cPtr->flags.active)
|
||||
return;
|
||||
return;
|
||||
|
||||
color = WMGetColorPanelColor(panel);
|
||||
|
||||
@@ -126,21 +132,30 @@ updateColorCallback(void *self, void *data)
|
||||
static void
|
||||
activatedObserver(void *data, WMNotification *notification)
|
||||
{
|
||||
/*
|
||||
WMColorWell *cPtr = (WMColorWell*)data;
|
||||
/*
|
||||
WMColorWell *cPtr = (WMColorWell*)data;
|
||||
|
||||
if (!cPtr->flags.active || WMGetNotificationObject(notification) == cPtr)
|
||||
return;
|
||||
if (!cPtr->flags.active || WMGetNotificationObject(notification) == cPtr)
|
||||
return;
|
||||
|
||||
W_SetViewBackgroundColor(cPtr->view, WMWidgetScreen(cPtr)->gray);
|
||||
paintColorWell(cPtr);
|
||||
W_SetViewBackgroundColor(cPtr->view, WMWidgetScreen(cPtr)->gray);
|
||||
paintColorWell(cPtr);
|
||||
|
||||
cPtr->flags.active = 0;
|
||||
*/
|
||||
cPtr->flags.active = 0;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
static WMArray*
|
||||
getXdndTypeArray()
|
||||
{
|
||||
WMArray *types = WMCreateArray(1);
|
||||
WMAddToArray(types, XDND_COLOR_DATA_TYPE);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
WMColorWell*
|
||||
WMCreateColorWell(WMWidget *parent)
|
||||
{
|
||||
@@ -153,8 +168,8 @@ WMCreateColorWell(WMWidget *parent)
|
||||
|
||||
cPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!cPtr->view) {
|
||||
wfree(cPtr);
|
||||
return NULL;
|
||||
wfree(cPtr);
|
||||
return NULL;
|
||||
}
|
||||
cPtr->view->self = cPtr;
|
||||
|
||||
@@ -162,22 +177,21 @@ WMCreateColorWell(WMWidget *parent)
|
||||
|
||||
cPtr->colorView = W_CreateView(cPtr->view);
|
||||
if (!cPtr->colorView) {
|
||||
W_DestroyView(cPtr->view);
|
||||
wfree(cPtr);
|
||||
return NULL;
|
||||
W_DestroyView(cPtr->view);
|
||||
wfree(cPtr);
|
||||
return NULL;
|
||||
}
|
||||
cPtr->colorView->self = cPtr;
|
||||
|
||||
WMCreateEventHandler(cPtr->view, ExposureMask|StructureNotifyMask
|
||||
|ClientMessageMask, handleEvents, cPtr);
|
||||
|ClientMessageMask, handleEvents, cPtr);
|
||||
|
||||
WMCreateEventHandler(cPtr->colorView, ExposureMask, handleEvents, cPtr);
|
||||
|
||||
WMCreateEventHandler(cPtr->colorView, ButtonPressMask|ButtonMotionMask
|
||||
|EnterWindowMask, handleDragEvents, cPtr);
|
||||
WMCreateDragHandler(cPtr->colorView, handleDragEvents, cPtr);
|
||||
|
||||
WMCreateEventHandler(cPtr->view, ButtonPressMask, handleActionEvents,
|
||||
cPtr);
|
||||
cPtr);
|
||||
|
||||
cPtr->colorView->flags.mapWhenRealized = 1;
|
||||
|
||||
@@ -186,21 +200,18 @@ WMCreateColorWell(WMWidget *parent)
|
||||
W_ResizeView(cPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
|
||||
WMAddNotificationObserver(activatedObserver, cPtr,
|
||||
_ColorWellActivatedNotification, NULL);
|
||||
_ColorWellActivatedNotification, NULL);
|
||||
|
||||
cPtr->color = WMBlackColor(WMWidgetScreen(cPtr));
|
||||
|
||||
WMAddNotificationObserver(colorChangedObserver, cPtr,
|
||||
WMColorPanelColorChangedNotification, NULL);
|
||||
WMColorPanelColorChangedNotification, NULL);
|
||||
|
||||
WMSetViewDragSourceProcs(cPtr->colorView, &_DragSourceProcs);
|
||||
WMSetViewDragDestinationProcs(cPtr->colorView, &_DragDestinationProcs);
|
||||
|
||||
{
|
||||
char *types[2] = {"application/X-color", NULL};
|
||||
|
||||
WMRegisterViewForDraggedTypes(cPtr->colorView, types);
|
||||
}
|
||||
cPtr->xdndTypes = getXdndTypeArray();
|
||||
WMRegisterViewForDraggedTypes(cPtr->colorView, cPtr->xdndTypes);
|
||||
|
||||
return cPtr;
|
||||
}
|
||||
@@ -210,12 +221,12 @@ void
|
||||
WMSetColorWellColor(WMColorWell *cPtr, WMColor *color)
|
||||
{
|
||||
if (cPtr->color)
|
||||
WMReleaseColor(cPtr->color);
|
||||
WMReleaseColor(cPtr->color);
|
||||
|
||||
cPtr->color = WMRetainColor(color);
|
||||
|
||||
if (cPtr->colorView->flags.realized && cPtr->colorView->flags.mapped)
|
||||
paintColorWell(cPtr);
|
||||
paintColorWell(cPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,36 +242,36 @@ WSetColorWellBordered(WMColorWell *cPtr, Bool flag)
|
||||
{
|
||||
flag = ((flag==0) ? 0 : 1);
|
||||
if (cPtr->flags.bordered != flag) {
|
||||
cPtr->flags.bordered = flag;
|
||||
W_ResizeView(cPtr->view, cPtr->view->size.width, cPtr->view->size.height);
|
||||
cPtr->flags.bordered = flag;
|
||||
W_ResizeView(cPtr->view, cPtr->view->size.width, cPtr->view->size.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
willResizeColorWell(W_ViewDelegate *self, WMView *view,
|
||||
unsigned int *width, unsigned int *height)
|
||||
unsigned int *width, unsigned int *height)
|
||||
{
|
||||
WMColorWell *cPtr = (WMColorWell*)view->self;
|
||||
int bw;
|
||||
|
||||
if (cPtr->flags.bordered) {
|
||||
|
||||
if (*width < MIN_WIDTH)
|
||||
*width = MIN_WIDTH;
|
||||
if (*height < MIN_HEIGHT)
|
||||
*height = MIN_HEIGHT;
|
||||
if (*width < MIN_WIDTH)
|
||||
*width = MIN_WIDTH;
|
||||
if (*height < MIN_HEIGHT)
|
||||
*height = MIN_HEIGHT;
|
||||
|
||||
bw = (int)((float)WMIN(*width, *height)*0.24);
|
||||
bw = (int)((float)WMIN(*width, *height)*0.24);
|
||||
|
||||
W_ResizeView(cPtr->colorView, *width-2*bw, *height-2*bw);
|
||||
W_ResizeView(cPtr->colorView, *width-2*bw, *height-2*bw);
|
||||
|
||||
if (cPtr->colorView->pos.x!=bw || cPtr->colorView->pos.y!=bw)
|
||||
W_MoveView(cPtr->colorView, bw, bw);
|
||||
if (cPtr->colorView->pos.x!=bw || cPtr->colorView->pos.y!=bw)
|
||||
W_MoveView(cPtr->colorView, bw, bw);
|
||||
} else {
|
||||
W_ResizeView(cPtr->colorView, *width, *height);
|
||||
W_ResizeView(cPtr->colorView, *width, *height);
|
||||
|
||||
W_MoveView(cPtr->colorView, 0, 0);
|
||||
W_MoveView(cPtr->colorView, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,16 +282,16 @@ paintColorWell(ColorWell *cPtr)
|
||||
W_Screen *scr = cPtr->view->screen;
|
||||
|
||||
W_DrawRelief(scr, cPtr->view->window, 0, 0, cPtr->view->size.width,
|
||||
cPtr->view->size.height, WRRaised);
|
||||
cPtr->view->size.height, WRRaised);
|
||||
|
||||
W_DrawRelief(scr, cPtr->colorView->window, 0, 0,
|
||||
cPtr->colorView->size.width, cPtr->colorView->size.height,
|
||||
WRSunken);
|
||||
cPtr->colorView->size.width, cPtr->colorView->size.height,
|
||||
WRSunken);
|
||||
|
||||
if (cPtr->color)
|
||||
WMPaintColorSwatch(cPtr->color, cPtr->colorView->window,
|
||||
2, 2, cPtr->colorView->size.width-4,
|
||||
cPtr->colorView->size.height-4);
|
||||
WMPaintColorSwatch(cPtr->color, cPtr->colorView->window,
|
||||
2, 2, cPtr->colorView->size.width-4,
|
||||
cPtr->colorView->size.height-4);
|
||||
}
|
||||
|
||||
|
||||
@@ -294,27 +305,41 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintColorWell(cPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintColorWell(cPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyColorWell(cPtr);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
destroyColorWell(cPtr);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static unsigned
|
||||
draggingSourceOperation(WMView *self, Bool local)
|
||||
static WMArray*
|
||||
dropDataTypes(WMView *self)
|
||||
{
|
||||
return ((ColorWell*)self->self)->xdndTypes;
|
||||
}
|
||||
|
||||
|
||||
static WMDragOperationType
|
||||
wantedDropOperation(WMView *self)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
acceptDropOperation(WMView *self, WMDragOperationType operation)
|
||||
{
|
||||
return (operation == WDOperationCopy);
|
||||
}
|
||||
|
||||
|
||||
static WMData*
|
||||
fetchDragData(WMView *self, char *type)
|
||||
{
|
||||
@@ -322,7 +347,6 @@ fetchDragData(WMView *self, char *type)
|
||||
WMData *data;
|
||||
|
||||
data = WMCreateDataWithBytes(color, strlen(color)+1);
|
||||
|
||||
wfree(color);
|
||||
|
||||
return data;
|
||||
@@ -350,36 +374,12 @@ handleDragEvents(XEvent *event, void *data)
|
||||
{
|
||||
WMColorWell *cPtr = (ColorWell*)data;
|
||||
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button == Button1) {
|
||||
cPtr->ipoint.x = event->xbutton.x;
|
||||
cPtr->ipoint.y = event->xbutton.y;
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (event->xmotion.state & Button1Mask) {
|
||||
if (abs(cPtr->ipoint.x - event->xmotion.x) > 4
|
||||
|| abs(cPtr->ipoint.y - event->xmotion.y) > 4) {
|
||||
WMSize offs;
|
||||
WMPixmap *pixmap;
|
||||
char *types[2] = {"application/X-color", NULL};
|
||||
|
||||
offs.width = 2;
|
||||
offs.height = 2;
|
||||
pixmap = makeDragPixmap(cPtr);
|
||||
|
||||
WMDragImageFromView(cPtr->colorView, pixmap, types,
|
||||
wmkpoint(event->xmotion.x_root,
|
||||
event->xmotion.y_root),
|
||||
offs, event, True);
|
||||
|
||||
WMReleasePixmap(pixmap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (event->type == ButtonPress && event->xbutton.button == Button1) {
|
||||
/* initialise drag icon */
|
||||
WMSetViewDragImage(cPtr->colorView, makeDragPixmap(cPtr));
|
||||
}
|
||||
|
||||
WMDragImageFromView(cPtr->colorView, event);
|
||||
}
|
||||
|
||||
|
||||
@@ -391,22 +391,22 @@ handleActionEvents(XEvent *event, void *data)
|
||||
WMColorPanel *cpanel;
|
||||
|
||||
if (cPtr->flags.active)
|
||||
W_SetViewBackgroundColor(cPtr->view, scr->gray);
|
||||
W_SetViewBackgroundColor(cPtr->view, scr->gray);
|
||||
else
|
||||
W_SetViewBackgroundColor(cPtr->view, scr->white);
|
||||
W_SetViewBackgroundColor(cPtr->view, scr->white);
|
||||
paintColorWell(cPtr);
|
||||
|
||||
cPtr->flags.active ^= 1;
|
||||
|
||||
if (cPtr->flags.active) {
|
||||
WMPostNotificationName(_ColorWellActivatedNotification, cPtr, NULL);
|
||||
WMPostNotificationName(_ColorWellActivatedNotification, cPtr, NULL);
|
||||
}
|
||||
cpanel = WMGetColorPanel(scr);
|
||||
|
||||
WMSetColorPanelAction(cpanel, updateColorCallback, cPtr);
|
||||
|
||||
if (cPtr->color)
|
||||
WMSetColorPanelColor(cpanel, cPtr->color);
|
||||
WMSetColorPanelColor(cpanel, cPtr->color);
|
||||
WMShowColorPanel(cpanel);
|
||||
}
|
||||
|
||||
@@ -417,58 +417,69 @@ destroyColorWell(ColorWell *cPtr)
|
||||
WMRemoveNotificationObserver(cPtr);
|
||||
|
||||
if (cPtr->color)
|
||||
WMReleaseColor(cPtr->color);
|
||||
WMReleaseColor(cPtr->color);
|
||||
|
||||
WMFreeArray(cPtr->xdndTypes);
|
||||
|
||||
wfree(cPtr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static unsigned
|
||||
draggingEntered(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
|
||||
static unsigned
|
||||
draggingUpdated(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draggingExited(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static char*
|
||||
prepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return "application/X-color";
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
performDragOperation(WMView *self, WMDraggingInfo *info, WMData *data)
|
||||
dropIsOk(WMDragOperationType request, WMArray *sourceDataTypes)
|
||||
{
|
||||
char *colorName = (char*)WMDataBytes(data);
|
||||
WMColor *color;
|
||||
WMArrayIterator iter;
|
||||
char *type;
|
||||
|
||||
color = WMCreateNamedColor(W_VIEW_SCREEN(self), colorName, True);
|
||||
if (request == WDOperationCopy) {
|
||||
WM_ITERATE_ARRAY(sourceDataTypes, type, iter) {
|
||||
if (type != NULL && strcmp(type, XDND_COLOR_DATA_TYPE)==0) {
|
||||
return True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WMSetColorWellColor(self->self, color);
|
||||
return False;
|
||||
}
|
||||
|
||||
WMReleaseColor(color);
|
||||
|
||||
return True;
|
||||
static WMArray*
|
||||
requiredDataTypes(WMView *self, WMDragOperationType request, WMArray *sourceDataTypes)
|
||||
{
|
||||
if (dropIsOk(request, sourceDataTypes))
|
||||
return ((ColorWell*)self->self)->xdndTypes;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static WMDragOperationType
|
||||
allowedOperation(WMView *self, WMDragOperationType request, WMArray *sourceDataTypes)
|
||||
{
|
||||
if (dropIsOk(request, sourceDataTypes))
|
||||
return WDOperationCopy;
|
||||
else
|
||||
return WDOperationNone;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
concludeDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
performDragOperation(WMView *self, WMArray *dropData, WMArray *operations,
|
||||
WMPoint* dropLocation)
|
||||
{
|
||||
char *colorName;
|
||||
WMColor *color;
|
||||
WMData* data;
|
||||
|
||||
/* only one operation requested (WDOperationCopy) implies only one data */
|
||||
data = (WMData*)WMGetFromArray(dropData, 0);
|
||||
|
||||
if (data != NULL) {
|
||||
colorName = (char*)WMDataBytes(data);
|
||||
color = WMCreateNamedColor(W_VIEW_SCREEN(self), colorName, True);
|
||||
WMSetColorWellColor(self->self, color);
|
||||
WMReleaseColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
234
WINGs/wevent.c
234
WINGs/wevent.c
@@ -66,17 +66,17 @@ static WMEventHook *extraEventHandler=NULL;
|
||||
*
|
||||
*/
|
||||
void
|
||||
WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
|
||||
void *clientData)
|
||||
WMCreateEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
|
||||
void *clientData)
|
||||
{
|
||||
W_EventHandler *hPtr;
|
||||
WMArrayIterator iter;
|
||||
|
||||
WM_ITERATE_ARRAY(view->eventHandlers, hPtr, iter) {
|
||||
if (hPtr->clientData==clientData && hPtr->proc==eventProc) {
|
||||
if (hPtr->clientData==clientData && hPtr->proc==eventProc) {
|
||||
hPtr->eventMask |= mask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hPtr = wmalloc(sizeof(W_EventHandler));
|
||||
@@ -109,7 +109,7 @@ matchHandler(void *item, void *cdata)
|
||||
*/
|
||||
void
|
||||
WMDeleteEventHandler(WMView *view, unsigned long mask, WMEventProc *eventProc,
|
||||
void *clientData)
|
||||
void *clientData)
|
||||
{
|
||||
W_EventHandler tmp;
|
||||
|
||||
@@ -124,27 +124,27 @@ static Time
|
||||
getEventTime(WMScreen *screen, XEvent *event)
|
||||
{
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
return event->xbutton.time;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
return event->xkey.time;
|
||||
case MotionNotify:
|
||||
return event->xmotion.time;
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
return event->xcrossing.time;
|
||||
case PropertyNotify:
|
||||
return event->xproperty.time;
|
||||
case SelectionClear:
|
||||
return event->xselectionclear.time;
|
||||
case SelectionRequest:
|
||||
return event->xselectionrequest.time;
|
||||
case SelectionNotify:
|
||||
return event->xselection.time;
|
||||
default:
|
||||
return screen->lastEventTime;
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
return event->xbutton.time;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
return event->xkey.time;
|
||||
case MotionNotify:
|
||||
return event->xmotion.time;
|
||||
case EnterNotify:
|
||||
case LeaveNotify:
|
||||
return event->xcrossing.time;
|
||||
case PropertyNotify:
|
||||
return event->xproperty.time;
|
||||
case SelectionClear:
|
||||
return event->xselectionclear.time;
|
||||
case SelectionRequest:
|
||||
return event->xselectionrequest.time;
|
||||
case SelectionNotify:
|
||||
return event->xselection.time;
|
||||
default:
|
||||
return screen->lastEventTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,9 +162,9 @@ W_CallDestroyHandlers(W_View *view)
|
||||
event.xdestroywindow.event = view->window;
|
||||
|
||||
WM_ITERATE_ARRAY(view->eventHandlers, hPtr, iter) {
|
||||
if (hPtr->eventMask & StructureNotifyMask) {
|
||||
(*hPtr->proc)(&event, hPtr->clientData);
|
||||
}
|
||||
if (hPtr->eventMask & StructureNotifyMask) {
|
||||
(*hPtr->proc)(&event, hPtr->clientData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,15 +186,15 @@ WMRelayToNextResponder(WMView *view, XEvent *event)
|
||||
unsigned long mask = eventMasks[event->xany.type];
|
||||
|
||||
if (view->nextResponder) {
|
||||
WMView *next = view->nextResponder;
|
||||
W_EventHandler *hPtr;
|
||||
WMArrayIterator iter;
|
||||
WMView *next = view->nextResponder;
|
||||
W_EventHandler *hPtr;
|
||||
WMArrayIterator iter;
|
||||
|
||||
WM_ITERATE_ARRAY(next->eventHandlers, hPtr, iter) {
|
||||
if ((hPtr->eventMask & mask)) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
}
|
||||
if ((hPtr->eventMask & mask)) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,8 +209,8 @@ WMHandleEvent(XEvent *event)
|
||||
WMArrayIterator iter;
|
||||
|
||||
if (event->type == MappingNotify) {
|
||||
XRefreshKeyboardMapping(&event->xmapping);
|
||||
return True;
|
||||
XRefreshKeyboardMapping(&event->xmapping);
|
||||
return True;
|
||||
}
|
||||
|
||||
mask = eventMasks[event->xany.type];
|
||||
@@ -219,18 +219,18 @@ WMHandleEvent(XEvent *event)
|
||||
|
||||
/* diferentiate SubstructureNotify with StructureNotify */
|
||||
if (mask == StructureNotifyMask) {
|
||||
if (event->xmap.event != event->xmap.window) {
|
||||
mask = SubstructureNotifyMask;
|
||||
window = event->xmap.event;
|
||||
}
|
||||
if (event->xmap.event != event->xmap.window) {
|
||||
mask = SubstructureNotifyMask;
|
||||
window = event->xmap.event;
|
||||
}
|
||||
}
|
||||
view = W_GetViewForXWindow(event->xany.display, window);
|
||||
|
||||
if (!view) {
|
||||
if (extraEventHandler)
|
||||
(extraEventHandler)(event);
|
||||
if (extraEventHandler)
|
||||
(extraEventHandler)(event);
|
||||
|
||||
return False;
|
||||
return False;
|
||||
}
|
||||
|
||||
view->screen->lastEventTime = getEventTime(view->screen, event);
|
||||
@@ -238,22 +238,19 @@ WMHandleEvent(XEvent *event)
|
||||
toplevel = W_TopLevelOfView(view);
|
||||
|
||||
if (event->type == SelectionNotify || event->type == SelectionClear
|
||||
|| event->type == SelectionRequest) {
|
||||
/* handle selection related events */
|
||||
W_HandleSelectionEvent(event);
|
||||
|| event->type == SelectionRequest) {
|
||||
/* handle selection related events */
|
||||
W_HandleSelectionEvent(event);
|
||||
|
||||
} else if (event->type == ClientMessage) {
|
||||
|
||||
W_HandleDNDClientMessage(toplevel, &event->xclient);
|
||||
}
|
||||
|
||||
/* if it's a key event, redispatch it to the focused control */
|
||||
if (mask & (KeyPressMask|KeyReleaseMask)) {
|
||||
W_View *focused = W_FocusedViewOfToplevel(toplevel);
|
||||
W_View *focused = W_FocusedViewOfToplevel(toplevel);
|
||||
|
||||
if (focused) {
|
||||
view = focused;
|
||||
}
|
||||
if (focused) {
|
||||
view = focused;
|
||||
}
|
||||
}
|
||||
|
||||
/* compress Motion events */
|
||||
@@ -262,9 +259,9 @@ WMHandleEvent(XEvent *event)
|
||||
XEvent ev;
|
||||
XPeekEvent(event->xmotion.display, &ev);
|
||||
if (ev.type == MotionNotify
|
||||
&& event->xmotion.window == ev.xmotion.window
|
||||
&& event->xmotion.subwindow == ev.xmotion.subwindow) {
|
||||
/* replace events */
|
||||
&& event->xmotion.window == ev.xmotion.window
|
||||
&& event->xmotion.subwindow == ev.xmotion.subwindow) {
|
||||
/* replace events */
|
||||
XNextEvent(event->xmotion.display, event);
|
||||
} else break;
|
||||
}
|
||||
@@ -273,25 +270,25 @@ WMHandleEvent(XEvent *event)
|
||||
/* compress expose events */
|
||||
if (event->type == Expose && !view->flags.dontCompressExpose) {
|
||||
while (XCheckTypedWindowEvent(event->xexpose.display, view->window,
|
||||
Expose, event));
|
||||
Expose, event));
|
||||
}
|
||||
|
||||
|
||||
if (view->screen->modalLoop && toplevel!=view->screen->modalView
|
||||
&& !toplevel->flags.worksWhenModal) {
|
||||
if (event->type == KeyPress || event->type == KeyRelease
|
||||
|| event->type == MotionNotify || event->type == ButtonPress
|
||||
|| event->type == ButtonRelease
|
||||
|| event->type == FocusIn || event->type == FocusOut) {
|
||||
return True;
|
||||
}
|
||||
&& !toplevel->flags.worksWhenModal) {
|
||||
if (event->type == KeyPress || event->type == KeyRelease
|
||||
|| event->type == MotionNotify || event->type == ButtonPress
|
||||
|| event->type == ButtonRelease
|
||||
|| event->type == FocusIn || event->type == FocusOut) {
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
/* do balloon stuffs */
|
||||
if (event->type == EnterNotify)
|
||||
W_BalloonHandleEnterView(view);
|
||||
W_BalloonHandleEnterView(view);
|
||||
else if (event->type == LeaveNotify)
|
||||
W_BalloonHandleLeaveView(view);
|
||||
W_BalloonHandleLeaveView(view);
|
||||
|
||||
/* This is a hack. It will make the panel be secure while
|
||||
* the event handlers are handled, as some event handler
|
||||
@@ -299,33 +296,38 @@ WMHandleEvent(XEvent *event)
|
||||
W_RetainView(toplevel);
|
||||
|
||||
WM_ITERATE_ARRAY(view->eventHandlers, hPtr, iter) {
|
||||
if ((hPtr->eventMask & mask)) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
if ((hPtr->eventMask & mask)) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
/* pass the event to the top level window of the widget */
|
||||
/* TODO: change this to a responder chain */
|
||||
if (view->parent != NULL) {
|
||||
vPtr = view;
|
||||
while (vPtr->parent != NULL)
|
||||
vPtr = vPtr->parent;
|
||||
vPtr = view;
|
||||
while (vPtr->parent != NULL)
|
||||
vPtr = vPtr->parent;
|
||||
|
||||
WM_ITERATE_ARRAY(vPtr->eventHandlers, hPtr, iter) {
|
||||
if (hPtr->eventMask & mask) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
}
|
||||
WM_ITERATE_ARRAY(vPtr->eventHandlers, hPtr, iter) {
|
||||
if (hPtr->eventMask & mask) {
|
||||
(*hPtr->proc)(event, hPtr->clientData);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* save button click info to track double-clicks */
|
||||
if (view->screen->ignoreNextDoubleClick) {
|
||||
view->screen->ignoreNextDoubleClick = 0;
|
||||
view->screen->ignoreNextDoubleClick = 0;
|
||||
} else {
|
||||
if (event->type == ButtonPress) {
|
||||
view->screen->lastClickWindow = event->xbutton.window;
|
||||
view->screen->lastClickTime = event->xbutton.time;
|
||||
}
|
||||
if (event->type == ButtonPress) {
|
||||
view->screen->lastClickWindow = event->xbutton.window;
|
||||
view->screen->lastClickTime = event->xbutton.time;
|
||||
}
|
||||
}
|
||||
|
||||
if (event->type == ClientMessage) {
|
||||
/* must be handled at the end, for such message can destroy the view */
|
||||
W_HandleDNDClientMessage(toplevel, &event->xclient);
|
||||
}
|
||||
|
||||
W_ReleaseView(toplevel);
|
||||
@@ -340,24 +342,24 @@ WMIsDoubleClick(XEvent *event)
|
||||
W_View *view;
|
||||
|
||||
if (event->type != ButtonPress)
|
||||
return False;
|
||||
return False;
|
||||
|
||||
view = W_GetViewForXWindow(event->xany.display, event->xbutton.window);
|
||||
|
||||
if (!view)
|
||||
return False;
|
||||
return False;
|
||||
|
||||
if (view->screen->lastClickWindow != event->xbutton.window)
|
||||
return False;
|
||||
return False;
|
||||
|
||||
if (event->xbutton.time - view->screen->lastClickTime
|
||||
< WINGsConfiguration.doubleClickDelay) {
|
||||
view->screen->lastClickTime = 0;
|
||||
view->screen->lastClickWindow = None;
|
||||
view->screen->ignoreNextDoubleClick = 1;
|
||||
return True;
|
||||
< WINGsConfiguration.doubleClickDelay) {
|
||||
view->screen->lastClickTime = 0;
|
||||
view->screen->lastClickWindow = None;
|
||||
view->screen->ignoreNextDoubleClick = 1;
|
||||
return True;
|
||||
} else
|
||||
return False;
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
@@ -381,14 +383,14 @@ waitForEvent(Display *dpy, unsigned long xeventmask, Bool waitForInput)
|
||||
{
|
||||
XSync(dpy, False);
|
||||
if (xeventmask==0) {
|
||||
if (XPending(dpy))
|
||||
return True;
|
||||
if (XPending(dpy))
|
||||
return True;
|
||||
} else {
|
||||
XEvent ev;
|
||||
if (XCheckMaskEvent(dpy, xeventmask, &ev)) {
|
||||
XPutBackEvent(dpy, &ev);
|
||||
return True;
|
||||
}
|
||||
XEvent ev;
|
||||
if (XCheckMaskEvent(dpy, xeventmask, &ev)) {
|
||||
XPutBackEvent(dpy, &ev);
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
return W_HandleInputEvents(waitForInput, ConnectionNumber(dpy));
|
||||
@@ -402,19 +404,19 @@ WMNextEvent(Display *dpy, XEvent *event)
|
||||
W_CheckTimerHandlers();
|
||||
|
||||
while (XPending(dpy) == 0) {
|
||||
/* Do idle and timer stuff while there are no input or X events */
|
||||
while (!waitForEvent(dpy, 0, False) && W_CheckIdleHandlers()) {
|
||||
/* dispatch timer events */
|
||||
/* Do idle and timer stuff while there are no input or X events */
|
||||
while (!waitForEvent(dpy, 0, False) && W_CheckIdleHandlers()) {
|
||||
/* dispatch timer events */
|
||||
W_CheckTimerHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure that new events did not arrive while we were doing
|
||||
* timer/idle stuff. Or we might block forever waiting for
|
||||
* an event that already arrived.
|
||||
*/
|
||||
/* wait for something to happen or a timer to expire */
|
||||
waitForEvent(dpy, 0, True);
|
||||
/*
|
||||
* Make sure that new events did not arrive while we were doing
|
||||
* timer/idle stuff. Or we might block forever waiting for
|
||||
* an event that already arrived.
|
||||
*/
|
||||
/* wait for something to happen or a timer to expire */
|
||||
waitForEvent(dpy, 0, True);
|
||||
|
||||
/* Check any expired timers */
|
||||
W_CheckTimerHandlers();
|
||||
@@ -431,16 +433,16 @@ WMMaskEvent(Display *dpy, long mask, XEvent *event)
|
||||
W_CheckTimerHandlers();
|
||||
|
||||
while (!XCheckMaskEvent(dpy, mask, event)) {
|
||||
/* Do idle and timer stuff while there are no input or X events */
|
||||
/* Do idle and timer stuff while there are no input or X events */
|
||||
while (!waitForEvent(dpy, mask, False) && W_CheckIdleHandlers()) {
|
||||
W_CheckTimerHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
if (XCheckMaskEvent(dpy, mask, event))
|
||||
return;
|
||||
|
||||
/* Wait for input on the X connection socket or another input handler */
|
||||
waitForEvent(dpy, mask, True);
|
||||
waitForEvent(dpy, mask, True);
|
||||
|
||||
/* Check any expired timers */
|
||||
W_CheckTimerHandlers();
|
||||
@@ -452,9 +454,9 @@ Bool
|
||||
WMScreenPending(WMScreen *scr)
|
||||
{
|
||||
if (XPending(scr->display))
|
||||
return True;
|
||||
return True;
|
||||
else
|
||||
return False;
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
427
WINGs/wfont.c
427
WINGs/wfont.c
@@ -149,8 +149,8 @@ alreadyHasStringValue(XftPattern *pattern, const char *object, char *value)
|
||||
return True;
|
||||
|
||||
id = 0;
|
||||
while ((r=XftPatternGetString(pattern, object, id, &s))!=XftResultNoId) {
|
||||
if (r == XftResultMatch && strcasecmp(value, s) == 0) {
|
||||
while ((r=XftPatternGetString(pattern, object, id, &s))==XftResultMatch) {
|
||||
if (strcasecmp(value, s) == 0) {
|
||||
return True;
|
||||
}
|
||||
id++;
|
||||
@@ -165,23 +165,21 @@ alreadyHasStringValue(XftPattern *pattern, const char *object, char *value)
|
||||
static char*
|
||||
makeFontOfSize(char *font, int size, char *fallback)
|
||||
{
|
||||
XftPattern *pattern;
|
||||
FcPattern *pattern;
|
||||
char *result;
|
||||
int len;
|
||||
|
||||
len = strlen(font) + 64;
|
||||
pattern = XftNameParse(font);
|
||||
XftPatternDel(pattern, "pixelsize");
|
||||
XftPatternAddDouble(pattern, "pixelsize", (double)size);
|
||||
|
||||
if (fallback) {
|
||||
if (!alreadyHasStringValue(pattern, "family", fallback)) {
|
||||
len += strlen(fallback);
|
||||
XftPatternAddString(pattern, "family", fallback);
|
||||
}
|
||||
}
|
||||
result = wmalloc(len);
|
||||
XftNameUnparse(pattern, result, len);
|
||||
XftPatternDestroy(pattern);
|
||||
|
||||
result = FcNameUnparse(pattern);
|
||||
FcPatternDestroy(pattern);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -198,17 +196,17 @@ WMCreateFont(WMScreen *scrPtr, char *fontName)
|
||||
if (fontName[0]=='-' && (ptr = strchr(fontName, ','))) {
|
||||
// warn for deprecation
|
||||
fname = wmalloc(ptr - fontName + 1);
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
} else {
|
||||
fname = wstrdup(fontName);
|
||||
fname = wstrdup(fontName);
|
||||
}
|
||||
|
||||
font = WMHashGet(scrPtr->fontCache, fname);
|
||||
if (font) {
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
}
|
||||
|
||||
font = wmalloc(sizeof(WMFont));
|
||||
@@ -217,7 +215,7 @@ WMCreateFont(WMScreen *scrPtr, char *fontName)
|
||||
font->screen = scrPtr;
|
||||
|
||||
// remove
|
||||
printf("%s\n", fname);
|
||||
printf("WMCreateFont: %s\n", fname);
|
||||
|
||||
if (fname[0] == '-') {
|
||||
// Backward compat thing. Remove in a later version
|
||||
@@ -264,9 +262,9 @@ WMReleaseFont(WMFont *font)
|
||||
XftFontClose(font->screen->display, font->font);
|
||||
if (font->name) {
|
||||
WMHashRemove(font->screen->fontCache, font->name);
|
||||
wfree(font->name);
|
||||
}
|
||||
wfree(font);
|
||||
wfree(font->name);
|
||||
}
|
||||
wfree(font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,166 +487,50 @@ WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background
|
||||
|
||||
|
||||
WMFont*
|
||||
WMCopyFontWithChanges(WMScreen *scrPtr, WMFont *font,
|
||||
const WMFontAttributes *changes)
|
||||
WMCopyFontWithStyle(WMScreen *scrPtr, WMFont *font, WMFontStyle style)
|
||||
{
|
||||
int index[FONT_PROPS], count[FONT_PROPS];
|
||||
int totalProps, i, j, carry;
|
||||
char fname[512];
|
||||
WMFontFlags fFlags;
|
||||
WMBag *props;
|
||||
WMArray *options;
|
||||
WMFont *result;
|
||||
char *prop;
|
||||
FcPattern *pattern;
|
||||
WMFont *copy;
|
||||
char *name;
|
||||
|
||||
snprintf(fname, 512, "%s", font->name);
|
||||
if (!font)
|
||||
return NULL;
|
||||
|
||||
fFlags = (font->antialiased ? WFAntialiased : WFNotAntialiased);
|
||||
fFlags |= (font->notFontSet ? WFNormalFont : WFFontSet);
|
||||
|
||||
props = WMCreateBagWithDestructor(1, (WMFreeDataProc*)WMFreeArray);
|
||||
|
||||
totalProps = 0;
|
||||
for (i=0; i<FONT_PROPS; i++) {
|
||||
prop = ((W_FontAttributes*)changes)->props[i];
|
||||
count[i] = index[i] = 0;
|
||||
if (!prop) {
|
||||
/* No change for this property */
|
||||
continue;
|
||||
} else if (strchr(prop, ',')==NULL) {
|
||||
/* Simple option */
|
||||
changeFontProp(fname, prop, i);
|
||||
} else {
|
||||
/* Option with fallback alternatives */
|
||||
if ((changes==WFAEmphasized || changes==WFABoldEmphasized) &&
|
||||
font->antialiased && strcmp(prop, "o,i")==0) {
|
||||
options = getOptions("i,o");
|
||||
} else {
|
||||
options = getOptions(prop);
|
||||
}
|
||||
WMInsertInBag(props, i, options);
|
||||
count[i] = WMGetArrayItemCount(options);
|
||||
if (totalProps==0)
|
||||
totalProps = 1;
|
||||
totalProps = totalProps * count[i];
|
||||
}
|
||||
pattern = XftNameParse(WMGetFontName(font));
|
||||
switch (style) {
|
||||
case WFSNormal:
|
||||
XftPatternDel(pattern, "weight");
|
||||
XftPatternDel(pattern, "slant");
|
||||
XftPatternAddString(pattern, "weight", "medium");
|
||||
XftPatternAddString(pattern, "slant", "roman");
|
||||
break;
|
||||
case WFSBold:
|
||||
XftPatternDel(pattern, "weight");
|
||||
XftPatternAddString(pattern, "weight", "bold");
|
||||
break;
|
||||
case WFSEmphasized:
|
||||
XftPatternDel(pattern, "slant");
|
||||
XftPatternAddString(pattern, "slant", "italic");
|
||||
XftPatternAddString(pattern, "slant", "oblique");
|
||||
break;
|
||||
case WFSBoldEmphasized:
|
||||
XftPatternDel(pattern, "weight");
|
||||
XftPatternDel(pattern, "slant");
|
||||
XftPatternAddString(pattern, "weight", "bold");
|
||||
XftPatternAddString(pattern, "slant", "italic");
|
||||
XftPatternAddString(pattern, "slant", "oblique");
|
||||
break;
|
||||
}
|
||||
|
||||
if (totalProps == 0) {
|
||||
/* No options with fallback alternatives at all */
|
||||
WMFreeBag(props);
|
||||
return WMCreateFontWithFlags(scrPtr, fname, fFlags);
|
||||
}
|
||||
name = FcNameUnparse(pattern);
|
||||
copy = WMCreateFont(scrPtr, name);
|
||||
FcPatternDestroy(pattern);
|
||||
wfree(name);
|
||||
|
||||
for (i=0; i<totalProps; i++) {
|
||||
for (j=0; j<FONT_PROPS; j++) {
|
||||
if (count[j]!=0) {
|
||||
options = WMGetFromBag(props, j);
|
||||
prop = WMGetFromArray(options, index[j]);
|
||||
if (prop) {
|
||||
changeFontProp(fname, prop, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
result = WMCreateFontWithFlags(scrPtr, fname, fFlags);
|
||||
if (result) {
|
||||
WMFreeBag(props);
|
||||
return result;
|
||||
}
|
||||
for (j=FONT_PROPS-1, carry=1; j>=0; j--) {
|
||||
if (count[j]!=0) {
|
||||
index[j] += carry;
|
||||
carry = (index[j]==count[j]);
|
||||
index[j] %= count[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WMFreeBag(props);
|
||||
|
||||
return NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
#define FONT_PROPS 14
|
||||
|
||||
typedef struct {
|
||||
char *props[FONT_PROPS];
|
||||
} W_FontAttributes;
|
||||
|
||||
|
||||
static void
|
||||
changeFontProp(char *buf, char *newprop, int position)
|
||||
{
|
||||
char buf2[512];
|
||||
char *ptr, *pptr, *rptr;
|
||||
int count;
|
||||
|
||||
if (buf[0]!='-') {
|
||||
/* // remove warning later. or maybe not */
|
||||
wwarning(_("Invalid font specification: '%s'\n"), buf);
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = pptr = rptr = buf;
|
||||
count = 0;
|
||||
while (*ptr && *ptr!=',') {
|
||||
if (*ptr == '-') {
|
||||
count++;
|
||||
if (count-1==position+1) {
|
||||
rptr = ptr;
|
||||
break;
|
||||
}
|
||||
if (count-1==position) {
|
||||
pptr = ptr+1;
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
if (position==FONT_PROPS-1) {
|
||||
rptr = ptr;
|
||||
}
|
||||
|
||||
*pptr = 0;
|
||||
snprintf(buf2, 512, "%s%s%s", buf, newprop, rptr);
|
||||
strcpy(buf, buf2);
|
||||
}
|
||||
|
||||
|
||||
static WMArray*
|
||||
getOptions(char *options)
|
||||
{
|
||||
char *ptr, *ptr2, *str;
|
||||
WMArray *result;
|
||||
int count;
|
||||
|
||||
result = WMCreateArrayWithDestructor(2, (WMFreeDataProc*)wfree);
|
||||
|
||||
ptr = options;
|
||||
while (1) {
|
||||
ptr2 = strchr(ptr, ',');
|
||||
if (!ptr2) {
|
||||
WMAddToArray(result, wstrdup(ptr));
|
||||
break;
|
||||
} else {
|
||||
count = ptr2 - ptr;
|
||||
str = wmalloc(count+1);
|
||||
memcpy(str, ptr, count);
|
||||
str[count] = 0;
|
||||
WMAddToArray(result, str);
|
||||
ptr = ptr2 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#else /* No XFT support */
|
||||
|
||||
|
||||
@@ -662,18 +544,18 @@ getElementFromXLFD(const char *xlfd, int index)
|
||||
{
|
||||
const char *p = xlfd;
|
||||
while (*p != 0) {
|
||||
if (*p == '-' && --index == 0) {
|
||||
const char *end = strchr(p + 1, '-');
|
||||
char *buf;
|
||||
size_t len;
|
||||
if (end == 0) end = p + strlen(p);
|
||||
len = end - (p + 1);
|
||||
buf = wmalloc(len);
|
||||
memcpy(buf, p + 1, len);
|
||||
buf[len] = 0;
|
||||
return buf;
|
||||
}
|
||||
p++;
|
||||
if (*p == '-' && --index == 0) {
|
||||
const char *end = strchr(p + 1, '-');
|
||||
char *buf;
|
||||
size_t len;
|
||||
if (end == 0) end = p + strlen(p);
|
||||
len = end - (p + 1);
|
||||
buf = wmalloc(len);
|
||||
memcpy(buf, p + 1, len);
|
||||
buf[len] = 0;
|
||||
return buf;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return strdup("*");
|
||||
}
|
||||
@@ -695,8 +577,8 @@ generalizeXLFD(const char *xlfd)
|
||||
|
||||
buf = wmalloc(len + 1);
|
||||
snprintf(buf, len + 1, "%s,-*-*-%s-%s-*-*-%s-*-*-*-*-*-*-*,"
|
||||
"-*-*-*-*-*-*-%s-*-*-*-*-*-*-*,*",
|
||||
xlfd, weight, slant, pxlsz, pxlsz);
|
||||
"-*-*-*-*-*-*-%s-*-*-*-*-*-*-*,*",
|
||||
xlfd, weight, slant, pxlsz, pxlsz);
|
||||
|
||||
wfree(pxlsz);
|
||||
wfree(slant);
|
||||
@@ -708,27 +590,27 @@ generalizeXLFD(const char *xlfd)
|
||||
/* XLFD pattern matching */
|
||||
static XFontSet
|
||||
W_CreateFontSetWithGuess(Display *dpy, char *xlfd, char ***missing,
|
||||
int *nmissing, char **def_string)
|
||||
int *nmissing, char **def_string)
|
||||
{
|
||||
XFontSet fs = XCreateFontSet(dpy, xlfd, missing, nmissing, def_string);
|
||||
|
||||
if (fs != NULL && *nmissing == 0) return fs;
|
||||
|
||||
/* for non-iso8859-1 language and iso8859-1 specification
|
||||
(this fontset is only for pattern analysis) */
|
||||
(this fontset is only for pattern analysis) */
|
||||
if (fs == NULL) {
|
||||
if (*nmissing != 0) XFreeStringList(*missing);
|
||||
setlocale(LC_CTYPE, "C");
|
||||
fs = XCreateFontSet(dpy, xlfd, missing, nmissing, def_string);
|
||||
setlocale(LC_CTYPE, "");
|
||||
if (*nmissing != 0) XFreeStringList(*missing);
|
||||
setlocale(LC_CTYPE, "C");
|
||||
fs = XCreateFontSet(dpy, xlfd, missing, nmissing, def_string);
|
||||
setlocale(LC_CTYPE, "");
|
||||
}
|
||||
|
||||
/* make XLFD font name for pattern analysis */
|
||||
if (fs != NULL) {
|
||||
XFontStruct **fontstructs;
|
||||
char **fontnames;
|
||||
if (XFontsOfFontSet(fs, &fontstructs, &fontnames) > 0)
|
||||
xlfd = fontnames[0];
|
||||
XFontStruct **fontstructs;
|
||||
char **fontnames;
|
||||
if (XFontsOfFontSet(fs, &fontstructs, &fontnames) > 0)
|
||||
xlfd = fontnames[0];
|
||||
}
|
||||
|
||||
xlfd = generalizeXLFD(xlfd);
|
||||
@@ -805,7 +687,7 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
|
||||
if (font) {
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
return font;
|
||||
}
|
||||
|
||||
font = wmalloc(sizeof(WMFont));
|
||||
@@ -819,21 +701,21 @@ WMCreateFontSet(WMScreen *scrPtr, char *fontName)
|
||||
font->font.set = W_CreateFontSetWithGuess(display, fname, &missing,
|
||||
&nmissing, &defaultString);
|
||||
if (nmissing > 0 && font->font.set) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
wwarning(_("the following character sets are missing in %s:"), fname);
|
||||
for (i = 0; i < nmissing; i++) {
|
||||
wwarning(missing[i]);
|
||||
}
|
||||
XFreeStringList(missing);
|
||||
if (defaultString)
|
||||
wwarning(_("the string \"%s\" will be used in place of any characters from those sets."),
|
||||
defaultString);
|
||||
wwarning(_("the following character sets are missing in %s:"), fname);
|
||||
for (i = 0; i < nmissing; i++) {
|
||||
wwarning(missing[i]);
|
||||
}
|
||||
XFreeStringList(missing);
|
||||
if (defaultString)
|
||||
wwarning(_("the string \"%s\" will be used in place of any characters from those sets."),
|
||||
defaultString);
|
||||
}
|
||||
if (!font->font.set) {
|
||||
wfree(font);
|
||||
wfree(fname);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extents = XExtentsOfFontSet(font->font.set);
|
||||
@@ -862,20 +744,20 @@ WMCreateNormalFont(WMScreen *scrPtr, char *fontName)
|
||||
fontName = xlfdFromFontName(fontName, False);
|
||||
|
||||
if ((ptr = strchr(fontName, ','))) {
|
||||
fname = wmalloc(ptr - fontName + 1);
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
fname = wmalloc(ptr - fontName + 1);
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
} else {
|
||||
fname = wstrdup(fontName);
|
||||
fname = wstrdup(fontName);
|
||||
}
|
||||
|
||||
wfree(fontName);
|
||||
|
||||
font = WMHashGet(scrPtr->fontCache, fname);
|
||||
if (font) {
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
}
|
||||
|
||||
font = wmalloc(sizeof(WMFont));
|
||||
@@ -916,20 +798,20 @@ WMCreateAntialiasedFont(WMScreen *scrPtr, char *fontName)
|
||||
fontName = xlfdFromFontName(fontName, True);
|
||||
|
||||
if ((ptr = strchr(fontName, ','))) {
|
||||
fname = wmalloc(ptr - fontName + 1);
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
fname = wmalloc(ptr - fontName + 1);
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
} else {
|
||||
fname = wstrdup(fontName);
|
||||
fname = wstrdup(fontName);
|
||||
}
|
||||
|
||||
wfree(fontName);
|
||||
|
||||
font = WMHashGet(scrPtr->xftFontCache, fname);
|
||||
if (font) {
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
}
|
||||
|
||||
font = wmalloc(sizeof(WMFont));
|
||||
@@ -993,19 +875,19 @@ WMCreateAntialiasedFontSet(WMScreen *scrPtr, char *fontName)
|
||||
|
||||
if ((ptr = strchr(fontName, ','))) {
|
||||
fname = wmalloc(ptr - fontName + 1);
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
strncpy(fname, fontName, ptr - fontName);
|
||||
fname[ptr - fontName] = 0;
|
||||
} else {
|
||||
fname = wstrdup(fontName);
|
||||
fname = wstrdup(fontName);
|
||||
}
|
||||
|
||||
wfree(fontName);
|
||||
|
||||
font = WMHashGet(scrPtr->xftFontSetCache, fname);
|
||||
if (font) {
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
WMRetainFont(font);
|
||||
wfree(fname);
|
||||
return font;
|
||||
}
|
||||
|
||||
font = wmalloc(sizeof(WMFont));
|
||||
@@ -1096,7 +978,7 @@ WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags)
|
||||
font = WMCreateNormalFont(scrPtr, fontName);
|
||||
}
|
||||
} else if (multiByte) {
|
||||
font = WMCreateFontSet(scrPtr, fontName);
|
||||
font = WMCreateFontSet(scrPtr, fontName);
|
||||
} else {
|
||||
font = WMCreateNormalFont(scrPtr, fontName);
|
||||
}
|
||||
@@ -1145,9 +1027,9 @@ WMReleaseFont(WMFont *font)
|
||||
} else {
|
||||
WMHashRemove(font->screen->fontSetCache, font->name);
|
||||
}
|
||||
wfree(font->name);
|
||||
}
|
||||
wfree(font);
|
||||
wfree(font->name);
|
||||
}
|
||||
wfree(font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1401,7 +1283,7 @@ WMDrawString(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
|
||||
/* we can draw normal text, or we can draw as much widechar
|
||||
* text as was already converted until the error. go figure */
|
||||
/*XftDrawString8(scr->xftdraw, &xftcolor, font->font.xft,
|
||||
x, y + font->y, (XftChar8*)text, length);*/
|
||||
x, y + font->y, (XftChar8*)text, length);*/
|
||||
}
|
||||
wfree(wtext);
|
||||
} else {
|
||||
@@ -1472,7 +1354,7 @@ WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background
|
||||
/* we can draw normal text, or we can draw as much widechar
|
||||
* text as was already converted until the error. go figure */
|
||||
/*XftDrawString8(scr->xftdraw, &textColor, font->font.xft,
|
||||
x, y + font->y, (XftChar8*)text, length);*/
|
||||
x, y + font->y, (XftChar8*)text, length);*/
|
||||
}
|
||||
wfree(wtext);
|
||||
} else {
|
||||
@@ -1507,42 +1389,42 @@ makeFontSetOfSize(char *fontset, int size)
|
||||
char *ptr;
|
||||
|
||||
do {
|
||||
char *tmp;
|
||||
int end;
|
||||
char *tmp;
|
||||
int end;
|
||||
|
||||
|
||||
f = fontset;
|
||||
ptr = strchr(fontset, ',');
|
||||
if (ptr) {
|
||||
int count = ptr-fontset;
|
||||
f = fontset;
|
||||
ptr = strchr(fontset, ',');
|
||||
if (ptr) {
|
||||
int count = ptr-fontset;
|
||||
|
||||
if (count > 255) {
|
||||
wwarning(_("font description %s is too large."), fontset);
|
||||
} else {
|
||||
memcpy(font, fontset, count);
|
||||
font[count] = 0;
|
||||
f = (char*)font;
|
||||
}
|
||||
}
|
||||
if (count > 255) {
|
||||
wwarning(_("font description %s is too large."), fontset);
|
||||
} else {
|
||||
memcpy(font, fontset, count);
|
||||
font[count] = 0;
|
||||
f = (char*)font;
|
||||
}
|
||||
}
|
||||
|
||||
if (newfs)
|
||||
end = strlen(newfs);
|
||||
else
|
||||
end = 0;
|
||||
if (newfs)
|
||||
end = strlen(newfs);
|
||||
else
|
||||
end = 0;
|
||||
|
||||
tmp = wmalloc(end + strlen(f) + 8);
|
||||
if (end != 0) {
|
||||
sprintf(tmp, "%s,", newfs);
|
||||
sprintf(tmp + end + 1, f, size);
|
||||
} else {
|
||||
sprintf(tmp + end, f, size);
|
||||
}
|
||||
tmp = wmalloc(end + strlen(f) + 8);
|
||||
if (end != 0) {
|
||||
sprintf(tmp, "%s,", newfs);
|
||||
sprintf(tmp + end + 1, f, size);
|
||||
} else {
|
||||
sprintf(tmp + end, f, size);
|
||||
}
|
||||
|
||||
if (newfs)
|
||||
wfree(newfs);
|
||||
newfs = tmp;
|
||||
if (newfs)
|
||||
wfree(newfs);
|
||||
newfs = tmp;
|
||||
|
||||
fontset = ptr+1;
|
||||
fontset = ptr+1;
|
||||
} while (ptr!=NULL);
|
||||
|
||||
return newfs;
|
||||
@@ -1623,6 +1505,25 @@ getOptions(char *options)
|
||||
}
|
||||
|
||||
|
||||
#define WFAUnchanged (NULL)
|
||||
/* Struct for font change operations */
|
||||
typedef struct WMFontAttributes {
|
||||
char *foundry;
|
||||
char *family;
|
||||
char *weight;
|
||||
char *slant;
|
||||
char *setWidth;
|
||||
char *addStyle;
|
||||
char *pixelSize;
|
||||
char *pointSize;
|
||||
char *resolutionX;
|
||||
char *resolutionY;
|
||||
char *spacing;
|
||||
char *averageWidth;
|
||||
char *registry;
|
||||
char *encoding;
|
||||
} WMFontAttributes;
|
||||
|
||||
WMFont*
|
||||
WMCopyFontWithChanges(WMScreen *scrPtr, WMFont *font,
|
||||
const WMFontAttributes *changes)
|
||||
@@ -1704,9 +1605,6 @@ WMCopyFontWithChanges(WMScreen *scrPtr, WMFont *font,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// should WFANormal also set "normal" or leave it alone?
|
||||
static const WMFontAttributes W_FANormal = {
|
||||
WFAUnchanged, WFAUnchanged, "medium,normal,regular", "r", "normal",
|
||||
@@ -1758,3 +1656,6 @@ const WMFontAttributes *WFANotEmphasized = &W_FANotEmphasized;
|
||||
const WMFontAttributes *WFABoldEmphasized = &W_FABoldEmphasized;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
170
WINGs/wframe.c
170
WINGs/wframe.c
@@ -9,8 +9,8 @@ typedef struct W_Frame {
|
||||
char *caption;
|
||||
|
||||
struct {
|
||||
WMReliefType relief:4;
|
||||
WMTitlePosition titlePosition:4;
|
||||
WMReliefType relief:4;
|
||||
WMTitlePosition titlePosition:4;
|
||||
} flags;
|
||||
} Frame;
|
||||
|
||||
@@ -33,7 +33,7 @@ WMSetFrameTitlePosition(WMFrame *fPtr, WMTitlePosition position)
|
||||
fPtr->flags.titlePosition = position;
|
||||
|
||||
if (fPtr->view->flags.realized) {
|
||||
repaintFrame(fPtr);
|
||||
repaintFrame(fPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,99 +100,99 @@ paintFrame(Frame *fPtr)
|
||||
fy = 0;
|
||||
|
||||
switch (fPtr->flags.titlePosition) {
|
||||
case WTPAboveTop:
|
||||
ty = 0;
|
||||
fy = th + 4;
|
||||
fh = view->size.height - fy;
|
||||
break;
|
||||
case WTPAboveTop:
|
||||
ty = 0;
|
||||
fy = th + 4;
|
||||
fh = view->size.height - fy;
|
||||
break;
|
||||
|
||||
case WTPAtTop:
|
||||
ty = 0;
|
||||
fy = th/2;
|
||||
fh = view->size.height - fy;
|
||||
break;
|
||||
case WTPAtTop:
|
||||
ty = 0;
|
||||
fy = th/2;
|
||||
fh = view->size.height - fy;
|
||||
break;
|
||||
|
||||
case WTPBelowTop:
|
||||
ty = 4;
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
break;
|
||||
case WTPBelowTop:
|
||||
ty = 4;
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
break;
|
||||
|
||||
case WTPAboveBottom:
|
||||
ty = view->size.height - th - 4;
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
break;
|
||||
case WTPAboveBottom:
|
||||
ty = view->size.height - th - 4;
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
break;
|
||||
|
||||
case WTPAtBottom:
|
||||
ty = view->size.height - th;
|
||||
fy = 0;
|
||||
fh = view->size.height - th/2;
|
||||
break;
|
||||
case WTPAtBottom:
|
||||
ty = view->size.height - th;
|
||||
fy = 0;
|
||||
fh = view->size.height - th/2;
|
||||
break;
|
||||
|
||||
case WTPBelowBottom:
|
||||
ty = view->size.height - th;
|
||||
fy = 0;
|
||||
fh = view->size.height - th - 4;
|
||||
break;
|
||||
case WTPBelowBottom:
|
||||
ty = view->size.height - th;
|
||||
fy = 0;
|
||||
fh = view->size.height - th - 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
ty = 0;
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
default:
|
||||
ty = 0;
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
}
|
||||
|
||||
if (tlen>0 && fPtr->flags.titlePosition!=WTPNoTitle) {
|
||||
tw = WMWidthOfString(font, fPtr->caption, tlen);
|
||||
tw = WMWidthOfString(font, fPtr->caption, tlen);
|
||||
|
||||
tx = (view->size.width - tw) / 2;
|
||||
|
||||
drawTitle = True;
|
||||
} else {
|
||||
drawTitle = False;
|
||||
drawTitle = False;
|
||||
}
|
||||
|
||||
{
|
||||
XRectangle rect;
|
||||
Region region, tmp;
|
||||
GC gc[4];
|
||||
int i;
|
||||
XRectangle rect;
|
||||
Region region, tmp;
|
||||
GC gc[4];
|
||||
int i;
|
||||
|
||||
region = XCreateRegion();
|
||||
region = XCreateRegion();
|
||||
|
||||
if (drawTitle) {
|
||||
tmp = XCreateRegion();
|
||||
rect.x = tx;
|
||||
rect.y = ty;
|
||||
rect.width = tw;
|
||||
rect.height = th;
|
||||
XUnionRectWithRegion(&rect, tmp, tmp);
|
||||
}
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = view->size.width;
|
||||
rect.height = view->size.height;
|
||||
XUnionRectWithRegion(&rect, region, region);
|
||||
if (drawTitle) {
|
||||
XSubtractRegion(region, tmp, region);
|
||||
XDestroyRegion(tmp);
|
||||
}
|
||||
gc[0] = WMColorGC(scrPtr->black);
|
||||
gc[1] = WMColorGC(scrPtr->darkGray);
|
||||
gc[2] = WMColorGC(scrPtr->gray);
|
||||
gc[3] = WMColorGC(scrPtr->white);
|
||||
if (drawTitle) {
|
||||
tmp = XCreateRegion();
|
||||
rect.x = tx;
|
||||
rect.y = ty;
|
||||
rect.width = tw;
|
||||
rect.height = th;
|
||||
XUnionRectWithRegion(&rect, tmp, tmp);
|
||||
}
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = view->size.width;
|
||||
rect.height = view->size.height;
|
||||
XUnionRectWithRegion(&rect, region, region);
|
||||
if (drawTitle) {
|
||||
XSubtractRegion(region, tmp, region);
|
||||
XDestroyRegion(tmp);
|
||||
}
|
||||
gc[0] = WMColorGC(scrPtr->black);
|
||||
gc[1] = WMColorGC(scrPtr->darkGray);
|
||||
gc[2] = WMColorGC(scrPtr->gray);
|
||||
gc[3] = WMColorGC(scrPtr->white);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
XSetRegion(display, gc[i], region);
|
||||
}
|
||||
XDestroyRegion(region);
|
||||
for (i = 0; i < 4; i++) {
|
||||
XSetRegion(display, gc[i], region);
|
||||
}
|
||||
XDestroyRegion(region);
|
||||
|
||||
W_DrawReliefWithGC(scrPtr, view->window, 0, fy, view->size.width, fh,
|
||||
fPtr->flags.relief, gc[0], gc[1], gc[2], gc[3]);
|
||||
W_DrawReliefWithGC(scrPtr, view->window, 0, fy, view->size.width, fh,
|
||||
fPtr->flags.relief, gc[0], gc[1], gc[2], gc[3]);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
XSetClipMask(display, gc[i], None);
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
XSetClipMask(display, gc[i], None);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawTitle) {
|
||||
@@ -226,14 +226,14 @@ handleEvents(XEvent *event, void *data)
|
||||
CHECK_CLASS(data, WC_Frame);
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count == 0)
|
||||
paintFrame(fPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count == 0)
|
||||
paintFrame(fPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyFrame(fPtr);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
destroyFrame(fPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,13 +250,13 @@ WMCreateFrame(WMWidget *parent)
|
||||
|
||||
fPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!fPtr->view) {
|
||||
wfree(fPtr);
|
||||
return NULL;
|
||||
wfree(fPtr);
|
||||
return NULL;
|
||||
}
|
||||
fPtr->view->self = fPtr;
|
||||
|
||||
WMCreateEventHandler(fPtr->view, ExposureMask|StructureNotifyMask,
|
||||
handleEvents, fPtr);
|
||||
handleEvents, fPtr);
|
||||
|
||||
|
||||
fPtr->flags.relief = DEFAULT_RELIEF;
|
||||
@@ -272,7 +272,7 @@ static void
|
||||
destroyFrame(Frame *fPtr)
|
||||
{
|
||||
if (fPtr->caption)
|
||||
wfree(fPtr->caption);
|
||||
wfree(fPtr->caption);
|
||||
|
||||
wfree(fPtr);
|
||||
}
|
||||
|
||||
314
WINGs/widgets.c
314
WINGs/widgets.c
@@ -323,7 +323,7 @@ static int userWidgetCount=0;
|
||||
|
||||
static void
|
||||
renderPixmap(W_Screen *screen, Pixmap d, Pixmap mask, char **data,
|
||||
int width, int height)
|
||||
int width, int height)
|
||||
{
|
||||
int x, y;
|
||||
GC whiteGC = WMColorGC(screen->white);
|
||||
@@ -333,37 +333,37 @@ renderPixmap(W_Screen *screen, Pixmap d, Pixmap mask, char **data,
|
||||
|
||||
|
||||
if (mask)
|
||||
XSetForeground(screen->display, screen->monoGC, 0);
|
||||
XSetForeground(screen->display, screen->monoGC, 0);
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
for (x = 0; x < width; x++) {
|
||||
switch (data[y][x]) {
|
||||
case ' ':
|
||||
case 'w':
|
||||
XDrawPoint(screen->display, d, whiteGC, x, y);
|
||||
break;
|
||||
for (x = 0; x < width; x++) {
|
||||
switch (data[y][x]) {
|
||||
case ' ':
|
||||
case 'w':
|
||||
XDrawPoint(screen->display, d, whiteGC, x, y);
|
||||
break;
|
||||
|
||||
case '=':
|
||||
if (mask)
|
||||
XDrawPoint(screen->display, mask, screen->monoGC, x, y);
|
||||
case '=':
|
||||
if (mask)
|
||||
XDrawPoint(screen->display, mask, screen->monoGC, x, y);
|
||||
|
||||
case '.':
|
||||
case 'l':
|
||||
XDrawPoint(screen->display, d, lightGC, x, y);
|
||||
break;
|
||||
case '.':
|
||||
case 'l':
|
||||
XDrawPoint(screen->display, d, lightGC, x, y);
|
||||
break;
|
||||
|
||||
case '%':
|
||||
case 'd':
|
||||
XDrawPoint(screen->display, d, darkGC, x, y);
|
||||
break;
|
||||
case '%':
|
||||
case 'd':
|
||||
XDrawPoint(screen->display, d, darkGC, x, y);
|
||||
break;
|
||||
|
||||
case '#':
|
||||
case 'b':
|
||||
default:
|
||||
XDrawPoint(screen->display, d, blackGC, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case '#':
|
||||
case 'b':
|
||||
default:
|
||||
XDrawPoint(screen->display, d, blackGC, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,18 +375,18 @@ makePixmap(W_Screen *sPtr, char **data, int width, int height, int masked)
|
||||
Pixmap pixmap, mask = None;
|
||||
|
||||
pixmap = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height,
|
||||
sPtr->depth);
|
||||
sPtr->depth);
|
||||
|
||||
if (masked) {
|
||||
mask = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height, 1);
|
||||
XSetForeground(sPtr->display, sPtr->monoGC, 1);
|
||||
XFillRectangle(sPtr->display, mask, sPtr->monoGC, 0, 0, width, height);
|
||||
mask = XCreatePixmap(sPtr->display, W_DRAWABLE(sPtr), width, height, 1);
|
||||
XSetForeground(sPtr->display, sPtr->monoGC, 1);
|
||||
XFillRectangle(sPtr->display, mask, sPtr->monoGC, 0, 0, width, height);
|
||||
}
|
||||
|
||||
renderPixmap(sPtr, pixmap, mask, data, width, height);
|
||||
|
||||
return WMCreatePixmapFromXPixmaps(sPtr, pixmap, mask, width, height,
|
||||
sPtr->depth);
|
||||
sPtr->depth);
|
||||
}
|
||||
|
||||
|
||||
@@ -414,11 +414,11 @@ loadPixmaps(WMScreen *scr)
|
||||
|
||||
image = RLoadImage(scr->rcontext, T_WINGS_IMAGES_FILE, 0);
|
||||
if (!image)
|
||||
image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0);
|
||||
image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0);
|
||||
if (!image) {
|
||||
wwarning(_("WINGs: could not load widget images file: %s"),
|
||||
RMessageForError(RErrorCode));
|
||||
return False;
|
||||
wwarning(_("WINGs: could not load widget images file: %s"),
|
||||
RMessageForError(RErrorCode));
|
||||
return False;
|
||||
}
|
||||
/* home icon */
|
||||
/* make it have a gray background */
|
||||
@@ -507,14 +507,14 @@ loadPixmaps(WMScreen *scr)
|
||||
|
||||
#if 0
|
||||
scr->defaultObjectIcon =
|
||||
WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
|
||||
WMCreatePixmapFromFile(scr, T_DEFAULT_OBJECT_ICON_FILE);
|
||||
if (!scr->defaultObjectIcon) {
|
||||
scr->defaultObjectIcon =
|
||||
WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
|
||||
scr->defaultObjectIcon =
|
||||
WMCreatePixmapFromFile(scr, X_DEFAULT_OBJECT_ICON_FILE);
|
||||
}
|
||||
if (!scr->defaultObjectIcon) {
|
||||
wwarning("WINGs: could not load default icon file");
|
||||
return False;
|
||||
wwarning("WINGs: could not load default icon file");
|
||||
return False;
|
||||
}
|
||||
#endif
|
||||
return True;
|
||||
@@ -527,9 +527,9 @@ WMOpenScreen(const char *display)
|
||||
Display *dpy = XOpenDisplay(display);
|
||||
|
||||
if (!dpy) {
|
||||
wwarning("WINGs: could not open display %s",
|
||||
XDisplayName(display));
|
||||
return NULL;
|
||||
wwarning("WINGs: could not open display %s",
|
||||
XDisplayName(display));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return WMCreateSimpleApplicationScreen(dpy);
|
||||
@@ -555,7 +555,7 @@ WMScreen*
|
||||
WMCreateScreen(Display *display, int screen)
|
||||
{
|
||||
return WMCreateScreenWithRContext(display, screen,
|
||||
RCreateContext(display, screen, NULL));
|
||||
RCreateContext(display, screen, NULL));
|
||||
}
|
||||
|
||||
|
||||
@@ -567,42 +567,44 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
Pixmap stipple;
|
||||
static int initialized = 0;
|
||||
static char *atomNames[] = {
|
||||
"_GNUSTEP_WM_ATTR",
|
||||
"WM_DELETE_WINDOW",
|
||||
"WM_PROTOCOLS",
|
||||
"CLIPBOARD",
|
||||
"XdndAware",
|
||||
"XdndSelection",
|
||||
"XdndEnter",
|
||||
"XdndLeave",
|
||||
"XdndPosition",
|
||||
"XdndDrop",
|
||||
"XdndFinished",
|
||||
"XdndTypeList",
|
||||
"XdndActionCopy",
|
||||
"XdndActionMove",
|
||||
"XdndActionLink",
|
||||
"XdndActionAsk",
|
||||
"XdndActionPrivate",
|
||||
"XdndStatus",
|
||||
"_WINGS_DND_MOUSE_OFFSET",
|
||||
"WM_STATE"
|
||||
"_GNUSTEP_WM_ATTR",
|
||||
"WM_DELETE_WINDOW",
|
||||
"WM_PROTOCOLS",
|
||||
"CLIPBOARD",
|
||||
"XdndAware",
|
||||
"XdndSelection",
|
||||
"XdndEnter",
|
||||
"XdndLeave",
|
||||
"XdndPosition",
|
||||
"XdndDrop",
|
||||
"XdndFinished",
|
||||
"XdndTypeList",
|
||||
"XdndActionList",
|
||||
"XdndActionDescription",
|
||||
"XdndStatus",
|
||||
"XdndActionCopy",
|
||||
"XdndActionMove",
|
||||
"XdndActionLink",
|
||||
"XdndActionAsk",
|
||||
"XdndActionPrivate",
|
||||
"_WINGS_DND_MOUSE_OFFSET",
|
||||
"WM_STATE"
|
||||
};
|
||||
Atom atoms[sizeof(atomNames)/sizeof(char*)];
|
||||
int i;
|
||||
|
||||
if (!initialized) {
|
||||
|
||||
initialized = 1;
|
||||
initialized = 1;
|
||||
|
||||
W_ReadConfigurations();
|
||||
W_ReadConfigurations();
|
||||
|
||||
assert(W_ApplicationInitialized());
|
||||
assert(W_ApplicationInitialized());
|
||||
}
|
||||
|
||||
scrPtr = malloc(sizeof(W_Screen));
|
||||
if (!scrPtr)
|
||||
return NULL;
|
||||
return NULL;
|
||||
memset(scrPtr, 0, sizeof(W_Screen));
|
||||
|
||||
scrPtr->aflags.hasAppIcon = 1;
|
||||
@@ -671,38 +673,38 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
|
||||
scrPtr->ignoredModifierMask = 0;
|
||||
{
|
||||
int i;
|
||||
XModifierKeymap *modmap;
|
||||
KeyCode nlock, slock;
|
||||
static int mask_table[8] = {
|
||||
ShiftMask,LockMask,ControlMask,Mod1Mask,
|
||||
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||
};
|
||||
unsigned int numLockMask=0, scrollLockMask=0;
|
||||
int i;
|
||||
XModifierKeymap *modmap;
|
||||
KeyCode nlock, slock;
|
||||
static int mask_table[8] = {
|
||||
ShiftMask,LockMask,ControlMask,Mod1Mask,
|
||||
Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
|
||||
};
|
||||
unsigned int numLockMask=0, scrollLockMask=0;
|
||||
|
||||
nlock = XKeysymToKeycode(display, XK_Num_Lock);
|
||||
slock = XKeysymToKeycode(display, XK_Scroll_Lock);
|
||||
nlock = XKeysymToKeycode(display, XK_Num_Lock);
|
||||
slock = XKeysymToKeycode(display, XK_Scroll_Lock);
|
||||
|
||||
/*
|
||||
* Find out the masks for the NumLock and ScrollLock modifiers,
|
||||
* so that we can bind the grabs for when they are enabled too.
|
||||
*/
|
||||
modmap = XGetModifierMapping(display);
|
||||
/*
|
||||
* Find out the masks for the NumLock and ScrollLock modifiers,
|
||||
* so that we can bind the grabs for when they are enabled too.
|
||||
*/
|
||||
modmap = XGetModifierMapping(display);
|
||||
|
||||
if (modmap!=NULL && modmap->max_keypermod>0) {
|
||||
for (i=0; i<8*modmap->max_keypermod; i++) {
|
||||
if (modmap->modifiermap[i]==nlock && nlock!=0)
|
||||
numLockMask = mask_table[i/modmap->max_keypermod];
|
||||
else if (modmap->modifiermap[i]==slock && slock!=0)
|
||||
scrollLockMask = mask_table[i/modmap->max_keypermod];
|
||||
}
|
||||
}
|
||||
if (modmap!=NULL && modmap->max_keypermod>0) {
|
||||
for (i=0; i<8*modmap->max_keypermod; i++) {
|
||||
if (modmap->modifiermap[i]==nlock && nlock!=0)
|
||||
numLockMask = mask_table[i/modmap->max_keypermod];
|
||||
else if (modmap->modifiermap[i]==slock && slock!=0)
|
||||
scrollLockMask = mask_table[i/modmap->max_keypermod];
|
||||
}
|
||||
}
|
||||
|
||||
if (modmap)
|
||||
XFreeModifiermap(modmap);
|
||||
if (modmap)
|
||||
XFreeModifiermap(modmap);
|
||||
|
||||
|
||||
scrPtr->ignoredModifierMask = numLockMask|scrollLockMask|LockMask;
|
||||
scrPtr->ignoredModifierMask = numLockMask|scrollLockMask|LockMask;
|
||||
}
|
||||
|
||||
/* initially allocate some colors */
|
||||
@@ -717,31 +719,31 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
gcv.foreground = W_PIXEL(scrPtr->white);
|
||||
if (gcv.foreground == 0) gcv.foreground = 1;
|
||||
scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|
||||
|GCGraphicsExposures|GCForeground, &gcv);
|
||||
|GCGraphicsExposures|GCForeground, &gcv);
|
||||
|
||||
gcv.function = GXxor;
|
||||
gcv.foreground = W_PIXEL(scrPtr->gray);
|
||||
gcv.subwindow_mode = IncludeInferiors;
|
||||
scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|
||||
|GCGraphicsExposures|GCForeground
|
||||
|GCSubwindowMode, &gcv);
|
||||
|GCGraphicsExposures|GCForeground
|
||||
|GCSubwindowMode, &gcv);
|
||||
|
||||
gcv.function = GXcopy;
|
||||
scrPtr->copyGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|
||||
scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|
||||
stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr),
|
||||
STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
|
||||
STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
|
||||
gcv.foreground = W_PIXEL(scrPtr->darkGray);
|
||||
gcv.background = W_PIXEL(scrPtr->gray);
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
|
||||
GCForeground|GCBackground|GCStipple
|
||||
|GCFillStyle|GCGraphicsExposures, &gcv);
|
||||
GCForeground|GCBackground|GCStipple
|
||||
|GCFillStyle|GCGraphicsExposures, &gcv);
|
||||
|
||||
scrPtr->drawStringGC = XCreateGC(display, W_DRAWABLE(scrPtr),
|
||||
GCGraphicsExposures, &gcv);
|
||||
@@ -760,66 +762,66 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
scrPtr->antialiasedText = WINGsConfiguration.antialiasedText;
|
||||
|
||||
scrPtr->normalFont = WMSystemFontOfSize(scrPtr,
|
||||
WINGsConfiguration.defaultFontSize);
|
||||
WINGsConfiguration.defaultFontSize);
|
||||
|
||||
scrPtr->boldFont = WMBoldSystemFontOfSize(scrPtr,
|
||||
WINGsConfiguration.defaultFontSize);
|
||||
WINGsConfiguration.defaultFontSize);
|
||||
|
||||
if (!scrPtr->boldFont)
|
||||
scrPtr->boldFont = scrPtr->normalFont;
|
||||
scrPtr->boldFont = scrPtr->normalFont;
|
||||
|
||||
if (!scrPtr->normalFont) {
|
||||
wwarning(_("could not load any fonts. Make sure your font installation"
|
||||
wwarning(_("could not load any fonts. Make sure your font installation"
|
||||
" and locale settings are correct."));
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scrPtr->checkButtonImageOn = makePixmap(scrPtr, CHECK_BUTTON_ON,
|
||||
CHECK_BUTTON_ON_WIDTH,
|
||||
CHECK_BUTTON_ON_HEIGHT, False);
|
||||
CHECK_BUTTON_ON_WIDTH,
|
||||
CHECK_BUTTON_ON_HEIGHT, False);
|
||||
|
||||
scrPtr->checkButtonImageOff = makePixmap(scrPtr, CHECK_BUTTON_OFF,
|
||||
CHECK_BUTTON_OFF_WIDTH,
|
||||
CHECK_BUTTON_OFF_HEIGHT, False);
|
||||
|
||||
scrPtr->radioButtonImageOn = makePixmap(scrPtr, RADIO_BUTTON_ON,
|
||||
RADIO_BUTTON_ON_WIDTH,
|
||||
RADIO_BUTTON_ON_HEIGHT, False);
|
||||
RADIO_BUTTON_ON_WIDTH,
|
||||
RADIO_BUTTON_ON_HEIGHT, False);
|
||||
|
||||
scrPtr->radioButtonImageOff = makePixmap(scrPtr, RADIO_BUTTON_OFF,
|
||||
RADIO_BUTTON_OFF_WIDTH,
|
||||
RADIO_BUTTON_OFF_HEIGHT, False);
|
||||
|
||||
scrPtr->buttonArrow = makePixmap(scrPtr, BUTTON_ARROW,
|
||||
BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
|
||||
False);
|
||||
BUTTON_ARROW_WIDTH, BUTTON_ARROW_HEIGHT,
|
||||
False);
|
||||
|
||||
scrPtr->pushedButtonArrow = makePixmap(scrPtr, BUTTON_ARROW2,
|
||||
BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
|
||||
False);
|
||||
BUTTON_ARROW2_WIDTH, BUTTON_ARROW2_HEIGHT,
|
||||
False);
|
||||
|
||||
|
||||
scrPtr->scrollerDimple = makePixmap(scrPtr, SCROLLER_DIMPLE,
|
||||
SCROLLER_DIMPLE_WIDTH,
|
||||
SCROLLER_DIMPLE_HEIGHT, False);
|
||||
SCROLLER_DIMPLE_WIDTH,
|
||||
SCROLLER_DIMPLE_HEIGHT, False);
|
||||
|
||||
|
||||
scrPtr->upArrow = makePixmap(scrPtr, SCROLLER_ARROW_UP,
|
||||
SCROLLER_ARROW_UP_WIDTH,
|
||||
SCROLLER_ARROW_UP_HEIGHT, True);
|
||||
SCROLLER_ARROW_UP_WIDTH,
|
||||
SCROLLER_ARROW_UP_HEIGHT, True);
|
||||
|
||||
scrPtr->downArrow = makePixmap(scrPtr, SCROLLER_ARROW_DOWN,
|
||||
SCROLLER_ARROW_DOWN_WIDTH,
|
||||
SCROLLER_ARROW_DOWN_HEIGHT, True);
|
||||
SCROLLER_ARROW_DOWN_WIDTH,
|
||||
SCROLLER_ARROW_DOWN_HEIGHT, True);
|
||||
|
||||
scrPtr->leftArrow = makePixmap(scrPtr, SCROLLER_ARROW_LEFT,
|
||||
SCROLLER_ARROW_LEFT_WIDTH,
|
||||
SCROLLER_ARROW_LEFT_HEIGHT, True);
|
||||
SCROLLER_ARROW_LEFT_WIDTH,
|
||||
SCROLLER_ARROW_LEFT_HEIGHT, True);
|
||||
|
||||
scrPtr->rightArrow = makePixmap(scrPtr, SCROLLER_ARROW_RIGHT,
|
||||
SCROLLER_ARROW_RIGHT_WIDTH,
|
||||
SCROLLER_ARROW_RIGHT_HEIGHT, True);
|
||||
SCROLLER_ARROW_RIGHT_WIDTH,
|
||||
SCROLLER_ARROW_RIGHT_HEIGHT, True);
|
||||
|
||||
scrPtr->hiUpArrow = makePixmap(scrPtr, HI_SCROLLER_ARROW_UP,
|
||||
SCROLLER_ARROW_UP_WIDTH,
|
||||
@@ -838,16 +840,16 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
SCROLLER_ARROW_RIGHT_HEIGHT, True);
|
||||
|
||||
scrPtr->popUpIndicator = makePixmap(scrPtr, POPUP_INDICATOR,
|
||||
POPUP_INDICATOR_WIDTH,
|
||||
POPUP_INDICATOR_HEIGHT, True);
|
||||
POPUP_INDICATOR_WIDTH,
|
||||
POPUP_INDICATOR_HEIGHT, True);
|
||||
|
||||
scrPtr->pullDownIndicator = makePixmap(scrPtr, PULLDOWN_INDICATOR,
|
||||
PULLDOWN_INDICATOR_WIDTH,
|
||||
PULLDOWN_INDICATOR_HEIGHT, True);
|
||||
PULLDOWN_INDICATOR_WIDTH,
|
||||
PULLDOWN_INDICATOR_HEIGHT, True);
|
||||
|
||||
scrPtr->checkMark = makePixmap(scrPtr, CHECK_MARK,
|
||||
CHECK_MARK_WIDTH,
|
||||
CHECK_MARK_HEIGHT, True);
|
||||
CHECK_MARK_WIDTH,
|
||||
CHECK_MARK_HEIGHT, True);
|
||||
|
||||
loadPixmaps(scrPtr);
|
||||
|
||||
@@ -856,21 +858,21 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
scrPtr->textCursor = XCreateFontCursor(display, XC_xterm);
|
||||
|
||||
{
|
||||
XColor bla;
|
||||
Pixmap blank;
|
||||
XColor bla;
|
||||
Pixmap blank;
|
||||
|
||||
blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
|
||||
XSetForeground(display, scrPtr->monoGC, 0);
|
||||
XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
|
||||
blank = XCreatePixmap(display, scrPtr->stipple, 1, 1, 1);
|
||||
XSetForeground(display, scrPtr->monoGC, 0);
|
||||
XFillRectangle(display, blank, scrPtr->monoGC, 0, 0, 1, 1);
|
||||
|
||||
scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
|
||||
&bla, &bla, 0, 0);
|
||||
XFreePixmap(display, blank);
|
||||
scrPtr->invisibleCursor = XCreatePixmapCursor(display, blank, blank,
|
||||
&bla, &bla, 0, 0);
|
||||
XFreePixmap(display, blank);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XINTERNATOMS
|
||||
XInternAtoms(display, atomNames, sizeof(atomNames)/sizeof(char*), False,
|
||||
atoms);
|
||||
atoms);
|
||||
#else
|
||||
for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) {
|
||||
atoms[i] = XInternAtom(display, atomNames[i], False);
|
||||
@@ -894,6 +896,8 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context)
|
||||
scrPtr->xdndDropAtom = atoms[i++];
|
||||
scrPtr->xdndFinishedAtom = atoms[i++];
|
||||
scrPtr->xdndTypeListAtom = atoms[i++];
|
||||
scrPtr->xdndActionListAtom = atoms[i++];
|
||||
scrPtr->xdndActionDescriptionAtom = atoms[i++];
|
||||
scrPtr->xdndStatusAtom = atoms[i++];
|
||||
|
||||
scrPtr->xdndActionCopy = atoms[i++];
|
||||
@@ -996,10 +1000,10 @@ makeChildrenAutomap(W_View *view, int flag)
|
||||
view = view->childrenList;
|
||||
|
||||
while (view) {
|
||||
view->flags.mapWhenRealized = flag;
|
||||
makeChildrenAutomap(view, flag);
|
||||
view->flags.mapWhenRealized = flag;
|
||||
makeChildrenAutomap(view, flag);
|
||||
|
||||
view = view->nextSister;
|
||||
view = view->nextSister;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1010,9 +1014,9 @@ WMMapSubwidgets(WMWidget *w)
|
||||
/* make sure that subwidgets created after the parent was realized
|
||||
* are mapped too */
|
||||
if (!W_VIEW(w)->flags.realized) {
|
||||
makeChildrenAutomap(W_VIEW(w), True);
|
||||
makeChildrenAutomap(W_VIEW(w), True);
|
||||
} else {
|
||||
W_MapSubviews(W_VIEW(w));
|
||||
W_MapSubviews(W_VIEW(w));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,9 +1025,9 @@ void
|
||||
WMUnmapSubwidgets(WMWidget *w)
|
||||
{
|
||||
if (!W_VIEW(w)->flags.realized) {
|
||||
makeChildrenAutomap(W_VIEW(w), False);
|
||||
makeChildrenAutomap(W_VIEW(w), False);
|
||||
} else {
|
||||
W_UnmapSubviews(W_VIEW(w));
|
||||
W_UnmapSubviews(W_VIEW(w));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,7 +1052,7 @@ WMSetWidgetBackgroundColor(WMWidget *w, WMColor *color)
|
||||
{
|
||||
W_SetViewBackgroundColor(W_VIEW(w), color);
|
||||
if (W_VIEW(w)->flags.mapped)
|
||||
WMRedisplayWidget(w);
|
||||
WMRedisplayWidget(w);
|
||||
}
|
||||
|
||||
|
||||
@@ -1062,14 +1066,14 @@ WMGetWidgetBackgroundColor(WMWidget *w)
|
||||
void
|
||||
WMRaiseWidget(WMWidget *w)
|
||||
{
|
||||
W_RaiseView(W_VIEW(w));
|
||||
W_RaiseView(W_VIEW(w));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMLowerWidget(WMWidget *w)
|
||||
{
|
||||
W_LowerView(W_VIEW(w));
|
||||
W_LowerView(W_VIEW(w));
|
||||
}
|
||||
|
||||
|
||||
@@ -1141,8 +1145,8 @@ WMScreenMainLoop(WMScreen *scr)
|
||||
XEvent event;
|
||||
|
||||
while (1) {
|
||||
WMNextEvent(scr->display, &event);
|
||||
WMHandleEvent(&event);
|
||||
WMNextEvent(scr->display, &event);
|
||||
WMHandleEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1166,10 +1170,10 @@ WMRunModalLoop(WMScreen *scr, WMView *view)
|
||||
|
||||
scr->modalLoop = 1;
|
||||
while (scr->modalLoop) {
|
||||
XEvent event;
|
||||
XEvent event;
|
||||
|
||||
WMNextEvent(scr->display, &event);
|
||||
WMHandleEvent(&event);
|
||||
WMNextEvent(scr->display, &event);
|
||||
WMHandleEvent(&event);
|
||||
}
|
||||
|
||||
scr->modalView = oldModalView;
|
||||
|
||||
250
WINGs/wtext.c
250
WINGs/wtext.c
@@ -166,6 +166,9 @@ typedef struct W_Text {
|
||||
unsigned int first:1; /* for plain text parsing, newline? */
|
||||
/* unsigned int RESERVED:1; */
|
||||
} flags;
|
||||
|
||||
WMArray *xdndSourceTypes;
|
||||
WMArray *xdndDestinationTypes;
|
||||
} Text;
|
||||
|
||||
|
||||
@@ -2533,36 +2536,24 @@ handleActionEvents(XEvent *event, void *data)
|
||||
break;
|
||||
|
||||
if ((event->xmotion.state & Button1Mask)) {
|
||||
TextBlock *tb = tPtr->currentTextBlock;
|
||||
|
||||
if(tb && tPtr->flags.isOverGraphic &&
|
||||
tb->graphic && !tb->object) {
|
||||
WMSize offs;
|
||||
WMPixmap *pixmap = tb->d.pixmap;
|
||||
char *types[2] = {"application/X-image", NULL};
|
||||
if (WMIsDraggingFromView(tPtr->view)) {
|
||||
WMDragImageFromView(tPtr->view, event);
|
||||
break;
|
||||
}
|
||||
|
||||
offs.width = 2;
|
||||
offs.height = 2;
|
||||
|
||||
WMDragImageFromView(tPtr->view, pixmap, types,
|
||||
wmkpoint(event->xmotion.x_root, event->xmotion.y_root),
|
||||
offs, event, True);
|
||||
|
||||
|
||||
} else {
|
||||
if (!tPtr->flags.ownsSelection) {
|
||||
WMCreateSelectionHandler(tPtr->view,
|
||||
XA_PRIMARY, event->xbutton.time,
|
||||
&selectionHandler, NULL);
|
||||
tPtr->flags.ownsSelection = True;
|
||||
}
|
||||
if (!tPtr->flags.ownsSelection) {
|
||||
WMCreateSelectionHandler(tPtr->view,
|
||||
XA_PRIMARY, event->xbutton.time,
|
||||
&selectionHandler, NULL);
|
||||
tPtr->flags.ownsSelection = True;
|
||||
}
|
||||
selectRegion(tPtr, event->xmotion.x, event->xmotion.y);
|
||||
break;
|
||||
}
|
||||
|
||||
mouseOverObject(tPtr, event->xmotion.x, event->xmotion.y);
|
||||
break;
|
||||
break;
|
||||
|
||||
|
||||
case ButtonPress:
|
||||
@@ -2586,9 +2577,9 @@ handleActionEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
if (event->xbutton.button == Button1) {
|
||||
TextBlock *tb = tPtr->currentTextBlock;
|
||||
|
||||
if(WMIsDoubleClick(event)) {
|
||||
TextBlock *tb = tPtr->currentTextBlock;
|
||||
|
||||
tPtr->lastClickTime = event->xbutton.time;
|
||||
if(tb && tb->graphic && !tb->object) {
|
||||
@@ -2605,8 +2596,8 @@ handleActionEvents(XEvent *event, void *data)
|
||||
autoSelectText(tPtr, 2);
|
||||
}
|
||||
break;
|
||||
} else if(event->xbutton.time - tPtr->lastClickTime
|
||||
< WINGsConfiguration.doubleClickDelay) {
|
||||
} else if (event->xbutton.time - tPtr->lastClickTime
|
||||
< WINGsConfiguration.doubleClickDelay) {
|
||||
tPtr->lastClickTime = event->xbutton.time;
|
||||
autoSelectText(tPtr, 3);
|
||||
break;
|
||||
@@ -2614,7 +2605,13 @@ handleActionEvents(XEvent *event, void *data)
|
||||
|
||||
if (!tPtr->flags.focused) {
|
||||
WMSetFocusToWidget(tPtr);
|
||||
tPtr->flags.focused = True;
|
||||
tPtr->flags.focused = True;
|
||||
} else if (tb && tPtr->flags.isOverGraphic &&
|
||||
tb->graphic && !tb->object && tb->d.pixmap) {
|
||||
|
||||
WMSetViewDragImage(tPtr->view, tb->d.pixmap);
|
||||
WMDragImageFromView(tPtr->view, event);
|
||||
break;
|
||||
}
|
||||
|
||||
tPtr->lastClickTime = event->xbutton.time;
|
||||
@@ -2684,7 +2681,10 @@ handleActionEvents(XEvent *event, void *data)
|
||||
|
||||
if (tPtr->flags.waitingForSelection)
|
||||
break;
|
||||
}
|
||||
|
||||
if (WMIsDraggingFromView(tPtr->view))
|
||||
WMDragImageFromView(tPtr->view, event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2763,6 +2763,9 @@ handleEvents(XEvent *event, void *data)
|
||||
WMDeleteSelectionHandler(tPtr->view, XA_PRIMARY, CurrentTime);
|
||||
WMRemoveNotificationObserver(tPtr);
|
||||
|
||||
WMFreeArray(tPtr->xdndSourceTypes);
|
||||
WMFreeArray(tPtr->xdndDestinationTypes);
|
||||
|
||||
wfree(tPtr);
|
||||
|
||||
break;
|
||||
@@ -2831,12 +2834,28 @@ rulerReleaseCallBack(WMWidget *w, void *self)
|
||||
return;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
draggingSourceOperation(WMView *self, Bool local)
|
||||
|
||||
static WMArray*
|
||||
dropDataTypes(WMView *self)
|
||||
{
|
||||
return ((Text*)self->self)->xdndSourceTypes;
|
||||
}
|
||||
|
||||
|
||||
static WMDragOperationType
|
||||
wantedDropOperation(WMView *self)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
acceptDropOperation(WMView *self, WMDragOperationType allowedOperation)
|
||||
{
|
||||
return (allowedOperation == WDOperationCopy);
|
||||
}
|
||||
|
||||
|
||||
static WMData*
|
||||
fetchDragData(WMView *self, char *type)
|
||||
{
|
||||
@@ -2844,137 +2863,83 @@ fetchDragData(WMView *self, char *type)
|
||||
char *desc;
|
||||
WMData *data;
|
||||
|
||||
if (!tb)
|
||||
return NULL;
|
||||
if (strcmp(type, "text/plain")) {
|
||||
if (!tb)
|
||||
return NULL;
|
||||
|
||||
printf("type is [%s]\n", type);
|
||||
desc = wmalloc(tb->used+1);
|
||||
memcpy(desc, tb->text, tb->used);
|
||||
desc[tb->used] = 0;
|
||||
data = WMCreateDataWithBytes(desc, strlen(desc)+1);
|
||||
desc = wmalloc(tb->used+1);
|
||||
memcpy(desc, tb->text, tb->used);
|
||||
desc[tb->used] = 0;
|
||||
data = WMCreateDataWithBytes(desc, strlen(desc)+1);
|
||||
|
||||
wfree(desc);
|
||||
wfree(desc);
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static WMDragSourceProcs _DragSourceProcs = {
|
||||
draggingSourceOperation,
|
||||
dropDataTypes,
|
||||
wantedDropOperation,
|
||||
NULL,
|
||||
acceptDropOperation,
|
||||
NULL,
|
||||
NULL,
|
||||
fetchDragData
|
||||
};
|
||||
|
||||
|
||||
static unsigned
|
||||
draggingEntered(WMView *self, WMDraggingInfo *info)
|
||||
static WMArray*
|
||||
requiredDataTypes(WMView *self, WMDragOperationType request, WMArray *sourceDataTypes)
|
||||
{
|
||||
printf("draggingEntered\n");
|
||||
return WDOperationCopy;
|
||||
return ((Text*)self->self)->xdndDestinationTypes;
|
||||
}
|
||||
|
||||
|
||||
static unsigned
|
||||
draggingUpdated(WMView *self, WMDraggingInfo *info)
|
||||
static WMDragOperationType
|
||||
allowedOperation(WMView *self, WMDragOperationType request, WMArray *sourceDataTypes)
|
||||
{
|
||||
return WDOperationCopy;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draggingExited(WMView *self, WMDraggingInfo *info)
|
||||
performDragOperation(WMView *self, WMArray *dropData, WMArray *operations,
|
||||
WMPoint* dropLocation)
|
||||
{
|
||||
printf("draggingExited\n");
|
||||
}
|
||||
|
||||
static Bool
|
||||
prepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
printf("prepareForDragOperation\n");
|
||||
return True;
|
||||
}
|
||||
|
||||
|
||||
char *badbadbad;
|
||||
|
||||
static void
|
||||
receivedData(WMView *view, Atom selection, Atom target, Time timestamp,
|
||||
void *cdata, WMData *data)
|
||||
{
|
||||
badbadbad = wstrdup((char *)WMDataBytes(data));
|
||||
}
|
||||
|
||||
|
||||
/* when it's done in WINGs, remove this */
|
||||
|
||||
Bool
|
||||
requestDroppedData(WMView *view, WMDraggingInfo *info, char *type)
|
||||
{
|
||||
WMScreen *scr = W_VIEW_SCREEN(view);
|
||||
|
||||
if (!WMRequestSelection(scr->dragInfo.destView,
|
||||
scr->xdndSelectionAtom,
|
||||
XInternAtom(scr->display, type, False),
|
||||
scr->dragInfo.timestamp,
|
||||
receivedData, &scr->dragInfo)) {
|
||||
wwarning("could not request data for dropped data");
|
||||
}
|
||||
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.message_type = scr->xdndFinishedAtom;
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.window = info->destinationWindow;
|
||||
ev.xclient.data.l[0] = 0;
|
||||
ev.xclient.data.l[1] = 0;
|
||||
ev.xclient.data.l[2] = 0;
|
||||
ev.xclient.data.l[3] = 0;
|
||||
ev.xclient.data.l[4] = 0;
|
||||
|
||||
XSendEvent(scr->display, info->sourceWindow, False, 0, &ev);
|
||||
XFlush(scr->display);
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
static Bool
|
||||
performDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
WMColor *color;
|
||||
WMText *tPtr = (WMText *)self->self;
|
||||
WMData* data;
|
||||
char* colorName;
|
||||
WMColor *color;
|
||||
|
||||
if (!tPtr)
|
||||
return True;
|
||||
if (tPtr) {
|
||||
|
||||
requestDroppedData(tPtr->view, info, "application/X-color");
|
||||
color = WMCreateNamedColor(W_VIEW_SCREEN(self), badbadbad, True);
|
||||
if(color) {
|
||||
WMSetTextSelectionColor(tPtr, color);
|
||||
WMReleaseColor(color);
|
||||
/* only one required type, implies only one drop data */
|
||||
|
||||
/* get application/X-color if any */
|
||||
data = (WMData*)WMPopFromArray(dropData);
|
||||
if (data != NULL) {
|
||||
colorName = (char*)WMDataBytes(data);
|
||||
color = WMCreateNamedColor(W_VIEW_SCREEN(self), colorName, True);
|
||||
|
||||
if(color) {
|
||||
WMSetTextSelectionColor(tPtr, color);
|
||||
WMReleaseColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
static void
|
||||
concludeDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
printf("concludeDragOperation\n");
|
||||
}
|
||||
|
||||
|
||||
static WMDragDestinationProcs _DragDestinationProcs = {
|
||||
draggingEntered,
|
||||
draggingUpdated,
|
||||
draggingExited,
|
||||
prepareForDragOperation,
|
||||
NULL,
|
||||
requiredDataTypes,
|
||||
allowedOperation,
|
||||
NULL,
|
||||
performDragOperation,
|
||||
concludeDragOperation
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -3106,7 +3071,27 @@ getStreamObjects(WMText *tPtr, int sel)
|
||||
}
|
||||
|
||||
|
||||
WMText *
|
||||
#define XDND_TEXT_DATA_TYPE "text/plain"
|
||||
#define XDND_COLOR_DATA_TYPE "application/X-color"
|
||||
static WMArray*
|
||||
getXdndSourceTypeArray()
|
||||
{
|
||||
WMArray *types = WMCreateArray(1);
|
||||
WMAddToArray(types, XDND_TEXT_DATA_TYPE);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
static WMArray*
|
||||
getXdndDestinationTypeArray()
|
||||
{
|
||||
WMArray *types = WMCreateArray(1);
|
||||
WMAddToArray(types, XDND_COLOR_DATA_TYPE);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
WMText*
|
||||
WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer)
|
||||
{
|
||||
Text *tPtr;
|
||||
@@ -3179,7 +3164,9 @@ WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer
|
||||
|
||||
|
||||
{
|
||||
char *types[3] = {"application/X-color", "application/X-image", NULL};
|
||||
WMArray *types = WMCreateArray(2);
|
||||
WMAddToArray(types, "application/X-color");
|
||||
WMAddToArray(types, "application/X-image");
|
||||
WMRegisterViewForDraggedTypes(tPtr->view, types);
|
||||
}
|
||||
|
||||
@@ -3242,6 +3229,9 @@ WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser, WMAction *writer
|
||||
tPtr->flags.alignment = WALeft;
|
||||
tPtr->flags.first = True;
|
||||
|
||||
tPtr->xdndSourceTypes = getXdndSourceTypeArray();
|
||||
tPtr->xdndDestinationTypes = getXdndDestinationTypeArray();
|
||||
|
||||
return tPtr;
|
||||
}
|
||||
|
||||
|
||||
347
WINGs/wview.c
347
WINGs/wview.c
@@ -14,10 +14,10 @@ char *WMViewRealizedNotification = "WMViewRealizedNotification";
|
||||
|
||||
|
||||
#define EVENT_MASK \
|
||||
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask| \
|
||||
EnterWindowMask|LeaveWindowMask|PointerMotionMask|ExposureMask| \
|
||||
VisibilityChangeMask|FocusChangeMask|PropertyChangeMask|\
|
||||
SubstructureNotifyMask|SubstructureRedirectMask
|
||||
KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask| \
|
||||
EnterWindowMask|LeaveWindowMask|PointerMotionMask|ExposureMask| \
|
||||
VisibilityChangeMask|FocusChangeMask|PropertyChangeMask|\
|
||||
SubstructureNotifyMask|SubstructureRedirectMask
|
||||
|
||||
|
||||
static XSetWindowAttributes defAtts= {
|
||||
@@ -26,21 +26,21 @@ static XSetWindowAttributes defAtts= {
|
||||
CopyFromParent, /* border_pixmap */
|
||||
0, /* border_pixel */
|
||||
ForgetGravity, /* bit_gravity */
|
||||
ForgetGravity, /* win_gravity */
|
||||
ForgetGravity, /* win_gravity */
|
||||
NotUseful, /* backing_store */
|
||||
(unsigned) ~0, /* backing_planes */
|
||||
0, /* backing_pixel */
|
||||
False, /* save_under */
|
||||
EVENT_MASK, /* event_mask */
|
||||
EVENT_MASK, /* event_mask */
|
||||
0, /* do_not_propagate_mask */
|
||||
False, /* override_redirect */
|
||||
None, /* colormap */
|
||||
None, /* colormap */
|
||||
None /* cursor */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static XContext ViewContext=0; /* context for views */
|
||||
static XContext ViewContext=0; /* context for views */
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ W_GetViewForXWindow(Display *display, Window window)
|
||||
W_View *view;
|
||||
|
||||
if (XFindContext(display, window, ViewContext, (XPointer*)&view)==0) {
|
||||
return view;
|
||||
return view;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -63,20 +63,20 @@ unparentView(W_View *view)
|
||||
{
|
||||
/* remove from parent's children list */
|
||||
if (view->parent!=NULL) {
|
||||
W_View *ptr;
|
||||
W_View *ptr;
|
||||
|
||||
ptr = view->parent->childrenList;
|
||||
if (ptr == view) {
|
||||
view->parent->childrenList = view->nextSister;
|
||||
} else {
|
||||
while (ptr!=NULL) {
|
||||
if (ptr->nextSister == view) {
|
||||
ptr->nextSister = view->nextSister;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->nextSister;
|
||||
}
|
||||
}
|
||||
ptr = view->parent->childrenList;
|
||||
if (ptr == view) {
|
||||
view->parent->childrenList = view->nextSister;
|
||||
} else {
|
||||
while (ptr!=NULL) {
|
||||
if (ptr->nextSister == view) {
|
||||
ptr->nextSister = view->nextSister;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->nextSister;
|
||||
}
|
||||
}
|
||||
}
|
||||
view->parent = NULL;
|
||||
}
|
||||
@@ -89,14 +89,14 @@ adoptChildView(W_View *view, W_View *child)
|
||||
|
||||
/* add to end of children list of parent */
|
||||
if (view->childrenList == NULL) {
|
||||
view->childrenList = child;
|
||||
view->childrenList = child;
|
||||
} else {
|
||||
W_View *ptr;
|
||||
W_View *ptr;
|
||||
|
||||
ptr = view->childrenList;
|
||||
while (ptr->nextSister!=NULL)
|
||||
ptr = ptr->nextSister;
|
||||
ptr->nextSister = child;
|
||||
ptr = view->childrenList;
|
||||
while (ptr->nextSister!=NULL)
|
||||
ptr = ptr->nextSister;
|
||||
ptr->nextSister = child;
|
||||
}
|
||||
child->parent = view;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ createView(W_Screen *screen, W_View *parent)
|
||||
W_View *view;
|
||||
|
||||
if (ViewContext==0)
|
||||
ViewContext = XUniqueContext();
|
||||
ViewContext = XUniqueContext();
|
||||
|
||||
view = wmalloc(sizeof(W_View));
|
||||
memset(view, 0, sizeof(W_View));
|
||||
@@ -116,18 +116,18 @@ createView(W_Screen *screen, W_View *parent)
|
||||
view->screen = screen;
|
||||
|
||||
if (parent!=NULL) {
|
||||
/* attributes are not valid for root window */
|
||||
view->attribFlags = CWEventMask|CWBitGravity;
|
||||
view->attribs = defAtts;
|
||||
/* attributes are not valid for root window */
|
||||
view->attribFlags = CWEventMask|CWBitGravity;
|
||||
view->attribs = defAtts;
|
||||
|
||||
view->attribFlags |= CWBackPixel|CWColormap|CWBorderPixel;
|
||||
view->attribs.background_pixel = W_PIXEL(screen->gray);
|
||||
view->attribs.border_pixel = W_PIXEL(screen->black);
|
||||
view->attribs.colormap = screen->colormap;
|
||||
view->attribFlags |= CWBackPixel|CWColormap|CWBorderPixel;
|
||||
view->attribs.background_pixel = W_PIXEL(screen->gray);
|
||||
view->attribs.border_pixel = W_PIXEL(screen->black);
|
||||
view->attribs.colormap = screen->colormap;
|
||||
|
||||
view->backColor = WMRetainColor(screen->gray);
|
||||
view->backColor = WMRetainColor(screen->gray);
|
||||
|
||||
adoptChildView(parent, view);
|
||||
adoptChildView(parent, view);
|
||||
}
|
||||
|
||||
view->refCount = 1;
|
||||
@@ -160,9 +160,9 @@ W_CreateRootView(W_Screen *screen)
|
||||
view->flags.root = 1;
|
||||
|
||||
view->size.width =
|
||||
WidthOfScreen(ScreenOfDisplay(screen->display, screen->screen));
|
||||
WidthOfScreen(ScreenOfDisplay(screen->display, screen->screen));
|
||||
view->size.height =
|
||||
HeightOfScreen(ScreenOfDisplay(screen->display, screen->screen));
|
||||
HeightOfScreen(ScreenOfDisplay(screen->display, screen->screen));
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ W_CreateTopView(W_Screen *screen)
|
||||
|
||||
view = createView(screen, screen->rootView);
|
||||
if (!view)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
view->flags.topLevel = 1;
|
||||
view->attribs.event_mask |= StructureNotifyMask;
|
||||
@@ -191,7 +191,7 @@ W_CreateUnmanagedTopView(W_Screen *screen)
|
||||
|
||||
view = createView(screen, screen->rootView);
|
||||
if (!view)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
view->flags.topLevel = 1;
|
||||
view->attribs.event_mask |= StructureNotifyMask;
|
||||
@@ -215,36 +215,36 @@ W_RealizeView(W_View *view)
|
||||
|
||||
|
||||
if (view->parent && !view->parent->flags.realized) {
|
||||
wwarning("trying to realize widget of unrealized parent");
|
||||
return;
|
||||
wwarning("trying to realize widget of unrealized parent");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!view->flags.realized) {
|
||||
parentWID = view->parent->window;
|
||||
view->window = XCreateWindow(dpy, parentWID, view->pos.x, view->pos.y,
|
||||
view->size.width, view->size.height, 0,
|
||||
view->screen->depth, InputOutput,
|
||||
view->screen->visual, view->attribFlags,
|
||||
&view->attribs);
|
||||
parentWID = view->parent->window;
|
||||
view->window = XCreateWindow(dpy, parentWID, view->pos.x, view->pos.y,
|
||||
view->size.width, view->size.height, 0,
|
||||
view->screen->depth, InputOutput,
|
||||
view->screen->visual, view->attribFlags,
|
||||
&view->attribs);
|
||||
|
||||
XSaveContext(dpy, view->window, ViewContext, (XPointer)view);
|
||||
XSaveContext(dpy, view->window, ViewContext, (XPointer)view);
|
||||
|
||||
view->flags.realized = 1;
|
||||
view->flags.realized = 1;
|
||||
|
||||
if (view->flags.mapWhenRealized) {
|
||||
W_MapView(view);
|
||||
view->flags.mapWhenRealized = 0;
|
||||
}
|
||||
if (view->flags.mapWhenRealized) {
|
||||
W_MapView(view);
|
||||
view->flags.mapWhenRealized = 0;
|
||||
}
|
||||
|
||||
WMPostNotificationName(WMViewRealizedNotification, view, NULL);
|
||||
WMPostNotificationName(WMViewRealizedNotification, view, NULL);
|
||||
}
|
||||
|
||||
/* realize children */
|
||||
ptr = view->childrenList;
|
||||
while (ptr!=NULL) {
|
||||
W_RealizeView(ptr);
|
||||
W_RealizeView(ptr);
|
||||
|
||||
ptr = ptr->nextSister;
|
||||
ptr = ptr->nextSister;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,12 +260,12 @@ W_ReparentView(W_View *view, W_View *newParent, int x, int y)
|
||||
adoptChildView(newParent, view);
|
||||
|
||||
if (view->flags.realized) {
|
||||
if (newParent->flags.realized) {
|
||||
XReparentWindow(dpy, view->window, newParent->window, x, y);
|
||||
} else {
|
||||
wwarning("trying to reparent realized view to unrealized parent");
|
||||
return;
|
||||
}
|
||||
if (newParent->flags.realized) {
|
||||
XReparentWindow(dpy, view->window, newParent->window, x, y);
|
||||
} else {
|
||||
wwarning("trying to reparent realized view to unrealized parent");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
view->pos.x = x;
|
||||
@@ -277,7 +277,7 @@ void
|
||||
W_RaiseView(W_View *view)
|
||||
{
|
||||
if (W_VIEW_REALIZED(view))
|
||||
XRaiseWindow(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view));
|
||||
XRaiseWindow(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view));
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ void
|
||||
W_LowerView(W_View *view)
|
||||
{
|
||||
if (W_VIEW_REALIZED(view))
|
||||
XLowerWindow(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view));
|
||||
XLowerWindow(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view));
|
||||
}
|
||||
|
||||
|
||||
@@ -295,13 +295,13 @@ void
|
||||
W_MapView(W_View *view)
|
||||
{
|
||||
if (!view->flags.mapped) {
|
||||
if (view->flags.realized) {
|
||||
XMapRaised(view->screen->display, view->window);
|
||||
XFlush(view->screen->display);
|
||||
view->flags.mapped = 1;
|
||||
} else {
|
||||
view->flags.mapWhenRealized = 1;
|
||||
}
|
||||
if (view->flags.realized) {
|
||||
XMapRaised(view->screen->display, view->window);
|
||||
XFlush(view->screen->display);
|
||||
view->flags.mapped = 1;
|
||||
} else {
|
||||
view->flags.mapWhenRealized = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,9 +318,9 @@ W_MapSubviews(W_View *view)
|
||||
|
||||
view = view->childrenList;
|
||||
while (view) {
|
||||
view->flags.mapped = 1;
|
||||
view->flags.mapWhenRealized = 0;
|
||||
view = view->nextSister;
|
||||
view->flags.mapped = 1;
|
||||
view->flags.mapWhenRealized = 0;
|
||||
view = view->nextSister;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,9 +334,9 @@ W_UnmapSubviews(W_View *view)
|
||||
|
||||
view = view->childrenList;
|
||||
while (view) {
|
||||
view->flags.mapped = 0;
|
||||
view->flags.mapWhenRealized = 0;
|
||||
view = view->nextSister;
|
||||
view->flags.mapped = 0;
|
||||
view->flags.mapWhenRealized = 0;
|
||||
view = view->nextSister;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ W_UnmapView(W_View *view)
|
||||
{
|
||||
view->flags.mapWhenRealized = 0;
|
||||
if (!view->flags.mapped)
|
||||
return;
|
||||
return;
|
||||
|
||||
XUnmapWindow(view->screen->display, view->window);
|
||||
XFlush(view->screen->display);
|
||||
@@ -362,8 +362,8 @@ W_TopLevelOfView(W_View *view)
|
||||
W_View *toplevel;
|
||||
|
||||
for (toplevel=view;
|
||||
toplevel && !toplevel->flags.topLevel;
|
||||
toplevel=toplevel->parent);
|
||||
toplevel && !toplevel->flags.topLevel;
|
||||
toplevel=toplevel->parent);
|
||||
|
||||
return toplevel;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ destroyView(W_View *view)
|
||||
W_View *ptr;
|
||||
|
||||
if (view->flags.alreadyDead)
|
||||
return;
|
||||
return;
|
||||
view->flags.alreadyDead = 1;
|
||||
|
||||
/* delete the balloon text for the view, if there's any */
|
||||
@@ -388,54 +388,54 @@ destroyView(W_View *view)
|
||||
|
||||
/* Do not leave focus in a inexisting control */
|
||||
if (W_FocusedViewOfToplevel(W_TopLevelOfView(view))==view)
|
||||
W_SetFocusOfTopLevel(W_TopLevelOfView(view), NULL);
|
||||
W_SetFocusOfTopLevel(W_TopLevelOfView(view), NULL);
|
||||
|
||||
if (view->flags.topLevel) {
|
||||
W_FocusInfo *info = view->screen->focusInfo;
|
||||
/* remove focus information associated to this toplevel */
|
||||
W_FocusInfo *info = view->screen->focusInfo;
|
||||
/* remove focus information associated to this toplevel */
|
||||
|
||||
if (info) {
|
||||
if (info->toplevel==view) {
|
||||
view->screen->focusInfo = info->next;
|
||||
wfree(info);
|
||||
} else {
|
||||
while (info->next) {
|
||||
if (info->next->toplevel == view)
|
||||
break;
|
||||
info = info->next;
|
||||
}
|
||||
if (info->next) {
|
||||
W_FocusInfo *next = info->next->next;
|
||||
wfree(info->next);
|
||||
info->next = next;
|
||||
}
|
||||
/* else the toplevel did not have any focused subview */
|
||||
}
|
||||
}
|
||||
if (info) {
|
||||
if (info->toplevel==view) {
|
||||
view->screen->focusInfo = info->next;
|
||||
wfree(info);
|
||||
} else {
|
||||
while (info->next) {
|
||||
if (info->next->toplevel == view)
|
||||
break;
|
||||
info = info->next;
|
||||
}
|
||||
if (info->next) {
|
||||
W_FocusInfo *next = info->next->next;
|
||||
wfree(info->next);
|
||||
info->next = next;
|
||||
}
|
||||
/* else the toplevel did not have any focused subview */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* destroy children recursively */
|
||||
while (view->childrenList!=NULL) {
|
||||
ptr = view->childrenList;
|
||||
ptr->flags.parentDying = 1;
|
||||
ptr = view->childrenList;
|
||||
ptr->flags.parentDying = 1;
|
||||
|
||||
W_DestroyView(ptr);
|
||||
W_DestroyView(ptr);
|
||||
|
||||
if (ptr == view->childrenList) {
|
||||
view->childrenList = ptr->nextSister;
|
||||
ptr->parent = NULL;
|
||||
}
|
||||
if (ptr == view->childrenList) {
|
||||
view->childrenList = ptr->nextSister;
|
||||
ptr->parent = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
W_CallDestroyHandlers(view);
|
||||
|
||||
if (view->flags.realized) {
|
||||
XDeleteContext(view->screen->display,
|
||||
view->window, ViewContext);
|
||||
XDeleteContext(view->screen->display,
|
||||
view->window, ViewContext);
|
||||
|
||||
/* if parent is being destroyed, it will die naturaly */
|
||||
if (!view->flags.parentDying || view->flags.topLevel)
|
||||
XDestroyWindow(view->screen->display, view->window);
|
||||
/* if parent is being destroyed, it will die naturaly */
|
||||
if (!view->flags.parentDying || view->flags.topLevel)
|
||||
XDestroyWindow(view->screen->display, view->window);
|
||||
}
|
||||
|
||||
/* remove self from parent's children list */
|
||||
@@ -445,21 +445,10 @@ destroyView(W_View *view)
|
||||
WMFreeArray(view->eventHandlers);
|
||||
view->eventHandlers = NULL;
|
||||
|
||||
WMUnregisterViewDraggedTypes(view);
|
||||
|
||||
WMRemoveNotificationObserver(view);
|
||||
|
||||
#if 0
|
||||
if (view->dragSourceProcs)
|
||||
wfree(view->dragSourceProcs);
|
||||
W_FreeViewXdndPart(view);
|
||||
|
||||
if (view->dragDestinationProcs)
|
||||
wfree(view->dragDestinationProcs);
|
||||
|
||||
if (scr->dragInfo.destView == view) {
|
||||
scr->dragInfo.destView = NULL;
|
||||
}
|
||||
#endif
|
||||
wfree(view);
|
||||
}
|
||||
|
||||
@@ -483,20 +472,20 @@ W_MoveView(W_View *view, int x, int y)
|
||||
assert(view->flags.root==0);
|
||||
|
||||
if (view->delegate && view->delegate->willMove) {
|
||||
(*view->delegate->willMove)(view->delegate, view, &x, &y);
|
||||
(*view->delegate->willMove)(view->delegate, view, &x, &y);
|
||||
}
|
||||
|
||||
if (view->pos.x == x && view->pos.y == y)
|
||||
return;
|
||||
return;
|
||||
|
||||
if (view->flags.realized) {
|
||||
XMoveWindow(view->screen->display, view->window, x, y);
|
||||
XMoveWindow(view->screen->display, view->window, x, y);
|
||||
}
|
||||
view->pos.x = x;
|
||||
view->pos.y = y;
|
||||
|
||||
if (view->delegate && view->delegate->didMove) {
|
||||
(*view->delegate->didMove)(view->delegate, view);
|
||||
(*view->delegate->didMove)(view->delegate, view);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,30 +496,30 @@ W_ResizeView(W_View *view, unsigned int width, unsigned int height)
|
||||
/*int shrinked;*/
|
||||
|
||||
if (view->delegate && view->delegate->willResize) {
|
||||
(*view->delegate->willResize)(view->delegate, view, &width, &height);
|
||||
(*view->delegate->willResize)(view->delegate, view, &width, &height);
|
||||
}
|
||||
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
|
||||
if (view->size.width == width && view->size.height == height)
|
||||
return;
|
||||
return;
|
||||
|
||||
/*shrinked = width < view->size.width || height < view->size.height;*/
|
||||
|
||||
if (view->flags.realized) {
|
||||
XResizeWindow(view->screen->display, view->window, width, height);
|
||||
XResizeWindow(view->screen->display, view->window, width, height);
|
||||
}
|
||||
view->size.width = width;
|
||||
view->size.height = height;
|
||||
|
||||
if (view->delegate && view->delegate->didResize) {
|
||||
(*view->delegate->didResize)(view->delegate, view);
|
||||
(*view->delegate->didResize)(view->delegate, view);
|
||||
}
|
||||
|
||||
/* // TODO. replace in WINGs code, with the didResize delegate */
|
||||
if (view->flags.notifySizeChanged)
|
||||
WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL);
|
||||
WMPostNotificationName(WMViewSizeDidChangeNotification, view, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -540,7 +529,7 @@ W_RedisplayView(W_View *view)
|
||||
XEvent ev;
|
||||
|
||||
if (!view->flags.mapped)
|
||||
return;
|
||||
return;
|
||||
|
||||
ev.xexpose.type = Expose;
|
||||
ev.xexpose.display = view->screen->display;
|
||||
@@ -557,15 +546,15 @@ void
|
||||
W_SetViewBackgroundColor(W_View *view, WMColor *color)
|
||||
{
|
||||
if (view->backColor)
|
||||
WMReleaseColor(view->backColor);
|
||||
WMReleaseColor(view->backColor);
|
||||
view->backColor = WMRetainColor(color);
|
||||
|
||||
view->attribFlags |= CWBackPixel;
|
||||
view->attribs.background_pixel = W_PIXEL(color);
|
||||
if (view->flags.realized) {
|
||||
XSetWindowBackground(view->screen->display, view->window,
|
||||
W_PIXEL(color));
|
||||
XClearWindow(view->screen->display, view->window);
|
||||
XSetWindowBackground(view->screen->display, view->window,
|
||||
W_PIXEL(color));
|
||||
XClearWindow(view->screen->display, view->window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,10 +564,10 @@ W_SetViewCursor(W_View *view, Cursor cursor)
|
||||
{
|
||||
view->cursor = cursor;
|
||||
if (W_VIEW_REALIZED(view)) {
|
||||
XDefineCursor(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view), cursor);
|
||||
XDefineCursor(W_VIEW_DISPLAY(view), W_VIEW_DRAWABLE(view), cursor);
|
||||
} else {
|
||||
view->attribFlags |= CWCursor;
|
||||
view->attribs.cursor = cursor;
|
||||
view->attribFlags |= CWCursor;
|
||||
view->attribs.cursor = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,11 +579,11 @@ W_FocusedViewOfToplevel(W_View *view)
|
||||
W_FocusInfo *info;
|
||||
|
||||
for (info = scr->focusInfo; info!=NULL; info = info->next)
|
||||
if (view == info->toplevel)
|
||||
break;
|
||||
if (view == info->toplevel)
|
||||
break;
|
||||
|
||||
if (!info)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
return info->focused;
|
||||
}
|
||||
@@ -608,29 +597,29 @@ W_SetFocusOfTopLevel(W_View *toplevel, W_View *view)
|
||||
W_FocusInfo *info;
|
||||
|
||||
for (info = scr->focusInfo; info!=NULL; info = info->next)
|
||||
if (toplevel == info->toplevel)
|
||||
break;
|
||||
if (toplevel == info->toplevel)
|
||||
break;
|
||||
|
||||
if (!info) {
|
||||
info = wmalloc(sizeof(W_FocusInfo));
|
||||
info->toplevel = toplevel;
|
||||
info->focused = view;
|
||||
info->next = scr->focusInfo;
|
||||
scr->focusInfo = info;
|
||||
info = wmalloc(sizeof(W_FocusInfo));
|
||||
info->toplevel = toplevel;
|
||||
info->focused = view;
|
||||
info->next = scr->focusInfo;
|
||||
scr->focusInfo = info;
|
||||
} else {
|
||||
event.xfocus.mode = NotifyNormal;
|
||||
event.xfocus.detail = NotifyDetailNone;
|
||||
if (info->focused) {
|
||||
/* simulate FocusOut event */
|
||||
event.xfocus.type = FocusOut;
|
||||
W_DispatchMessage(info->focused, &event);
|
||||
}
|
||||
info->focused = view;
|
||||
event.xfocus.mode = NotifyNormal;
|
||||
event.xfocus.detail = NotifyDetailNone;
|
||||
if (info->focused) {
|
||||
/* simulate FocusOut event */
|
||||
event.xfocus.type = FocusOut;
|
||||
W_DispatchMessage(info->focused, &event);
|
||||
}
|
||||
info->focused = view;
|
||||
}
|
||||
if (view) {
|
||||
/* simulate FocusIn event */
|
||||
event.xfocus.type = FocusIn;
|
||||
W_DispatchMessage(view, &event);
|
||||
/* simulate FocusIn event */
|
||||
event.xfocus.type = FocusIn;
|
||||
W_DispatchMessage(view, &event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,9 +631,9 @@ W_BroadcastMessage(W_View *targetParent, XEvent *event)
|
||||
|
||||
target = targetParent->childrenList;
|
||||
while (target!=NULL) {
|
||||
W_DispatchMessage(target, event);
|
||||
W_DispatchMessage(target, event);
|
||||
|
||||
target = target->nextSister;
|
||||
target = target->nextSister;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,14 +642,14 @@ void
|
||||
W_DispatchMessage(W_View *target, XEvent *event)
|
||||
{
|
||||
if (target->window==None)
|
||||
return;
|
||||
return;
|
||||
event->xclient.window = target->window;
|
||||
event->xclient.display = target->screen->display;
|
||||
|
||||
WMHandleEvent(event);
|
||||
/*
|
||||
XSendEvent(target->screen->display, target->window, False,
|
||||
SubstructureNotifyMask, event);
|
||||
XSendEvent(target->screen->display, target->window, False,
|
||||
SubstructureNotifyMask, event);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -681,7 +670,7 @@ W_ReleaseView(WMView *view)
|
||||
view->refCount--;
|
||||
|
||||
if (view->refCount < 1) {
|
||||
destroyView(view);
|
||||
destroyView(view);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,7 +727,7 @@ WMGetViewScreenPosition(WMView *view)
|
||||
}
|
||||
|
||||
XTranslateCoordinates(scr->display, W_VIEW_DRAWABLE(view),
|
||||
scr->rootWin, 0, 0, &x, &y, &foo);
|
||||
scr->rootWin, 0, 0, &x, &y, &foo);
|
||||
|
||||
return wmkpoint(x-topX, y-topY);
|
||||
}
|
||||
@@ -752,13 +741,13 @@ resizedParent(void *self, WMNotification *notif)
|
||||
|
||||
W_MoveView(view, view->leftOffs, view->topOffs);
|
||||
W_ResizeView(view, size.width - (view->leftOffs + view->rightOffs),
|
||||
size.height - (view->topOffs + view->bottomOffs));
|
||||
size.height - (view->topOffs + view->bottomOffs));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetViewExpandsToParent(WMView *view, int leftOffs, int topOffs,
|
||||
int rightOffs, int bottomOffs)
|
||||
int rightOffs, int bottomOffs)
|
||||
{
|
||||
WMSize size = view->parent->size;
|
||||
|
||||
@@ -768,13 +757,13 @@ WMSetViewExpandsToParent(WMView *view, int leftOffs, int topOffs,
|
||||
view->rightOffs = rightOffs;
|
||||
|
||||
WMAddNotificationObserver(resizedParent, view,
|
||||
WMViewSizeDidChangeNotification,
|
||||
view->parent);
|
||||
WMViewSizeDidChangeNotification,
|
||||
view->parent);
|
||||
WMSetViewNotifySizeChanges(view->parent, True);
|
||||
|
||||
W_MoveView(view, leftOffs, topOffs);
|
||||
W_ResizeView(view, size.width - (leftOffs + rightOffs),
|
||||
size.height - (topOffs + bottomOffs));
|
||||
size.height - (topOffs + bottomOffs));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ showData(_Panel *panel)
|
||||
WMSetButtonSelected(panel->swi[4], GetBoolForKey("WindozeCycling"));
|
||||
WMSetButtonSelected(panel->swi[5], GetBoolForKey("DontConfirmKill"));
|
||||
WMSetButtonSelected(panel->swi[6], GetBoolForKey("DisableBlinking"));
|
||||
if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
//if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
WMSetButtonSelected(panel->swi[7], GetBoolForKey("AntialiasedText"));
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ createPanel(Panel *p)
|
||||
WMSetButtonText(panel->swi[6], _("Disable selection animation for selected icons."));
|
||||
WMSetButtonText(panel->swi[7], _("Smooth font edges (needs restart)."));
|
||||
|
||||
if (!WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
//if (!WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
WMSetButtonEnabled(panel->swi[7], False);
|
||||
|
||||
WMRealizeWidget(panel->box);
|
||||
@@ -107,7 +107,7 @@ storeDefaults(_Panel *panel)
|
||||
SetBoolForKey(WMGetButtonSelected(panel->swi[4]), "WindozeCycling");
|
||||
SetBoolForKey(WMGetButtonSelected(panel->swi[5]), "DontConfirmKill");
|
||||
SetBoolForKey(WMGetButtonSelected(panel->swi[6]), "DisableBlinking");
|
||||
if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
//if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
SetBoolForKey(WMGetButtonSelected(panel->swi[7]), "AntialiasedText");
|
||||
}
|
||||
|
||||
|
||||
@@ -1284,16 +1284,16 @@ getFontForPreview(void *data, int element)
|
||||
WMScreen *scr = WMWidgetScreen(panel->box);
|
||||
char *encoding = getFontEncoding(panel);
|
||||
fname = fontOfLang(panel, encoding, element);
|
||||
if (WMHasAntialiasingSupport(scr))
|
||||
{
|
||||
//if (WMHasAntialiasingSupport(scr)) {
|
||||
if(panel->AntialiasedText) {
|
||||
font = WMCreateFontWithFlags(scr, fname, WFAntialiased);
|
||||
// fix this -Dan font = WMCreateFontWithFlags(scr, fname, WFAntialiased);
|
||||
font = WMCreateFont(scr, fname);
|
||||
} else {
|
||||
font = WMCreateFont(scr, fname);
|
||||
}
|
||||
} else {
|
||||
font = WMCreateFont(scr, fname);
|
||||
}
|
||||
//} else {
|
||||
// font = WMCreateFont(scr, fname);
|
||||
//}
|
||||
if(!font) {
|
||||
char *msg;
|
||||
int length;
|
||||
@@ -1822,8 +1822,7 @@ showData(_Panel *panel)
|
||||
/* gotta check for Antialiasing AFTER MultiByte incase the use has both
|
||||
* to maintain behavior in Current Fonts set or i could add another if
|
||||
* statement to setLanguageType =) */
|
||||
if (WMHasAntialiasingSupport(scr))
|
||||
{
|
||||
//if (WMHasAntialiasingSupport(scr)) {
|
||||
WMMapWidget(panel->togAA);
|
||||
if(GetBoolForKey("AntialiasedText")){
|
||||
WMSetButtonSelected(panel->togAA, True);
|
||||
@@ -1832,9 +1831,9 @@ showData(_Panel *panel)
|
||||
WMSetButtonSelected(panel->togAA, False);
|
||||
panel->AntialiasedText = False;
|
||||
}
|
||||
} else {
|
||||
WMUnmapWidget(panel->togAA);
|
||||
}
|
||||
//} else {
|
||||
// WMUnmapWidget(panel->togAA);
|
||||
//}
|
||||
|
||||
|
||||
paintPreviewBox(panel, EVERYTHING);
|
||||
@@ -1909,17 +1908,16 @@ createPanel(Panel *p)
|
||||
WMMapSubwidgets(panel->langF);
|
||||
|
||||
/* Antialiasing */
|
||||
if (WMHasAntialiasingSupport(scr))
|
||||
{
|
||||
panel->togAA = WMCreateSwitchButton(panel->box);
|
||||
WMResizeWidget(panel->togAA, 110, 20);
|
||||
WMMoveWidget(panel->togAA, 155, 10);
|
||||
WMSetButtonText(panel->togAA, _("Smooth Fonts"));
|
||||
WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n"
|
||||
"requires a restart after saving"),
|
||||
WMWidgetView(panel->togAA));
|
||||
WMSetButtonAction(panel->togAA, toggleAA, panel);
|
||||
}
|
||||
//if (WMHasAntialiasingSupport(scr)) {
|
||||
panel->togAA = WMCreateSwitchButton(panel->box);
|
||||
WMResizeWidget(panel->togAA, 110, 20);
|
||||
WMMoveWidget(panel->togAA, 155, 10);
|
||||
WMSetButtonText(panel->togAA, _("Smooth Fonts"));
|
||||
WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n"
|
||||
"requires a restart after saving"),
|
||||
WMWidgetView(panel->togAA));
|
||||
WMSetButtonAction(panel->togAA, toggleAA, panel);
|
||||
//}
|
||||
/* multibyte */
|
||||
panel->fsetL = WMCreateLabel(panel->box);
|
||||
WMResizeWidget(panel->fsetL, 245, 20);
|
||||
@@ -2063,7 +2061,7 @@ storeData(Panel *p)
|
||||
}
|
||||
}
|
||||
|
||||
if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
//if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
|
||||
SetBoolForKey(WMGetButtonSelected(panel->togAA), "AntialiasedText");
|
||||
|
||||
if(panel->MultiByteText)
|
||||
|
||||
@@ -15,7 +15,7 @@ AC_INIT(src/WindowMaker.h)
|
||||
|
||||
|
||||
|
||||
AM_INIT_AUTOMAKE(WindowMaker, 0.81.0)
|
||||
AM_INIT_AUTOMAKE(WindowMaker, 0.90.0)
|
||||
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
@@ -102,8 +102,8 @@ AC_FUNC_VPRINTF
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_FUNCS(gethostname select poll strerror strcasecmp strncasecmp \
|
||||
setsid atexit mallinfo mkstemp snprintf vsnprintf asprintf \
|
||||
vasprintf mbsnrtowcs mbsrtowcs mbrtowc mbrlen)
|
||||
|
||||
vasprintf mbsnrtowcs mbsrtowcs mbrtowc mbrlen wcsnrtombs \
|
||||
wcsrtombs wcstombs)
|
||||
|
||||
dnl ripped from samba
|
||||
dnl
|
||||
|
||||
@@ -1312,7 +1312,8 @@ wShowInfoPanel(WScreen *scr)
|
||||
WMSetLabelTextAlignment(panel->copyrL, WALeft);
|
||||
WMSetLabelText(panel->copyrL, COPYRIGHT_TEXT);
|
||||
/* we want the (c) character in the font, so don't use a FontSet here */
|
||||
font = WMCreateFontWithFlags(scr->wmscreen, "SystemFont-11", WFNormalFont);
|
||||
// fix this -Dan font = WMCreateFontWithFlags(scr->wmscreen, "SystemFont-11", WFNormalFont);
|
||||
font = WMSystemFontOfSize(scr->wmscreen, 11);
|
||||
if (font) {
|
||||
WMSetLabelFont(panel->copyrL, font);
|
||||
WMReleaseFont(font);
|
||||
|
||||
@@ -821,9 +821,11 @@ wScreenInit(int screen_number)
|
||||
|
||||
scr->info_text_font = WMBoldSystemFontOfSize(scr->wmscreen, 12);
|
||||
|
||||
scr->tech_draw_font = WMCreateFontWithFlags(scr->wmscreen,
|
||||
"BoldSystemFont-12",
|
||||
WFNotAntialiased);
|
||||
// fix this too -Dan
|
||||
//scr->tech_draw_font = WMCreateFontWithFlags(scr->wmscreen,
|
||||
// "BoldSystemFont-12",
|
||||
// WFNotAntialiased);
|
||||
scr->tech_draw_font = WMBoldSystemFontOfSize(scr->wmscreen, 12);
|
||||
|
||||
scr->gview = WCreateGeometryView(scr->wmscreen);
|
||||
WMRealizeWidget(scr->gview);
|
||||
|
||||
Reference in New Issue
Block a user