mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-30 18:32:34 +01:00
fixed color dragging from colorwell
This commit is contained in:
@@ -219,7 +219,7 @@ DIST_COMMON = README ChangeLog Makefile.am Makefile.in TODO
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(libWINGs_a_SOURCES) $(libWUtil_a_SOURCES) $(wtest_SOURCES) $(wmquery_SOURCES) $(wmfile_SOURCES) $(fontl_SOURCES) $(testmywidget_SOURCES) $(testcolorpanel_SOURCES) $(connect_SOURCES)
|
||||
OBJECTS = $(libWINGs_a_OBJECTS) $(libWUtil_a_OBJECTS) $(wtest_OBJECTS) $(wmquery_OBJECTS) $(wmfile_OBJECTS) $(fontl_OBJECTS) $(testmywidget_OBJECTS) $(testcolorpanel_OBJECTS) $(connect_OBJECTS)
|
||||
@@ -228,7 +228,7 @@ all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .lo .o .s
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WINGs/Makefile
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu WINGs/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
@@ -483,7 +483,7 @@ distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|
||||
@@ -109,14 +109,14 @@ DIST_COMMON = Makefile.am Makefile.in
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WINGs/Resources/Makefile
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu WINGs/Resources/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
@@ -148,10 +148,15 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
subdir = WINGs/Resources
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu WINGs/Resources/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|
||||
@@ -319,6 +319,97 @@ slideView(WMView *view, int srcX, int srcY, int dstX, int dstY)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Window
|
||||
findChildInWindow(Display *dpy, Window toplevel, int x, int y)
|
||||
{
|
||||
Window foo, bar;
|
||||
Window *children;
|
||||
unsigned nchildren;
|
||||
int i;
|
||||
|
||||
if (!XQueryTree(dpy, toplevel, &foo, &bar,
|
||||
&children, &nchildren) || children == NULL) {
|
||||
return None;
|
||||
}
|
||||
|
||||
/* first window that contains the point is the one */
|
||||
for (i = nchildren-1; i >= 0; i--) {
|
||||
XWindowAttributes attr;
|
||||
|
||||
if (XGetWindowAttributes(dpy, children[i], &attr)
|
||||
&& attr.map_state == IsViewable
|
||||
&& x >= attr.x && y >= attr.y
|
||||
&& x < attr.x + attr.width && y < attr.y + attr.height) {
|
||||
Window child;
|
||||
|
||||
child = findChildInWindow(dpy, children[i],
|
||||
x - attr.x, y - attr.y);
|
||||
|
||||
XFree(children);
|
||||
|
||||
if (!child)
|
||||
return toplevel;
|
||||
else
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(children);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
static Window
|
||||
findWindowUnderDragPointer(WMScreen *scr, int x, int y, Window iconWindow)
|
||||
{
|
||||
Window foo, bar;
|
||||
Window *children;
|
||||
unsigned nchildren;
|
||||
int i;
|
||||
|
||||
if (!XQueryTree(scr->display, scr->rootWin, &foo, &bar,
|
||||
&children, &nchildren) || children == NULL) {
|
||||
return None;
|
||||
}
|
||||
|
||||
/* try to find the window below the iconWindow by traversing
|
||||
* the whole window list */
|
||||
|
||||
/* first find the position of the iconWindow */
|
||||
for (i = nchildren-1; i >= 0; i--) {
|
||||
if (children[i] == iconWindow) {
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i <= 0) {
|
||||
XFree(children);
|
||||
return scr->rootWin;
|
||||
}
|
||||
|
||||
/* first window that contains the point is the one */
|
||||
for (; i >= 0; i--) {
|
||||
XWindowAttributes attr;
|
||||
Window child;
|
||||
|
||||
if (XGetWindowAttributes(scr->display, children[i], &attr)
|
||||
&& attr.map_state == IsViewable
|
||||
&& x >= attr.x && y >= attr.y
|
||||
&& x < attr.x + attr.width && y < attr.y + attr.height
|
||||
&& (child = findChildInWindow(scr->display, children[i],
|
||||
x - attr.x, y - attr.y))) {
|
||||
XFree(children);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(children);
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
dragColor(ColorWell *cPtr, XEvent *event, WMPixmap *image)
|
||||
{
|
||||
@@ -349,14 +440,15 @@ dragColor(ColorWell *cPtr, XEvent *event, WMPixmap *image)
|
||||
XClearWindow(dpy, dragView->window);
|
||||
|
||||
|
||||
XGrabPointer(dpy, dragView->window, True,
|
||||
ButtonMotionMask|ButtonReleaseMask|EnterWindowMask,
|
||||
XGrabPointer(dpy, scr->rootWin, True,
|
||||
ButtonMotionMask|ButtonReleaseMask,
|
||||
GrabModeSync, GrabModeAsync,
|
||||
scr->rootWin, scr->defaultCursor, CurrentTime);
|
||||
|
||||
while (!done) {
|
||||
XEvent ev;
|
||||
WMView *view;
|
||||
Window win;
|
||||
|
||||
XAllowEvents(dpy, SyncPointer, CurrentTime);
|
||||
WMNextEvent(dpy, &ev);
|
||||
@@ -375,23 +467,33 @@ dragColor(ColorWell *cPtr, XEvent *event, WMPixmap *image)
|
||||
done = True;
|
||||
break;
|
||||
|
||||
case EnterNotify:
|
||||
view = W_GetViewForXWindow(dpy, ev.xcrossing.window);
|
||||
case MotionNotify:
|
||||
while (XCheckTypedEvent(dpy, MotionNotify, &ev)) ;
|
||||
|
||||
W_MoveView(dragView, ev.xmotion.x_root-8, ev.xmotion.y_root-8);
|
||||
|
||||
win = findWindowUnderDragPointer(scr, ev.xmotion.x_root,
|
||||
ev.xmotion.y_root,
|
||||
dragView->window);
|
||||
|
||||
if (win != None && win != scr->rootWin) {
|
||||
view = W_GetViewForXWindow(dpy, win);
|
||||
} else {
|
||||
view = NULL;
|
||||
}
|
||||
|
||||
if (view && view->self && W_CLASS(view->self) == WC_ColorWell
|
||||
&& view->self != activeWell && view->self != cPtr) {
|
||||
|
||||
|
||||
activeWell = view->self;
|
||||
XRecolorCursor(dpy, scr->defaultCursor, &green, &back);
|
||||
} else if (view->self!=NULL && view->self != activeWell) {
|
||||
|
||||
} else if (!view || view->self != activeWell) {
|
||||
|
||||
XRecolorCursor(dpy, scr->defaultCursor, &black, &back);
|
||||
activeWell = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
W_MoveView(dragView, ev.xmotion.x_root-8, ev.xmotion.y_root-8);
|
||||
break;
|
||||
|
||||
default:
|
||||
WMHandleEvent(&ev);
|
||||
|
||||
@@ -720,6 +720,7 @@ int main(int argc, char **argv)
|
||||
|
||||
testTabView(scr);
|
||||
|
||||
testColorWell(scr);
|
||||
#if 0
|
||||
testFontPanel(scr);
|
||||
|
||||
@@ -727,7 +728,6 @@ int main(int argc, char **argv)
|
||||
|
||||
testGradientButtons(scr);
|
||||
testProgressIndicator(scr);
|
||||
testColorWell(scr);
|
||||
|
||||
testTextField(scr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user