From 67f73e9d54b37e241a8275803b2bf328d3a740d4 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 29 Oct 2012 15:35:56 -0700 Subject: [PATCH] AppIcon helper functions. Create wAppIconFor() and wAppIconTouchesHead() to match wWindowFor() and wWindowTouchesHead(). These functions will allow us to locate the window and head associated with a particular app icon or dock icon. --- src/appicon.c | 17 +++++++++++++++++ src/appicon.h | 1 + src/xinerama.c | 19 +++++++++++++++++++ src/xinerama.h | 2 ++ 4 files changed, 39 insertions(+) diff --git a/src/appicon.c b/src/appicon.c index 9bac0ef6..6be30577 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -60,6 +60,7 @@ extern Cursor wCursor[WCUR_LAST]; extern WPreferences wPreferences; extern WDDomain *WDWindowAttributes; +extern XContext wWinContext; #define MOD_MASK wPreferences.modifier_mask @@ -1016,3 +1017,19 @@ static void remove_from_appicon_list(WScreen *scr, WAppIcon *appicon) appicon->prev = NULL; appicon->next = NULL; } + +WAppIcon *wAppIconFor(Window window) +{ + WObjDescriptor *desc; + + if (window == None) + return NULL; + + if (XFindContext(dpy, window, wWinContext, (XPointer *) & desc) == XCNOENT) + return NULL; + + if (desc->parent_type == WCLASS_APPICON || desc->parent_type == WCLASS_DOCK_ICON) + return desc->parent; + + return NULL; +} diff --git a/src/appicon.h b/src/appicon.h index a6c6a6a3..6f72c8e4 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -83,4 +83,5 @@ void paint_app_icon(WApplication *wapp); void unpaint_app_icon(WApplication *wapp); void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance, char *wm_class); +WAppIcon *wAppIconFor(Window window); #endif diff --git a/src/xinerama.c b/src/xinerama.c index 823df997..4bd9ca44 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -201,6 +201,25 @@ Bool wWindowTouchesHead(WWindow * wwin, int head) return (a != 0); } +Bool wAppIconTouchesHead(WAppIcon * aicon, int head) +{ + WScreen *scr; + WMRect rect; + int a; + + if (!aicon || !aicon->icon) + return False; + + scr = aicon->icon->core->screen_ptr; + rect = wGetRectForHead(scr, head); + a = calcIntersectionArea(aicon->x_pos, aicon->y_pos, + aicon->icon->core->width, + aicon->icon->core->height, + rect.pos.x, rect.pos.y, rect.size.width, rect.size.height); + + return (a != 0); +} + int wGetHeadForWindow(WWindow * wwin) { WMRect rect; diff --git a/src/xinerama.h b/src/xinerama.h index 06997267..fd1d4692 100644 --- a/src/xinerama.h +++ b/src/xinerama.h @@ -21,6 +21,7 @@ #ifndef _WMXINERAMA_H_ #define _WMXINERAMA_H_ +#include "appicon.h" #include "screen.h" #include "window.h" #include @@ -51,6 +52,7 @@ WArea wGetUsableAreaForHead(WScreen *scr, int head, WArea *totalAreaPtr, Bool no WMPoint wGetPointToCenterRectInHead(WScreen *scr, int head, int width, int height); Bool wWindowTouchesHead(WWindow *wwin, int head); +Bool wAppIconTouchesHead(WAppIcon *aicon, int head); #endif -- 2.11.4.GIT