mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-11 11:15:55 +01:00
more dnd changes
window cycling stuff finnish pot files
This commit is contained in:
@@ -402,6 +402,7 @@ typedef void WMAction2(void *self, void *clientData);
|
||||
|
||||
typedef void WMCallback(void *data);
|
||||
|
||||
typedef void WMDropDataCallback(WMView *view, WMData *data);
|
||||
|
||||
/* delegate method like stuff */
|
||||
typedef void WMListDrawProc(WMList *lPtr, int index, Drawable d, char *text,
|
||||
@@ -509,9 +510,8 @@ typedef struct W_DragDestinationProcs {
|
||||
unsigned (*draggingEntered)(WMView *self, WMDraggingInfo *info);
|
||||
unsigned (*draggingUpdated)(WMView *self, WMDraggingInfo *info);
|
||||
void (*draggingExited)(WMView *self, WMDraggingInfo *info);
|
||||
char *(*prepareForDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
Bool (*performDragOperation)(WMView *self, WMDraggingInfo *info,
|
||||
WMData *data);
|
||||
Bool (*prepareForDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
Bool (*performDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
void (*concludeDragOperation)(WMView *self, WMDraggingInfo *info);
|
||||
} WMDragDestinationProcs;
|
||||
|
||||
|
||||
@@ -454,6 +454,10 @@ void W_SetViewBackgroundColor(W_View *view, WMColor *color);
|
||||
void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
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);
|
||||
|
||||
void W_CleanUpEvents(W_View *view);
|
||||
|
||||
|
||||
@@ -108,13 +108,12 @@ static void defDraggingExited(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
}
|
||||
|
||||
static char* defPrepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
static Bool defPrepareForDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return NULL;
|
||||
return False;
|
||||
}
|
||||
|
||||
static Bool defPerformDragOperation(WMView *self, WMDraggingInfo *info,
|
||||
WMData *data)
|
||||
static Bool defPerformDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
@@ -168,3 +167,49 @@ WMPoint WMGetDraggingInfoImageLocation(WMDraggingInfo *info)
|
||||
{
|
||||
return info->imageLocation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
receivedData(WMView *view, Atom selection, Atom target, Time timestamp,
|
||||
void *cdata, WMData *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Bool WMRequestDroppedData(WMView *view, WMDraggingInfo *info, char *type,
|
||||
WMDropDataCallback *callback)
|
||||
{
|
||||
WMScreen *scr = W_VIEW_SCREEN(view);
|
||||
#if 0
|
||||
if (info->finished) {
|
||||
return False;
|
||||
}
|
||||
|
||||
if (type != NULL) {
|
||||
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");
|
||||
|
||||
/* send finished message */
|
||||
sendClientMessage(scr->display, source,
|
||||
scr->xdndFinishedAtom,
|
||||
scr->dragInfo.destinationWindow,
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
} else {
|
||||
/* send finished message */
|
||||
sendClientMessage(scr->display, source,
|
||||
scr->xdndFinishedAtom,
|
||||
scr->dragInfo.destinationWindow,
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -261,8 +261,6 @@ lookForToplevel(WMScreen *scr, Window window, Bool *isAware)
|
||||
}
|
||||
|
||||
XFree(children);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return toplevel;
|
||||
@@ -1093,7 +1091,7 @@ receivedData(WMView *view, Atom selection, Atom target,
|
||||
WMDraggingInfo *info = (WMDraggingInfo*)cdata;
|
||||
Bool res;
|
||||
|
||||
res = view->dragDestinationProcs->performDragOperation(view, info, data);
|
||||
res = view->dragDestinationProcs->performDragOperation(view, info);
|
||||
|
||||
if (res) {
|
||||
DISPATCH(view, concludeDragOperation, info);
|
||||
@@ -1297,30 +1295,16 @@ W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event)
|
||||
|
||||
case WDrop:
|
||||
{
|
||||
char *type;
|
||||
Bool res;
|
||||
|
||||
type = DISPATCH(oldView, prepareForDragOperation, &scr->dragInfo);
|
||||
res = DISPATCH(oldView, prepareForDragOperation, &scr->dragInfo);
|
||||
|
||||
if (type != NULL) {
|
||||
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");
|
||||
|
||||
/* send finished message */
|
||||
sendClientMessage(scr->display, source,
|
||||
scr->xdndFinishedAtom,
|
||||
scr->dragInfo.destinationWindow,
|
||||
0, 0, 0, 0);
|
||||
}
|
||||
} else {
|
||||
/* send finished message */
|
||||
sendClientMessage(scr->display, source,
|
||||
scr->xdndFinishedAtom,
|
||||
scr->dragInfo.destinationWindow,
|
||||
0, 0, 0, 0);
|
||||
if (res) {
|
||||
res = DISPATCH(oldView, performDragOperation, &scr->dragInfo);
|
||||
}
|
||||
|
||||
if (res) {
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -72,7 +72,8 @@ paintFrame(Frame *fPtr)
|
||||
W_Screen *scrPtr = view->screen;
|
||||
int tx, ty, tw, th;
|
||||
int fy, fh;
|
||||
|
||||
Bool drawTitle;
|
||||
|
||||
if (fPtr->caption!=NULL)
|
||||
th = WMFontHeight(scrPtr->normalFont);
|
||||
else {
|
||||
@@ -124,27 +125,66 @@ paintFrame(Frame *fPtr)
|
||||
fy = 0;
|
||||
fh = view->size.height;
|
||||
}
|
||||
/*
|
||||
XClearArea(scrPtr->display, view->window, fy+2, 2, fh-4, view->size.width-4,
|
||||
False);
|
||||
*/
|
||||
XClearWindow(scrPtr->display, view->window);
|
||||
|
||||
W_DrawRelief(scrPtr, view->window, 0, fy, view->size.width, fh,
|
||||
fPtr->flags.relief);
|
||||
|
||||
if (fPtr->caption!=NULL && fPtr->flags.titlePosition!=WTPNoTitle) {
|
||||
|
||||
|
||||
tw = WMWidthOfString(scrPtr->normalFont, fPtr->caption,
|
||||
strlen(fPtr->caption));
|
||||
|
||||
tx = (view->size.width - tw) / 2;
|
||||
|
||||
XFillRectangle(scrPtr->display, view->window, WMColorGC(scrPtr->gray),
|
||||
tx, ty, tw, th);
|
||||
strlen(fPtr->caption));
|
||||
|
||||
WMDrawString(scrPtr, view->window, WMColorGC(scrPtr->black),
|
||||
tx = (view->size.width - tw) / 2;
|
||||
|
||||
drawTitle = True;
|
||||
} else {
|
||||
drawTitle = False;
|
||||
}
|
||||
|
||||
/* XClearArea(scrPtr->display, view->window, x, y, width, height, False);
|
||||
*/
|
||||
|
||||
{
|
||||
XRectangle rect;
|
||||
Region region, tmp;
|
||||
GC gc[4];
|
||||
int i;
|
||||
|
||||
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);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
XSetRegion(scrPtr->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]);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
XSetClipMask(scrPtr->display, gc[i], None);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawTitle) {
|
||||
WMDrawString(scrPtr, view->window, WMColorGC(scrPtr->black),
|
||||
scrPtr->normalFont, tx, ty, fPtr->caption,
|
||||
strlen(fPtr->caption));
|
||||
}
|
||||
@@ -163,9 +203,8 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintFrame(fPtr);
|
||||
if (event->xexpose.count == 0)
|
||||
paintFrame(fPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
|
||||
@@ -8,6 +8,17 @@
|
||||
void
|
||||
W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
unsigned int height, WMReliefType relief)
|
||||
{
|
||||
W_DrawReliefWithGC(scr, d, x, y, width, height, relief,
|
||||
WMColorGC(scr->black), WMColorGC(scr->darkGray),
|
||||
WMColorGC(scr->gray), WMColorGC(scr->white));
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
Display *dpy = scr->display;
|
||||
GC bgc;
|
||||
@@ -17,37 +28,36 @@ W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
|
||||
switch (relief) {
|
||||
case WRSimple:
|
||||
XDrawRectangle(dpy, d, WMColorGC(scr->black), x, y, width-1, height-1);
|
||||
XDrawRectangle(dpy, d, black, x, y, width-1, height-1);
|
||||
return;
|
||||
break;
|
||||
|
||||
case WRRaised:
|
||||
bgc = WMColorGC(scr->black);
|
||||
dgc = WMColorGC(scr->darkGray);
|
||||
wgc = WMColorGC(scr->white);
|
||||
lgc = WMColorGC(scr->gray);
|
||||
bgc = black;
|
||||
dgc = dark;
|
||||
wgc = white;
|
||||
lgc = light;
|
||||
break;
|
||||
|
||||
case WRSunken:
|
||||
wgc = WMColorGC(scr->darkGray);
|
||||
lgc = WMColorGC(scr->black);
|
||||
bgc = WMColorGC(scr->white);
|
||||
dgc = WMColorGC(scr->gray);
|
||||
wgc = dark;
|
||||
lgc = black;
|
||||
bgc = white;
|
||||
dgc = light;
|
||||
break;
|
||||
|
||||
case WRPushed:
|
||||
lgc = wgc = WMColorGC(scr->black);
|
||||
dgc = bgc = WMColorGC(scr->white);
|
||||
lgc = wgc = black;
|
||||
dgc = bgc = white;
|
||||
break;
|
||||
|
||||
case WRRidge:
|
||||
lgc = bgc = WMColorGC(scr->darkGray);
|
||||
dgc = wgc = WMColorGC(scr->white);
|
||||
lgc = bgc = dark;
|
||||
dgc = wgc = white;
|
||||
break;
|
||||
|
||||
case WRGroove:
|
||||
wgc = dgc = WMColorGC(scr->darkGray);
|
||||
lgc = bgc = WMColorGC(scr->white);
|
||||
wgc = dgc = dark;
|
||||
lgc = bgc = white;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -77,6 +87,8 @@ W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int
|
||||
fitText(char *text, WMFont *font, int width, int wrap)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,50 @@ testFontPanel(WMScreen *scr)
|
||||
|
||||
|
||||
|
||||
void
|
||||
testFrame(WMScreen *scr)
|
||||
{
|
||||
WMWindow *win;
|
||||
WMFrame *frame;
|
||||
int i;
|
||||
static char* titles[] = {
|
||||
"AboveTop",
|
||||
"AtTop",
|
||||
"BelowTop",
|
||||
"AboveBottom",
|
||||
"AtBottom",
|
||||
"BelowBottom"
|
||||
};
|
||||
static WMTitlePosition pos[] = {
|
||||
WTPAboveTop,
|
||||
WTPAtTop,
|
||||
WTPBelowTop,
|
||||
WTPAboveBottom,
|
||||
WTPAtBottom,
|
||||
WTPBelowBottom
|
||||
};
|
||||
|
||||
windowCount++;
|
||||
|
||||
win = WMCreateWindow(scr, "testFrame");
|
||||
WMSetWindowTitle(win, "Frame");
|
||||
WMSetWindowCloseAction(win, closeAction, NULL);
|
||||
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);
|
||||
WMSetFrameTitle(frame, titles[i]);
|
||||
WMSetFrameTitlePosition(frame, pos[i]);
|
||||
}
|
||||
|
||||
WMRealizeWidget(win);
|
||||
WMMapSubwidgets(win);
|
||||
WMMapWidget(win);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
testList(WMScreen *scr)
|
||||
{
|
||||
@@ -812,8 +856,7 @@ Bool performDragOperation(WMView *self, WMDraggingInfo *info,
|
||||
|
||||
void concludeDragOperation(WMView *self, WMDraggingInfo *info)
|
||||
{
|
||||
puts("concluded");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -955,7 +998,7 @@ int main(int argc, char **argv)
|
||||
* Do NOT use it unless when debugging. It will cause a major
|
||||
* slowdown in your application
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
#if 1
|
||||
XSynchronize(dpy, True);
|
||||
#endif
|
||||
/*
|
||||
@@ -978,12 +1021,15 @@ int main(int argc, char **argv)
|
||||
*
|
||||
* Put the testSomething() function you want to test here.
|
||||
*/
|
||||
|
||||
|
||||
testDragAndDrop(scr);
|
||||
testDragAndDrop(scr);
|
||||
|
||||
#if 0
|
||||
testFrame(scr);
|
||||
|
||||
|
||||
testDragAndDrop(scr);
|
||||
testDragAndDrop(scr);
|
||||
|
||||
#if 0
|
||||
testColorWell(scr);
|
||||
|
||||
testTabView(scr);
|
||||
|
||||
Reference in New Issue
Block a user