Change to the linux kernel coding style

for arq in `git ls-files *.c`; do
    echo $arq;
    indent -linux -l115 $arq;
    done

The different line break at 115 columns is because
I use a widescreen monitor :-)
This commit is contained in:
Carlos R. Mafra committed 2009-08-20 00:59:40 +02:00
1 parent 59fc927dc9
commit 688a56e8ab
209 files changed
+87034 -98138

No files matched your search

+1391 -1491
View File
File diff suppressed because it is too large. Load diff
+511 -579
View File
File diff suppressed because it is too large. Load diff
+324 -355
View File
@@ -36,7 +36,7 @@
#include "window.h"
#ifdef USER_MENU
#include "usermenu.h"
#endif /* USER_MENU */
#endif /* USER_MENU */
#include "icon.h"
#include "appicon.h"
#include "application.h"
@@ -52,7 +52,6 @@
#include "xinerama.h"
/******** Global variables ********/
extern XContext wAppWinContext;
@@ -63,447 +62,417 @@ extern WDDomain *WDWindowAttributes;
/******** Local variables ********/
static WWindow*
makeMainWindow(WScreen *scr, Window window)
static WWindow *makeMainWindow(WScreen * scr, Window window)
{
WWindow *wwin;
XWindowAttributes attr;
WWindow *wwin;
XWindowAttributes attr;
if (!XGetWindowAttributes(dpy, window, &attr)) {
return NULL;
}
if (!XGetWindowAttributes(dpy, window, &attr)) {
return NULL;
}
wwin = wWindowCreate();
wwin->screen_ptr = scr;
wwin->client_win = window;
wwin->main_window = window;
wwin->wm_hints = XGetWMHints(dpy, window);
/* if (!MyXFetchName(dpy, window, &(wwin->frame->title))) {
wwin->frame->title = NULL;
}
*/
PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance);
wwin = wWindowCreate();
wwin->screen_ptr = scr;
wwin->client_win = window;
wwin->main_window = window;
wwin->wm_hints = XGetWMHints(dpy, window);
/* if (!MyXFetchName(dpy, window, &(wwin->frame->title))) {
wwin->frame->title = NULL;
}
*/
PropGetWMClass(window, &wwin->wm_class, &wwin->wm_instance);
wDefaultFillAttributes(scr, wwin->wm_instance, wwin->wm_class,
&wwin->user_flags, &wwin->defined_user_flags, True);
wDefaultFillAttributes(scr, wwin->wm_instance, wwin->wm_class,
&wwin->user_flags, &wwin->defined_user_flags, True);
XSelectInput(dpy, window, attr.your_event_mask | PropertyChangeMask
| StructureNotifyMask);
return wwin;
XSelectInput(dpy, window, attr.your_event_mask | PropertyChangeMask | StructureNotifyMask);
return wwin;
}
WApplication*
wApplicationOf(Window window)
WApplication *wApplicationOf(Window window)
{
WApplication *wapp;
WApplication *wapp;
if (window == None)
return NULL;
if (XFindContext(dpy, window, wAppWinContext, (XPointer*)&wapp)!=XCSUCCESS)
return NULL;
return wapp;
if (window == None)
return NULL;
if (XFindContext(dpy, window, wAppWinContext, (XPointer *) & wapp) != XCSUCCESS)
return NULL;
return wapp;
}
static WAppIcon*
findDockIconFor(WDock *dock, Window main_window)
static WAppIcon *findDockIconFor(WDock * dock, Window main_window)
{
WAppIcon *aicon = NULL;
WAppIcon *aicon = NULL;
aicon = wDockFindIconForWindow(dock, main_window);
if (!aicon) {
wDockTrackWindowLaunch(dock, main_window);
aicon = wDockFindIconForWindow(dock, main_window);
}
return aicon;
aicon = wDockFindIconForWindow(dock, main_window);
if (!aicon) {
wDockTrackWindowLaunch(dock, main_window);
aicon = wDockFindIconForWindow(dock, main_window);
}
return aicon;
}
static void
extractIcon(WWindow *wwin)
static void extractIcon(WWindow * wwin)
{
char *progname;
char *progname;
progname = GetProgramNameForWindow(wwin->client_win);
if (progname) {
wApplicationExtractDirPackIcon(wwin->screen_ptr, progname,
wwin->wm_instance, wwin->wm_class);
wfree(progname);
}
progname = GetProgramNameForWindow(wwin->client_win);
if (progname) {
wApplicationExtractDirPackIcon(wwin->screen_ptr, progname, wwin->wm_instance, wwin->wm_class);
wfree(progname);
}
}
static void
saveIconNameFor(char *iconPath, char *wm_instance, char *wm_class)
static void saveIconNameFor(char *iconPath, char *wm_instance, char *wm_class)
{
WMPropList *dict = WDWindowAttributes->dictionary;
WMPropList *adict, *key, *iconk;
WMPropList *val;
char *tmp;
int i;
WMPropList *dict = WDWindowAttributes->dictionary;
WMPropList *adict, *key, *iconk;
WMPropList *val;
char *tmp;
int i;
i = 0;
if (wm_instance)
i += strlen(wm_instance);
if (wm_class)
i += strlen(wm_class);
i = 0;
if (wm_instance)
i += strlen(wm_instance);
if (wm_class)
i += strlen(wm_class);
tmp = wmalloc(i+8);
*tmp = 0;
if (wm_class && wm_instance) {
sprintf(tmp, "%s.%s", wm_instance, wm_class);
} else {
if (wm_instance)
strcat(tmp, wm_instance);
if (wm_class)
strcat(tmp, wm_class);
}
tmp = wmalloc(i + 8);
*tmp = 0;
if (wm_class && wm_instance) {
sprintf(tmp, "%s.%s", wm_instance, wm_class);
} else {
if (wm_instance)
strcat(tmp, wm_instance);
if (wm_class)
strcat(tmp, wm_class);
}
key = WMCreatePLString(tmp);
wfree(tmp);
adict = WMGetFromPLDictionary(dict, key);
key = WMCreatePLString(tmp);
wfree(tmp);
adict = WMGetFromPLDictionary(dict, key);
iconk = WMCreatePLString("Icon");
iconk = WMCreatePLString("Icon");
if (adict) {
val = WMGetFromPLDictionary(adict, iconk);
} else {
/* no dictionary for app, so create one */
adict = WMCreatePLDictionary(NULL, NULL);
WMPutInPLDictionary(dict, key, adict);
WMReleasePropList(adict);
val = NULL;
}
if (!val) {
val = WMCreatePLString(iconPath);
WMPutInPLDictionary(adict, iconk, val);
WMReleasePropList(val);
}
WMReleasePropList(key);
WMReleasePropList(iconk);
if (adict) {
val = WMGetFromPLDictionary(adict, iconk);
} else {
/* no dictionary for app, so create one */
adict = WMCreatePLDictionary(NULL, NULL);
WMPutInPLDictionary(dict, key, adict);
WMReleasePropList(adict);
val = NULL;
}
if (!val) {
val = WMCreatePLString(iconPath);
WMPutInPLDictionary(adict, iconk, val);
WMReleasePropList(val);
}
WMReleasePropList(key);
WMReleasePropList(iconk);
if (val && !wPreferences.flags.noupdates) {
UpdateDomainFile(WDWindowAttributes);
}
if (val && !wPreferences.flags.noupdates) {
UpdateDomainFile(WDWindowAttributes);
}
}
void
wApplicationExtractDirPackIcon(WScreen *scr, char *path,
char *wm_instance, char *wm_class)
void wApplicationExtractDirPackIcon(WScreen * scr, char *path, char *wm_instance, char *wm_class)
{
char *iconPath=NULL;
/* Maybe the app is a .app and it has an icon in it, like
* /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
*/
if (strstr(path, ".app")) {
char *tmp;
char *iconPath = NULL;
/* Maybe the app is a .app and it has an icon in it, like
* /usr/local/GNUstep/Applications/WPrefs.app/WPrefs.tiff
*/
if (strstr(path, ".app")) {
char *tmp;
tmp = wmalloc(strlen(path)+16);
tmp = wmalloc(strlen(path) + 16);
if (scr->flags.supports_tiff) {
strcpy(tmp, path);
strcat(tmp, ".tiff");
if (access(tmp, R_OK)==0)
iconPath = tmp;
}
if (!path) {
strcpy(tmp, path);
strcat(tmp, ".xpm");
if (access(tmp, R_OK)==0)
iconPath = tmp;
}
if (!iconPath)
wfree(tmp);
}
if (scr->flags.supports_tiff) {
strcpy(tmp, path);
strcat(tmp, ".tiff");
if (access(tmp, R_OK) == 0)
iconPath = tmp;
}
if (!path) {
strcpy(tmp, path);
strcat(tmp, ".xpm");
if (access(tmp, R_OK) == 0)
iconPath = tmp;
}
if (!iconPath)
wfree(tmp);
}
if (iconPath) {
saveIconNameFor(iconPath, wm_instance, wm_class);
if (iconPath) {
saveIconNameFor(iconPath, wm_instance, wm_class);
wfree(iconPath);
}
wfree(iconPath);
}
}
static Bool
extractClientIcon(WAppIcon *icon)
static Bool extractClientIcon(WAppIcon * icon)
{
char *path;
char *path;
path = wIconStore(icon->icon);
if (!path)
return False;
path = wIconStore(icon->icon);
if (!path)
return False;
saveIconNameFor(path, icon->wm_instance, icon->wm_class);
saveIconNameFor(path, icon->wm_instance, icon->wm_class);
wfree(path);
wfree(path);
return True;
return True;
}
WApplication*
wApplicationCreate(WWindow *wwin)
WApplication *wApplicationCreate(WWindow * wwin)
{
WScreen *scr = wwin->screen_ptr;
Window main_window = wwin->main_window;
WApplication *wapp;
WWindow *leader;
WScreen *scr = wwin->screen_ptr;
Window main_window = wwin->main_window;
WApplication *wapp;
WWindow *leader;
if (main_window==None || main_window==scr->root_win) {
if (main_window == None || main_window == scr->root_win) {
#ifdef DEBUG0
wwarning("trying to create application for %x",(unsigned)main_window);
wwarning("trying to create application for %x", (unsigned)main_window);
#endif
return NULL;
}
return NULL;
}
{
Window root;
int foo;
unsigned int bar;
/* check if the window is valid */
if (!XGetGeometry(dpy, main_window, &root, &foo, &foo, &bar, &bar,
&bar, &bar)) {
return NULL;
}
}
{
Window root;
int foo;
unsigned int bar;
/* check if the window is valid */
if (!XGetGeometry(dpy, main_window, &root, &foo, &foo, &bar, &bar, &bar, &bar)) {
return NULL;
}
}
wapp = wApplicationOf(main_window);
if (wapp) {
wapp->refcount++;
if (wapp->app_icon && wapp->app_icon->docked &&
wapp->app_icon->relaunching && wapp->main_window_desc->fake_group) {
wDockFinishLaunch(wapp->app_icon->dock, wapp->app_icon);
}
wapp = wApplicationOf(main_window);
if (wapp) {
wapp->refcount++;
if (wapp->app_icon && wapp->app_icon->docked &&
wapp->app_icon->relaunching && wapp->main_window_desc->fake_group) {
wDockFinishLaunch(wapp->app_icon->dock, wapp->app_icon);
}
return wapp;
}
return wapp;
}
wapp = wmalloc(sizeof(WApplication));
memset(wapp, 0, sizeof(WApplication));
wapp = wmalloc(sizeof(WApplication));
memset(wapp, 0, sizeof(WApplication));
wapp->refcount = 1;
wapp->last_focused = NULL;
wapp->refcount = 1;
wapp->last_focused = NULL;
wapp->last_workspace = 0;
wapp->last_workspace = 0;
wapp->main_window = main_window;
wapp->main_window_desc = makeMainWindow(scr, main_window);
if (!wapp->main_window_desc) {
wfree(wapp);
return NULL;
}
wapp->main_window = main_window;
wapp->main_window_desc = makeMainWindow(scr, main_window);
if (!wapp->main_window_desc) {
wfree(wapp);
return NULL;
}
wapp->main_window_desc->fake_group = wwin->fake_group;
wapp->main_window_desc->fake_group = wwin->fake_group;
#ifdef NETWM_HINTS
wapp->main_window_desc->net_icon_image = RRetainImage(wwin->net_icon_image);
wapp->main_window_desc->net_icon_image = RRetainImage(wwin->net_icon_image);
#endif
extractIcon(wapp->main_window_desc);
extractIcon(wapp->main_window_desc);
leader = wWindowFor(main_window);
if (leader) {
leader->main_window = main_window;
}
wapp->menu = wAppMenuGet(scr, main_window);
leader = wWindowFor(main_window);
if (leader) {
leader->main_window = main_window;
}
wapp->menu = wAppMenuGet(scr, main_window);
#ifdef USER_MENU
if (!wapp->menu) wapp->menu = wUserMenuGet(scr, wapp->main_window_desc);
#endif /* USER_MENU */
if (!wapp->menu)
wapp->menu = wUserMenuGet(scr, wapp->main_window_desc);
#endif /* USER_MENU */
/*
* Set application wide attributes from the leader.
*/
wapp->flags.hidden = WFLAGP(wapp->main_window_desc, start_hidden);
/*
* Set application wide attributes from the leader.
*/
wapp->flags.hidden = WFLAGP(wapp->main_window_desc, start_hidden);
wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon);
wapp->flags.emulated = WFLAGP(wapp->main_window_desc, emulate_appicon);
/* application descriptor */
XSaveContext(dpy, main_window, wAppWinContext, (XPointer) wapp);
/* application descriptor */
XSaveContext(dpy, main_window, wAppWinContext, (XPointer)wapp);
if (!WFLAGP(wapp->main_window_desc, no_appicon)) {
wapp->app_icon = NULL;
if (scr->last_dock)
wapp->app_icon = findDockIconFor(scr->last_dock, main_window);
/* check main dock if we did not find it in last dock */
if (!wapp->app_icon && scr->dock) {
wapp->app_icon = findDockIconFor(scr->dock, main_window);
}
/* finally check clips */
if (!wapp->app_icon) {
int i;
for (i = 0; i < scr->workspace_count; i++) {
WDock *dock = scr->workspaces[i]->clip;
if (dock)
wapp->app_icon = findDockIconFor(dock, main_window);
if (wapp->app_icon)
break;
}
}
if (!WFLAGP(wapp->main_window_desc, no_appicon)) {
wapp->app_icon = NULL;
if (scr->last_dock)
wapp->app_icon = findDockIconFor(scr->last_dock, main_window);
/* check main dock if we did not find it in last dock */
if (!wapp->app_icon && scr->dock) {
wapp->app_icon = findDockIconFor(scr->dock, main_window);
}
/* finally check clips */
if (!wapp->app_icon) {
int i;
for (i=0; i<scr->workspace_count; i++) {
WDock *dock = scr->workspaces[i]->clip;
if (dock)
wapp->app_icon = findDockIconFor(dock, main_window);
if (wapp->app_icon)
break;
}
}
if (wapp->app_icon) {
WWindow *mainw = wapp->main_window_desc;
if (wapp->app_icon) {
WWindow *mainw = wapp->main_window_desc;
wapp->app_icon->running = 1;
wapp->app_icon->icon->force_paint = 1;
wapp->app_icon->icon->owner = mainw;
if (mainw->wm_hints && (mainw->wm_hints->flags & IconWindowHint))
wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window;
wAppIconPaint(wapp->app_icon);
} else {
wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
}
} else {
wapp->app_icon = NULL;
}
wapp->app_icon->running = 1;
wapp->app_icon->icon->force_paint = 1;
wapp->app_icon->icon->owner = mainw;
if (mainw->wm_hints && (mainw->wm_hints->flags&IconWindowHint))
wapp->app_icon->icon->icon_win = mainw->wm_hints->icon_window;
wAppIconPaint(wapp->app_icon);
} else {
wapp->app_icon = wAppIconCreate(wapp->main_window_desc);
}
} else {
wapp->app_icon = NULL;
}
if (wapp->app_icon) {
wapp->app_icon->main_window = main_window;
}
if (wapp->app_icon) {
wapp->app_icon->main_window = main_window;
}
if (wapp->app_icon && !wapp->app_icon->docked) {
WIcon *icon = wapp->app_icon->icon;
WDock *clip = scr->workspaces[scr->current_workspace]->clip;
int x = 0, y = 0;
if (wapp->app_icon && !wapp->app_icon->docked) {
WIcon *icon = wapp->app_icon->icon;
WDock *clip = scr->workspaces[scr->current_workspace]->clip;
int x=0, y=0;
if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
wapp->app_icon->attracted = 1;
if (!icon->shadowed) {
icon->shadowed = 1;
icon->force_paint = 1;
/* wAppIconPaint() is done in wDockAttachIcon() below */
}
wDockAttachIcon(clip, wapp->app_icon, x, y);
} else {
PlaceIcon(scr, &x, &y, wGetHeadForWindow(wapp->main_window_desc));
wAppIconMove(wapp->app_icon, x, y);
wLowerFrame(icon->core);
}
if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
XMapWindow(dpy, icon->core->window);
}
if (clip && clip->attract_icons && wDockFindFreeSlot(clip, &x, &y)) {
wapp->app_icon->attracted = 1;
if (!icon->shadowed) {
icon->shadowed = 1;
icon->force_paint = 1;
/* wAppIconPaint() is done in wDockAttachIcon() below */
}
wDockAttachIcon(clip, wapp->app_icon, x, y);
} else {
PlaceIcon(scr, &x, &y, wGetHeadForWindow(wapp->main_window_desc));
wAppIconMove(wapp->app_icon, x, y);
wLowerFrame(icon->core);
}
if (!clip || !wapp->app_icon->attracted || !clip->collapsed)
XMapWindow(dpy, icon->core->window);
}
if (wPreferences.auto_arrange_icons && wapp->app_icon && !wapp->app_icon->attracted) {
wArrangeIcons(scr, True);
}
if (wPreferences.auto_arrange_icons && wapp->app_icon && !wapp->app_icon->attracted) {
wArrangeIcons(scr, True);
}
if (wapp->app_icon) {
char *tmp, *path;
struct stat dummy;
RImage *image;
if (wapp->app_icon) {
char *tmp, *path;
struct stat dummy;
RImage *image;
tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True);
tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance,
wapp->app_icon->wm_class, True);
/* If the icon was saved by us from the client supplied icon, but is
* missing, recreate it. */
if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL &&
stat(tmp, &dummy) != 0 && errno == ENOENT) {
wmessage(_("recreating missing icon '%s'"), tmp);
path = wIconStore(wapp->app_icon->icon);
if (path) {
wfree(path);
}
image = wDefaultGetImage(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class);
if (image) {
wIconChangeImage(wapp->app_icon->icon, image);
wAppIconPaint(wapp->app_icon);
/* TODO:
* wIconChangeImage() should be rewriten to use retain/release
* The way it is now is too confusing about where the icon is
* finally released. -Dan */
/* --this is wrong at the moment-- RReleaseImage(image); */
}
}
/* If the icon was saved by us from the client supplied icon, but is
* missing, recreate it. */
if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps")!=NULL &&
stat(tmp, &dummy)!=0 && errno==ENOENT) {
wmessage(_("recreating missing icon '%s'"), tmp);
path = wIconStore(wapp->app_icon->icon);
if (path) {
wfree(path);
}
image = wDefaultGetImage(scr, wapp->app_icon->wm_instance,
wapp->app_icon->wm_class);
if (image) {
wIconChangeImage(wapp->app_icon->icon, image);
wAppIconPaint(wapp->app_icon);
/* TODO:
* wIconChangeImage() should be rewriten to use retain/release
* The way it is now is too confusing about where the icon is
* finally released. -Dan */
/* --this is wrong at the moment-- RReleaseImage(image);*/
}
}
/* if the displayed icon was supplied by the client, save the icon */
if (!tmp)
extractClientIcon(wapp->app_icon);
}
/* if the displayed icon was supplied by the client, save the icon */
if (!tmp)
extractClientIcon(wapp->app_icon);
}
wSoundPlay(WSOUND_APPSTART);
wSoundPlay(WSOUND_APPSTART);
#ifdef DEBUG
printf("Created application for %x\n", (unsigned)main_window);
printf("Created application for %x\n", (unsigned)main_window);
#endif
return wapp;
return wapp;
}
void
wApplicationDestroy(WApplication *wapp)
void wApplicationDestroy(WApplication * wapp)
{
Window main_window;
WWindow *wwin;
WScreen *scr;
Window main_window;
WWindow *wwin;
WScreen *scr;
if (!wapp)
return;
if (!wapp)
return;
wapp->refcount--;
if (wapp->refcount>0)
return;
wapp->refcount--;
if (wapp->refcount > 0)
return;
scr = wapp->main_window_desc->screen_ptr;
main_window = wapp->main_window;
scr = wapp->main_window_desc->screen_ptr;
main_window = wapp->main_window;
if (wapp == scr->wapp_list) {
if (wapp->next)
wapp->next->prev = NULL;
scr->wapp_list = wapp->next;
} else {
if (wapp->next)
wapp->next->prev = wapp->prev;
if (wapp->prev)
wapp->prev->next = wapp->next;
}
if (wapp == scr->wapp_list) {
if (wapp->next)
wapp->next->prev = NULL;
scr->wapp_list = wapp->next;
} else {
if (wapp->next)
wapp->next->prev = wapp->prev;
if (wapp->prev)
wapp->prev->next = wapp->next;
}
XDeleteContext(dpy, wapp->main_window, wAppWinContext);
wAppMenuDestroy(wapp->menu);
if (wapp->app_icon) {
if (wapp->app_icon->docked && !wapp->app_icon->attracted) {
wapp->app_icon->running = 0;
/* since we keep it, we don't care if it was attracted or not */
wapp->app_icon->attracted = 0;
wapp->app_icon->icon->shadowed = 0;
wapp->app_icon->main_window = None;
wapp->app_icon->pid = 0;
wapp->app_icon->icon->owner = NULL;
wapp->app_icon->icon->icon_win = None;
wapp->app_icon->icon->force_paint = 1;
wAppIconPaint(wapp->app_icon);
} else if (wapp->app_icon->docked) {
wapp->app_icon->running = 0;
wDockDetach(wapp->app_icon->dock, wapp->app_icon);
} else {
wAppIconDestroy(wapp->app_icon);
}
}
wwin = wWindowFor(wapp->main_window_desc->client_win);
XDeleteContext(dpy, wapp->main_window, wAppWinContext);
wAppMenuDestroy(wapp->menu);
if (wapp->app_icon) {
if (wapp->app_icon->docked && !wapp->app_icon->attracted) {
wapp->app_icon->running = 0;
/* since we keep it, we don't care if it was attracted or not */
wapp->app_icon->attracted = 0;
wapp->app_icon->icon->shadowed = 0;
wapp->app_icon->main_window = None;
wapp->app_icon->pid = 0;
wapp->app_icon->icon->owner = NULL;
wapp->app_icon->icon->icon_win = None;
wapp->app_icon->icon->force_paint = 1;
wAppIconPaint(wapp->app_icon);
} else if (wapp->app_icon->docked) {
wapp->app_icon->running = 0;
wDockDetach(wapp->app_icon->dock, wapp->app_icon);
} else {
wAppIconDestroy(wapp->app_icon);
}
}
wwin = wWindowFor(wapp->main_window_desc->client_win);
wWindowDestroy(wapp->main_window_desc);
if (wwin) {
/* undelete client window context that was deleted in
* wWindowDestroy */
XSaveContext(dpy, wwin->client_win, wWinContext,
(XPointer)&wwin->client_descriptor);
}
wfree(wapp);
wWindowDestroy(wapp->main_window_desc);
if (wwin) {
/* undelete client window context that was deleted in
* wWindowDestroy */
XSaveContext(dpy, wwin->client_win, wWinContext, (XPointer) & wwin->client_descriptor);
}
wfree(wapp);
#ifdef DEBUG
printf("Destroyed application for %x\n", (unsigned)main_window);
printf("Destroyed application for %x\n", (unsigned)main_window);
#endif
if (wPreferences.auto_arrange_icons) {
wArrangeIcons(scr, True);
}
if (wPreferences.auto_arrange_icons) {
wArrangeIcons(scr, True);
}
wSoundPlay(WSOUND_APPEXIT);
wSoundPlay(WSOUND_APPEXIT);
}
+193 -228
View File
@@ -39,7 +39,6 @@
#include "framewin.h"
/******** Global Variables **********/
extern Atom _XA_WINDOWMAKER_MENU;
extern Atom _XA_WINDOWMAKER_WM_PROTOCOLS;
@@ -48,290 +47,256 @@ extern Time LastTimestamp;
extern WPreferences wPreferences;
typedef struct {
short code;
short tag;
Window window;
short code;
short tag;
Window window;
} WAppMenuData;
enum {
wmBeginMenu = 1,
wmEndMenu = 2,
wmNormalItem = 10,
wmDoubleItem = 11,
wmSubmenuItem = 12
wmBeginMenu = 1,
wmEndMenu = 2,
wmNormalItem = 10,
wmDoubleItem = 11,
wmSubmenuItem = 12
};
enum {
wmSelectItem = 1
wmSelectItem = 1
};
static void
sendMessage(Window window, int what, int tag)
static void sendMessage(Window window, int what, int tag)
{
XEvent event;
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.message_type = _XA_WINDOWMAKER_MENU;
event.xclient.format = 32;
event.xclient.display = dpy;
event.xclient.window = window;
event.xclient.data.l[0] = LastTimestamp;
event.xclient.data.l[1] = what;
event.xclient.data.l[2] = tag;
event.xclient.data.l[3] = 0;
XSendEvent(dpy, window, False, NoEventMask, &event);
XFlush(dpy);
event.xclient.type = ClientMessage;
event.xclient.message_type = _XA_WINDOWMAKER_MENU;
event.xclient.format = 32;
event.xclient.display = dpy;
event.xclient.window = window;
event.xclient.data.l[0] = LastTimestamp;
event.xclient.data.l[1] = what;
event.xclient.data.l[2] = tag;
event.xclient.data.l[3] = 0;
XSendEvent(dpy, window, False, NoEventMask, &event);
XFlush(dpy);
}
static void
notifyClient(WMenu *menu, WMenuEntry *entry)
static void notifyClient(WMenu * menu, WMenuEntry * entry)
{
WAppMenuData *data = entry->clientdata;
WAppMenuData *data = entry->clientdata;
sendMessage(data->window, wmSelectItem, data->tag);
sendMessage(data->window, wmSelectItem, data->tag);
}
static WMenu*
parseMenuCommand(WScreen *scr, Window win, char **slist, int count, int *index)
static WMenu *parseMenuCommand(WScreen * scr, Window win, char **slist, int count, int *index)
{
WMenu *menu;
int command;
int code, pos;
char title[300];
char rtext[300];
WMenu *menu;
int command;
int code, pos;
char title[300];
char rtext[300];
if (strlen(slist[*index])>300) {
wwarning("appmenu: menu command size exceeded in window %x", win);
return NULL;
}
if (sscanf(slist[*index], "%i %i %n", &command, &code, &pos)<2
|| command!=wmBeginMenu) {
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
menu = wMenuCreateForApp(scr, title, *index==1);
if (!menu)
return NULL;
*index += 1;
while (*index<count) {
int ecode, etag, enab;
if (strlen(slist[*index]) > 300) {
wwarning("appmenu: menu command size exceeded in window %x", win);
return NULL;
}
if (sscanf(slist[*index], "%i %i %n", &command, &code, &pos) < 2 || command != wmBeginMenu) {
wwarning("appmenu: bad menu entry \"%s\" in window %x", slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
menu = wMenuCreateForApp(scr, title, *index == 1);
if (!menu)
return NULL;
*index += 1;
while (*index < count) {
int ecode, etag, enab;
if (sscanf(slist[*index], "%i", &command)!=1) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
if (sscanf(slist[*index], "%i", &command) != 1) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x", slist[*index], win);
return NULL;
}
if (command==wmEndMenu) {
*index += 1;
break;
if (command == wmEndMenu) {
*index += 1;
break;
} else if (command==wmNormalItem
|| command==wmDoubleItem) {
WAppMenuData *data;
WMenuEntry *entry;
} else if (command == wmNormalItem || command == wmDoubleItem) {
WAppMenuData *data;
WMenuEntry *entry;
if (command == wmNormalItem) {
if (sscanf(slist[*index], "%i %i %i %i %n",
&command, &ecode, &etag, &enab, &pos)!=4
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
rtext[0] = 0;
} else {
if (sscanf(slist[*index], "%i %i %i %i %s %n",
&command, &ecode, &etag, &enab, rtext, &pos)!=5
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
}
if (!(data = malloc(sizeof(WAppMenuData)))) {
wwarning("appmenu: out of memory making menu for window %x",
win);
wMenuDestroy(menu, True);
return NULL;
}
data->code = code;
data->tag = etag;
data->window = win;
entry = wMenuAddCallback(menu, title, notifyClient, data);
if (!entry) {
wMenuDestroy(menu, True);
wwarning("appmenu: out of memory creating menu for window %x",
slist[*index], win);
wfree(data);
return NULL;
}
if (rtext[0]!=0)
entry->rtext = wstrdup(rtext);
else
entry->rtext = NULL;
entry->free_cdata = free;
*index += 1;
if (command == wmNormalItem) {
if (sscanf(slist[*index], "%i %i %i %i %n",
&command, &ecode, &etag, &enab, &pos) != 4 || ecode != code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
rtext[0] = 0;
} else {
if (sscanf(slist[*index], "%i %i %i %i %s %n",
&command, &ecode, &etag, &enab, rtext, &pos) != 5 || ecode != code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
}
if (!(data = malloc(sizeof(WAppMenuData)))) {
wwarning("appmenu: out of memory making menu for window %x", win);
wMenuDestroy(menu, True);
return NULL;
}
data->code = code;
data->tag = etag;
data->window = win;
entry = wMenuAddCallback(menu, title, notifyClient, data);
if (!entry) {
wMenuDestroy(menu, True);
wwarning("appmenu: out of memory creating menu for window %x", slist[*index], win);
wfree(data);
return NULL;
}
if (rtext[0] != 0)
entry->rtext = wstrdup(rtext);
else
entry->rtext = NULL;
entry->free_cdata = free;
*index += 1;
} else if (command==wmSubmenuItem) {
int ncode;
WMenuEntry *entry;
WMenu *submenu;
} else if (command == wmSubmenuItem) {
int ncode;
WMenuEntry *entry;
WMenu *submenu;
if (sscanf(slist[*index], "%i %i %i %i %i %n",
&command, &ecode, &etag, &enab, &ncode, &pos)!=5
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
if (sscanf(slist[*index], "%i %i %i %i %i %n",
&command, &ecode, &etag, &enab, &ncode, &pos) != 5 || ecode != code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x", slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
*index += 1;
return NULL;
}
strcpy(title, &slist[*index][pos]);
*index += 1;
submenu = parseMenuCommand(scr, win, slist, count, index);
submenu = parseMenuCommand(scr, win, slist, count, index);
entry = wMenuAddCallback(menu, title, NULL, NULL);
entry = wMenuAddCallback(menu, title, NULL, NULL);
if (!entry) {
wMenuDestroy(menu, True);
wMenuDestroy(submenu, True);
wwarning("appmenu: out of memory creating menu for window %x",
slist[*index], win);
return NULL;
}
if (!entry) {
wMenuDestroy(menu, True);
wMenuDestroy(submenu, True);
wwarning("appmenu: out of memory creating menu for window %x", slist[*index], win);
return NULL;
}
wMenuEntrySetCascade(menu, entry, submenu);
wMenuEntrySetCascade(menu, entry, submenu);
} else {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
}
} else {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x", slist[*index], win);
return NULL;
}
}
return menu;
return menu;
}
WMenu*
wAppMenuGet(WScreen *scr, Window window)
WMenu *wAppMenuGet(WScreen * scr, Window window)
{
XTextProperty text_prop;
int count, i;
char **slist;
WMenu *menu;
XTextProperty text_prop;
int count, i;
char **slist;
WMenu *menu;
if (!XGetTextProperty(dpy, window, &text_prop, _XA_WINDOWMAKER_MENU)) {
return NULL;
}
if (!XTextPropertyToStringList(&text_prop, &slist, &count) || count<1) {
XFree(text_prop.value);
return NULL;
}
XFree(text_prop.value);
if (strcmp(slist[0], "WMMenu 0")!=0) {
wwarning("appmenu: unknown version of WMMenu in window %x: %s",
window, slist[0]);
XFreeStringList(slist);
return NULL;
}
if (!XGetTextProperty(dpy, window, &text_prop, _XA_WINDOWMAKER_MENU)) {
return NULL;
}
if (!XTextPropertyToStringList(&text_prop, &slist, &count) || count < 1) {
XFree(text_prop.value);
return NULL;
}
XFree(text_prop.value);
if (strcmp(slist[0], "WMMenu 0") != 0) {
wwarning("appmenu: unknown version of WMMenu in window %x: %s", window, slist[0]);
XFreeStringList(slist);
return NULL;
}
i = 1;
menu = parseMenuCommand(scr, window, slist, count, &i);
if (menu)
menu->parent = NULL;
i = 1;
menu = parseMenuCommand(scr, window, slist, count, &i);
if (menu)
menu->parent = NULL;
XFreeStringList(slist);
XFreeStringList(slist);
return menu;
return menu;
}
void
wAppMenuDestroy(WMenu *menu)
void wAppMenuDestroy(WMenu * menu)
{
if (menu)
wMenuDestroy(menu, True);
if (menu)
wMenuDestroy(menu, True);
}
static void
mapmenus(WMenu *menu)
static void mapmenus(WMenu * menu)
{
int i;
int i;
if (menu->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XMapWindow(dpy, menu->brother->frame->core->window);
for (i=0; i<menu->cascade_no; i++) {
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
}
if (menu->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XMapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
}
}
void
wAppMenuMap(WMenu *menu, WWindow *wwin)
void wAppMenuMap(WMenu * menu, WWindow * wwin)
{
if (!menu)
return;
if (!menu)
return;
if (!menu->flags.mapped) {
wMenuMap(menu);
}
if(wwin && (wPreferences.focus_mode!=WKF_CLICK)) {
int x, min;
if (!menu->flags.mapped) {
wMenuMap(menu);
}
if (wwin && (wPreferences.focus_mode != WKF_CLICK)) {
int x, min;
min = 20; /* Keep at least 20 pixels visible */
if (wwin->frame_x > min) {
x = wwin->frame_x - menu->frame->core->width;
}
else {
x = min - menu->frame->core->width;
}
wMenuMove(menu, x, wwin->frame_y, True);
}
mapmenus(menu);
min = 20; /* Keep at least 20 pixels visible */
if (wwin->frame_x > min) {
x = wwin->frame_x - menu->frame->core->width;
} else {
x = min - menu->frame->core->width;
}
wMenuMove(menu, x, wwin->frame_y, True);
}
mapmenus(menu);
}
static void
unmapmenus(WMenu *menu)
static void unmapmenus(WMenu * menu)
{
int i;
int i;
if (menu->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XUnmapWindow(dpy, menu->brother->frame->core->window);
for (i=0; i<menu->cascade_no; i++) {
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
}
if (menu->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XUnmapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
}
}
void
wAppMenuUnmap(WMenu *menu)
void wAppMenuUnmap(WMenu * menu)
{
if (menu)
unmapmenus(menu);
if (menu)
unmapmenus(menu);
}
+379 -451
View File
@@ -45,31 +45,28 @@
#include "workspace.h"
#include "balloon.h"
extern WPreferences wPreferences;
typedef struct _WBalloon {
Window window;
Window window;
#ifdef SHAPED_BALLOON
GC monoGC;
GC monoGC;
#endif
int prevType;
int prevType;
Window objectWindow;
char *text;
int h;
Window objectWindow;
char *text;
int h;
WMHandlerID timer;
WMHandlerID timer;
Pixmap contents;
Pixmap contents;
char mapped;
char ignoreTimer;
char mapped;
char ignoreTimer;
} WBalloon;
#define TOP 0
#define BOTTOM 1
#define LEFT 0
@@ -80,552 +77,483 @@ typedef struct _WBalloon {
#define BLEFT (BOTTOM|LEFT)
#define BRIGHT (BOTTOM|RIGHT)
static int
countLines(const char *text)
static int countLines(const char *text)
{
const char *p = text;
int h = 1;
const char *p = text;
int h = 1;
while (*p) {
if (*p == '\n' && p[1] != 0)
h++;
p++;
}
return h;
while (*p) {
if (*p == '\n' && p[1] != 0)
h++;
p++;
}
return h;
}
static int
getMaxStringWidth(WMFont *font, char *text)
static int getMaxStringWidth(WMFont * font, char *text)
{
char *p = text;
char *pb = p;
int pos = 0;
int w = 0, wt;
char *p = text;
char *pb = p;
int pos = 0;
int w = 0, wt;
while (*p) {
if (*p == '\n') {
wt = WMWidthOfString(font, pb, pos);
if (wt > w)
w = wt;
pos = 0;
pb = p + 1;
} else {
pos++;
}
p++;
}
if (pos > 0) {
wt = WMWidthOfString(font, pb, pos);
if (wt > w)
w = wt;
}
return w;
while (*p) {
if (*p == '\n') {
wt = WMWidthOfString(font, pb, pos);
if (wt > w)
w = wt;
pos = 0;
pb = p + 1;
} else {
pos++;
}
p++;
}
if (pos > 0) {
wt = WMWidthOfString(font, pb, pos);
if (wt > w)
w = wt;
}
return w;
}
static void
drawMultiLineString(WMScreen *scr, Pixmap pixmap, WMColor *color,
WMFont *font, int x, int y, char *text, int len)
drawMultiLineString(WMScreen * scr, Pixmap pixmap, WMColor * color,
WMFont * font, int x, int y, char *text, int len)
{
char *p = text;
char *pb = p;
int l = 0, pos = 0;
int height = WMFontHeight(font);
char *p = text;
char *pb = p;
int l = 0, pos = 0;
int height = WMFontHeight(font);
while (*p && p - text < len) {
if (*p == '\n') {
WMDrawString(scr, pixmap, color, font, x, y + l * height, pb,
pos);
l++;
pos = 0;
pb = p + 1;
} else {
pos++;
}
p++;
}
if (pos > 0) {
WMDrawString(scr, pixmap, color, font, x, y + l * height, pb, pos);
}
while (*p && p - text < len) {
if (*p == '\n') {
WMDrawString(scr, pixmap, color, font, x, y + l * height, pb, pos);
l++;
pos = 0;
pb = p + 1;
} else {
pos++;
}
p++;
}
if (pos > 0) {
WMDrawString(scr, pixmap, color, font, x, y + l * height, pb, pos);
}
}
#ifdef SHAPED_BALLOON
#define SPACE 12
static void
drawBalloon(WScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
int h, int side)
static void drawBalloon(WScreen * scr, Pixmap bitmap, Pixmap pix, int x, int y, int w, int h, int side)
{
GC bgc = scr->balloon->monoGC;
GC gc = scr->draw_gc;
int rad = h * 3 / 10;
XPoint pt[3], ipt[3];
int w1;
GC bgc = scr->balloon->monoGC;
GC gc = scr->draw_gc;
int rad = h * 3 / 10;
XPoint pt[3], ipt[3];
int w1;
/* outline */
XSetForeground(dpy, bgc, 1);
/* outline */
XSetForeground(dpy, bgc, 1);
XFillArc(dpy, bitmap, bgc, x, y, rad, rad, 90 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x, y + h - 1 - rad, rad, rad, 180 * 64,
90 * 64);
XFillArc(dpy, bitmap, bgc, x, y, rad, rad, 90 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x, y + h - 1 - rad, rad, rad, 180 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y, rad, rad, 0 * 64,
90 * 64);
XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y + h - 1 - rad, rad, rad,
270 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y, rad, rad, 0 * 64, 90 * 64);
XFillArc(dpy, bitmap, bgc, x + w - 1 - rad, y + h - 1 - rad, rad, rad, 270 * 64, 90 * 64);
XFillRectangle(dpy, bitmap, bgc, x, y + rad / 2, w, h - rad);
XFillRectangle(dpy, bitmap, bgc, x + rad / 2, y, w - rad, h);
XFillRectangle(dpy, bitmap, bgc, x, y + rad / 2, w, h - rad);
XFillRectangle(dpy, bitmap, bgc, x + rad / 2, y, w - rad, h);
/* interior */
XSetForeground(dpy, gc, scr->white_pixel);
/* interior */
XSetForeground(dpy, gc, scr->white_pixel);
XFillArc(dpy, pix, gc, x + 1, y + 1, rad, rad, 90 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + 1, y + h - 2 - rad, rad, rad, 180 * 64,
90 * 64);
XFillArc(dpy, pix, gc, x + 1, y + 1, rad, rad, 90 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + 1, y + h - 2 - rad, rad, rad, 180 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + w - 2 - rad, y + 1, rad, rad, 0 * 64,
90 * 64);
XFillArc(dpy, pix, gc, x + w - 2 - rad, y + h - 2 - rad, rad, rad,
270 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + w - 2 - rad, y + 1, rad, rad, 0 * 64, 90 * 64);
XFillArc(dpy, pix, gc, x + w - 2 - rad, y + h - 2 - rad, rad, rad, 270 * 64, 90 * 64);
XFillRectangle(dpy, pix, gc, x + 1, y + 1 + rad / 2, w - 2,
h - 2 - rad);
XFillRectangle(dpy, pix, gc, x + 1 + rad / 2, y + 1, w - 2 - rad,
h - 2);
XFillRectangle(dpy, pix, gc, x + 1, y + 1 + rad / 2, w - 2, h - 2 - rad);
XFillRectangle(dpy, pix, gc, x + 1 + rad / 2, y + 1, w - 2 - rad, h - 2);
if (side & BOTTOM) {
pt[0].y = y + h - 1;
pt[1].y = y + h - 1 + SPACE;
pt[2].y = y + h - 1;
ipt[0].y = pt[0].y - 1;
ipt[1].y = pt[1].y - 1;
ipt[2].y = pt[2].y - 1;
} else {
pt[0].y = y;
pt[1].y = y - SPACE;
pt[2].y = y;
ipt[0].y = pt[0].y + 1;
ipt[1].y = pt[1].y + 1;
ipt[2].y = pt[2].y + 1;
}
if (side & BOTTOM) {
pt[0].y = y + h - 1;
pt[1].y = y + h - 1 + SPACE;
pt[2].y = y + h - 1;
ipt[0].y = pt[0].y - 1;
ipt[1].y = pt[1].y - 1;
ipt[2].y = pt[2].y - 1;
} else {
pt[0].y = y;
pt[1].y = y - SPACE;
pt[2].y = y;
ipt[0].y = pt[0].y + 1;
ipt[1].y = pt[1].y + 1;
ipt[2].y = pt[2].y + 1;
}
/*w1 = WMAX(h, 24); */
w1 = WMAX(h, 21);
/*w1 = WMAX(h, 24); */
w1 = WMAX(h, 21);
if (side & RIGHT) {
pt[0].x = x + w - w1 + 2 * w1 / 16;
pt[1].x = x + w - w1 + 11 * w1 / 16;
pt[2].x = x + w - w1 + 7 * w1 / 16;
ipt[0].x = x + 1 + w - w1 + 2 * (w1 - 1) / 16;
ipt[1].x = x + 1 + w - w1 + 11 * (w1 - 1) / 16;
ipt[2].x = x + 1 + w - w1 + 7 * (w1 - 1) / 16;
/*ipt[0].x = pt[0].x+1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x; */
} else {
pt[0].x = x + w1 - 2 * w1 / 16;
pt[1].x = x + w1 - 11 * w1 / 16;
pt[2].x = x + w1 - 7 * w1 / 16;
ipt[0].x = x - 1 + w1 - 2 * (w1 - 1) / 16;
ipt[1].x = x - 1 + w1 - 11 * (w1 - 1) / 16;
ipt[2].x = x - 1 + w1 - 7 * (w1 - 1) / 16;
/*ipt[0].x = pt[0].x-1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x; */
}
if (side & RIGHT) {
pt[0].x = x + w - w1 + 2 * w1 / 16;
pt[1].x = x + w - w1 + 11 * w1 / 16;
pt[2].x = x + w - w1 + 7 * w1 / 16;
ipt[0].x = x + 1 + w - w1 + 2 * (w1 - 1) / 16;
ipt[1].x = x + 1 + w - w1 + 11 * (w1 - 1) / 16;
ipt[2].x = x + 1 + w - w1 + 7 * (w1 - 1) / 16;
/*ipt[0].x = pt[0].x+1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x; */
} else {
pt[0].x = x + w1 - 2 * w1 / 16;
pt[1].x = x + w1 - 11 * w1 / 16;
pt[2].x = x + w1 - 7 * w1 / 16;
ipt[0].x = x - 1 + w1 - 2 * (w1 - 1) / 16;
ipt[1].x = x - 1 + w1 - 11 * (w1 - 1) / 16;
ipt[2].x = x - 1 + w1 - 7 * (w1 - 1) / 16;
/*ipt[0].x = pt[0].x-1;
ipt[1].x = pt[1].x;
ipt[2].x = pt[2].x; */
}
XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
XFillPolygon(dpy, pix, gc, ipt, 3, Convex, CoordModeOrigin);
/* fix outline */
XSetForeground(dpy, gc, scr->black_pixel);
/* fix outline */
XSetForeground(dpy, gc, scr->black_pixel);
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
if (side & RIGHT) {
pt[0].x++;
pt[2].x--;
} else {
pt[0].x--;
pt[2].x++;
}
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
if (side & RIGHT) {
pt[0].x++;
pt[2].x--;
} else {
pt[0].x--;
pt[2].x++;
}
XDrawLines(dpy, pix, gc, pt, 3, CoordModeOrigin);
}
static Pixmap
makePixmap(WScreen *scr, int width, int height, int side, Pixmap *mask)
static Pixmap makePixmap(WScreen * scr, int width, int height, int side, Pixmap * mask)
{
WBalloon *bal = scr->balloon;
Pixmap bitmap;
Pixmap pixmap;
int x, y;
WBalloon *bal = scr->balloon;
Pixmap bitmap;
Pixmap pixmap;
int x, y;
bitmap =
XCreatePixmap(dpy, scr->root_win, width + SPACE, height + SPACE,
1);
bitmap = XCreatePixmap(dpy, scr->root_win, width + SPACE, height + SPACE, 1);
if (!bal->monoGC) {
bal->monoGC = XCreateGC(dpy, bitmap, 0, NULL);
}
XSetForeground(dpy, bal->monoGC, 0);
XFillRectangle(dpy, bitmap, bal->monoGC, 0, 0, width + SPACE,
height + SPACE);
if (!bal->monoGC) {
bal->monoGC = XCreateGC(dpy, bitmap, 0, NULL);
}
XSetForeground(dpy, bal->monoGC, 0);
XFillRectangle(dpy, bitmap, bal->monoGC, 0, 0, width + SPACE, height + SPACE);
pixmap =
XCreatePixmap(dpy, scr->root_win, width + SPACE, height + SPACE,
scr->w_depth);
XSetForeground(dpy, scr->draw_gc, scr->black_pixel);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width + SPACE,
height + SPACE);
pixmap = XCreatePixmap(dpy, scr->root_win, width + SPACE, height + SPACE, scr->w_depth);
XSetForeground(dpy, scr->draw_gc, scr->black_pixel);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width + SPACE, height + SPACE);
if (side & BOTTOM) {
y = 0;
} else {
y = SPACE;
}
x = 0;
if (side & BOTTOM) {
y = 0;
} else {
y = SPACE;
}
x = 0;
drawBalloon(scr, bitmap, pixmap, x, y, width, height, side);
drawBalloon(scr, bitmap, pixmap, x, y, width, height, side);
*mask = bitmap;
*mask = bitmap;
return pixmap;
return pixmap;
}
static void
showText(WScreen *scr, int x, int y, int h, int w, char *text)
static void showText(WScreen * scr, int x, int y, int h, int w, char *text)
{
int width;
int height;
Pixmap pixmap;
Pixmap mask;
WMFont *font = scr->info_text_font;
int side = 0;
int ty;
int bx, by;
int width;
int height;
Pixmap pixmap;
Pixmap mask;
WMFont *font = scr->info_text_font;
int side = 0;
int ty;
int bx, by;
if (scr->balloon->contents)
XFreePixmap(dpy, scr->balloon->contents);
if (scr->balloon->contents)
XFreePixmap(dpy, scr->balloon->contents);
width = getMaxStringWidth(font, text) + 16;
height = countLines(text) * WMFontHeight(font) + 4;
width = getMaxStringWidth(font, text) + 16;
height = countLines(text) * WMFontHeight(font) + 4;
if (height < 16)
height = 16;
if (width < height)
width = height;
if (height < 16)
height = 16;
if (width < height)
width = height;
if (x + width > scr->scr_width) {
side = RIGHT;
bx = x - width + w / 2;
if (bx < 0)
bx = 0;
} else {
side = LEFT;
bx = x + w / 2;
}
if (bx + width > scr->scr_width)
bx = scr->scr_width - width;
if (x + width > scr->scr_width) {
side = RIGHT;
bx = x - width + w / 2;
if (bx < 0)
bx = 0;
} else {
side = LEFT;
bx = x + w / 2;
}
if (bx + width > scr->scr_width)
bx = scr->scr_width - width;
if (y - (height + SPACE) < 0) {
side |= TOP;
by = y + h - 1;
ty = SPACE;
} else {
side |= BOTTOM;
by = y - (height + SPACE);
ty = 0;
}
pixmap = makePixmap(scr, width, height, side, &mask);
if (y - (height + SPACE) < 0) {
side |= TOP;
by = y + h - 1;
ty = SPACE;
} else {
side |= BOTTOM;
by = y - (height + SPACE);
ty = 0;
}
pixmap = makePixmap(scr, width, height, side, &mask);
drawMultiLineString(scr->wmscreen, pixmap, scr->black, font, 8, ty + 2, text, strlen(text));
drawMultiLineString(scr->wmscreen, pixmap, scr->black, font, 8, ty + 2,
text, strlen(text));
XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
scr->balloon->contents = pixmap;
XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
scr->balloon->contents = pixmap;
XResizeWindow(dpy, scr->balloon->window, width, height + SPACE);
XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, mask, ShapeSet);
XFreePixmap(dpy, mask);
XMoveWindow(dpy, scr->balloon->window, bx, by);
XMapRaised(dpy, scr->balloon->window);
XResizeWindow(dpy, scr->balloon->window, width, height + SPACE);
XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, mask,
ShapeSet);
XFreePixmap(dpy, mask);
XMoveWindow(dpy, scr->balloon->window, bx, by);
XMapRaised(dpy, scr->balloon->window);
scr->balloon->mapped = 1;
scr->balloon->mapped = 1;
}
#else /* !SHAPED_BALLOON */
static void
showText(WScreen *scr, int x, int y, int h, int w, char *text)
static void showText(WScreen * scr, int x, int y, int h, int w, char *text)
{
int width;
int height;
Pixmap pixmap;
WMFont *font = scr->info_text_font;
int width;
int height;
Pixmap pixmap;
WMFont *font = scr->info_text_font;
if (scr->balloon->contents)
XFreePixmap(dpy, scr->balloon->contents);
if (scr->balloon->contents)
XFreePixmap(dpy, scr->balloon->contents);
width = getMaxStringWidth(font, text) + 8;
/*width = WMWidthOfString(font, text, strlen(text))+8;*/
height = countLines(text) * WMFontHeight(font) + 4;
width = getMaxStringWidth(font, text) + 8;
/*width = WMWidthOfString(font, text, strlen(text))+8; */
height = countLines(text) * WMFontHeight(font) + 4;
if (x < 0)
x = 0;
else if (x + width > scr->scr_width - 1)
x = scr->scr_width - width;
if (x < 0)
x = 0;
else if (x + width > scr->scr_width - 1)
x = scr->scr_width - width;
if (y - height - 2 < 0) {
y += h;
if (y < 0)
y = 0;
} else {
y -= height + 2;
}
if (y - height - 2 < 0) {
y += h;
if (y < 0)
y = 0;
} else {
y -= height + 2;
}
if (scr->window_title_texture[0])
XSetForeground(dpy, scr->draw_gc,
scr->window_title_texture[0]->any.color.pixel);
else
XSetForeground(dpy, scr->draw_gc, scr->light_pixel);
if (scr->window_title_texture[0])
XSetForeground(dpy, scr->draw_gc, scr->window_title_texture[0]->any.color.pixel);
else
XSetForeground(dpy, scr->draw_gc, scr->light_pixel);
pixmap =
XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);
pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);
drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0],
font, 4, 2, text, strlen(text));
drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font, 4, 2, text, strlen(text));
XResizeWindow(dpy, scr->balloon->window, width, height);
XMoveWindow(dpy, scr->balloon->window, x, y);
XResizeWindow(dpy, scr->balloon->window, width, height);
XMoveWindow(dpy, scr->balloon->window, x, y);
XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
XClearWindow(dpy, scr->balloon->window);
XMapRaised(dpy, scr->balloon->window);
XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);
XClearWindow(dpy, scr->balloon->window);
XMapRaised(dpy, scr->balloon->window);
scr->balloon->contents = pixmap;
scr->balloon->contents = pixmap;
scr->balloon->mapped = 1;
scr->balloon->mapped = 1;
}
#endif /* !SHAPED_BALLOON */
static void
showBalloon(WScreen *scr)
static void showBalloon(WScreen * scr)
{
int x, y;
Window foow;
unsigned foo, w;
int x, y;
Window foow;
unsigned foo, w;
if (scr->balloon) {
scr->balloon->timer = NULL;
scr->balloon->ignoreTimer = 1;
}
if (scr->balloon) {
scr->balloon->timer = NULL;
scr->balloon->ignoreTimer = 1;
}
if (!XGetGeometry(dpy, scr->balloon->objectWindow, &foow, &x, &y,
&w, &foo, &foo, &foo)) {
scr->balloon->prevType = 0;
return;
}
showText(scr, x, y, scr->balloon->h, w, scr->balloon->text);
if (!XGetGeometry(dpy, scr->balloon->objectWindow, &foow, &x, &y, &w, &foo, &foo, &foo)) {
scr->balloon->prevType = 0;
return;
}
showText(scr, x, y, scr->balloon->h, w, scr->balloon->text);
}
static void
frameBalloon(WObjDescriptor *object)
static void frameBalloon(WObjDescriptor * object)
{
WFrameWindow *fwin = (WFrameWindow *) object->parent;
WScreen *scr = fwin->core->screen_ptr;
WFrameWindow *fwin = (WFrameWindow *) object->parent;
WScreen *scr = fwin->core->screen_ptr;
if (fwin->titlebar != object->self
|| !fwin->flags.is_client_window_frame) {
wBalloonHide(scr);
return;
}
if (fwin->title && fwin->flags.incomplete_title) {
scr->balloon->h = (fwin->titlebar ? fwin->titlebar->height : 0);
scr->balloon->text = wstrdup(fwin->title);
scr->balloon->objectWindow = fwin->core->window;
scr->balloon->timer = WMAddTimerHandler(BALLOON_DELAY,
(WMCallback *) showBalloon,
scr);
}
if (fwin->titlebar != object->self || !fwin->flags.is_client_window_frame) {
wBalloonHide(scr);
return;
}
if (fwin->title && fwin->flags.incomplete_title) {
scr->balloon->h = (fwin->titlebar ? fwin->titlebar->height : 0);
scr->balloon->text = wstrdup(fwin->title);
scr->balloon->objectWindow = fwin->core->window;
scr->balloon->timer = WMAddTimerHandler(BALLOON_DELAY, (WMCallback *) showBalloon, scr);
}
}
static void
miniwindowBalloon(WObjDescriptor *object)
static void miniwindowBalloon(WObjDescriptor * object)
{
WIcon *icon = (WIcon *) object->parent;
WScreen *scr = icon->core->screen_ptr;
WIcon *icon = (WIcon *) object->parent;
WScreen *scr = icon->core->screen_ptr;
if (!icon->icon_name) {
wBalloonHide(scr);
return;
}
scr->balloon->h = icon->core->height;
scr->balloon->text = wstrdup(icon->icon_name);
scr->balloon->objectWindow = icon->core->window;
if ((scr->balloon->prevType == object->parent_type
|| scr->balloon->prevType == WCLASS_APPICON)
&& scr->balloon->ignoreTimer) {
XUnmapWindow(dpy, scr->balloon->window);
showBalloon(scr);
} else {
scr->balloon->timer = WMAddTimerHandler(BALLOON_DELAY,
(WMCallback *) showBalloon,
scr);
}
if (!icon->icon_name) {
wBalloonHide(scr);
return;
}
scr->balloon->h = icon->core->height;
scr->balloon->text = wstrdup(icon->icon_name);
scr->balloon->objectWindow = icon->core->window;
if ((scr->balloon->prevType == object->parent_type || scr->balloon->prevType == WCLASS_APPICON)
&& scr->balloon->ignoreTimer) {
XUnmapWindow(dpy, scr->balloon->window);
showBalloon(scr);
} else {
scr->balloon->timer = WMAddTimerHandler(BALLOON_DELAY, (WMCallback *) showBalloon, scr);
}
}
static void
appiconBalloon(WObjDescriptor *object)
static void appiconBalloon(WObjDescriptor * object)
{
WAppIcon *aicon = (WAppIcon *) object->parent;
WScreen *scr = aicon->icon->core->screen_ptr;
char *tmp;
WAppIcon *aicon = (WAppIcon *) object->parent;
WScreen *scr = aicon->icon->core->screen_ptr;
char *tmp;
if (aicon->command && aicon->wm_class) {
int len = strlen(aicon->command) + strlen(aicon->wm_class) + 8;
tmp = wmalloc(len);
snprintf(tmp, len, "%s\n(%s)", aicon->wm_class, aicon->command);
scr->balloon->text = tmp;
} else if (aicon->command) {
scr->balloon->text = wstrdup(aicon->command);
} else if (aicon->wm_class) {
scr->balloon->text = wstrdup(aicon->wm_class);
} else {
wBalloonHide(scr);
return;
}
scr->balloon->h = aicon->icon->core->height - 2;
if (aicon->command && aicon->wm_class) {
int len = strlen(aicon->command) + strlen(aicon->wm_class) + 8;
tmp = wmalloc(len);
snprintf(tmp, len, "%s\n(%s)", aicon->wm_class, aicon->command);
scr->balloon->text = tmp;
} else if (aicon->command) {
scr->balloon->text = wstrdup(aicon->command);
} else if (aicon->wm_class) {
scr->balloon->text = wstrdup(aicon->wm_class);
} else {
wBalloonHide(scr);
return;
}
scr->balloon->h = aicon->icon->core->height - 2;
scr->balloon->objectWindow = aicon->icon->core->window;
if ((scr->balloon->prevType == object->parent_type
|| scr->balloon->prevType == WCLASS_MINIWINDOW)
&& scr->balloon->ignoreTimer) {
XUnmapWindow(dpy, scr->balloon->window);
showBalloon(scr);
} else {
scr->balloon->timer = WMAddTimerHandler(BALLOON_DELAY,
(WMCallback *) showBalloon,
scr);
}
scr->balloon->objectWindow = aicon->icon->core->window;
if ((scr->balloon->prevType == object->parent_type || scr->balloon->prevType == WCLASS_MINIWINDOW)
&& scr->balloon->ignoreTimer) {
XUnmapWindow(dpy, scr->balloon->window);
showBalloon(scr);
} else {
scr->balloon->timer = WMAddTimerHandler(BALLOON_DELAY, (WMCallback *) showBalloon, scr);
}
}
void
wBalloonInitialize(WScreen *scr)
void wBalloonInitialize(WScreen * scr)
{
WBalloon *bal;
XSetWindowAttributes attribs;
unsigned long vmask;
WBalloon *bal;
XSetWindowAttributes attribs;
unsigned long vmask;
bal = wmalloc(sizeof(WBalloon));
memset(bal, 0, sizeof(WBalloon));
bal = wmalloc(sizeof(WBalloon));
memset(bal, 0, sizeof(WBalloon));
scr->balloon = bal;
scr->balloon = bal;
vmask = CWSaveUnder | CWOverrideRedirect | CWColormap | CWBackPixel
| CWBorderPixel;
attribs.save_under = True;
attribs.override_redirect = True;
attribs.colormap = scr->w_colormap;
attribs.background_pixel = scr->icon_back_texture->normal.pixel;
attribs.border_pixel = 0; /* do not care */
vmask = CWSaveUnder | CWOverrideRedirect | CWColormap | CWBackPixel | CWBorderPixel;
attribs.save_under = True;
attribs.override_redirect = True;
attribs.colormap = scr->w_colormap;
attribs.background_pixel = scr->icon_back_texture->normal.pixel;
attribs.border_pixel = 0; /* do not care */
bal->window = XCreateWindow(dpy, scr->root_win, 1, 1, 10, 10, 1,
scr->w_depth, CopyFromParent,
scr->w_visual, vmask, &attribs);
bal->window = XCreateWindow(dpy, scr->root_win, 1, 1, 10, 10, 1,
scr->w_depth, CopyFromParent, scr->w_visual, vmask, &attribs);
#if 0
/* select EnterNotify to so that the balloon will be unmapped
* when the pointer is moved over it */
XSelectInput(dpy, bal->window, EnterWindowMask);
/* select EnterNotify to so that the balloon will be unmapped
* when the pointer is moved over it */
XSelectInput(dpy, bal->window, EnterWindowMask);
#endif
}
void
wBalloonEnteredObject(WScreen *scr, WObjDescriptor *object)
void wBalloonEnteredObject(WScreen * scr, WObjDescriptor * object)
{
WBalloon *balloon = scr->balloon;
WBalloon *balloon = scr->balloon;
if (balloon->timer) {
WMDeleteTimerHandler(balloon->timer);
balloon->timer = NULL;
balloon->ignoreTimer = 0;
}
if (balloon->timer) {
WMDeleteTimerHandler(balloon->timer);
balloon->timer = NULL;
balloon->ignoreTimer = 0;
}
if (scr->balloon->text)
wfree(scr->balloon->text);
scr->balloon->text = NULL;
if (scr->balloon->text)
wfree(scr->balloon->text);
scr->balloon->text = NULL;
if (!object) {
wBalloonHide(scr);
balloon->ignoreTimer = 0;
return;
}
switch (object->parent_type) {
case WCLASS_FRAME:
if (wPreferences.window_balloon) {
frameBalloon(object);
}
break;
if (!object) {
wBalloonHide(scr);
balloon->ignoreTimer = 0;
return;
}
switch (object->parent_type) {
case WCLASS_FRAME:
if (wPreferences.window_balloon) {
frameBalloon(object);
}
break;
case WCLASS_DOCK_ICON:
if (object->parent != scr->clip_icon
&& wPreferences.appicon_balloon)
appiconBalloon(object);
else
wBalloonHide(scr);
break;
case WCLASS_DOCK_ICON:
if (object->parent != scr->clip_icon && wPreferences.appicon_balloon)
appiconBalloon(object);
else
wBalloonHide(scr);
break;
case WCLASS_MINIWINDOW:
if (wPreferences.miniwin_balloon) {
miniwindowBalloon(object);
}
break;
case WCLASS_APPICON:
if (wPreferences.appicon_balloon)
appiconBalloon(object);
break;
default:
wBalloonHide(scr);
break;
}
scr->balloon->prevType = object->parent_type;
case WCLASS_MINIWINDOW:
if (wPreferences.miniwin_balloon) {
miniwindowBalloon(object);
}
break;
case WCLASS_APPICON:
if (wPreferences.appicon_balloon)
appiconBalloon(object);
break;
default:
wBalloonHide(scr);
break;
}
scr->balloon->prevType = object->parent_type;
}
void
wBalloonHide(WScreen *scr)
void wBalloonHide(WScreen * scr)
{
if (scr) {
if (scr->balloon->mapped) {
XUnmapWindow(dpy, scr->balloon->window);
scr->balloon->mapped = 0;
} else if (scr->balloon->timer) {
WMDeleteTimerHandler(scr->balloon->timer);
scr->balloon->timer = NULL;
}
scr->balloon->prevType = 0;
}
if (scr) {
if (scr->balloon->mapped) {
XUnmapWindow(dpy, scr->balloon->window);
scr->balloon->mapped = 0;
} else if (scr->balloon->timer) {
WMDeleteTimerHandler(scr->balloon->timer);
scr->balloon->timer = NULL;
}
scr->balloon->prevType = 0;
}
}
#endif
+549 -582
View File
File diff suppressed because it is too large. Load diff
+74 -85
View File
@@ -24,116 +24,105 @@
* USA.
*/
#include "wconfig.h"
#include "WindowMaker.h"
#include <X11/Xatom.h>
#include "window.h"
#include "framewin.h"
void
wColormapInstallForWindow(WScreen *scr, WWindow *wwin)
void wColormapInstallForWindow(WScreen * scr, WWindow * wwin)
{
int i;
XWindowAttributes attributes;
int done = 0;
Window xwin = None;
int i;
XWindowAttributes attributes;
int done = 0;
Window xwin = None;
if (wwin) {
xwin = wwin->client_win;
} else {
xwin = scr->root_win;
}
if (wwin) {
xwin = wwin->client_win;
} else {
xwin = scr->root_win;
}
scr->cmap_window = wwin;
scr->cmap_window = wwin;
if (scr->root_colormap_install_count > 0) {
scr->original_cmap_window = wwin;
return;
}
if (scr->root_colormap_install_count > 0) {
scr->original_cmap_window = wwin;
return;
}
/* install colormap for all windows of the client */
if (wwin && wwin->cmap_window_no > 0 && wwin->cmap_windows) {
for (i = wwin->cmap_window_no - 1; i >= 0; i--) {
Window w;
/* install colormap for all windows of the client */
if (wwin && wwin->cmap_window_no > 0 && wwin->cmap_windows) {
for (i = wwin->cmap_window_no - 1; i >= 0; i--) {
Window w;
w = wwin->cmap_windows[i];
if (w == wwin->client_win)
done = 1;
w = wwin->cmap_windows[i];
if (w == wwin->client_win)
done = 1;
XGetWindowAttributes(dpy, w, &attributes);
if (attributes.colormap == None)
attributes.colormap = scr->colormap;
XGetWindowAttributes(dpy, w, &attributes);
if (attributes.colormap == None)
attributes.colormap = scr->colormap;
if (scr->current_colormap != attributes.colormap) {
scr->current_colormap = attributes.colormap;
/*
* ICCCM 2.0: some client requested permission
* to install colormaps by itself and we granted.
* So, we can't install any colormaps.
*/
if (!scr->flags.colormap_stuff_blocked)
XInstallColormap(dpy, attributes.colormap);
}
}
}
if (scr->current_colormap != attributes.colormap) {
scr->current_colormap = attributes.colormap;
/*
* ICCCM 2.0: some client requested permission
* to install colormaps by itself and we granted.
* So, we can't install any colormaps.
*/
if (!scr->flags.colormap_stuff_blocked)
XInstallColormap(dpy, attributes.colormap);
}
}
}
if (!done) {
attributes.colormap = None;
if (xwin != None)
XGetWindowAttributes(dpy, xwin, &attributes);
if (attributes.colormap == None)
attributes.colormap = scr->colormap;
if (!done) {
attributes.colormap = None;
if (xwin != None)
XGetWindowAttributes(dpy, xwin, &attributes);
if (attributes.colormap == None)
attributes.colormap = scr->colormap;
if (scr->current_colormap != attributes.colormap) {
scr->current_colormap = attributes.colormap;
if (!scr->flags.colormap_stuff_blocked)
XInstallColormap(dpy, attributes.colormap);
}
}
XSync(dpy, False);
if (scr->current_colormap != attributes.colormap) {
scr->current_colormap = attributes.colormap;
if (!scr->flags.colormap_stuff_blocked)
XInstallColormap(dpy, attributes.colormap);
}
}
XSync(dpy, False);
}
void
wColormapInstallRoot(WScreen *scr)
void wColormapInstallRoot(WScreen * scr)
{
if (scr->root_colormap_install_count == 0) {
wColormapInstallForWindow(scr, NULL);
scr->original_cmap_window = scr->cmap_window;
}
scr->root_colormap_install_count++;
if (scr->root_colormap_install_count == 0) {
wColormapInstallForWindow(scr, NULL);
scr->original_cmap_window = scr->cmap_window;
}
scr->root_colormap_install_count++;
}
void
wColormapUninstallRoot(WScreen *scr)
void wColormapUninstallRoot(WScreen * scr)
{
if (scr->root_colormap_install_count > 0)
scr->root_colormap_install_count--;
if (scr->root_colormap_install_count > 0)
scr->root_colormap_install_count--;
if (scr->root_colormap_install_count == 0) {
wColormapInstallForWindow(scr, scr->original_cmap_window);
scr->original_cmap_window = NULL;
}
if (scr->root_colormap_install_count == 0) {
wColormapInstallForWindow(scr, scr->original_cmap_window);
scr->original_cmap_window = NULL;
}
}
void
wColormapAllowClientInstallation(WScreen *scr, Bool starting)
void wColormapAllowClientInstallation(WScreen * scr, Bool starting)
{
scr->flags.colormap_stuff_blocked = starting;
/*
* Client stopped managing the colormap stuff. Restore the colormap
* that would be installed if the client did not request colormap
* stuff.
*/
if (!starting) {
XInstallColormap(dpy, scr->current_colormap);
XSync(dpy, False);
}
scr->flags.colormap_stuff_blocked = starting;
/*
* Client stopped managing the colormap stuff. Restore the colormap
* that would be installed if the client did not request colormap
* stuff.
*/
if (!starting) {
XInstallColormap(dpy, scr->current_colormap);
XSync(dpy, False);
}
}
+176 -186
View File
@@ -44,224 +44,214 @@ extern WPreferences wPreferences;
extern WShortKey wKeyBindings[WKBD_LAST];
static void raiseWindow(WSwitchPanel *swpanel, WWindow *wwin)
static void raiseWindow(WSwitchPanel * swpanel, WWindow * wwin)
{
Window swwin= wSwitchPanelGetWindow(swpanel);
if (wwin->flags.mapped) {
if (swwin!=None) {
Window win[2];
win[0]= swwin;
win[1]= wwin->frame->core->window;
XRestackWindows(dpy, win, 2);
} else
XRaiseWindow(dpy, wwin->frame->core->window);
}
Window swwin = wSwitchPanelGetWindow(swpanel);
if (wwin->flags.mapped) {
if (swwin != None) {
Window win[2];
win[0] = swwin;
win[1] = wwin->frame->core->window;
XRestackWindows(dpy, win, 2);
} else
XRaiseWindow(dpy, wwin->frame->core->window);
}
}
void
StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
void StartWindozeCycle(WWindow * wwin, XEvent * event, Bool next)
{
WScreen *scr = wScreenForRootWindow(event->xkey.root);
Bool done = False;
WWindow *newFocused;
WWindow *oldFocused;
int modifiers;
XModifierKeymap *keymap = NULL;
Bool hasModifier;
Bool somethingElse = False;
XEvent ev;
WSwitchPanel *swpanel = NULL;
KeyCode leftKey, rightKey, homeKey, endKey, shiftLKey, shiftRKey;
WScreen *scr = wScreenForRootWindow(event->xkey.root);
Bool done = False;
WWindow *newFocused;
WWindow *oldFocused;
int modifiers;
XModifierKeymap *keymap = NULL;
Bool hasModifier;
Bool somethingElse = False;
XEvent ev;
WSwitchPanel *swpanel = NULL;
KeyCode leftKey, rightKey, homeKey, endKey, shiftLKey, shiftRKey;
if (!wwin)
return;
leftKey = XKeysymToKeycode(dpy, XK_Left);
rightKey = XKeysymToKeycode(dpy, XK_Right);
homeKey = XKeysymToKeycode(dpy, XK_Home);
endKey = XKeysymToKeycode(dpy, XK_End);
shiftLKey = XKeysymToKeycode(dpy, XK_Shift_L);
shiftRKey = XKeysymToKeycode(dpy, XK_Shift_R);
if (!wwin)
return;
if (next)
hasModifier = (wKeyBindings[WKBD_FOCUSNEXT].modifier != 0);
else
hasModifier = (wKeyBindings[WKBD_FOCUSPREV].modifier != 0);
leftKey = XKeysymToKeycode(dpy, XK_Left);
rightKey = XKeysymToKeycode(dpy, XK_Right);
homeKey = XKeysymToKeycode(dpy, XK_Home);
endKey = XKeysymToKeycode(dpy, XK_End);
shiftLKey = XKeysymToKeycode(dpy, XK_Shift_L);
shiftRKey = XKeysymToKeycode(dpy, XK_Shift_R);
if (hasModifier) {
keymap = XGetModifierMapping(dpy);
if (next)
hasModifier = (wKeyBindings[WKBD_FOCUSNEXT].modifier != 0);
else
hasModifier = (wKeyBindings[WKBD_FOCUSPREV].modifier != 0);
if (hasModifier) {
keymap = XGetModifierMapping(dpy);
#ifdef DEBUG
printf("Grabbing keyboard\n");
printf("Grabbing keyboard\n");
#endif
XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync,
CurrentTime);
}
XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
}
scr->flags.doing_alt_tab = 1;
scr->flags.doing_alt_tab = 1;
swpanel = wInitSwitchPanel(scr, wwin, scr->current_workspace);
oldFocused = wwin;
if (swpanel) {
newFocused = wSwitchPanelSelectNext(swpanel, !next);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
swpanel = wInitSwitchPanel(scr, wwin, scr->current_workspace);
oldFocused = wwin;
if (wPreferences.circ_raise)
raiseWindow(swpanel, newFocused);
}
}
else
{
if (wwin->frame->workspace == scr->current_workspace)
newFocused= wwin;
else
newFocused= NULL;
}
if (swpanel) {
newFocused = wSwitchPanelSelectNext(swpanel, !next);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
while (hasModifier && !done) {
int i;
if (wPreferences.circ_raise)
raiseWindow(swpanel, newFocused);
}
} else {
if (wwin->frame->workspace == scr->current_workspace)
newFocused = wwin;
else
newFocused = NULL;
}
WMMaskEvent(dpy, KeyPressMask|KeyReleaseMask|ExposureMask
|PointerMotionMask|ButtonReleaseMask, &ev);
while (hasModifier && !done) {
int i;
/* ignore CapsLock */
modifiers = ev.xkey.state & ValidModMask;
WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask
| PointerMotionMask | ButtonReleaseMask, &ev);
switch (ev.type) {
case KeyPress:
/* ignore CapsLock */
modifiers = ev.xkey.state & ValidModMask;
switch (ev.type) {
case KeyPress:
#ifdef DEBUG
printf("Got key press\n");
printf("Got key press\n");
#endif
if ((wKeyBindings[WKBD_FOCUSNEXT].keycode == ev.xkey.keycode
&& wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers)
|| ev.xkey.keycode == rightKey) {
if ((wKeyBindings[WKBD_FOCUSNEXT].keycode == ev.xkey.keycode
&& wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers)
|| ev.xkey.keycode == rightKey) {
if (swpanel) {
newFocused = wSwitchPanelSelectNext(swpanel, False);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
}
}
} else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode
&& wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers)
|| ev.xkey.keycode == leftKey) {
if (swpanel) {
newFocused = wSwitchPanelSelectNext(swpanel, False);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (swpanel) {
newFocused = wSwitchPanelSelectNext(swpanel, True);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
}
}
} else if (ev.xkey.keycode == homeKey || ev.xkey.keycode == endKey) {
if (swpanel) {
newFocused = wSwitchPanelSelectFirst(swpanel, ev.xkey.keycode != homeKey);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
}
}
} else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode
&& wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers)
|| ev.xkey.keycode == leftKey) {
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
}
}
} else if (ev.xkey.keycode != shiftLKey && ev.xkey.keycode != shiftRKey) {
if (swpanel) {
newFocused = wSwitchPanelSelectNext(swpanel, True);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
}
}
} else if (ev.xkey.keycode == homeKey || ev.xkey.keycode == endKey) {
if (swpanel) {
newFocused = wSwitchPanelSelectFirst(swpanel, ev.xkey.keycode != homeKey);
if (newFocused) {
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
}
}
} else if (ev.xkey.keycode != shiftLKey && ev.xkey.keycode != shiftRKey) {
#ifdef DEBUG
printf("Got something else\n");
printf("Got something else\n");
#endif
somethingElse = True;
done = True;
}
break;
case KeyRelease:
somethingElse = True;
done = True;
}
break;
case KeyRelease:
#ifdef DEBUG
printf("Got key release\n");
printf("Got key release\n");
#endif
for (i = 0; i < 8 * keymap->max_keypermod; i++) {
if (keymap->modifiermap[i] == ev.xkey.keycode &&
wKeyBindings[WKBD_FOCUSNEXT].modifier
& 1<<(i/keymap->max_keypermod)) {
done = True;
break;
}
}
break;
case LeaveNotify:
case MotionNotify:
case ButtonRelease:
{
WWindow *tmp;
if (swpanel) {
tmp = wSwitchPanelHandleEvent(swpanel, &ev);
if (tmp) {
newFocused = tmp;
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
if (ev.type == ButtonRelease)
done= True;
}
}
}
break;
for (i = 0; i < 8 * keymap->max_keypermod; i++) {
if (keymap->modifiermap[i] == ev.xkey.keycode &&
wKeyBindings[WKBD_FOCUSNEXT].modifier & 1 << (i / keymap->max_keypermod)) {
done = True;
break;
}
}
break;
default:
WMHandleEvent(&ev);
break;
}
}
if (keymap)
XFreeModifiermap(keymap);
case LeaveNotify:
case MotionNotify:
case ButtonRelease:
{
WWindow *tmp;
if (swpanel) {
tmp = wSwitchPanelHandleEvent(swpanel, &ev);
if (tmp) {
newFocused = tmp;
wWindowFocus(newFocused, oldFocused);
oldFocused = newFocused;
if (hasModifier) {
if (wPreferences.circ_raise) {
CommitStacking(scr);
raiseWindow(swpanel, newFocused);
}
if (ev.type == ButtonRelease)
done = True;
}
}
}
break;
default:
WMHandleEvent(&ev);
break;
}
}
if (keymap)
XFreeModifiermap(keymap);
if (hasModifier) {
#ifdef DEBUG
printf("Ungrabbing keyboard\n");
printf("Ungrabbing keyboard\n");
#endif
XUngrabKeyboard(dpy, CurrentTime);
}
XUngrabKeyboard(dpy, CurrentTime);
}
if (swpanel)
wSwitchPanelDestroy(swpanel);
if (swpanel)
wSwitchPanelDestroy(swpanel);
if (newFocused) {
wRaiseFrame(newFocused->frame->core);
CommitStacking(scr);
if (!newFocused->flags.mapped)
wMakeWindowVisible(newFocused);
wSetFocusTo(scr, newFocused);
}
if (newFocused) {
wRaiseFrame(newFocused->frame->core);
CommitStacking(scr);
if (!newFocused->flags.mapped)
wMakeWindowVisible(newFocused);
wSetFocusTo(scr, newFocused);
}
scr->flags.doing_alt_tab = 0;
scr->flags.doing_alt_tab = 0;
if (somethingElse)
WMHandleEvent(&ev);
if (somethingElse)
WMHandleEvent(&ev);
}
+2415 -2848
View File
File diff suppressed because it is too large. Load diff
+1332 -1444
View File
File diff suppressed because it is too large. Load diff
+3160 -3482
View File
File diff suppressed because it is too large. Load diff
+313 -366
View File
@@ -20,7 +20,6 @@
* USA.
*/
#include "wconfig.h"
#include <X11/Xlib.h>
@@ -40,480 +39,428 @@
#include "framewin.h"
#include "xinerama.h"
/**** Global variables ****/
extern WPreferences wPreferences;
typedef struct _AppSettingsPanel {
WMWindow *win;
WAppIcon *editedIcon;
WMWindow *win;
WAppIcon *editedIcon;
WWindow *wwin;
WWindow *wwin;
WMLabel *iconLabel;
WMLabel *nameLabel;
WMLabel *iconLabel;
WMLabel *nameLabel;
WMFrame *commandFrame;
WMTextField *commandField;
WMFrame *commandFrame;
WMTextField *commandField;
WMFrame *dndCommandFrame;
WMTextField *dndCommandField;
WMLabel *dndCommandLabel;
WMFrame *dndCommandFrame;
WMTextField *dndCommandField;
WMLabel *dndCommandLabel;
WMFrame *pasteCommandFrame;
WMTextField *pasteCommandField;
WMLabel *pasteCommandLabel;
WMFrame *pasteCommandFrame;
WMTextField *pasteCommandField;
WMLabel *pasteCommandLabel;
WMFrame *iconFrame;
WMTextField *iconField;
WMButton *browseBtn;
WMFrame *iconFrame;
WMTextField *iconField;
WMButton *browseBtn;
WMButton *autoLaunchBtn;
WMButton *lockBtn;
WMButton *autoLaunchBtn;
WMButton *lockBtn;
WMButton *okBtn;
WMButton *cancelBtn;
WMButton *okBtn;
WMButton *cancelBtn;
Window parent;
Window parent;
/* kluge */
unsigned int destroyed:1;
unsigned int choosingIcon:1;
/* kluge */
unsigned int destroyed:1;
unsigned int choosingIcon:1;
} AppSettingsPanel;
void DestroyDockAppSettingsPanel(AppSettingsPanel * panel);
void DestroyDockAppSettingsPanel(AppSettingsPanel *panel);
static void
updateCommand(WAppIcon *icon, char *command)
static void updateCommand(WAppIcon * icon, char *command)
{
if (icon->command)
wfree(icon->command);
if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) {
wfree(command);
command = NULL;
}
icon->command = command;
if (icon->command)
wfree(icon->command);
if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) {
wfree(command);
command = NULL;
}
icon->command = command;
if (!icon->wm_class && !icon->wm_instance && icon->command
&& strlen(icon->command)>0) {
icon->forced_dock = 1;
}
if (!icon->wm_class && !icon->wm_instance && icon->command && strlen(icon->command) > 0) {
icon->forced_dock = 1;
}
}
static void
updatePasteCommand(WAppIcon *icon, char *command)
static void updatePasteCommand(WAppIcon * icon, char *command)
{
if (icon->paste_command)
wfree(icon->paste_command);
if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) {
wfree(command);
command = NULL;
}
icon->paste_command = command;
if (icon->paste_command)
wfree(icon->paste_command);
if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) {
wfree(command);
command = NULL;
}
icon->paste_command = command;
}
#ifdef XDND
static void
updateDNDCommand(WAppIcon *icon, char *command)
static void updateDNDCommand(WAppIcon * icon, char *command)
{
if (icon->dnd_command)
wfree(icon->dnd_command);
if (command && (command[0]==0 || (command[0]=='-' && command[1]==0))) {
wfree(command);
command = NULL;
}
icon->dnd_command = command;
if (icon->dnd_command)
wfree(icon->dnd_command);
if (command && (command[0] == 0 || (command[0] == '-' && command[1] == 0))) {
wfree(command);
command = NULL;
}
icon->dnd_command = command;
}
#endif /* XDND */
#endif /* XDND */
static void
updateSettingsPanelIcon(AppSettingsPanel *panel)
static void updateSettingsPanelIcon(AppSettingsPanel * panel)
{
char *file;
char *file;
file = WMGetTextFieldText(panel->iconField);
if (!file)
WMSetLabelImage(panel->iconLabel, NULL);
else {
char *path;
file = WMGetTextFieldText(panel->iconField);
if (!file)
WMSetLabelImage(panel->iconLabel, NULL);
else {
char *path;
path = FindImage(wPreferences.icon_path, file);
if (!path) {
wwarning(_("could not find icon %s, used in a docked application"),
file);
wfree(file);
WMSetLabelImage(panel->iconLabel, NULL);
return;
} else {
WMPixmap *pixmap;
RColor color;
path = FindImage(wPreferences.icon_path, file);
if (!path) {
wwarning(_("could not find icon %s, used in a docked application"), file);
wfree(file);
WMSetLabelImage(panel->iconLabel, NULL);
return;
} else {
WMPixmap *pixmap;
RColor color;
color.red = 0xae;
color.green = 0xaa;
color.blue = 0xae;
color.alpha = 0;
pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win),
path, &color);
if (!pixmap) {
WMSetLabelImage(panel->iconLabel, NULL);
} else {
WMSetLabelImage(panel->iconLabel, pixmap);
WMReleasePixmap(pixmap);
}
}
wfree(file);
wfree(path);
}
color.red = 0xae;
color.green = 0xaa;
color.blue = 0xae;
color.alpha = 0;
pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color);
if (!pixmap) {
WMSetLabelImage(panel->iconLabel, NULL);
} else {
WMSetLabelImage(panel->iconLabel, pixmap);
WMReleasePixmap(pixmap);
}
}
wfree(file);
wfree(path);
}
}
static void
chooseIconCallback(WMWidget *self, void *clientData)
static void chooseIconCallback(WMWidget * self, void *clientData)
{
char *file;
AppSettingsPanel *panel = (AppSettingsPanel*)clientData;
int result;
char *file;
AppSettingsPanel *panel = (AppSettingsPanel *) clientData;
int result;
panel->choosingIcon = 1;
panel->choosingIcon = 1;
WMSetButtonEnabled(panel->browseBtn, False);
WMSetButtonEnabled(panel->browseBtn, False);
result = wIconChooserDialog(panel->wwin->screen_ptr, &file,
panel->editedIcon->wm_instance,
panel->editedIcon->wm_class);
result = wIconChooserDialog(panel->wwin->screen_ptr, &file,
panel->editedIcon->wm_instance, panel->editedIcon->wm_class);
panel->choosingIcon = 0;
if (!panel->destroyed) {
if (result) {
WMSetTextFieldText(panel->iconField, file);
wfree(file);
updateSettingsPanelIcon(panel);
}
panel->choosingIcon = 0;
if (!panel->destroyed) {
if (result) {
WMSetTextFieldText(panel->iconField, file);
wfree(file);
updateSettingsPanelIcon(panel);
}
WMSetButtonEnabled(panel->browseBtn, True);
} else {
/* kluge for the case, the user asked to close the panel before
* the icon chooser */
DestroyDockAppSettingsPanel(panel);
}
WMSetButtonEnabled(panel->browseBtn, True);
} else {
/* kluge for the case, the user asked to close the panel before
* the icon chooser */
DestroyDockAppSettingsPanel(panel);
}
}
static void
panelBtnCallback(WMWidget *self, void *data)
static void panelBtnCallback(WMWidget * self, void *data)
{
WMButton *btn = self;
AppSettingsPanel *panel = (AppSettingsPanel*)data;
char *text;
int done;
WMButton *btn = self;
AppSettingsPanel *panel = (AppSettingsPanel *) data;
char *text;
int done;
done = 1;
if (panel->okBtn == btn) {
text = WMGetTextFieldText(panel->iconField);
if (text[0]==0) {
wfree(text);
text = NULL;
}
if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
char *buf;
int len = strlen(text) + 64;
done = 1;
if (panel->okBtn == btn) {
text = WMGetTextFieldText(panel->iconField);
if (text[0] == 0) {
wfree(text);
text = NULL;
}
if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
char *buf;
int len = strlen(text) + 64;
buf = wmalloc(len);
snprintf(buf, len, _("Could not open specified icon file: %s"), text);
if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf,
_("OK"), _("Ignore"), NULL) == WAPRDefault) {
if (text)
wfree(text);
wfree(buf);
return;
}
wfree(buf);
} else {
WAppIcon *aicon = panel->editedIcon;
buf = wmalloc(len);
snprintf(buf, len, _("Could not open specified icon file: %s"), text);
if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf,
_("OK"), _("Ignore"), NULL) == WAPRDefault) {
if (text)
wfree(text);
wfree(buf);
return;
}
wfree(buf);
} else {
WAppIcon *aicon = panel->editedIcon;
if (aicon == aicon->icon->core->screen_ptr->clip_icon)
wClipIconPaint(aicon);
else
wAppIconPaint(aicon);
if (aicon == aicon->icon->core->screen_ptr->clip_icon)
wClipIconPaint(aicon);
else
wAppIconPaint(aicon);
wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance,
aicon->wm_class, text);
}
if (text)
wfree(text);
wDefaultChangeIcon(panel->wwin->screen_ptr, aicon->wm_instance, aicon->wm_class, text);
}
if (text)
wfree(text);
/* cannot free text from this, because it will be not be duplicated
* in updateCommand */
text = WMGetTextFieldText(panel->commandField);
if (text[0]==0) {
wfree(text);
text = NULL;
}
updateCommand(panel->editedIcon, text);
/* cannot free text from this, because it will be not be duplicated
* in updateCommand */
text = WMGetTextFieldText(panel->commandField);
if (text[0] == 0) {
wfree(text);
text = NULL;
}
updateCommand(panel->editedIcon, text);
#ifdef XDND
/* cannot free text from this, because it will be not be duplicated
* in updateDNDCommand */
text = WMGetTextFieldText(panel->dndCommandField);
updateDNDCommand(panel->editedIcon, text);
/* cannot free text from this, because it will be not be duplicated
* in updateDNDCommand */
text = WMGetTextFieldText(panel->dndCommandField);
updateDNDCommand(panel->editedIcon, text);
#endif
text = WMGetTextFieldText(panel->pasteCommandField);
updatePasteCommand(panel->editedIcon, text);
text = WMGetTextFieldText(panel->pasteCommandField);
updatePasteCommand(panel->editedIcon, text);
panel->editedIcon->auto_launch = WMGetButtonSelected(panel->autoLaunchBtn);
panel->editedIcon->auto_launch =
WMGetButtonSelected(panel->autoLaunchBtn);
panel->editedIcon->lock = WMGetButtonSelected(panel->lockBtn);
}
panel->editedIcon->lock =
WMGetButtonSelected(panel->lockBtn);
}
if (done)
DestroyDockAppSettingsPanel(panel);
if (done)
DestroyDockAppSettingsPanel(panel);
}
#define PWIDTH 295
#define PHEIGHT 430
void
ShowDockAppSettingsPanel(WAppIcon *aicon)
void ShowDockAppSettingsPanel(WAppIcon * aicon)
{
AppSettingsPanel *panel;
WScreen *scr = aicon->icon->core->screen_ptr;
Window parent;
WMFont *font;
int x, y;
WMBox *vbox;
AppSettingsPanel *panel;
WScreen *scr = aicon->icon->core->screen_ptr;
Window parent;
WMFont *font;
int x, y;
WMBox *vbox;
panel = wmalloc(sizeof(AppSettingsPanel));
memset(panel, 0, sizeof(AppSettingsPanel));
panel = wmalloc(sizeof(AppSettingsPanel));
memset(panel, 0, sizeof(AppSettingsPanel));
panel->editedIcon = aicon;
panel->editedIcon = aicon;
aicon->panel = panel;
aicon->editing = 1;
aicon->panel = panel;
aicon->editing = 1;
panel->win = WMCreateWindow(scr->wmscreen, "applicationSettings");
WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
panel->win = WMCreateWindow(scr->wmscreen, "applicationSettings");
WMResizeWidget(panel->win, PWIDTH, PHEIGHT);
panel->iconLabel = WMCreateLabel(panel->win);
WMResizeWidget(panel->iconLabel, 64, 64);
WMMoveWidget(panel->iconLabel, 10, 10);
WMSetLabelImagePosition(panel->iconLabel, WIPImageOnly);
panel->iconLabel = WMCreateLabel(panel->win);
WMResizeWidget(panel->iconLabel, 64, 64);
WMMoveWidget(panel->iconLabel, 10, 10);
WMSetLabelImagePosition(panel->iconLabel, WIPImageOnly);
panel->nameLabel = WMCreateLabel(panel->win);
WMResizeWidget(panel->nameLabel, 190, 18);
WMMoveWidget(panel->nameLabel, 80, 35);
WMSetLabelTextAlignment(panel->nameLabel, WALeft);
font = WMBoldSystemFontOfSize(scr->wmscreen, 14);
WMSetLabelFont(panel->nameLabel, font);
WMReleaseFont(font);
if (aicon->wm_class && strcmp(aicon->wm_class, "DockApp")==0)
WMSetLabelText(panel->nameLabel, aicon->wm_instance);
else
WMSetLabelText(panel->nameLabel, aicon->wm_class);
panel->nameLabel = WMCreateLabel(panel->win);
WMResizeWidget(panel->nameLabel, 190, 18);
WMMoveWidget(panel->nameLabel, 80, 35);
WMSetLabelTextAlignment(panel->nameLabel, WALeft);
font = WMBoldSystemFontOfSize(scr->wmscreen, 14);
WMSetLabelFont(panel->nameLabel, font);
WMReleaseFont(font);
if (aicon->wm_class && strcmp(aicon->wm_class, "DockApp") == 0)
WMSetLabelText(panel->nameLabel, aicon->wm_instance);
else
WMSetLabelText(panel->nameLabel, aicon->wm_class);
vbox = WMCreateBox(panel->win);
WMResizeWidget(vbox, PWIDTH - 20, PHEIGHT - 84 - 10);
WMMoveWidget(vbox, 10, 84);
vbox = WMCreateBox(panel->win);
WMResizeWidget(vbox, PWIDTH-20, PHEIGHT-84-10);
WMMoveWidget(vbox, 10, 84);
panel->autoLaunchBtn = WMCreateSwitchButton(vbox);
WMAddBoxSubview(vbox, WMWidgetView(panel->autoLaunchBtn), False, True, 20, 20, 2);
WMSetButtonText(panel->autoLaunchBtn, _("Start when Window Maker is started"));
WMSetButtonSelected(panel->autoLaunchBtn, aicon->auto_launch);
panel->autoLaunchBtn = WMCreateSwitchButton(vbox);
WMAddBoxSubview(vbox, WMWidgetView(panel->autoLaunchBtn), False, True,
20, 20, 2);
WMSetButtonText(panel->autoLaunchBtn,
_("Start when Window Maker is started"));
WMSetButtonSelected(panel->autoLaunchBtn, aicon->auto_launch);
panel->lockBtn = WMCreateSwitchButton(vbox);
WMAddBoxSubview(vbox, WMWidgetView(panel->lockBtn), False, True, 20, 20, 5);
WMSetButtonText(panel->lockBtn, _("Lock (prevent accidental removal)"));
WMSetButtonSelected(panel->lockBtn, aicon->lock);
panel->lockBtn = WMCreateSwitchButton(vbox);
WMAddBoxSubview(vbox, WMWidgetView(panel->lockBtn), False, True,
20, 20, 5);
WMSetButtonText(panel->lockBtn,
_("Lock (prevent accidental removal)"));
WMSetButtonSelected(panel->lockBtn, aicon->lock);
panel->commandFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->commandFrame, _("Application path and arguments"));
WMAddBoxSubview(vbox, WMWidgetView(panel->commandFrame), False, True, 50, 50, 5);
panel->commandFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->commandFrame, _("Application path and arguments"));
WMAddBoxSubview(vbox, WMWidgetView(panel->commandFrame), False, True,
50, 50, 5);
panel->commandField = WMCreateTextField(panel->commandFrame);
WMResizeWidget(panel->commandField, 256, 20);
WMMoveWidget(panel->commandField, 10, 20);
WMSetTextFieldText(panel->commandField, aicon->command);
panel->commandField = WMCreateTextField(panel->commandFrame);
WMResizeWidget(panel->commandField, 256, 20);
WMMoveWidget(panel->commandField, 10, 20);
WMSetTextFieldText(panel->commandField, aicon->command);
WMMapSubwidgets(panel->commandFrame);
WMMapSubwidgets(panel->commandFrame);
panel->pasteCommandFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->pasteCommandFrame, _("Command for middle-click launch"));
WMAddBoxSubview(vbox, WMWidgetView(panel->pasteCommandFrame), False, True, 70, 70, 5);
panel->pasteCommandFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->pasteCommandFrame,
_("Command for middle-click launch"));
WMAddBoxSubview(vbox, WMWidgetView(panel->pasteCommandFrame), False, True,
70, 70, 5);
panel->pasteCommandField = WMCreateTextField(panel->pasteCommandFrame);
WMResizeWidget(panel->pasteCommandField, 256, 20);
WMMoveWidget(panel->pasteCommandField, 10, 20);
panel->pasteCommandField = WMCreateTextField(panel->pasteCommandFrame);
WMResizeWidget(panel->pasteCommandField, 256, 20);
WMMoveWidget(panel->pasteCommandField, 10, 20);
panel->pasteCommandLabel = WMCreateLabel(panel->pasteCommandFrame);
WMResizeWidget(panel->pasteCommandLabel, 256, 18);
WMMoveWidget(panel->pasteCommandLabel, 10, 45);
panel->pasteCommandLabel = WMCreateLabel(panel->pasteCommandFrame);
WMResizeWidget(panel->pasteCommandLabel, 256, 18);
WMMoveWidget(panel->pasteCommandLabel, 10, 45);
WMSetTextFieldText(panel->pasteCommandField, aicon->paste_command);
WMSetLabelText(panel->pasteCommandLabel, _("%s will be replaced with current selection"));
WMMapSubwidgets(panel->pasteCommandFrame);
WMSetTextFieldText(panel->pasteCommandField, aicon->paste_command);
WMSetLabelText(panel->pasteCommandLabel,
_("%s will be replaced with current selection"));
WMMapSubwidgets(panel->pasteCommandFrame);
panel->dndCommandFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->dndCommandFrame, _("Command for files dropped with DND"));
WMAddBoxSubview(vbox, WMWidgetView(panel->dndCommandFrame), False, True, 70, 70, 5);
panel->dndCommandFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->dndCommandFrame,
_("Command for files dropped with DND"));
WMAddBoxSubview(vbox, WMWidgetView(panel->dndCommandFrame), False, True,
70, 70, 5);
panel->dndCommandField = WMCreateTextField(panel->dndCommandFrame);
WMResizeWidget(panel->dndCommandField, 256, 20);
WMMoveWidget(panel->dndCommandField, 10, 20);
panel->dndCommandField = WMCreateTextField(panel->dndCommandFrame);
WMResizeWidget(panel->dndCommandField, 256, 20);
WMMoveWidget(panel->dndCommandField, 10, 20);
panel->dndCommandLabel = WMCreateLabel(panel->dndCommandFrame);
WMResizeWidget(panel->dndCommandLabel, 256, 18);
WMMoveWidget(panel->dndCommandLabel, 10, 45);
panel->dndCommandLabel = WMCreateLabel(panel->dndCommandFrame);
WMResizeWidget(panel->dndCommandLabel, 256, 18);
WMMoveWidget(panel->dndCommandLabel, 10, 45);
#ifdef XDND
WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command);
WMSetLabelText(panel->dndCommandLabel,
_("%d will be replaced with the file name"));
WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command);
WMSetLabelText(panel->dndCommandLabel, _("%d will be replaced with the file name"));
#else
WMSetTextFieldEditable(panel->dndCommandField, False);
WMSetLabelText(panel->dndCommandLabel,
_("DND support was not compiled in"));
WMSetTextFieldEditable(panel->dndCommandField, False);
WMSetLabelText(panel->dndCommandLabel, _("DND support was not compiled in"));
#endif
WMMapSubwidgets(panel->dndCommandFrame);
WMMapSubwidgets(panel->dndCommandFrame);
panel->iconFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->iconFrame, _("Icon Image"));
WMAddBoxSubview(vbox, WMWidgetView(panel->iconFrame), False, True,
50, 50, 10);
panel->iconFrame = WMCreateFrame(vbox);
WMSetFrameTitle(panel->iconFrame, _("Icon Image"));
WMAddBoxSubview(vbox, WMWidgetView(panel->iconFrame), False, True, 50, 50, 10);
panel->iconField = WMCreateTextField(panel->iconFrame);
WMResizeWidget(panel->iconField, 176, 20);
WMMoveWidget(panel->iconField, 10, 20);
WMSetTextFieldText(panel->iconField,
wDefaultGetIconFile(scr, aicon->wm_instance,
aicon->wm_class, True));
panel->iconField = WMCreateTextField(panel->iconFrame);
WMResizeWidget(panel->iconField, 176, 20);
WMMoveWidget(panel->iconField, 10, 20);
WMSetTextFieldText(panel->iconField, wDefaultGetIconFile(scr, aicon->wm_instance, aicon->wm_class, True));
panel->browseBtn = WMCreateCommandButton(panel->iconFrame);
WMResizeWidget(panel->browseBtn, 70, 24);
WMMoveWidget(panel->browseBtn, 195, 18);
WMSetButtonText(panel->browseBtn, _("Browse..."));
WMSetButtonAction(panel->browseBtn, chooseIconCallback, panel);
panel->browseBtn = WMCreateCommandButton(panel->iconFrame);
WMResizeWidget(panel->browseBtn, 70, 24);
WMMoveWidget(panel->browseBtn, 195, 18);
WMSetButtonText(panel->browseBtn, _("Browse..."));
WMSetButtonAction(panel->browseBtn, chooseIconCallback, panel);
{
WMBox *hbox;
{
WMBox *hbox;
hbox = WMCreateBox(vbox);
WMSetBoxHorizontal(hbox, True);
WMAddBoxSubview(vbox, WMWidgetView(hbox), False, True, 24, 24, 0);
hbox = WMCreateBox(vbox);
WMSetBoxHorizontal(hbox, True);
WMAddBoxSubview(vbox, WMWidgetView(hbox), False, True, 24, 24, 0);
panel->okBtn = WMCreateCommandButton(hbox);
WMSetButtonText(panel->okBtn, _("OK"));
WMSetButtonAction(panel->okBtn, panelBtnCallback, panel);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->okBtn), False, True, 80, 80, 0);
panel->cancelBtn = WMCreateCommandButton(hbox);
WMSetButtonText(panel->cancelBtn, _("Cancel"));
WMSetButtonAction(panel->cancelBtn, panelBtnCallback, panel);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->cancelBtn), False, True, 80, 80, 5);
panel->okBtn = WMCreateCommandButton(hbox);
WMSetButtonText(panel->okBtn, _("OK"));
WMSetButtonAction(panel->okBtn, panelBtnCallback, panel);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->okBtn), False, True, 80, 80, 0);
WMMapSubwidgets(hbox);
}
panel->cancelBtn = WMCreateCommandButton(hbox);
WMSetButtonText(panel->cancelBtn, _("Cancel"));
WMSetButtonAction(panel->cancelBtn, panelBtnCallback, panel);
WMAddBoxSubviewAtEnd(hbox, WMWidgetView(panel->cancelBtn), False, True, 80, 80, 5);
WMRealizeWidget(panel->win);
WMMapSubwidgets(panel->win);
WMMapSubwidgets(vbox);
WMMapSubwidgets(panel->iconFrame);
WMMapSubwidgets(hbox);
}
updateSettingsPanelIcon(panel);
WMRealizeWidget(panel->win);
WMMapSubwidgets(panel->win);
WMMapSubwidgets(vbox);
WMMapSubwidgets(panel->iconFrame);
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, 0, 0, 0);
XSelectInput(dpy, parent, KeyPressMask | KeyReleaseMask);
updateSettingsPanelIcon(panel);
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT,
0, 0, 0);
XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);
/*
* make things relative to head
*/
{
WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));
XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);
y = aicon->y_pos;
if (y < 0)
y = 0;
else if (y + PHEIGHT > rect.pos.y + rect.size.height)
y = rect.pos.y + rect.size.height - PHEIGHT - 30;
/*
* make things relative to head
*/
{
WMRect rect = wGetRectForHead(scr, wGetHeadForPointerLocation(scr));
if (aicon->dock && aicon->dock->type == WM_DOCK) {
if (aicon->dock->on_right_side)
x = rect.pos.x + rect.size.width / 2;
else
x = rect.pos.x + rect.size.width / 2 - PWIDTH - 2;
} else {
x = rect.pos.x + (rect.size.width - PWIDTH) / 2;
}
}
y = aicon->y_pos;
if (y < 0)
y = 0;
else if (y + PHEIGHT > rect.pos.y + rect.size.height)
y = rect.pos.y + rect.size.height - PHEIGHT - 30;
panel->wwin = wManageInternalWindow(scr, parent, None,
_("Docked Application Settings"), x, y, PWIDTH, PHEIGHT);
if (aicon->dock && aicon->dock->type == WM_DOCK) {
if (aicon->dock->on_right_side)
x = rect.pos.x + rect.size.width/2;
else
x = rect.pos.x + rect.size.width/2 - PWIDTH - 2;
} else {
x = rect.pos.x + (rect.size.width - PWIDTH)/2;
}
}
panel->wwin->client_leader = WMWidgetXID(panel->win);
panel->wwin = wManageInternalWindow(scr, parent, None,
_("Docked Application Settings"),
x, y, PWIDTH, PHEIGHT);
panel->parent = parent;
panel->wwin->client_leader = WMWidgetXID(panel->win);
WMMapWidget(panel->win);
panel->parent = parent;
WMMapWidget(panel->win);
wWindowMap(panel->wwin);
wWindowMap(panel->wwin);
}
void
DestroyDockAppSettingsPanel(AppSettingsPanel *panel)
void DestroyDockAppSettingsPanel(AppSettingsPanel * panel)
{
if (!panel->destroyed) {
XUnmapWindow(dpy, panel->wwin->client_win);
XReparentWindow(dpy, panel->wwin->client_win,
panel->wwin->screen_ptr->root_win, 0, 0);
wUnmanageWindow(panel->wwin, False, False);
}
if (!panel->destroyed) {
XUnmapWindow(dpy, panel->wwin->client_win);
XReparentWindow(dpy, panel->wwin->client_win, panel->wwin->screen_ptr->root_win, 0, 0);
wUnmanageWindow(panel->wwin, False, False);
}
panel->destroyed = 1;
panel->destroyed = 1;
/*
* kluge. If we destroy the panel before the icon chooser is closed,
* we will crash when it does close, trying to access something in the
* destroyed panel. Could use wretain()/wrelease() in the panel,
* but it is not working for some reason.
*/
if (panel->choosingIcon)
return;
/*
* kluge. If we destroy the panel before the icon chooser is closed,
* we will crash when it does close, trying to access something in the
* destroyed panel. Could use wretain()/wrelease() in the panel,
* but it is not working for some reason.
*/
if (panel->choosingIcon)
return;
WMDestroyWidget(panel->win);
WMDestroyWidget(panel->win);
XDestroyWindow(dpy, panel->parent);
XDestroyWindow(dpy, panel->parent);
panel->editedIcon->panel = NULL;
panel->editedIcon->panel = NULL;
panel->editedIcon->editing = 0;
panel->editedIcon->editing = 0;
wfree(panel);
wfree(panel);
}
+1227 -1342
View File
File diff suppressed because it is too large. Load diff
+1054 -1178
View File
File diff suppressed because it is too large. Load diff
+83 -108
View File
@@ -1,155 +1,130 @@
#include <WINGs/WINGsP.h>
typedef struct W_GeometryView {
W_Class widgetClass;
WMView *view;
W_Class widgetClass;
WMView *view;
WMColor *color;
WMColor *bgColor;
WMColor *color;
WMColor *bgColor;
WMFont *font;
WMFont *font;
WMSize textSize;
WMSize textSize;
union {
struct {
int x, y;
} pos;
struct {
unsigned width, height;
} size;
} data;
union {
struct {
int x, y;
} pos;
struct {
unsigned width, height;
} size;
} data;
unsigned showPosition:1;
unsigned showPosition:1;
} WGeometryView;
static void handleEvents(XEvent * event, void *clientData);
static void paint(WGeometryView * gview);
static void handleEvents(XEvent *event, void *clientData);
static void paint(WGeometryView *gview);
WGeometryView*
WCreateGeometryView(WMScreen *scr)
WGeometryView *WCreateGeometryView(WMScreen * scr)
{
WGeometryView *gview;
char buffer[64];
static W_Class widgetClass = 0;
WGeometryView *gview;
char buffer[64];
static W_Class widgetClass = 0;
if (!widgetClass) {
widgetClass = W_RegisterUserWidget();
}
if (!widgetClass) {
widgetClass = W_RegisterUserWidget();
}
gview = malloc(sizeof(WGeometryView));
if (!gview) {
return NULL;
}
memset(gview, 0, sizeof(WGeometryView));
gview = malloc(sizeof(WGeometryView));
if (!gview) {
return NULL;
}
memset(gview, 0, sizeof(WGeometryView));
gview->widgetClass = widgetClass;
gview->widgetClass = widgetClass;
gview->view = W_CreateTopView(scr);
if (!gview->view) {
wfree(gview);
gview->view = W_CreateTopView(scr);
if (!gview->view) {
wfree(gview);
return NULL;
}
gview->view->self = gview;
return NULL;
}
gview->view->self = gview;
gview->font = WMSystemFontOfSize(scr, 12);
if (!gview->font) {
W_DestroyView(gview->view);
wfree(gview);
gview->font = WMSystemFontOfSize(scr, 12);
if (!gview->font) {
W_DestroyView(gview->view);
wfree(gview);
return NULL;
}
return NULL;
}
gview->bgColor = WMCreateRGBColor(scr, 0x3333, 0x6666, 0x9999, True);
gview->color = WMWhiteColor(scr);
gview->bgColor = WMCreateRGBColor(scr, 0x3333, 0x6666, 0x9999, True);
gview->color = WMWhiteColor(scr);
WMCreateEventHandler(gview->view, ExposureMask, handleEvents, gview);
WMCreateEventHandler(gview->view, ExposureMask, handleEvents, gview);
snprintf(buffer, sizeof(buffer), "%+05i, %+05i", 0, 0);
snprintf(buffer, sizeof(buffer), "%+05i, %+05i", 0, 0);
gview->textSize.width = WMWidthOfString(gview->font, buffer,
strlen(buffer));
gview->textSize.height = WMFontHeight(gview->font);
gview->textSize.width = WMWidthOfString(gview->font, buffer, strlen(buffer));
gview->textSize.height = WMFontHeight(gview->font);
WMSetWidgetBackgroundColor(gview, gview->bgColor);
WMSetWidgetBackgroundColor(gview, gview->bgColor);
W_ResizeView(gview->view, gview->textSize.width+8,
gview->textSize.height+6);
W_ResizeView(gview->view, gview->textSize.width + 8, gview->textSize.height + 6);
return gview;
return gview;
}
void
WSetGeometryViewShownPosition(WGeometryView *gview, int x, int y)
void WSetGeometryViewShownPosition(WGeometryView * gview, int x, int y)
{
gview->showPosition = 1;
gview->data.pos.x = x;
gview->data.pos.y = y;
gview->showPosition = 1;
gview->data.pos.x = x;
gview->data.pos.y = y;
paint(gview);
paint(gview);
}
void
WSetGeometryViewShownSize(WGeometryView *gview,
unsigned width, unsigned height)
void WSetGeometryViewShownSize(WGeometryView * gview, unsigned width, unsigned height)
{
gview->showPosition = 0;
gview->data.size.width = width;
gview->data.size.height = height;
gview->showPosition = 0;
gview->data.size.width = width;
gview->data.size.height = height;
paint(gview);
paint(gview);
}
static void
paint(WGeometryView *gview)
static void paint(WGeometryView * gview)
{
char buffer[64];
char buffer[64];
if (gview->showPosition) {
snprintf(buffer, sizeof(buffer), "%+5i , %+5i ",
gview->data.pos.x, gview->data.pos.y);
} else {
snprintf(buffer, sizeof(buffer), "%+5i x %+5i ",
gview->data.size.width, gview->data.size.height);
}
if (gview->showPosition) {
snprintf(buffer, sizeof(buffer), "%+5i , %+5i ", gview->data.pos.x, gview->data.pos.y);
} else {
snprintf(buffer, sizeof(buffer), "%+5i x %+5i ",
gview->data.size.width, gview->data.size.height);
}
WMDrawImageString(W_VIEW_SCREEN(gview->view),
W_VIEW_DRAWABLE(gview->view),
gview->color, gview->bgColor, gview->font,
(W_VIEW_WIDTH(gview->view)-gview->textSize.width)/2,
(W_VIEW_HEIGHT(gview->view)-gview->textSize.height)/2,
buffer, strlen(buffer));
WMDrawImageString(W_VIEW_SCREEN(gview->view),
W_VIEW_DRAWABLE(gview->view),
gview->color, gview->bgColor, gview->font,
(W_VIEW_WIDTH(gview->view) - gview->textSize.width) / 2,
(W_VIEW_HEIGHT(gview->view) - gview->textSize.height) / 2, buffer, strlen(buffer));
W_DrawRelief(W_VIEW_SCREEN(gview->view), W_VIEW_DRAWABLE(gview->view),
0, 0, W_VIEW_WIDTH(gview->view), W_VIEW_HEIGHT(gview->view),
WRSimple);
W_DrawRelief(W_VIEW_SCREEN(gview->view), W_VIEW_DRAWABLE(gview->view),
0, 0, W_VIEW_WIDTH(gview->view), W_VIEW_HEIGHT(gview->view), WRSimple);
}
static void
handleEvents(XEvent *event, void *clientData)
static void handleEvents(XEvent * event, void *clientData)
{
WGeometryView *gview = (WGeometryView*)clientData;
WGeometryView *gview = (WGeometryView *) clientData;
switch (event->type) {
case Expose:
paint(gview);
break;
switch (event->type) {
case Expose:
paint(gview);
break;
}
}
}
+625 -707
View File
File diff suppressed because it is too large. Load diff
+434 -490
View File
File diff suppressed because it is too large. Load diff
+1925 -2125
View File
File diff suppressed because it is too large. Load diff
+219 -291
View File
@@ -20,7 +20,6 @@
* USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,39 +32,35 @@
#include "rootmenu.h"
typedef struct PLMenuReaderData {
WRootMenuReader *reader;
WRootMenuReader *reader;
WMPropList *pl;
int curIndex;
WMPropList *pl;
int curIndex;
WMPropList **submenu;
int *curSubIndex;
int submenuDepth;
WMPropList **submenu;
int *curSubIndex;
int submenuDepth;
} PLMenuReaderData;
typedef struct TextMenuReaderData {
WRootMenuReader *reader;
WRootMenuReader *reader;
FILE *file;
FILE *file;
} TextMenuReaderData;
typedef struct PipeMenuReaderData {
WRootMenuReader *reader;
WRootMenuReader *reader;
} PipeMenuReaderData;
typedef struct DirMenuReaderData {
WRootMenuReader *reader;
WRootMenuReader *reader;
char **dirList;
int dirCount;
char **dirList;
int dirCount;
} DirMenuReaderData;
@@ -74,61 +69,38 @@ typedef struct DirMenuReaderData {
} GNOMEMenuReaderData;
*/
static WRootMenuData *pl_openMenu(WMPropList *pl);
static Bool pl_hasMoreData(WRootMenuData *data);
static Bool pl_nextCommand(WRootMenuData *data,
char **title,
char **command,
char **parameter,
char **shortcut);
static void pl_closeMenuFile(WRootMenuData *data);
static WRootMenuData *pl_openMenu(WMPropList * pl);
static Bool pl_hasMoreData(WRootMenuData * data);
static Bool pl_nextCommand(WRootMenuData * data, char **title, char **command, char **parameter, char **shortcut);
static void pl_closeMenuFile(WRootMenuData * data);
static WRootMenuData *text_openMenuFile(char *path);
static Bool text_hasMoreData(WRootMenuData *data);
static Bool text_nextCommand(WRootMenuData *data,
char **title,
char **command,
char **parameter,
char **shortcut);
static void text_closeMenuFile(WRootMenuData *data);
static Bool text_hasMoreData(WRootMenuData * data);
static Bool text_nextCommand(WRootMenuData * data,
char **title, char **command, char **parameter, char **shortcut);
static void text_closeMenuFile(WRootMenuData * data);
static WRootMenuData *dir_openMenuFile(char *path);
static Bool dir_hasMoreData(WRootMenuData *data);
static Bool dir_nextCommand(WRootMenuData *data,
char **title,
char **command,
char **parameter,
char **shortcut);
static void dir_closeMenuFile(WRootMenuData *data);
static Bool dir_hasMoreData(WRootMenuData * data);
static Bool dir_nextCommand(WRootMenuData * data, char **title, char **command, char **parameter, char **shortcut);
static void dir_closeMenuFile(WRootMenuData * data);
static WRootMenuReader PLMenuReader = {
pl_hasMoreData,
pl_nextCommand,
pl_closeMenuFile
pl_hasMoreData,
pl_nextCommand,
pl_closeMenuFile
};
static WRootMenuReader TextMenuReader = {
text_hasMoreData,
text_nextCommand,
text_closeMenuFile
text_hasMoreData,
text_nextCommand,
text_closeMenuFile
};
static WRootMenuReader DirMenuReaderData = {
dir_hasMoreData,
dir_nextCommand,
dir_closeMenuFile
dir_hasMoreData,
dir_nextCommand,
dir_closeMenuFile
};
/*
@@ -136,328 +108,284 @@ static WRootMenuReader DirMenuReaderData = {
};
*/
#define LINESIZE 1024
static char linebuf[LINESIZE];
/* ---------- proplist ---------- */
static WRootMenuData*
pl_openMenuFile(WMPropList *pl)
static WRootMenuData *pl_openMenuFile(WMPropList * pl)
{
PLRootMenuData *data = wmalloc(sizeof(PLRootMenuData));
PLRootMenuData *data = wmalloc(sizeof(PLRootMenuData));
data->reader = PLMenuReader;
data->reader = PLMenuReader;
data->pl = pl;
data->curIndex = 0;
data->pl = pl;
data->curIndex = 0;
data->submenu = NULL;
data->curSubIndex = NULL;
data->submenuDepth = 0;
data->submenu = NULL;
data->curSubIndex = NULL;
data->submenuDepth = 0;
return data;
return data;
}
static Bool
pl_hasMoreData(WRootMenuData *data)
static Bool pl_hasMoreData(WRootMenuData * data)
{
}
static Bool
pl_nextCommand(WRootMenuData *data, char **title, char **command,
char **parameter, char **shortcut)
static Bool pl_nextCommand(WRootMenuData * data, char **title, char **command, char **parameter, char **shortcut)
{
}
static void
pl_closeMenuFile(WRootMenuData *data)
static void pl_closeMenuFile(WRootMenuData * data)
{
if (data->submenu)
wfree(data->submenu);
if (data->curSubIndex)
wfree(data->curSubIndex);
if (data->submenu)
wfree(data->submenu);
if (data->curSubIndex)
wfree(data->curSubIndex);
WMReleasePropList(data->pl);
WMReleasePropList(data->pl);
wfree(data);
wfree(data);
}
/* ---------- text ---------- */
static WRootMenuData*
text_openMenuFile(char *path)
static WRootMenuData *text_openMenuFile(char *path)
{
TextMenuReaderData *data;
TextMenuReaderData *data;
data = wmalloc(sizeof(TextMenuReaderData));
data->reader = TextMenuReader;
data = wmalloc(sizeof(TextMenuReaderData));
data->reader = TextMenuReader;
data->file = fopen(path, "rb");
if (!data->file) {
data->file = fopen(path, "rb");
if (!data->file) {
return NULL;
}
return NULL;
}
}
static Bool
text_hasMoreData(WRootMenuData *data)
static Bool text_hasMoreData(WRootMenuData * data)
{
}
static Bool
text_nextCommand(WRootMenuData *data, char **title, char **command,
char **parameter, char **shortcut)
static Bool text_nextCommand(WRootMenuData * data, char **title, char **command, char **parameter, char **shortcut)
{
}
static void
text_closeMenuFile(WRootMenuData *data)
static void text_closeMenuFile(WRootMenuData * data)
{
}
/* ---------- directory ---------- */
static WRootMenuData*
dir_openMenuFile(char *paths, time_t *timestamp)
static WRootMenuData *dir_openMenuFile(char *paths, time_t * timestamp)
{
DirMenuReaderData *data;
char **dirs;
int dirN;
time_t checksum = 0;
int i, c;
DirMenuReaderData *data;
char **dirs;
int dirN;
time_t checksum = 0;
int i, c;
/* timestamp for directory is a "checksum" of the directory times */
/* timestamp for directory is a "checksum" of the directory times */
wtokensplit(paths, &dirs, &dirN);
wtokensplit(paths, &dirs, &dirN);
if (dirN == 0) {
return NULL;
}
if (dirN == 0) {
return NULL;
}
for (c = 0, i = 0; i < dirN; i++) {
char *tmp;
for (c = 0, i = 0; i < dirN; i++) {
char *tmp;
if (strcmp(dirs[i], "-noext")==0) {
i++;
continue;
}
if (strcmp(dirs[i], "-noext") == 0) {
i++;
continue;
}
tmp = wexpandpath(dirs[i]);
wfree(dirs[i]);
dirs[i] = tmp;
tmp = wexpandpath(dirs[i]);
wfree(dirs[i]);
dirs[i] = tmp;
if (stat(dirs[i], &stat_buf)<0) {
wsyserror(_("%s:could not stat menu"), dirs[i]);
wfree(dirs[i]);
dirs[i] = NULL;
} else {
c++;
checksum += stat_buf.st_mtime;
}
}
if (stat(dirs[i], &stat_buf) < 0) {
wsyserror(_("%s:could not stat menu"), dirs[i]);
wfree(dirs[i]);
dirs[i] = NULL;
} else {
c++;
checksum += stat_buf.st_mtime;
}
}
if (*timestamp == checksum && *timestamp != 0) {
return NULL;
}
if (*timestamp == checksum && *timestamp != 0) {
return NULL;
}
if (c == 0) {
for (i = 0; i < dirN; i++) {
if (dirs[i])
wfree(dirs[i]);
}
wfree(dirs);
return NULL;
}
data = wmalloc(sizeof(DirMenuReaderData));
data->reader = DirMenuReader;
if (c == 0) {
for (i = 0; i < dirN; i++) {
if (dirs[i])
wfree(dirs[i]);
}
wfree(dirs);
return NULL;
}
data = wmalloc(sizeof(DirMenuReaderData));
data->reader = DirMenuReader;
}
static Bool
dir_hasMoreData(WRootMenuData *data)
static Bool dir_hasMoreData(WRootMenuData * data)
{
}
static Bool
dir_nextCommand(WRootMenuData *data, char **title, char **command,
char **parameter, char **shortcut)
static Bool dir_nextCommand(WRootMenuData * data, char **title, char **command, char **parameter, char **shortcut)
{
}
static void
dir_closeMenuFile(WRootMenuData *data)
static void dir_closeMenuFile(WRootMenuData * data)
{
}
WRootMenuData*
OpenMenu(char *path, time_t *menuTime)
WRootMenuData *OpenMenu(char *path, time_t * menuTime)
{
proplist pl;
struct stat stat_buf;
WRootMenuData *data;
proplist pl;
struct stat stat_buf;
WRootMenuData *data;
/* check whether it's a piped menu */
if (*path == '|') {
/* piped menus have the following semantics for menuTime:
* if it's 0, then it wasnt loaded yet
* if it's 1, it was already loaded, so do not reload
* (would be too slow)
* now, menuTime will only be set to 1 if the pipe command is
* specified as ||command instead of |command
* in other words ||command means force the submenu to always refresh
*/
if (*menuTime == 0) {
data = pipe_openMenu(path);
}
if (path[1] != '|') {
*menuTime = 1;
}
return data;
}
/* check whether it's a piped menu */
if (*path == '|') {
/* piped menus have the following semantics for menuTime:
* if it's 0, then it wasnt loaded yet
* if it's 1, it was already loaded, so do not reload
* (would be too slow)
* now, menuTime will only be set to 1 if the pipe command is
* specified as ||command instead of |command
* in other words ||command means force the submenu to always refresh
*/
if (*menuTime == 0) {
data = pipe_openMenu(path);
}
if (path[1] != '|') {
*menuTime = 1;
}
return data;
}
if (stat(path, &stat_buf) < 0) {
wsyserror(_("could not stat() menu file '%s'"));
return NULL;
}
if (stat(path, &stat_buf) < 0) {
wsyserror(_("could not stat() menu file '%s'"));
return NULL;
}
/* check whether it's a directory */
if (S_ISDIR(stat_buf.st_mode)) {
return dir_openMenuFile(path, menuTime);
}
/* check whether it's a directory */
if (S_ISDIR(stat_buf.st_mode)) {
return dir_openMenuFile(path, menuTime);
}
if (*menuTime >= stat_buf.st_mtime && *menuTime != 0) {
/* no changes in the menu file */
return NULL;
}
if (*menuTime >= stat_buf.st_mtime && *menuTime != 0) {
/* no changes in the menu file */
return NULL;
}
/* then check whether it's a proplist menu */
pl = WMReadPropListFromFile(path);
if (pl && WMIsPLArray(pl)) {
*menuTime = stat_buf.st_mtime;
return pl_openMenu(pl);
}
/* then check whether it's a proplist menu */
pl = WMReadPropListFromFile(path);
if (pl && WMIsPLArray(pl)) {
*menuTime = stat_buf.st_mtime;
return pl_openMenu(pl);
}
*menuTime = stat_buf.st_mtime;
/* assume its a plain text menu */
return text_openMenuFile(path);
*menuTime = stat_buf.st_mtime;
/* assume its a plain text menu */
return text_openMenuFile(path);
}
WRootMenuData*
ReopenRootMenu(time_t *checkTime, char **menuPath, time_t *menuTimestamp)
WRootMenuData *ReopenRootMenu(time_t * checkTime, char **menuPath, time_t * menuTimestamp)
{
proplist pl;
struct stat stat_buf;
char *path;
proplist pl;
struct stat stat_buf;
char *path;
if (stat(path, &stat_buf) < 0) {
wsyserror(_("could not stat() menu file '%s'"));
return NULL;
}
if (stat(path, &stat_buf) < 0) {
wsyserror(_("could not stat() menu file '%s'"));
return NULL;
}
if (*menuTime >= stat_buf.st_mtime && *checkTime != 0) {
/* no changes in WMRootMenu, see if the contents changed */
if (*menuPath != NULL) {
return OpenMenu(*menuPath, menuTimestamp);
} else {
return NULL;
}
}
if (*menuTime >= stat_buf.st_mtime && *checkTime != 0) {
/* no changes in WMRootMenu, see if the contents changed */
if (*menuPath != NULL) {
return OpenMenu(*menuPath, menuTimestamp);
} else {
return NULL;
}
}
*checkTime = stat_buf.st_mtime;
*checkTime = stat_buf.st_mtime;
pl = WMReadPropListFromFile(path);
if (!pl) {
wwarning(_("could not load domain %s from user defaults database"), "WMRootMenu");
return NULL;
}
pl = WMReadPropListFromFile(path);
if (!pl) {
wwarning(_("could not load domain %s from user defaults database"),
"WMRootMenu");
return NULL;
}
if (WMIsPLString(pl)) {
char *tmp;
char *path;
Bool menu_is_default = False;
if (WMIsPLString(pl)) {
char *tmp;
char *path;
Bool menu_is_default = False;
tmp = wexpandpath(WMGetFromPLString(pl));
tmp = wexpandpath(WMGetFromPLString(pl));
path = getLocalizedMenuFile(tmp);
path = getLocalizedMenuFile(tmp);
if (!path) {
path = wfindfile(DEF_CONFIG_PATHS, tmp);
}
if (!path) {
path = wfindfile(DEF_CONFIG_PATHS, tmp);
}
if (!path) {
wwarning(_("could not find menu file '%s' referenced in WMRootMenu"), tmp);
path = wfindfile(DEF_CONFIG_PATHS, DEF_MENU_FILE);
menu_is_default = True;
}
if (!path) {
wwarning(_("could not find menu file '%s' referenced in WMRootMenu"),
tmp);
path = wfindfile(DEF_CONFIG_PATHS, DEF_MENU_FILE);
menu_is_default = True;
}
if (!path) {
wwarning(_("could not find any usable menu files. Please check '%s'"), tmp);
wfree(tmp);
return NULL;
}
if (!path) {
wwarning(_("could not find any usable menu files. Please check '%s'"),
tmp);
wfree(tmp);
return NULL;
}
wfree(tmp);
wfree(tmp);
if (*menuPath) {
if (strcmp(*menuPath, path) != 0) {
*menuTimestamp = 0;
wfree(*menuPath);
*menuPath = path;
if (*menuPath) {
if (strcmp(*menuPath, path) != 0) {
*menuTimestamp = 0;
wfree(*menuPath);
*menuPath = path;
if (menu_is_default) {
wwarning(_
("using default menu file \"%s\" as the menu referenced in WMRootMenu could not be found "),
path);
}
} else {
/* the menu path didn't change, but the
* pointed file might have changed, so we don't return
*/
}
} else {
*menuPath = path;
}
if (menu_is_default) {
wwarning(_("using default menu file \"%s\" as the menu referenced in WMRootMenu could not be found "),
path);
}
} else {
/* the menu path didn't change, but the
* pointed file might have changed, so we don't return
*/
}
} else {
*menuPath = path;
}
return OpenMenu(*menuPath, menuTimestamp);
} else if (WMIsPLArray(pl)) {
return OpenMenu(*menuPath, menuTimestamp);
} else if (WMIsPLArray(pl)) {
*menuTimestamp = stat_buf.st_mtime;
*menuTimestamp = stat_buf.st_mtime;
return pl_openMenu(pl);
} else {
wwarning(_("invalid content in menu file '%s'.\nIt should either be a property list menu or the path to the file, enclosed in \"."),
path);
return NULL;
}
return pl_openMenu(pl);
} else {
wwarning(_
("invalid content in menu file '%s'.\nIt should either be a property list menu or the path to the file, enclosed in \"."),
path);
return NULL;
}
}
+921 -998
View File
File diff suppressed because it is too large. Load diff
+76 -93
View File
@@ -46,115 +46,98 @@ extern WPreferences wPreferences;
extern int wScreenCount;
int showCrashDialog(int sig)
{
int crashAction;
dpy = XOpenDisplay(NULL);
if (dpy) {
int crashAction;
dpy = XOpenDisplay(NULL);
if (dpy) {
/* XXX TODO make sure that window states are saved and restored via netwm */
XGrabServer(dpy);
crashAction = wShowCrashingDialogPanel(sig);
XCloseDisplay(dpy);
dpy = NULL;
} else {
wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
crashAction = WMAbort;
}
if (crashAction == WMStartAlternate)
{
int i;
XGrabServer(dpy);
crashAction = wShowCrashingDialogPanel(sig);
XCloseDisplay(dpy);
dpy = NULL;
} else {
wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
crashAction = WMAbort;
}
wmessage(_("trying to start alternate window manager..."));
if (crashAction == WMStartAlternate) {
int i;
for (i=0; i<WMGetArrayItemCount(wPreferences.fallbackWMs); i++) {
Restart(WMGetFromArray(wPreferences.fallbackWMs, i), False);
}
wmessage(_("trying to start alternate window manager..."));
wfatal(_("failed to start alternate window manager. Aborting."));
for (i = 0; i < WMGetArrayItemCount(wPreferences.fallbackWMs); i++) {
Restart(WMGetFromArray(wPreferences.fallbackWMs, i), False);
}
return 0;
}
else if (crashAction == WMAbort)
return 0;
else
return 1;
wfatal(_("failed to start alternate window manager. Aborting."));
return 0;
} else if (crashAction == WMAbort)
return 0;
else
return 1;
}
int MonitorLoop(int argc, char **argv)
{
pid_t pid, exited;
char **child_argv= wmalloc(sizeof(char*)*(argc+2));
int i, status;
time_t last_start;
Bool error = False;
pid_t pid, exited;
char **child_argv = wmalloc(sizeof(char *) * (argc + 2));
int i, status;
time_t last_start;
Bool error = False;
for (i= 0; i < argc; i++)
child_argv[i]= argv[i];
child_argv[i++]= "--for-real";
child_argv[i]= NULL;
for (i = 0; i < argc; i++)
child_argv[i] = argv[i];
child_argv[i++] = "--for-real";
child_argv[i] = NULL;
for (;;)
{
last_start= time(NULL);
for (;;) {
last_start = time(NULL);
/* Start Window Maker */
pid = fork();
if (pid == 0)
{
execvp(child_argv[0], child_argv);
wsyserror(_("Error respawning Window Maker"));
exit(1);
}
else if (pid < 0)
{
wsyserror(_("Error respawning Window Maker"));
exit(1);
}
/* Start Window Maker */
pid = fork();
if (pid == 0) {
execvp(child_argv[0], child_argv);
wsyserror(_("Error respawning Window Maker"));
exit(1);
} else if (pid < 0) {
wsyserror(_("Error respawning Window Maker"));
exit(1);
}
do {
if ((exited=waitpid(-1, &status, 0)) < 0)
{
wsyserror(_("Error during monitoring of Window Maker process."));
error = True;
break;
}
} while (exited != pid);
do {
if ((exited = waitpid(-1, &status, 0)) < 0) {
wsyserror(_("Error during monitoring of Window Maker process."));
error = True;
break;
}
} while (exited != pid);
if (error)
break;
if (error)
break;
child_argv[argc]= "--for-real-";
/* Check if the wmaker process exited due to a crash */
if (WIFSIGNALED(status) &&
(WTERMSIG(status) == SIGSEGV ||
WTERMSIG(status) == SIGBUS ||
WTERMSIG(status) == SIGILL ||
WTERMSIG(status) == SIGABRT ||
WTERMSIG(status) == SIGFPE))
{
/* If so, we check when was the last restart.
* If it was less than 3s ago, it's a bad sign, so we show
* the crash panel and ask the user what to do */
if (time(NULL) - last_start < 3)
{
if (showCrashDialog(WTERMSIG(status)) == 0) {
return 1;
}
}
wwarning(_("Window Maker exited due to a crash (signal %i) and will be restarted."),
WTERMSIG(status));
}
else
break;
}
return 0;
child_argv[argc] = "--for-real-";
/* Check if the wmaker process exited due to a crash */
if (WIFSIGNALED(status) &&
(WTERMSIG(status) == SIGSEGV ||
WTERMSIG(status) == SIGBUS ||
WTERMSIG(status) == SIGILL || WTERMSIG(status) == SIGABRT || WTERMSIG(status) == SIGFPE)) {
/* If so, we check when was the last restart.
* If it was less than 3s ago, it's a bad sign, so we show
* the crash panel and ask the user what to do */
if (time(NULL) - last_start < 3) {
if (showCrashDialog(WTERMSIG(status)) == 0) {
return 1;
}
}
wwarning(_("Window Maker exited due to a crash (signal %i) and will be restarted."),
WTERMSIG(status));
} else
break;
}
return 0;
}
+129 -144
View File
@@ -20,7 +20,6 @@
* USA.
*/
#include "wconfig.h"
#ifdef MWM_HINTS
@@ -32,7 +31,6 @@
#include <stdio.h>
#include <string.h>
#include "WindowMaker.h"
#include "wcore.h"
@@ -45,7 +43,6 @@
#include "motif.h"
/* Motif window hints */
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
@@ -71,194 +68,182 @@
/* Motif window hints */
typedef struct {
long flags;
long functions;
long decorations;
long inputMode;
long unknown;
long flags;
long functions;
long decorations;
long inputMode;
long unknown;
} MWMHints;
static Atom _XA_MOTIF_WM_HINTS;
static void
setupMWMHints(WWindow *wwin, MWMHints *mwm_hints)
static void setupMWMHints(WWindow * wwin, MWMHints * mwm_hints)
{
/*
* We will ignore all decoration hints that have an equivalent as
* functions, because wmaker does not distinguish decoration hints
*/
/*
* We will ignore all decoration hints that have an equivalent as
* functions, because wmaker does not distinguish decoration hints
*/
if (mwm_hints->flags & MWM_HINTS_DECORATIONS) {
if (mwm_hints->flags & MWM_HINTS_DECORATIONS) {
# ifdef DEBUG
fprintf(stderr,"has decor hints [ ");
fprintf(stderr, "has decor hints [ ");
# endif
WSETUFLAG(wwin, no_titlebar, 1);
WSETUFLAG(wwin, no_close_button, 1);
WSETUFLAG(wwin, no_miniaturize_button, 1);
WSETUFLAG(wwin, no_resizebar, 1);
WSETUFLAG(wwin, no_titlebar, 1);
WSETUFLAG(wwin, no_close_button, 1);
WSETUFLAG(wwin, no_miniaturize_button, 1);
WSETUFLAG(wwin, no_resizebar, 1);
if (mwm_hints->decorations & MWM_DECOR_ALL) {
if (mwm_hints->decorations & MWM_DECOR_ALL) {
# ifdef DEBUG
fprintf(stderr,"ALL ");
fprintf(stderr, "ALL ");
# endif
WSETUFLAG(wwin, no_titlebar, 0);
WSETUFLAG(wwin, no_close_button, 0);
WSETUFLAG(wwin, no_closable, 0);
WSETUFLAG(wwin, no_miniaturize_button, 0);
WSETUFLAG(wwin, no_miniaturizable, 0);
WSETUFLAG(wwin, no_resizebar, 0);
WSETUFLAG(wwin, no_resizable, 0);
}
/*
if (mwm_hints->decorations & MWM_DECOR_BORDER) {
# ifdef DEBUG
fprintf(stderr,"(BORDER) ");
# endif
}
*/
WSETUFLAG(wwin, no_titlebar, 0);
WSETUFLAG(wwin, no_close_button, 0);
WSETUFLAG(wwin, no_closable, 0);
WSETUFLAG(wwin, no_miniaturize_button, 0);
WSETUFLAG(wwin, no_miniaturizable, 0);
WSETUFLAG(wwin, no_resizebar, 0);
WSETUFLAG(wwin, no_resizable, 0);
}
/*
if (mwm_hints->decorations & MWM_DECOR_BORDER) {
# ifdef DEBUG
fprintf(stderr,"(BORDER) ");
# endif
}
*/
if (mwm_hints->decorations & MWM_DECOR_RESIZEH) {
if (mwm_hints->decorations & MWM_DECOR_RESIZEH) {
# ifdef DEBUG
fprintf(stderr,"RESIZEH ");
fprintf(stderr, "RESIZEH ");
# endif
WSETUFLAG(wwin, no_resizebar, 0);
}
WSETUFLAG(wwin, no_resizebar, 0);
}
if (mwm_hints->decorations & MWM_DECOR_TITLE) {
if (mwm_hints->decorations & MWM_DECOR_TITLE) {
# ifdef DEBUG
fprintf(stderr,"TITLE+close ");
fprintf(stderr, "TITLE+close ");
# endif
WSETUFLAG(wwin, no_titlebar, 0);
WSETUFLAG(wwin, no_close_button, 0);
WSETUFLAG(wwin, no_closable, 0);
}
/*
if (mwm_hints->decorations & MWM_DECOR_MENU) {
# ifdef DEBUG
fprintf(stderr,"(MENU) ");
# endif
}
*/
WSETUFLAG(wwin, no_titlebar, 0);
WSETUFLAG(wwin, no_close_button, 0);
WSETUFLAG(wwin, no_closable, 0);
}
/*
if (mwm_hints->decorations & MWM_DECOR_MENU) {
# ifdef DEBUG
fprintf(stderr,"(MENU) ");
# endif
}
*/
if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) {
if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) {
# ifdef DEBUG
fprintf(stderr,"MINIMIZE ");
fprintf(stderr, "MINIMIZE ");
# endif
WSETUFLAG(wwin, no_miniaturize_button, 0);
WSETUFLAG(wwin, no_miniaturizable, 0);
}
/*
if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
# ifdef DEBUG
fprintf(stderr,"(MAXIMIZE) ");
# endif
}
*/
WSETUFLAG(wwin, no_miniaturize_button, 0);
WSETUFLAG(wwin, no_miniaturizable, 0);
}
/*
if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
# ifdef DEBUG
fprintf(stderr,"(MAXIMIZE) ");
# endif
}
*/
# ifdef DEBUG
fprintf(stderr,"]\n");
fprintf(stderr, "]\n");
# endif
}
}
if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) {
# ifdef DEBUG
fprintf(stderr, "has function hints [ ");
# endif
WSETUFLAG(wwin, no_closable, 1);
WSETUFLAG(wwin, no_miniaturizable, 1);
WSETUFLAG(wwin, no_resizable, 1);
if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) {
if (mwm_hints->functions & MWM_FUNC_ALL) {
# ifdef DEBUG
fprintf(stderr,"has function hints [ ");
fprintf(stderr, "ALL ");
# endif
WSETUFLAG(wwin, no_closable, 1);
WSETUFLAG(wwin, no_miniaturizable, 1);
WSETUFLAG(wwin, no_resizable, 1);
if (mwm_hints->functions & MWM_FUNC_ALL) {
WSETUFLAG(wwin, no_closable, 0);
WSETUFLAG(wwin, no_miniaturizable, 0);
WSETUFLAG(wwin, no_resizable, 0);
}
if (mwm_hints->functions & MWM_FUNC_RESIZE) {
# ifdef DEBUG
fprintf(stderr,"ALL ");
fprintf(stderr, "RESIZE ");
# endif
WSETUFLAG(wwin, no_closable, 0);
WSETUFLAG(wwin, no_miniaturizable, 0);
WSETUFLAG(wwin, no_resizable, 0);
}
if (mwm_hints->functions & MWM_FUNC_RESIZE) {
WSETUFLAG(wwin, no_resizable, 0);
}
/*
if (mwm_hints->functions & MWM_FUNC_MOVE) {
# ifdef DEBUG
fprintf(stderr,"(MOVE) ");
# endif
}
*/
if (mwm_hints->functions & MWM_FUNC_MINIMIZE) {
# ifdef DEBUG
fprintf(stderr,"RESIZE ");
fprintf(stderr, "MINIMIZE ");
# endif
WSETUFLAG(wwin, no_resizable, 0);
}
/*
if (mwm_hints->functions & MWM_FUNC_MOVE) {
# ifdef DEBUG
fprintf(stderr,"(MOVE) ");
# endif
}
*/
if (mwm_hints->functions & MWM_FUNC_MINIMIZE) {
WSETUFLAG(wwin, no_miniaturizable, 0);
}
if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) {
# ifdef DEBUG
fprintf(stderr,"MINIMIZE ");
fprintf(stderr, "MAXIMIZE ");
/* a window must be resizable to be maximizable */
WSETUFLAG(wwin, no_resizable, 0);
# endif
WSETUFLAG(wwin, no_miniaturizable, 0);
}
if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) {
}
if (mwm_hints->functions & MWM_FUNC_CLOSE) {
# ifdef DEBUG
fprintf(stderr,"MAXIMIZE ");
/* a window must be resizable to be maximizable */
WSETUFLAG(wwin, no_resizable, 0);
fprintf(stderr, "CLOSE ");
# endif
}
if (mwm_hints->functions & MWM_FUNC_CLOSE) {
WSETUFLAG(wwin, no_closable, 0);
}
# ifdef DEBUG
fprintf(stderr,"CLOSE ");
fprintf(stderr, "]\n");
# endif
WSETUFLAG(wwin, no_closable, 0);
}
# ifdef DEBUG
fprintf(stderr,"]\n");
# endif
}
}
}
static int
getMWMHints(Window window, MWMHints *mwmhints)
static int getMWMHints(Window window, MWMHints * mwmhints)
{
unsigned long *data;
int count;
unsigned long *data;
int count;
if (!_XA_MOTIF_WM_HINTS) {
_XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
}
if (!_XA_MOTIF_WM_HINTS) {
_XA_MOTIF_WM_HINTS = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
}
data = (unsigned long*)PropGetCheckProperty(window, _XA_MOTIF_WM_HINTS,
_XA_MOTIF_WM_HINTS, 32,
0, &count);
data = (unsigned long *)PropGetCheckProperty(window, _XA_MOTIF_WM_HINTS,
_XA_MOTIF_WM_HINTS, 32, 0, &count);
if (!data)
return 0;
if (!data)
return 0;
if (count >= 4) {
mwmhints->flags = data[0];
mwmhints->functions = data[1];
mwmhints->decorations = data[2];
mwmhints->inputMode = data[3];
if (count > 5)
mwmhints->unknown = data[4];
}
XFree(data);
if (count >= 4) {
mwmhints->flags = data[0];
mwmhints->functions = data[1];
mwmhints->decorations = data[2];
mwmhints->inputMode = data[3];
if (count > 5)
mwmhints->unknown = data[4];
}
XFree(data);
return 1;
return 1;
}
void
wMWMCheckClientHints(WWindow *wwin)
void wMWMCheckClientHints(WWindow * wwin)
{
MWMHints hints;
MWMHints hints;
if (getMWMHints(wwin->client_win, &hints)) {
setupMWMHints(wwin, &hints);
}
if (getMWMHints(wwin->client_win, &hints)) {
setupMWMHints(wwin, &hints);
}
}
#endif /* MWM_HINTS */
#endif /* MWM_HINTS */
+1832 -1962
View File
File diff suppressed because it is too large. Load diff
+131 -152
View File
@@ -31,8 +31,6 @@
#include "WindowMaker.h"
#include "wcore.h"
/*
*----------------------------------------------------------------------
* wPixmapCreateFromXPMData--
@@ -46,31 +44,29 @@
* DEF_XPM_CLOSENESS specifies the XpmCloseness
*----------------------------------------------------------------------
*/
WPixmap*
wPixmapCreateFromXPMData(WScreen *scr, char **data)
WPixmap *wPixmapCreateFromXPMData(WScreen * scr, char **data)
{
RImage *image;
WPixmap *pix;
RImage *image;
WPixmap *pix;
image = RGetImageFromXPMData(scr->rcontext, data);
if (!image)
return NULL;
image = RGetImageFromXPMData(scr->rcontext, data);
if (!image)
return NULL;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
RConvertImageMask(scr->rcontext, image, &pix->image, &pix->mask, 128);
RConvertImageMask(scr->rcontext, image, &pix->image, &pix->mask, 128);
pix->width = image->width;
pix->height = image->height;
pix->depth = scr->w_depth;
pix->width = image->width;
pix->height = image->height;
pix->depth = scr->w_depth;
RReleaseImage(image);
RReleaseImage(image);
return pix;
return pix;
}
/*
*----------------------------------------------------------------------
* wPixmapCreateFromXBMData--
@@ -82,117 +78,106 @@ wPixmapCreateFromXPMData(WScreen *scr, char **data)
*
*----------------------------------------------------------------------
*/
WPixmap*
wPixmapCreateFromXBMData(WScreen *scr, char *data, char *mask,
int width, int height, unsigned long fg,
unsigned long bg)
WPixmap *wPixmapCreateFromXBMData(WScreen * scr, char *data, char *mask,
int width, int height, unsigned long fg, unsigned long bg)
{
WPixmap *pix;
WPixmap *pix;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width,
height, fg, bg, scr->w_depth);
if (pix->image==None) {
wfree(pix);
return NULL;
}
if (mask) {
pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width,
height);
} else {
pix->mask = None;
}
pix->width = width;
pix->height = height;
pix->depth = scr->w_depth;
return pix;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix->image = XCreatePixmapFromBitmapData(dpy, scr->w_win, data, width, height, fg, bg, scr->w_depth);
if (pix->image == None) {
wfree(pix);
return NULL;
}
if (mask) {
pix->mask = XCreateBitmapFromData(dpy, scr->w_win, mask, width, height);
} else {
pix->mask = None;
}
pix->width = width;
pix->height = height;
pix->depth = scr->w_depth;
return pix;
}
#ifdef unused
WPixmap*
wPixmapCreateFromBitmap(WScreen *scr, Pixmap bitmap, Pixmap mask,
unsigned long fg, unsigned long bg)
WPixmap *wPixmapCreateFromBitmap(WScreen * scr, Pixmap bitmap, Pixmap mask, unsigned long fg, unsigned long bg)
{
WPixmap *pix;
XImage *img, *img2;
Window foo;
int bar, x, y;
Pixmap pixmap;
unsigned int width, height, baz, d;
WPixmap *pix;
XImage *img, *img2;
Window foo;
int bar, x, y;
Pixmap pixmap;
unsigned int width, height, baz, d;
if (!XGetGeometry(dpy, bitmap, &foo, &bar, &bar, &width, &height, &baz,
&d) || d!=1) {
return NULL;
}
img = XGetImage(dpy, bitmap, 0, 0, width, height, AllPlanes, XYPixmap);
if (!img)
return NULL;
if (!XGetGeometry(dpy, bitmap, &foo, &bar, &bar, &width, &height, &baz, &d) || d != 1) {
return NULL;
}
img = XGetImage(dpy, bitmap, 0, 0, width, height, AllPlanes, XYPixmap);
if (!img)
return NULL;
img2=XCreateImage(dpy, scr->w_visual, scr->w_depth, ZPixmap,
0, NULL, width, height, 8, 0);
if (!img2) {
XDestroyImage(img);
return NULL;
}
img2 = XCreateImage(dpy, scr->w_visual, scr->w_depth, ZPixmap, 0, NULL, width, height, 8, 0);
if (!img2) {
XDestroyImage(img);
return NULL;
}
pixmap = XCreatePixmap(dpy, scr->w_win, width, height, scr->w_depth);
if (pixmap==None) {
XDestroyImage(img);
XDestroyImage(img2);
return NULL;
}
pixmap = XCreatePixmap(dpy, scr->w_win, width, height, scr->w_depth);
if (pixmap == None) {
XDestroyImage(img);
XDestroyImage(img2);
return NULL;
}
img2->data = wmalloc(height * img2->bytes_per_line);
img2->data = wmalloc(height * img2->bytes_per_line);
for (y=0; y<height; y++) {
for (x=0; x<width; x++) {
if (XGetPixel(img, x, y)==0) {
XPutPixel(img2, x, y, bg);
} else {
XPutPixel(img2, x, y, fg);
}
}
}
XSetClipMask(dpy, scr->copy_gc, None);
XPutImage(dpy, pixmap, scr->copy_gc, img2, 0, 0, 0, 0, width, height);
XDestroyImage(img);
XDestroyImage(img2);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
if (XGetPixel(img, x, y) == 0) {
XPutPixel(img2, x, y, bg);
} else {
XPutPixel(img2, x, y, fg);
}
}
}
XSetClipMask(dpy, scr->copy_gc, None);
XPutImage(dpy, pixmap, scr->copy_gc, img2, 0, 0, 0, 0, width, height);
XDestroyImage(img);
XDestroyImage(img2);
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix->image = pixmap;
pix->mask = mask;
pix->width = width;
pix->height = height;
pix->depth = scr->w_depth;
return pix;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix->image = pixmap;
pix->mask = mask;
pix->width = width;
pix->height = height;
pix->depth = scr->w_depth;
return pix;
}
#endif /* unused */
#endif /* unused */
WPixmap*
wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask)
WPixmap *wPixmapCreate(WScreen * scr, Pixmap image, Pixmap mask)
{
WPixmap *pix;
Window foo;
int bar;
unsigned int width, height, depth, baz;
WPixmap *pix;
Window foo;
int bar;
unsigned int width, height, depth, baz;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix->image = image;
pix->mask = mask;
if (!XGetGeometry(dpy, image, &foo, &bar, &bar, &width, &height, &baz,
&depth)) {
wwarning("XGetGeometry() failed during wPixmapCreate()");
wfree(pix);
return NULL;
}
pix->width = width;
pix->height = height;
pix->depth = depth;
return pix;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix->image = image;
pix->mask = mask;
if (!XGetGeometry(dpy, image, &foo, &bar, &bar, &width, &height, &baz, &depth)) {
wwarning("XGetGeometry() failed during wPixmapCreate()");
wfree(pix);
return NULL;
}
pix->width = width;
pix->height = height;
pix->depth = depth;
return pix;
}
#if 0
@@ -211,36 +196,33 @@ wPixmapCreate(WScreen *scr, Pixmap image, Pixmap mask)
* continues as no mask was supplied.
*----------------------------------------------------------------------
*/
WPixmap*
wPixmapLoadXBMFile(WScreen *scr, char *path, char *mask_path)
WPixmap *wPixmapLoadXBMFile(WScreen * scr, char *path, char *mask_path)
{
WPixmap *pix;
int junk;
WPixmap *pix;
int junk;
if (!path) return NULL;
if (!path)
return NULL;
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
pix = wmalloc(sizeof(WPixmap));
memset(pix, 0, sizeof(WPixmap));
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&(pix->width),
(unsigned *)&(pix->height),
&(pix->image), &junk, &junk)!=BitmapSuccess) {
wfree(pix);
return NULL;
}
if (mask_path!=NULL) {
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&junk,
(unsigned *)&junk, &(pix->mask),
&junk, &junk) !=BitmapSuccess) {
wwarning(_("could not load mask bitmap file \"%s\". Won't use mask"),
mask_path);
pix->mask = None;
}
} else {
pix->mask = None;
}
pix->depth = 1;
return pix;
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&(pix->width),
(unsigned *)&(pix->height), &(pix->image), &junk, &junk) != BitmapSuccess) {
wfree(pix);
return NULL;
}
if (mask_path != NULL) {
if (XReadBitmapFile(dpy, scr->w_win, path, (unsigned *)&junk,
(unsigned *)&junk, &(pix->mask), &junk, &junk) != BitmapSuccess) {
wwarning(_("could not load mask bitmap file \"%s\". Won't use mask"), mask_path);
pix->mask = None;
}
} else {
pix->mask = None;
}
pix->depth = 1;
return pix;
}
#endif
@@ -254,19 +236,16 @@ wPixmapLoadXBMFile(WScreen *scr, char *path, char *mask_path)
* None
*----------------------------------------------------------------------
*/
void
wPixmapDestroy(WPixmap *pix)
void wPixmapDestroy(WPixmap * pix)
{
if (!pix->shared) {
if (pix->mask && !pix->client_owned_mask) {
XFreePixmap(dpy, pix->mask);
}
if (!pix->shared) {
if (pix->mask && !pix->client_owned_mask) {
XFreePixmap(dpy, pix->mask);
}
if (pix->image && !pix->client_owned) {
XFreePixmap(dpy, pix->image);
}
}
wfree(pix);
if (pix->image && !pix->client_owned) {
XFreePixmap(dpy, pix->image);
}
}
wfree(pix);
}
+440 -475
View File
File diff suppressed because it is too large. Load diff
+199 -236
View File
@@ -31,7 +31,6 @@
#include "window.h"
#include "GNUstep.h"
/* atoms */
extern Atom _XA_WM_STATE;
extern Atom _XA_WM_CHANGE_STATE;
@@ -45,7 +44,6 @@ extern Atom _XA_WM_WINDOW_ROLE;
extern Atom _XA_SM_CLIENT_ID;
#endif
extern Atom _XA_GNUSTEP_WM_ATTR;
extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW;
@@ -56,323 +54,288 @@ extern Atom _XA_WINDOWMAKER_NOTICEBOARD;
extern Atom _XA_WINDOWMAKER_ICON_TILE;
extern Atom _XA_WINDOWMAKER_ICON_SIZE;
int
PropGetNormalHints(Window window, XSizeHints *size_hints, int *pre_iccm)
int PropGetNormalHints(Window window, XSizeHints * size_hints, int *pre_iccm)
{
long supplied_hints;
long supplied_hints;
if (!XGetWMNormalHints(dpy, window, size_hints, &supplied_hints)) {
return False;
}
if (supplied_hints==(USPosition|USSize|PPosition|PSize|PMinSize|PMaxSize
|PResizeInc|PAspect)) {
*pre_iccm = 1;
} else {
*pre_iccm = 0;
}
return True;
if (!XGetWMNormalHints(dpy, window, size_hints, &supplied_hints)) {
return False;
}
if (supplied_hints == (USPosition | USSize | PPosition | PSize | PMinSize | PMaxSize
| PResizeInc | PAspect)) {
*pre_iccm = 1;
} else {
*pre_iccm = 0;
}
return True;
}
int
PropGetWMClass(Window window, char **wm_class, char **wm_instance)
int PropGetWMClass(Window window, char **wm_class, char **wm_instance)
{
XClassHint *class_hint;
XClassHint *class_hint;
class_hint = XAllocClassHint();
if (XGetClassHint(dpy,window,class_hint) == 0) {
*wm_class = NULL;
*wm_instance = NULL;
XFree(class_hint);
return False;
}
*wm_instance = class_hint->res_name;
*wm_class = class_hint->res_class;
class_hint = XAllocClassHint();
if (XGetClassHint(dpy, window, class_hint) == 0) {
*wm_class = NULL;
*wm_instance = NULL;
XFree(class_hint);
return False;
}
*wm_instance = class_hint->res_name;
*wm_class = class_hint->res_class;
XFree(class_hint);
return True;
XFree(class_hint);
return True;
}
void
PropGetProtocols(Window window, WProtocols *prots)
void PropGetProtocols(Window window, WProtocols * prots)
{
Atom *protocols;
int count, i;
Atom *protocols;
int count, i;
memset(prots, 0, sizeof(WProtocols));
if (!XGetWMProtocols(dpy, window, &protocols, &count)) {
return;
}
for (i=0; i<count; i++) {
if (protocols[i]==_XA_WM_TAKE_FOCUS)
prots->TAKE_FOCUS=1;
else if (protocols[i]==_XA_WM_DELETE_WINDOW)
prots->DELETE_WINDOW=1;
else if (protocols[i]==_XA_WM_SAVE_YOURSELF)
prots->SAVE_YOURSELF=1;
else if (protocols[i]==_XA_GNUSTEP_WM_MINIATURIZE_WINDOW)
prots->MINIATURIZE_WINDOW=1;
}
XFree(protocols);
memset(prots, 0, sizeof(WProtocols));
if (!XGetWMProtocols(dpy, window, &protocols, &count)) {
return;
}
for (i = 0; i < count; i++) {
if (protocols[i] == _XA_WM_TAKE_FOCUS)
prots->TAKE_FOCUS = 1;
else if (protocols[i] == _XA_WM_DELETE_WINDOW)
prots->DELETE_WINDOW = 1;
else if (protocols[i] == _XA_WM_SAVE_YOURSELF)
prots->SAVE_YOURSELF = 1;
else if (protocols[i] == _XA_GNUSTEP_WM_MINIATURIZE_WINDOW)
prots->MINIATURIZE_WINDOW = 1;
}
XFree(protocols);
}
unsigned char*
PropGetCheckProperty(Window window, Atom hint, Atom type, int format,
int count, int *retCount)
unsigned char *PropGetCheckProperty(Window window, Atom hint, Atom type, int format, int count, int *retCount)
{
Atom type_ret;
int fmt_ret;
unsigned long nitems_ret;
unsigned long bytes_after_ret;
unsigned char *data;
int tmp;
Atom type_ret;
int fmt_ret;
unsigned long nitems_ret;
unsigned long bytes_after_ret;
unsigned char *data;
int tmp;
if (count <= 0)
tmp = 0xffffff;
else
tmp = count;
if (count <= 0)
tmp = 0xffffff;
else
tmp = count;
if (XGetWindowProperty(dpy, window, hint, 0, tmp, False, type,
&type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret,
(unsigned char **)&data)!=Success || !data)
return NULL;
if (XGetWindowProperty(dpy, window, hint, 0, tmp, False, type,
&type_ret, &fmt_ret, &nitems_ret, &bytes_after_ret,
(unsigned char **)&data) != Success || !data)
return NULL;
if ((type!=AnyPropertyType && type!=type_ret)
|| (count > 0 && nitems_ret != count)
|| (format != 0 && format != fmt_ret)) {
XFree(data);
return NULL;
}
if ((type != AnyPropertyType && type != type_ret)
|| (count > 0 && nitems_ret != count)
|| (format != 0 && format != fmt_ret)) {
XFree(data);
return NULL;
}
if (retCount)
*retCount = nitems_ret;
if (retCount)
*retCount = nitems_ret;
return data;
return data;
}
int
PropGetGNUstepWMAttr(Window window, GNUstepWMAttributes **attr)
int PropGetGNUstepWMAttr(Window window, GNUstepWMAttributes ** attr)
{
unsigned long *data;
unsigned long *data;
data = (unsigned long*)PropGetCheckProperty(window, _XA_GNUSTEP_WM_ATTR,
_XA_GNUSTEP_WM_ATTR, 32, 9,
NULL);
data = (unsigned long *)PropGetCheckProperty(window, _XA_GNUSTEP_WM_ATTR,
_XA_GNUSTEP_WM_ATTR, 32, 9, NULL);
if (!data)
return False;
if (!data)
return False;
*attr = malloc(sizeof(GNUstepWMAttributes));
if (!*attr) {
XFree(data);
return False;
}
(*attr)->flags = data[0];
(*attr)->window_style = data[1];
(*attr)->window_level = data[2];
(*attr)->reserved = data[3];
(*attr)->miniaturize_pixmap = data[4];
(*attr)->close_pixmap = data[5];
(*attr)->miniaturize_mask = data[6];
(*attr)->close_mask = data[7];
(*attr)->extra_flags = data[8];
*attr = malloc(sizeof(GNUstepWMAttributes));
if (!*attr) {
XFree(data);
return False;
}
(*attr)->flags = data[0];
(*attr)->window_style = data[1];
(*attr)->window_level = data[2];
(*attr)->reserved = data[3];
(*attr)->miniaturize_pixmap = data[4];
(*attr)->close_pixmap = data[5];
(*attr)->miniaturize_mask = data[6];
(*attr)->close_mask = data[7];
(*attr)->extra_flags = data[8];
XFree(data);
XFree(data);
return True;
return True;
}
void
PropSetWMakerProtocols(Window root)
void PropSetWMakerProtocols(Window root)
{
Atom protocols[3];
int count=0;
Atom protocols[3];
int count = 0;
protocols[count++] = _XA_WINDOWMAKER_MENU;
protocols[count++] = _XA_WINDOWMAKER_WM_FUNCTION;
protocols[count++] = _XA_WINDOWMAKER_NOTICEBOARD;
protocols[count++] = _XA_WINDOWMAKER_MENU;
protocols[count++] = _XA_WINDOWMAKER_WM_FUNCTION;
protocols[count++] = _XA_WINDOWMAKER_NOTICEBOARD;
XChangeProperty(dpy, root, _XA_WINDOWMAKER_WM_PROTOCOLS, XA_ATOM,
32, PropModeReplace, (unsigned char *)protocols, count);
XChangeProperty(dpy, root, _XA_WINDOWMAKER_WM_PROTOCOLS, XA_ATOM,
32, PropModeReplace, (unsigned char *)protocols, count);
}
void
PropSetIconTileHint(WScreen *scr, RImage *image)
void PropSetIconTileHint(WScreen * scr, RImage * image)
{
static Atom imageAtom = 0;
unsigned char *tmp;
int x, y;
static Atom imageAtom = 0;
unsigned char *tmp;
int x, y;
if (scr->info_window == None)
return;
if (scr->info_window == None)
return;
if (!imageAtom) {
/*
* WIDTH, HEIGHT (16 bits, MSB First)
* array of R,G,B,A bytes
*/
imageAtom = XInternAtom(dpy, "_RGBA_IMAGE", False);
}
if (!imageAtom) {
/*
* WIDTH, HEIGHT (16 bits, MSB First)
* array of R,G,B,A bytes
*/
imageAtom = XInternAtom(dpy, "_RGBA_IMAGE", False);
}
tmp = malloc(image->width * image->height * 4 + 4);
if (!tmp) {
wwarning("could not allocate memory to set _WINDOWMAKER_ICON_TILE hint");
return;
}
tmp = malloc(image->width * image->height * 4 + 4);
if (!tmp) {
wwarning("could not allocate memory to set _WINDOWMAKER_ICON_TILE hint");
return;
}
tmp[0] = image->width>>8;
tmp[1] = image->width&0xff;
tmp[2] = image->height>>8;
tmp[3] = image->height&0xff;
tmp[0] = image->width >> 8;
tmp[1] = image->width & 0xff;
tmp[2] = image->height >> 8;
tmp[3] = image->height & 0xff;
if (image->format == RRGBAFormat) {
memcpy(&tmp[4], image->data, image->width*image->height*4);
} else {
char *ptr = (char*)(tmp+4);
char *src = (char*)image->data;
if (image->format == RRGBAFormat) {
memcpy(&tmp[4], image->data, image->width * image->height * 4);
} else {
char *ptr = (char *)(tmp + 4);
char *src = (char *)image->data;
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
*ptr++ = *src++;
*ptr++ = *src++;
*ptr++ = *src++;
*ptr++ = 255;
}
}
}
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
*ptr++ = *src++;
*ptr++ = *src++;
*ptr++ = *src++;
*ptr++ = 255;
}
}
}
XChangeProperty(dpy, scr->info_window, _XA_WINDOWMAKER_ICON_TILE,
imageAtom, 8, PropModeReplace, tmp,
image->width * image->height * 4 + 4);
wfree(tmp);
XChangeProperty(dpy, scr->info_window, _XA_WINDOWMAKER_ICON_TILE,
imageAtom, 8, PropModeReplace, tmp, image->width * image->height * 4 + 4);
wfree(tmp);
}
Window
PropGetClientLeader(Window window)
Window PropGetClientLeader(Window window)
{
Window *win;
Window leader;
Window *win;
Window leader;
win = (Window*)PropGetCheckProperty(window, _XA_WM_CLIENT_LEADER,
XA_WINDOW, 32, 1, NULL);
win = (Window *) PropGetCheckProperty(window, _XA_WM_CLIENT_LEADER, XA_WINDOW, 32, 1, NULL);
if (!win)
return None;
if (!win)
return None;
leader = (Window)*win;
XFree(win);
leader = (Window) * win;
XFree(win);
return leader;
return leader;
}
#ifdef XSMP_ENABLED
char*
PropGetClientID(Window window)
char *PropGetClientID(Window window)
{
XTextProperty txprop;
XTextProperty txprop;
txprop.value = NULL;
txprop.value = NULL;
if (XGetTextProperty(dpy, window, &txprop, _XA_SM_CLIENT_ID)!=Success) {
return NULL;
}
if (XGetTextProperty(dpy, window, &txprop, _XA_SM_CLIENT_ID) != Success) {
return NULL;
}
if (txprop.encoding == XA_STRING && txprop.format == 8
&& txprop.nitems > 0) {
if (txprop.encoding == XA_STRING && txprop.format == 8 && txprop.nitems > 0) {
return (char*)txprop.value;
} else {
return (char *)txprop.value;
} else {
if (txprop.value)
XFree(txprop.value);
if (txprop.value)
XFree(txprop.value);
return NULL;
}
return NULL;
}
}
char*
PropGetWindowRole(Window window)
char *PropGetWindowRole(Window window)
{
XTextProperty txprop;
XTextProperty txprop;
txprop.value = NULL;
txprop.value = NULL;
if (XGetTextProperty(dpy, window, &txprop, _XA_WM_WINDOW_ROLE)!=Success) {
return NULL;
}
if (XGetTextProperty(dpy, window, &txprop, _XA_WM_WINDOW_ROLE) != Success) {
return NULL;
}
if (txprop.encoding == XA_STRING && txprop.format == 8
&& txprop.nitems > 0) {
if (txprop.encoding == XA_STRING && txprop.format == 8 && txprop.nitems > 0) {
return (char*)txprop.value;
} else {
return (char *)txprop.value;
} else {
if (txprop.value)
XFree(txprop.value);
if (txprop.value)
XFree(txprop.value);
return NULL;
}
return NULL;
}
}
#endif /* XSMP_ENABLED */
#endif /* XSMP_ENABLED */
void
PropWriteGNUstepWMAttr(Window window, GNUstepWMAttributes *attr)
void PropWriteGNUstepWMAttr(Window window, GNUstepWMAttributes * attr)
{
unsigned long data[9];
unsigned long data[9];
data[0] = attr->flags;
data[1] = attr->window_style;
data[2] = attr->window_level;
data[3] = 0; /* reserved */
/* The X protocol says XIDs are 32bit */
data[4] = attr->miniaturize_pixmap;
data[5] = attr->close_pixmap;
data[6] = attr->miniaturize_mask;
data[7] = attr->close_mask;
data[8] = attr->extra_flags;
XChangeProperty(dpy, window, _XA_GNUSTEP_WM_ATTR, _XA_GNUSTEP_WM_ATTR,
32, PropModeReplace, (unsigned char *)data, 9);
data[0] = attr->flags;
data[1] = attr->window_style;
data[2] = attr->window_level;
data[3] = 0; /* reserved */
/* The X protocol says XIDs are 32bit */
data[4] = attr->miniaturize_pixmap;
data[5] = attr->close_pixmap;
data[6] = attr->miniaturize_mask;
data[7] = attr->close_mask;
data[8] = attr->extra_flags;
XChangeProperty(dpy, window, _XA_GNUSTEP_WM_ATTR, _XA_GNUSTEP_WM_ATTR,
32, PropModeReplace, (unsigned char *)data, 9);
}
int
PropGetWindowState(Window window)
int PropGetWindowState(Window window)
{
long *data;
long state;
long *data;
long state;
data = (long*)PropGetCheckProperty(window, _XA_WM_STATE, _XA_WM_STATE,
32, 1, NULL);
data = (long *)PropGetCheckProperty(window, _XA_WM_STATE, _XA_WM_STATE, 32, 1, NULL);
if (!data)
return -1;
if (!data)
return -1;
state = *data;
XFree(data);
state = *data;
XFree(data);
return state;
return state;
}
void
PropCleanUp(Window root)
void PropCleanUp(Window root)
{
XDeleteProperty(dpy, root, _XA_WINDOWMAKER_WM_PROTOCOLS);
XDeleteProperty(dpy, root, _XA_WINDOWMAKER_WM_PROTOCOLS);
XDeleteProperty(dpy, root, _XA_WINDOWMAKER_NOTICEBOARD);
XDeleteProperty(dpy, root, _XA_WINDOWMAKER_NOTICEBOARD);
XDeleteProperty(dpy, root, XA_WM_ICON_SIZE);
XDeleteProperty(dpy, root, XA_WM_ICON_SIZE);
}
+16 -21
View File
@@ -36,30 +36,25 @@
#include "screen.h"
#include "pixmap.h"
int
wGetColor(WScreen *scr, char *color_name, XColor *color)
int wGetColor(WScreen * scr, char *color_name, XColor * color)
{
if (!XParseColor(dpy, scr->w_colormap, color_name, color)) {
wwarning(_("could not parse color \"%s\""), color_name);
return False;
}
if (!XAllocColor(dpy, scr->w_colormap, color)) {
wwarning(_("could not allocate color \"%s\""), color_name);
return False;
}
return True;
if (!XParseColor(dpy, scr->w_colormap, color_name, color)) {
wwarning(_("could not parse color \"%s\""), color_name);
return False;
}
if (!XAllocColor(dpy, scr->w_colormap, color)) {
wwarning(_("could not allocate color \"%s\""), color_name);
return False;
}
return True;
}
void
wFreeColor(WScreen *scr, unsigned long pixel)
void wFreeColor(WScreen * scr, unsigned long pixel)
{
if (pixel!=scr->white_pixel && pixel!=scr->black_pixel) {
unsigned long colors[1];
if (pixel != scr->white_pixel && pixel != scr->black_pixel) {
unsigned long colors[1];
colors[0] = pixel;
XFreeColors(dpy, scr->w_colormap, colors, 1, 0);
}
colors[0] = pixel;
XFreeColors(dpy, scr->w_colormap, colors, 1, 0);
}
}
+1238 -1354
View File
File diff suppressed because it is too large. Load diff
+771 -856
View File
File diff suppressed because it is too large. Load diff
+830 -926
View File
File diff suppressed because it is too large. Load diff
+107 -118
View File
@@ -41,9 +41,7 @@ extern Atom _XA_WM_DELETE_WINDOW;
extern Time LastTimestamp;
extern int wScreenCount;
static void wipeDesktop(WScreen *scr);
static void wipeDesktop(WScreen * scr);
/*
*----------------------------------------------------------------------
@@ -55,121 +53,116 @@ static void wipeDesktop(WScreen *scr);
*
*----------------------------------------------------------------------
*/
void
Shutdown(WShutdownMode mode)
void Shutdown(WShutdownMode mode)
{
int i;
extern int inotifyFD;
int i;
extern int inotifyFD;
switch (mode) {
case WSLogoutMode:
switch (mode) {
case WSLogoutMode:
#ifdef XSMP_ENABLED
wSessionRequestShutdown();
break;
wSessionRequestShutdown();
break;
#else
/* fall through */
/* fall through */
#endif
case WSKillMode:
case WSExitMode:
/* if there is no session manager, send SAVE_YOURSELF to
* the clients */
case WSKillMode:
case WSExitMode:
/* if there is no session manager, send SAVE_YOURSELF to
* the clients */
#if 0
#ifdef XSMP_ENABLED
if (!wSessionIsManaged())
if (!wSessionIsManaged())
#endif
for (i = 0; i < wScreenCount; i++) {
WScreen *scr;
for (i = 0; i < wScreenCount; i++) {
WScreen *scr;
scr = wScreenWithNumber(i);
if (scr) {
wSessionSendSaveYourself(scr);
}
}
scr = wScreenWithNumber(i);
if (scr) {
wSessionSendSaveYourself(scr);
}
}
#endif
close(inotifyFD);
for (i = 0; i < wScreenCount; i++) {
WScreen *scr;
close(inotifyFD);
for (i = 0; i < wScreenCount; i++) {
WScreen *scr;
scr = wScreenWithNumber(i);
if (scr) {
if (scr->helper_pid)
kill(scr->helper_pid, SIGKILL);
scr = wScreenWithNumber(i);
if (scr) {
if (scr->helper_pid)
kill(scr->helper_pid, SIGKILL);
/* if the session is not being managed, save restart info */
/* if the session is not being managed, save restart info */
#ifdef XSMP_ENABLED
if (!wSessionIsManaged())
if (!wSessionIsManaged())
#endif
wSessionSaveClients(scr);
wSessionSaveClients(scr);
wScreenSaveState(scr);
wScreenSaveState(scr);
if (mode == WSKillMode)
wipeDesktop(scr);
else
RestoreDesktop(scr);
}
}
ExecExitScript();
Exit(0);
break;
if (mode == WSKillMode)
wipeDesktop(scr);
else
RestoreDesktop(scr);
}
}
ExecExitScript();
Exit(0);
break;
case WSRestartPreparationMode:
for (i=0; i<wScreenCount; i++) {
WScreen *scr;
case WSRestartPreparationMode:
for (i = 0; i < wScreenCount; i++) {
WScreen *scr;
close(inotifyFD);
scr = wScreenWithNumber(i);
if (scr) {
if (scr->helper_pid)
kill(scr->helper_pid, SIGKILL);
wScreenSaveState(scr);
RestoreDesktop(scr);
}
}
break;
}
close(inotifyFD);
scr = wScreenWithNumber(i);
if (scr) {
if (scr->helper_pid)
kill(scr->helper_pid, SIGKILL);
wScreenSaveState(scr);
RestoreDesktop(scr);
}
}
break;
}
}
static void
restoreWindows(WMBag *bag, WMBagIterator iter)
static void restoreWindows(WMBag * bag, WMBagIterator iter)
{
WCoreWindow *next;
WCoreWindow *core;
WWindow *wwin;
WCoreWindow *next;
WCoreWindow *core;
WWindow *wwin;
if (iter == NULL) {
core = WMBagFirst(bag, &iter);
} else {
core = WMBagNext(bag, &iter);
}
if (iter == NULL) {
core = WMBagFirst(bag, &iter);
} else {
core = WMBagNext(bag, &iter);
}
if (core == NULL)
return;
if (core == NULL)
return;
restoreWindows(bag, iter);
restoreWindows(bag, iter);
/* go to the end of the list */
while (core->stacking->under)
core = core->stacking->under;
/* go to the end of the list */
while (core->stacking->under)
core = core->stacking->under;
while (core) {
next = core->stacking->above;
while (core) {
next = core->stacking->above;
if (core->descriptor.parent_type == WCLASS_WINDOW) {
Window window;
if (core->descriptor.parent_type==WCLASS_WINDOW) {
Window window;
wwin = core->descriptor.parent;
window = wwin->client_win;
wUnmanageWindow(wwin, !wwin->flags.internal_window, False);
XMapWindow(dpy, window);
}
core = next;
}
wwin = core->descriptor.parent;
window = wwin->client_win;
wUnmanageWindow(wwin, !wwin->flags.internal_window, False);
XMapWindow(dpy, window);
}
core = next;
}
}
/*
*----------------------------------------------------------------------
* RestoreDesktop--
@@ -182,29 +175,27 @@ restoreWindows(WMBag *bag, WMBagIterator iter)
*
*----------------------------------------------------------------------
*/
void
RestoreDesktop(WScreen *scr)
void RestoreDesktop(WScreen * scr)
{
if (scr->helper_pid > 0) {
kill(scr->helper_pid, SIGTERM);
scr->helper_pid = 0;
}
if (scr->helper_pid > 0) {
kill(scr->helper_pid, SIGTERM);
scr->helper_pid = 0;
}
XGrabServer(dpy);
wDestroyInspectorPanels();
XGrabServer(dpy);
wDestroyInspectorPanels();
/* reparent windows back to the root window, keeping the stacking order */
restoreWindows(scr->stacking_list, NULL);
/* reparent windows back to the root window, keeping the stacking order */
restoreWindows(scr->stacking_list, NULL);
XUngrabServer(dpy);
XSetInputFocus(dpy, PointerRoot, RevertToParent, CurrentTime);
wColormapInstallForWindow(scr, NULL);
PropCleanUp(scr->root_win);
wNETWMCleanup(scr);
XSync(dpy, 0);
XUngrabServer(dpy);
XSetInputFocus(dpy, PointerRoot, RevertToParent, CurrentTime);
wColormapInstallForWindow(scr, NULL);
PropCleanUp(scr->root_win);
wNETWMCleanup(scr);
XSync(dpy, 0);
}
/*
*----------------------------------------------------------------------
* wipeDesktop--
@@ -217,19 +208,17 @@ RestoreDesktop(WScreen *scr)
* TODO: change to XQueryTree()
*----------------------------------------------------------------------
*/
static void
wipeDesktop(WScreen *scr)
static void wipeDesktop(WScreen * scr)
{
WWindow *wwin;
WWindow *wwin;
wwin = scr->focused_window;
while (wwin) {
if (wwin->protocols.DELETE_WINDOW)
wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp);
else
wClientKill(wwin);
wwin = wwin->prev;
}
XSync(dpy, False);
wwin = scr->focused_window;
while (wwin) {
if (wwin->protocols.DELETE_WINDOW)
wClientSendProtocol(wwin, _XA_WM_DELETE_WINDOW, LastTimestamp);
else
wClientKill(wwin);
wwin = wwin->prev;
}
XSync(dpy, False);
}
+357 -384
View File
@@ -37,22 +37,18 @@
#include "stacking.h"
#include "workspace.h"
/*** Global Variables ***/
extern XContext wStackContext;
extern WPreferences wPreferences;
static void
notifyStackChange(WCoreWindow *frame, char *detail)
static void notifyStackChange(WCoreWindow * frame, char *detail)
{
WWindow *wwin = wWindowFor(frame->window);
WWindow *wwin = wWindowFor(frame->window);
WMPostNotificationName(WMNChangedStacking, wwin, detail);
WMPostNotificationName(WMNChangedStacking, wwin, detail);
}
/*
*----------------------------------------------------------------------
* RemakeStackList--
@@ -66,54 +62,52 @@ notifyStackChange(WCoreWindow *frame, char *detail)
*
*----------------------------------------------------------------------
*/
void
RemakeStackList(WScreen *scr)
void RemakeStackList(WScreen * scr)
{
Window *windows;
unsigned int nwindows;
Window junkr, junkp;
WCoreWindow *frame;
WCoreWindow *tmp;
int level;
int i, c;
Window *windows;
unsigned int nwindows;
Window junkr, junkp;
WCoreWindow *frame;
WCoreWindow *tmp;
int level;
int i, c;
if (!XQueryTree(dpy, scr->root_win, &junkr, &junkp, &windows, &nwindows)) {
wwarning(_("could not get window list!!"));
return;
} else {
WMEmptyBag(scr->stacking_list);
if (!XQueryTree(dpy, scr->root_win, &junkr, &junkp, &windows, &nwindows)) {
wwarning(_("could not get window list!!"));
return;
} else {
WMEmptyBag(scr->stacking_list);
/* verify list integrity */
c=0;
for (i=0; i<nwindows; i++) {
if (XFindContext(dpy, windows[i], wStackContext, (XPointer*)&frame)
==XCNOENT) {
continue;
}
if (!frame) continue;
c++;
level = frame->stacking->window_level;
tmp = WMGetFromBag(scr->stacking_list, level);
if (tmp)
tmp->stacking->above = frame;
frame->stacking->under = tmp;
frame->stacking->above = NULL;
WMSetInBag(scr->stacking_list, level, frame);
}
XFree(windows);
/* verify list integrity */
c = 0;
for (i = 0; i < nwindows; i++) {
if (XFindContext(dpy, windows[i], wStackContext, (XPointer *) & frame)
== XCNOENT) {
continue;
}
if (!frame)
continue;
c++;
level = frame->stacking->window_level;
tmp = WMGetFromBag(scr->stacking_list, level);
if (tmp)
tmp->stacking->above = frame;
frame->stacking->under = tmp;
frame->stacking->above = NULL;
WMSetInBag(scr->stacking_list, level, frame);
}
XFree(windows);
#ifdef DEBUG
if (c!=scr->window_count) {
puts("Found different number of windows than in window lists!!!");
}
if (c != scr->window_count) {
puts("Found different number of windows than in window lists!!!");
}
#endif
scr->window_count = c;
}
scr->window_count = c;
}
CommitStacking(scr);
CommitStacking(scr);
}
/*
*----------------------------------------------------------------------
* CommitStacking--
@@ -125,40 +119,39 @@ RemakeStackList(WScreen *scr)
* Windows may be restacked.
*----------------------------------------------------------------------
*/
void
CommitStacking(WScreen *scr)
void CommitStacking(WScreen * scr)
{
WCoreWindow *tmp;
int nwindows, i;
Window *windows;
WMBagIterator iter;
WCoreWindow *tmp;
int nwindows, i;
Window *windows;
WMBagIterator iter;
nwindows = scr->window_count;
windows = wmalloc(sizeof(Window)*nwindows);
nwindows = scr->window_count;
windows = wmalloc(sizeof(Window) * nwindows);
i = 0;
WM_ETARETI_BAG(scr->stacking_list, tmp, iter) {
while (tmp) {
i = 0;
WM_ETARETI_BAG(scr->stacking_list, tmp, iter) {
while (tmp) {
#ifdef DEBUG
if (i>=nwindows) {
puts("Internal inconsistency! window_count is incorrect!!!");
printf("window_count says %i windows\n", nwindows);
wfree(windows);
return;
}
if (i >= nwindows) {
puts("Internal inconsistency! window_count is incorrect!!!");
printf("window_count says %i windows\n", nwindows);
wfree(windows);
return;
}
#endif
windows[i++] = tmp->window;
tmp = tmp->stacking->under;
}
}
XRestackWindows(dpy, windows, i);
wfree(windows);
windows[i++] = tmp->window;
tmp = tmp->stacking->under;
}
}
XRestackWindows(dpy, windows, i);
wfree(windows);
#ifdef VIRTUAL_DESKTOP
wWorkspaceRaiseEdge(scr);
wWorkspaceRaiseEdge(scr);
#endif
WMPostNotificationName(WMNResetStacking, scr, NULL);
WMPostNotificationName(WMNResetStacking, scr, NULL);
}
/*
@@ -173,14 +166,13 @@ CommitStacking(WScreen *scr)
* Changes the stacking order of frame.
*----------------------------------------------------------------------
*/
static void
moveFrameToUnder(WCoreWindow *under, WCoreWindow *frame)
static void moveFrameToUnder(WCoreWindow * under, WCoreWindow * frame)
{
Window wins[2];
Window wins[2];
wins[0] = under->window;
wins[1] = frame->window;
XRestackWindows(dpy, wins, 2);
wins[0] = under->window;
wins[1] = frame->window;
XRestackWindows(dpy, wins, 2);
}
/*
@@ -196,198 +188,191 @@ moveFrameToUnder(WCoreWindow *under, WCoreWindow *frame)
*
*----------------------------------------------------------------------
*/
void
wRaiseFrame(WCoreWindow *frame)
void wRaiseFrame(WCoreWindow * frame)
{
WCoreWindow *wlist = frame;
int level = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
WCoreWindow *wlist = frame;
int level = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
/* already on top */
if (frame->stacking->above == NULL) {
return;
}
/* already on top */
if (frame->stacking->above == NULL) {
return;
}
/* insert it on top of other windows on the same level */
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
/* insert it on top of other windows on the same level */
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
frame->stacking->above = NULL;
frame->stacking->under = WMGetFromBag(scr->stacking_list, level);
if (frame->stacking->under) {
frame->stacking->under->stacking->above = frame;
}
WMSetInBag(scr->stacking_list, level, frame);
frame->stacking->above = NULL;
frame->stacking->under = WMGetFromBag(scr->stacking_list, level);
if (frame->stacking->under) {
frame->stacking->under->stacking->above = frame;
}
WMSetInBag(scr->stacking_list, level, frame);
/* raise transients under us from bottom to top
* so that the order is kept */
again:
wlist = frame->stacking->under;
while (wlist && wlist->stacking->under)
wlist = wlist->stacking->under;
while (wlist && wlist!=frame) {
if (wlist->stacking->child_of == frame) {
wRaiseFrame(wlist);
goto again;
}
wlist = wlist->stacking->above;
}
/* raise transients under us from bottom to top
* so that the order is kept */
again:
wlist = frame->stacking->under;
while (wlist && wlist->stacking->under)
wlist = wlist->stacking->under;
while (wlist && wlist != frame) {
if (wlist->stacking->child_of == frame) {
wRaiseFrame(wlist);
goto again;
}
wlist = wlist->stacking->above;
}
/* try to optimize things a little */
if (frame->stacking->above == NULL) {
WMBagIterator iter;
WCoreWindow *above = WMBagLast(scr->stacking_list, &iter);
int i, last = above->stacking->window_level;
/* try to optimize things a little */
if (frame->stacking->above == NULL) {
WMBagIterator iter;
WCoreWindow *above = WMBagLast(scr->stacking_list, &iter);
int i, last = above->stacking->window_level;
/* find the 1st level above us which has windows in it */
for (i = level+1, above = NULL; i <= last; i++) {
above = WMGetFromBag(scr->stacking_list, i);
if (above != NULL)
break;
}
/* find the 1st level above us which has windows in it */
for (i = level + 1, above = NULL; i <= last; i++) {
above = WMGetFromBag(scr->stacking_list, i);
if (above != NULL)
break;
}
if (above != frame && above != NULL) {
while (above->stacking->under)
above = above->stacking->under;
moveFrameToUnder(above, frame);
} else {
/* no window above us */
above = NULL;
XRaiseWindow(dpy, frame->window);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
}
if (above != frame && above != NULL) {
while (above->stacking->under)
above = above->stacking->under;
moveFrameToUnder(above, frame);
} else {
/* no window above us */
above = NULL;
XRaiseWindow(dpy, frame->window);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
}
notifyStackChange(frame, "raise");
notifyStackChange(frame, "raise");
#ifdef VIRTUAL_DESKTOP
wWorkspaceRaiseEdge(scr);
wWorkspaceRaiseEdge(scr);
#endif
}
void
wRaiseLowerFrame(WCoreWindow *frame)
void wRaiseLowerFrame(WCoreWindow * frame)
{
if (!frame->stacking->above
||(frame->stacking->window_level
!=frame->stacking->above->stacking->window_level)) {
if (!frame->stacking->above
|| (frame->stacking->window_level != frame->stacking->above->stacking->window_level)) {
wLowerFrame(frame);
} else {
WCoreWindow *scan = frame->stacking->above;
WWindow *frame_wwin = (WWindow*) frame->descriptor.parent;
wLowerFrame(frame);
} else {
WCoreWindow *scan = frame->stacking->above;
WWindow *frame_wwin = (WWindow *) frame->descriptor.parent;
while (scan) {
while (scan) {
if (scan->descriptor.parent_type == WCLASS_WINDOW) {
WWindow *scan_wwin = (WWindow*)scan->descriptor.parent;
if (scan->descriptor.parent_type == WCLASS_WINDOW) {
WWindow *scan_wwin = (WWindow *) scan->descriptor.parent;
if (wWindowObscuresWindow(scan_wwin, frame_wwin)
&& scan_wwin->flags.mapped) {
break;
}
}
scan = scan->stacking->above;
}
if (wWindowObscuresWindow(scan_wwin, frame_wwin)
&& scan_wwin->flags.mapped) {
break;
}
}
scan = scan->stacking->above;
}
if (scan) {
wRaiseFrame(frame);
} else {
wLowerFrame(frame);
}
}
if (scan) {
wRaiseFrame(frame);
} else {
wLowerFrame(frame);
}
}
}
void
wLowerFrame(WCoreWindow *frame)
void wLowerFrame(WCoreWindow * frame)
{
WScreen *scr = frame->screen_ptr;
WCoreWindow *wlist=frame;
int level = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
WCoreWindow *wlist = frame;
int level = frame->stacking->window_level;
/* already in bottom */
if (wlist->stacking->under == NULL) {
return;
}
/* cant lower transient below below its owner */
if (wlist->stacking->under == wlist->stacking->child_of) {
return;
}
/* remove from the list */
if (WMGetFromBag(scr->stacking_list, level) == frame) {
/* it was the top window */
WMSetInBag(scr->stacking_list, level, frame->stacking->under);
frame->stacking->under->stacking->above = NULL;
} else {
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
}
wlist = WMGetFromBag(scr->stacking_list, level);
/* already in bottom */
if (wlist->stacking->under == NULL) {
return;
}
/* cant lower transient below below its owner */
if (wlist->stacking->under == wlist->stacking->child_of) {
return;
}
/* remove from the list */
if (WMGetFromBag(scr->stacking_list, level) == frame) {
/* it was the top window */
WMSetInBag(scr->stacking_list, level, frame->stacking->under);
frame->stacking->under->stacking->above = NULL;
} else {
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
}
wlist = WMGetFromBag(scr->stacking_list, level);
/* look for place to put this window */
if (wlist) {
WCoreWindow *owner = frame->stacking->child_of;
/* look for place to put this window */
if (wlist) {
WCoreWindow *owner = frame->stacking->child_of;
if (owner != wlist) {
while (wlist->stacking->under) {
/* if this is a transient, it should not be placed under
* it's owner */
if (owner == wlist->stacking->under)
break;
wlist = wlist->stacking->under;
}
}
}
/* insert under the place found */
frame->stacking->above = wlist;
if (wlist) {
frame->stacking->under = wlist->stacking->under;
if (wlist->stacking->under)
wlist->stacking->under->stacking->above = frame;
wlist->stacking->under = frame;
} else {
frame->stacking->under = NULL;
}
if (owner != wlist) {
while (wlist->stacking->under) {
/* if this is a transient, it should not be placed under
* it's owner */
if (owner == wlist->stacking->under)
break;
wlist = wlist->stacking->under;
}
}
}
/* insert under the place found */
frame->stacking->above = wlist;
if (wlist) {
frame->stacking->under = wlist->stacking->under;
if (wlist->stacking->under)
wlist->stacking->under->stacking->above = frame;
wlist->stacking->under = frame;
} else {
frame->stacking->under = NULL;
}
if (frame->stacking->above == NULL) {
WMBagIterator iter;
WCoreWindow *above = WMBagLast(scr->stacking_list, &iter);
int i, last = above->stacking->window_level;
if (frame->stacking->above == NULL) {
WMBagIterator iter;
WCoreWindow *above = WMBagLast(scr->stacking_list, &iter);
int i, last = above->stacking->window_level;
/* find the 1st level above us which has windows in it */
for (i = level+1, above = NULL; i <= last; i++) {
above = WMGetFromBag(scr->stacking_list, i);
if (above != NULL)
break;
}
/* find the 1st level above us which has windows in it */
for (i = level + 1, above = NULL; i <= last; i++) {
above = WMGetFromBag(scr->stacking_list, i);
if (above != NULL)
break;
}
if (above != frame && above != NULL) {
while (above->stacking->under)
above = above->stacking->under;
moveFrameToUnder(above, frame);
} else {
/* no window below us */
XLowerWindow(dpy, frame->window);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
}
if (above != frame && above != NULL) {
while (above->stacking->under)
above = above->stacking->under;
moveFrameToUnder(above, frame);
} else {
/* no window below us */
XLowerWindow(dpy, frame->window);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
}
notifyStackChange(frame, "lower");
notifyStackChange(frame, "lower");
#ifdef VIRTUAL_DESKTOP
wWorkspaceRaiseEdge(scr);
wWorkspaceRaiseEdge(scr);
#endif
}
/*
*----------------------------------------------------------------------
* AddToStackList--
@@ -401,57 +386,55 @@ wLowerFrame(WCoreWindow *frame)
* The frame is added to it's screen's window list.
*----------------------------------------------------------------------
*/
void
AddToStackList(WCoreWindow *frame)
void AddToStackList(WCoreWindow * frame)
{
WCoreWindow *curtop, *wlist;
int index = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
WCoreWindow *trans = NULL;
WCoreWindow *curtop, *wlist;
int index = frame->stacking->window_level;
WScreen *scr = frame->screen_ptr;
WCoreWindow *trans = NULL;
frame->screen_ptr->window_count++;
XSaveContext(dpy, frame->window, wStackContext, (XPointer)frame);
curtop = WMGetFromBag(scr->stacking_list, index);
frame->screen_ptr->window_count++;
XSaveContext(dpy, frame->window, wStackContext, (XPointer) frame);
curtop = WMGetFromBag(scr->stacking_list, index);
/* first window in this level */
if (curtop == NULL) {
WMSetInBag(scr->stacking_list, index, frame);
frame->stacking->above = NULL;
frame->stacking->under = NULL;
CommitStacking(scr);
return;
}
/* first window in this level */
if (curtop == NULL) {
WMSetInBag(scr->stacking_list, index, frame);
frame->stacking->above = NULL;
frame->stacking->under = NULL;
CommitStacking(scr);
return;
}
/* check if this is a transient owner */
wlist = curtop;
while (wlist) {
if (wlist->stacking->child_of == frame)
trans = wlist;
wlist = wlist->stacking->under;
}
/* trans will hold the transient in the lowest position
* in stacking list */
/* check if this is a transient owner */
wlist = curtop;
while (wlist) {
if (wlist->stacking->child_of == frame)
trans = wlist;
wlist = wlist->stacking->under;
}
/* trans will hold the transient in the lowest position
* in stacking list */
frame->stacking->above = trans;
if (trans != NULL) {
/* window is owner of a transient.. put it below
* the lowest transient */
frame->stacking->under = trans->stacking->under;
if (trans->stacking->under) {
trans->stacking->under->stacking->above = frame;
}
trans->stacking->under = frame;
} else {
/* window is not owner of transients.. just put it in the
* top of other windows */
frame->stacking->under = curtop;
curtop->stacking->above = frame;
WMSetInBag(scr->stacking_list, index, frame);
}
CommitStacking(scr);
frame->stacking->above = trans;
if (trans != NULL) {
/* window is owner of a transient.. put it below
* the lowest transient */
frame->stacking->under = trans->stacking->under;
if (trans->stacking->under) {
trans->stacking->under->stacking->above = frame;
}
trans->stacking->under = frame;
} else {
/* window is not owner of transients.. just put it in the
* top of other windows */
frame->stacking->under = curtop;
curtop->stacking->above = frame;
WMSetInBag(scr->stacking_list, index, frame);
}
CommitStacking(scr);
}
/*
*----------------------------------------------------------------------
* MoveInStackListAbove--
@@ -465,67 +448,64 @@ AddToStackList(WCoreWindow *frame)
* Window level for frame may be changed.
*----------------------------------------------------------------------
*/
void
MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame)
void MoveInStackListAbove(WCoreWindow * next, WCoreWindow * frame)
{
WCoreWindow *tmpw;
WScreen *scr = frame->screen_ptr;
int index;
WCoreWindow *tmpw;
WScreen *scr = frame->screen_ptr;
int index;
if (!next || frame->stacking->under == next)
return;
if (!next || frame->stacking->under == next)
return;
if (frame->stacking->window_level != next->stacking->window_level)
ChangeStackingLevel(frame, next->stacking->window_level);
if (frame->stacking->window_level != next->stacking->window_level)
ChangeStackingLevel(frame, next->stacking->window_level);
index = frame->stacking->window_level;
index = frame->stacking->window_level;
tmpw = WMGetFromBag(scr->stacking_list, index);
if (tmpw == frame)
WMSetInBag(scr->stacking_list, index, frame->stacking->under);
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
if (next->stacking->above)
next->stacking->above->stacking->under = frame;
frame->stacking->under = next;
frame->stacking->above = next->stacking->above;
next->stacking->above = frame;
if (tmpw == next)
WMSetInBag(scr->stacking_list, index, frame);
tmpw = WMGetFromBag(scr->stacking_list, index);
if (tmpw == frame)
WMSetInBag(scr->stacking_list, index, frame->stacking->under);
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
if (next->stacking->above)
next->stacking->above->stacking->under = frame;
frame->stacking->under = next;
frame->stacking->above = next->stacking->above;
next->stacking->above = frame;
if (tmpw == next)
WMSetInBag(scr->stacking_list, index, frame);
/* try to optimize things a little */
if (frame->stacking->above == NULL) {
WCoreWindow *above = NULL;
WMBagIterator iter;
/* try to optimize things a little */
if (frame->stacking->above == NULL) {
WCoreWindow *above = NULL;
WMBagIterator iter;
for (above = WMBagIteratorAtIndex(scr->stacking_list, index+1, &iter);
above != NULL;
above = WMBagNext(scr->stacking_list, &iter)) {
for (above = WMBagIteratorAtIndex(scr->stacking_list, index + 1, &iter);
above != NULL; above = WMBagNext(scr->stacking_list, &iter)) {
/* can't optimize */
while (above->stacking->under)
above = above->stacking->under;
break;
}
if (above == NULL) {
XRaiseWindow(dpy, frame->window);
} else {
moveFrameToUnder(above, frame);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
}
/* can't optimize */
while (above->stacking->under)
above = above->stacking->under;
break;
}
if (above == NULL) {
XRaiseWindow(dpy, frame->window);
} else {
moveFrameToUnder(above, frame);
}
} else {
moveFrameToUnder(frame->stacking->above, frame);
}
WMPostNotificationName(WMNResetStacking, scr, NULL);
WMPostNotificationName(WMNResetStacking, scr, NULL);
#ifdef VIRTUAL_DESKTOP
wWorkspaceRaiseEdge(scr);
wWorkspaceRaiseEdge(scr);
#endif
}
/*
*----------------------------------------------------------------------
* MoveInStackListUnder--
@@ -539,79 +519,72 @@ MoveInStackListAbove(WCoreWindow *next, WCoreWindow *frame)
* Window level for frame may be changed.
*----------------------------------------------------------------------
*/
void
MoveInStackListUnder(WCoreWindow *prev, WCoreWindow *frame)
void MoveInStackListUnder(WCoreWindow * prev, WCoreWindow * frame)
{
WCoreWindow *tmpw;
int index;
WScreen *scr = frame->screen_ptr;
WCoreWindow *tmpw;
int index;
WScreen *scr = frame->screen_ptr;
if (!prev || frame->stacking->above == prev)
return;
if (!prev || frame->stacking->above == prev)
return;
if (frame->stacking->window_level != prev->stacking->window_level)
ChangeStackingLevel(frame, prev->stacking->window_level);
if (frame->stacking->window_level != prev->stacking->window_level)
ChangeStackingLevel(frame, prev->stacking->window_level);
index = frame->stacking->window_level;
index = frame->stacking->window_level;
tmpw = WMGetFromBag(scr->stacking_list, index);
if (tmpw == frame)
WMSetInBag(scr->stacking_list, index, frame->stacking->under);
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
if (prev->stacking->under)
prev->stacking->under->stacking->above = frame;
frame->stacking->above = prev;
frame->stacking->under = prev->stacking->under;
prev->stacking->under = frame;
moveFrameToUnder(prev, frame);
tmpw = WMGetFromBag(scr->stacking_list, index);
if (tmpw == frame)
WMSetInBag(scr->stacking_list, index, frame->stacking->under);
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
if (prev->stacking->under)
prev->stacking->under->stacking->above = frame;
frame->stacking->above = prev;
frame->stacking->under = prev->stacking->under;
prev->stacking->under = frame;
moveFrameToUnder(prev, frame);
WMPostNotificationName(WMNResetStacking, scr, NULL);
WMPostNotificationName(WMNResetStacking, scr, NULL);
}
void
RemoveFromStackList(WCoreWindow *frame)
void RemoveFromStackList(WCoreWindow * frame)
{
int index = frame->stacking->window_level;
int index = frame->stacking->window_level;
if (XDeleteContext(dpy, frame->window, wStackContext)==XCNOENT) {
wwarning("RemoveFromStackingList(): window not in list ");
return;
}
/* remove from the window stack list */
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
else /* this was the first window on the list */
WMSetInBag(frame->screen_ptr->stacking_list, index,
frame->stacking->under);
if (XDeleteContext(dpy, frame->window, wStackContext) == XCNOENT) {
wwarning("RemoveFromStackingList(): window not in list ");
return;
}
/* remove from the window stack list */
if (frame->stacking->under)
frame->stacking->under->stacking->above = frame->stacking->above;
if (frame->stacking->above)
frame->stacking->above->stacking->under = frame->stacking->under;
else /* this was the first window on the list */
WMSetInBag(frame->screen_ptr->stacking_list, index, frame->stacking->under);
frame->screen_ptr->window_count--;
frame->screen_ptr->window_count--;
WMPostNotificationName(WMNResetStacking, frame->screen_ptr, NULL);
WMPostNotificationName(WMNResetStacking, frame->screen_ptr, NULL);
}
void
ChangeStackingLevel(WCoreWindow *frame, int new_level)
void ChangeStackingLevel(WCoreWindow * frame, int new_level)
{
int old_level;
int old_level;
if (frame->stacking->window_level == new_level)
return;
old_level = frame->stacking->window_level;
if (frame->stacking->window_level == new_level)
return;
old_level = frame->stacking->window_level;
RemoveFromStackList(frame);
frame->stacking->window_level = new_level;
AddToStackList(frame);
if (old_level > new_level) {
wRaiseFrame(frame);
} else {
wLowerFrame(frame);
}
RemoveFromStackList(frame);
frame->stacking->window_level = new_level;
AddToStackList(frame);
if (old_level > new_level) {
wRaiseFrame(frame);
} else {
wLowerFrame(frame);
}
}
+566 -629
View File
File diff suppressed because it is too large. Load diff
+508 -578
View File
File diff suppressed because it is too large. Load diff
+286 -319
View File
@@ -20,7 +20,6 @@
* USA.
*/
#include "wconfig.h"
#ifndef LITE
@@ -46,13 +45,10 @@
extern WPreferences wPreferences;
extern Time LastTimestamp;
static int initialized = 0;
static void observer(void *self, WMNotification *notif);
static void wsobserver(void *self, WMNotification *notif);
static void observer(void *self, WMNotification * notif);
static void wsobserver(void *self, WMNotification * notif);
/*
* FocusWindow
@@ -65,397 +61,368 @@ static void wsobserver(void *self, WMNotification *notif);
* Unshade if shaded
* If iconified then deiconify else focus/raise.
*/
static void
focusWindow(WMenu *menu, WMenuEntry *entry)
static void focusWindow(WMenu * menu, WMenuEntry * entry)
{
WWindow *wwin;
WScreen *scr;
int x, y, move=0;
WWindow *wwin;
WScreen *scr;
int x, y, move = 0;
wwin = (WWindow*)entry->clientdata;
scr = wwin->screen_ptr;
wwin = (WWindow *) entry->clientdata;
scr = wwin->screen_ptr;
wMakeWindowVisible(wwin);
wMakeWindowVisible(wwin);
x = wwin->frame_x;
y = wwin->frame_y;
x = wwin->frame_x;
y = wwin->frame_y;
/* bring window back to visible area */
move = wScreenBringInside(scr, &x, &y, wwin->frame->core->width,
wwin->frame->core->height);
/* bring window back to visible area */
move = wScreenBringInside(scr, &x, &y, wwin->frame->core->width, wwin->frame->core->height);
if (move) {
wWindowConfigure(wwin, x, y, wwin->client.width, wwin->client.height);
}
if (move) {
wWindowConfigure(wwin, x, y, wwin->client.width, wwin->client.height);
}
}
void
InitializeSwitchMenu()
void InitializeSwitchMenu()
{
if (!initialized) {
initialized = 1;
if (!initialized) {
initialized = 1;
WMAddNotificationObserver(observer, NULL, WMNManaged, NULL);
WMAddNotificationObserver(observer, NULL, WMNUnmanaged, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedWorkspace, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedState, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedFocus, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedStacking, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedName, NULL);
WMAddNotificationObserver(observer, NULL, WMNManaged, NULL);
WMAddNotificationObserver(observer, NULL, WMNUnmanaged, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedWorkspace, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedState, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedFocus, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedStacking, NULL);
WMAddNotificationObserver(observer, NULL, WMNChangedName, NULL);
WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceChanged, NULL);
WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceNameChanged, NULL);
}
WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceChanged, NULL);
WMAddNotificationObserver(wsobserver, NULL, WMNWorkspaceNameChanged, NULL);
}
}
/*
*
* Open switch menu
*
*/
void
OpenSwitchMenu(WScreen *scr, int x, int y, int keyboard)
void OpenSwitchMenu(WScreen * scr, int x, int y, int keyboard)
{
WMenu *switchmenu = scr->switch_menu;
WWindow *wwin;
WMenu *switchmenu = scr->switch_menu;
WWindow *wwin;
if (switchmenu) {
if (switchmenu->flags.mapped) {
if (!switchmenu->flags.buttoned) {
wMenuUnmap(switchmenu);
} else {
wRaiseFrame(switchmenu->frame->core);
if (switchmenu) {
if (switchmenu->flags.mapped) {
if (!switchmenu->flags.buttoned) {
wMenuUnmap(switchmenu);
} else {
wRaiseFrame(switchmenu->frame->core);
if (keyboard)
wMenuMapAt(switchmenu, 0, 0, True);
else
wMenuMapCopyAt(switchmenu,
x-switchmenu->frame->core->width/2, y);
}
} else {
if (keyboard && x==scr->scr_width/2 && y==scr->scr_height/2) {
y = y - switchmenu->frame->core->height/2;
}
wMenuMapAt(switchmenu, x-switchmenu->frame->core->width/2, y,
keyboard);
}
return;
}
switchmenu = wMenuCreate(scr,_("Windows"),True);
scr->switch_menu = switchmenu;
if (keyboard)
wMenuMapAt(switchmenu, 0, 0, True);
else
wMenuMapCopyAt(switchmenu, x - switchmenu->frame->core->width / 2, y);
}
} else {
if (keyboard && x == scr->scr_width / 2 && y == scr->scr_height / 2) {
y = y - switchmenu->frame->core->height / 2;
}
wMenuMapAt(switchmenu, x - switchmenu->frame->core->width / 2, y, keyboard);
}
return;
}
switchmenu = wMenuCreate(scr, _("Windows"), True);
scr->switch_menu = switchmenu;
wwin = scr->focused_window;
while (wwin) {
UpdateSwitchMenu(scr, wwin, ACTION_ADD);
wwin = scr->focused_window;
while (wwin) {
UpdateSwitchMenu(scr, wwin, ACTION_ADD);
wwin = wwin->prev;
}
wwin = wwin->prev;
}
if (switchmenu) {
int newx, newy;
if (switchmenu) {
int newx, newy;
if (!switchmenu->flags.realized)
wMenuRealize(switchmenu);
if (!switchmenu->flags.realized)
wMenuRealize(switchmenu);
if (keyboard && x==0 && y==0) {
newx = newy = 0;
} else if (keyboard && x==scr->scr_width/2 && y==scr->scr_height/2) {
newx = x - switchmenu->frame->core->width/2;
newy = y - switchmenu->frame->core->height/2;
} else {
newx = x - switchmenu->frame->core->width/2;
newy = y;
}
wMenuMapAt(switchmenu, newx, newy, keyboard);
}
if (keyboard && x == 0 && y == 0) {
newx = newy = 0;
} else if (keyboard && x == scr->scr_width / 2 && y == scr->scr_height / 2) {
newx = x - switchmenu->frame->core->width / 2;
newy = y - switchmenu->frame->core->height / 2;
} else {
newx = x - switchmenu->frame->core->width / 2;
newy = y;
}
wMenuMapAt(switchmenu, newx, newy, keyboard);
}
}
static int
menuIndexForWindow(WMenu *menu, WWindow *wwin, int old_pos)
static int menuIndexForWindow(WMenu * menu, WWindow * wwin, int old_pos)
{
int idx;
int idx;
if (menu->entry_no <= old_pos)
return -1;
if (menu->entry_no <= old_pos)
return -1;
#define WS(i) ((WWindow*)menu->entries[i]->clientdata)->frame->workspace
if (old_pos >= 0) {
if (WS(old_pos) >= wwin->frame->workspace
&& (old_pos == 0 || WS(old_pos-1) <= wwin->frame->workspace)) {
return old_pos;
}
}
if (old_pos >= 0) {
if (WS(old_pos) >= wwin->frame->workspace
&& (old_pos == 0 || WS(old_pos - 1) <= wwin->frame->workspace)) {
return old_pos;
}
}
#undef WS
for (idx = 0; idx < menu->entry_no; idx++) {
WWindow *tw = (WWindow*)menu->entries[idx]->clientdata;
for (idx = 0; idx < menu->entry_no; idx++) {
WWindow *tw = (WWindow *) menu->entries[idx]->clientdata;
if (!IS_OMNIPRESENT(tw)
&& tw->frame->workspace > wwin->frame->workspace) {
break;
}
}
if (!IS_OMNIPRESENT(tw)
&& tw->frame->workspace > wwin->frame->workspace) {
break;
}
}
return idx;
return idx;
}
/*
* Update switch menu
*/
void
UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
void UpdateSwitchMenu(WScreen * scr, WWindow * wwin, int action)
{
WMenu *switchmenu = scr->switch_menu;
WMenuEntry *entry;
char title[MAX_MENU_TEXT_LENGTH+6];
int len = sizeof(title);
int i;
int checkVisibility = 0;
WMenu *switchmenu = scr->switch_menu;
WMenuEntry *entry;
char title[MAX_MENU_TEXT_LENGTH + 6];
int len = sizeof(title);
int i;
int checkVisibility = 0;
if (!wwin->screen_ptr->switch_menu)
return;
/*
* This menu is updated under the following conditions:
*
* 1. When a window is created.
* 2. When a window is destroyed.
*
* 3. When a window changes it's title.
* 4. When a window changes its workspace.
*/
if (action == ACTION_ADD) {
char *t;
int idx;
if (!wwin->screen_ptr->switch_menu)
return;
/*
* This menu is updated under the following conditions:
*
* 1. When a window is created.
* 2. When a window is destroyed.
*
* 3. When a window changes it's title.
* 4. When a window changes its workspace.
*/
if (action == ACTION_ADD) {
char *t;
int idx;
if (wwin->flags.internal_window ||
WFLAGP(wwin, skip_window_list) ||
IS_GNUSTEP_MENU(wwin)) {
return;
}
if (wwin->flags.internal_window || WFLAGP(wwin, skip_window_list) || IS_GNUSTEP_MENU(wwin)) {
return;
}
if (wwin->frame->title)
snprintf(title, len, "%s", wwin->frame->title);
else
snprintf(title, len, "%s", DEF_WINDOW_TITLE);
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
if (wwin->frame->title)
snprintf(title, len, "%s", wwin->frame->title);
else
snprintf(title, len, "%s", DEF_WINDOW_TITLE);
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
if (IS_OMNIPRESENT(wwin))
idx = -1;
else {
idx = menuIndexForWindow(switchmenu, wwin, -1);
}
if (IS_OMNIPRESENT(wwin))
idx = -1;
else {
idx = menuIndexForWindow(switchmenu, wwin, -1);
}
entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin);
wfree(t);
entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin);
wfree(t);
entry->flags.indicator = 1;
entry->rtext = wmalloc(MAX_WORKSPACENAME_WIDTH+8);
if (IS_OMNIPRESENT(wwin))
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]");
else
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]",
scr->workspaces[wwin->frame->workspace]->name);
entry->flags.indicator = 1;
entry->rtext = wmalloc(MAX_WORKSPACENAME_WIDTH + 8);
if (IS_OMNIPRESENT(wwin))
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]");
else
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]",
scr->workspaces[wwin->frame->workspace]->name);
if (wwin->flags.hidden) {
entry->flags.indicator_type = MI_HIDDEN;
entry->flags.indicator_on = 1;
} else if (wwin->flags.miniaturized) {
entry->flags.indicator_type = MI_MINIWINDOW;
entry->flags.indicator_on = 1;
} else if (wwin->flags.focused) {
entry->flags.indicator_type = MI_DIAMOND;
entry->flags.indicator_on = 1;
} else if (wwin->flags.shaded) {
entry->flags.indicator_type = MI_SHADED;
entry->flags.indicator_on = 1;
}
if (wwin->flags.hidden) {
entry->flags.indicator_type = MI_HIDDEN;
entry->flags.indicator_on = 1;
} else if (wwin->flags.miniaturized) {
entry->flags.indicator_type = MI_MINIWINDOW;
entry->flags.indicator_on = 1;
} else if (wwin->flags.focused) {
entry->flags.indicator_type = MI_DIAMOND;
entry->flags.indicator_on = 1;
} else if (wwin->flags.shaded) {
entry->flags.indicator_type = MI_SHADED;
entry->flags.indicator_on = 1;
}
wMenuRealize(switchmenu);
checkVisibility = 1;
} else {
char *t;
for (i=0; i<switchmenu->entry_no; i++) {
entry = switchmenu->entries[i];
/* this is the entry that was changed */
if (entry->clientdata == wwin) {
switch (action) {
case ACTION_REMOVE:
wMenuRemoveItem(switchmenu, i);
wMenuRealize(switchmenu);
checkVisibility = 1;
break;
wMenuRealize(switchmenu);
checkVisibility = 1;
} else {
char *t;
for (i = 0; i < switchmenu->entry_no; i++) {
entry = switchmenu->entries[i];
/* this is the entry that was changed */
if (entry->clientdata == wwin) {
switch (action) {
case ACTION_REMOVE:
wMenuRemoveItem(switchmenu, i);
wMenuRealize(switchmenu);
checkVisibility = 1;
break;
case ACTION_CHANGE:
if (entry->text)
wfree(entry->text);
case ACTION_CHANGE:
if (entry->text)
wfree(entry->text);
if (wwin->frame->title)
snprintf(title, MAX_MENU_TEXT_LENGTH, "%s",
wwin->frame->title);
else
snprintf(title, MAX_MENU_TEXT_LENGTH, "%s",
DEF_WINDOW_TITLE);
if (wwin->frame->title)
snprintf(title, MAX_MENU_TEXT_LENGTH, "%s", wwin->frame->title);
else
snprintf(title, MAX_MENU_TEXT_LENGTH, "%s", DEF_WINDOW_TITLE);
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
entry->text = t;
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
entry->text = t;
wMenuRealize(switchmenu);
checkVisibility = 1;
break;
wMenuRealize(switchmenu);
checkVisibility = 1;
break;
case ACTION_CHANGE_WORKSPACE:
if (entry->rtext) {
int idx = -1;
char *t, *rt;
int it, ion;
case ACTION_CHANGE_WORKSPACE:
if (entry->rtext) {
int idx = -1;
char *t, *rt;
int it, ion;
if (IS_OMNIPRESENT(wwin)) {
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,
"[*]");
} else {
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,
"[%s]", scr->workspaces[wwin->frame->workspace]->name);
}
if (IS_OMNIPRESENT(wwin)) {
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]");
} else {
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,
"[%s]",
scr->workspaces[wwin->frame->workspace]->name);
}
rt = entry->rtext;
entry->rtext = NULL;
t = entry->text;
entry->text = NULL;
rt = entry->rtext;
entry->rtext = NULL;
t = entry->text;
entry->text = NULL;
it = entry->flags.indicator_type;
ion = entry->flags.indicator_on;
it = entry->flags.indicator_type;
ion = entry->flags.indicator_on;
if (!IS_OMNIPRESENT(wwin) && idx < 0) {
idx = menuIndexForWindow(switchmenu, wwin, i);
}
if (!IS_OMNIPRESENT(wwin) && idx < 0) {
idx = menuIndexForWindow(switchmenu, wwin, i);
}
wMenuRemoveItem(switchmenu, i);
wMenuRemoveItem(switchmenu, i);
entry = wMenuInsertCallback(switchmenu, idx, t,
focusWindow, wwin);
wfree(t);
entry->rtext = rt;
entry->flags.indicator = 1;
entry->flags.indicator_type = it;
entry->flags.indicator_on = ion;
}
wMenuRealize(switchmenu);
checkVisibility = 1;
break;
entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin);
wfree(t);
entry->rtext = rt;
entry->flags.indicator = 1;
entry->flags.indicator_type = it;
entry->flags.indicator_on = ion;
}
wMenuRealize(switchmenu);
checkVisibility = 1;
break;
case ACTION_CHANGE_STATE:
if (wwin->flags.hidden) {
entry->flags.indicator_type = MI_HIDDEN;
entry->flags.indicator_on = 1;
} else if (wwin->flags.miniaturized) {
entry->flags.indicator_type = MI_MINIWINDOW;
entry->flags.indicator_on = 1;
} else if (wwin->flags.shaded && !wwin->flags.focused) {
entry->flags.indicator_type = MI_SHADED;
entry->flags.indicator_on = 1;
} else {
entry->flags.indicator_on = wwin->flags.focused;
entry->flags.indicator_type = MI_DIAMOND;
}
break;
}
break;
}
}
}
if (checkVisibility) {
int tmp;
case ACTION_CHANGE_STATE:
if (wwin->flags.hidden) {
entry->flags.indicator_type = MI_HIDDEN;
entry->flags.indicator_on = 1;
} else if (wwin->flags.miniaturized) {
entry->flags.indicator_type = MI_MINIWINDOW;
entry->flags.indicator_on = 1;
} else if (wwin->flags.shaded && !wwin->flags.focused) {
entry->flags.indicator_type = MI_SHADED;
entry->flags.indicator_on = 1;
} else {
entry->flags.indicator_on = wwin->flags.focused;
entry->flags.indicator_type = MI_DIAMOND;
}
break;
}
break;
}
}
}
if (checkVisibility) {
int tmp;
tmp = switchmenu->frame->top_width + 5;
/* if menu got unreachable, bring it to a visible place */
if (switchmenu->frame_x < tmp - (int)switchmenu->frame->core->width) {
wMenuMove(switchmenu, tmp - (int)switchmenu->frame->core->width,
switchmenu->frame_y, False);
}
}
wMenuPaint(switchmenu);
tmp = switchmenu->frame->top_width + 5;
/* if menu got unreachable, bring it to a visible place */
if (switchmenu->frame_x < tmp - (int)switchmenu->frame->core->width) {
wMenuMove(switchmenu, tmp - (int)switchmenu->frame->core->width,
switchmenu->frame_y, False);
}
}
wMenuPaint(switchmenu);
}
void
UpdateSwitchMenuWorkspace(WScreen *scr, int workspace)
void UpdateSwitchMenuWorkspace(WScreen * scr, int workspace)
{
WMenu *menu = scr->switch_menu;
int i;
WWindow *wwin;
WMenu *menu = scr->switch_menu;
int i;
WWindow *wwin;
if (!menu)
return;
if (!menu)
return;
for (i=0; i<menu->entry_no; i++) {
wwin = (WWindow*)menu->entries[i]->clientdata;
for (i = 0; i < menu->entry_no; i++) {
wwin = (WWindow *) menu->entries[i]->clientdata;
if (wwin->frame->workspace==workspace
&& !IS_OMNIPRESENT(wwin)) {
if (IS_OMNIPRESENT(wwin))
snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[*]");
else
snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[%s]",
scr->workspaces[wwin->frame->workspace]->name);
menu->flags.realized = 0;
}
}
if (!menu->flags.realized)
wMenuRealize(menu);
if (wwin->frame->workspace == workspace && !IS_OMNIPRESENT(wwin)) {
if (IS_OMNIPRESENT(wwin))
snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH, "[*]");
else
snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]",
scr->workspaces[wwin->frame->workspace]->name);
menu->flags.realized = 0;
}
}
if (!menu->flags.realized)
wMenuRealize(menu);
}
static void
observer(void *self, WMNotification *notif)
static void observer(void *self, WMNotification * notif)
{
WWindow *wwin = (WWindow*)WMGetNotificationObject(notif);
const char *name = WMGetNotificationName(notif);
void *data = WMGetNotificationClientData(notif);
WWindow *wwin = (WWindow *) WMGetNotificationObject(notif);
const char *name = WMGetNotificationName(notif);
void *data = WMGetNotificationClientData(notif);
if (!wwin)
return;
if (!wwin)
return;
if (strcmp(name, WMNManaged) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_ADD);
else if (strcmp(name, WMNUnmanaged) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_REMOVE);
else if (strcmp(name, WMNChangedWorkspace) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
else if (strcmp(name, WMNChangedFocus) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE);
else if (strcmp(name, WMNChangedName) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE);
else if (strcmp(name, WMNChangedState) == 0) {
if (strcmp((char*)data, "omnipresent") == 0) {
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
} else {
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE);
}
}
if (strcmp(name, WMNManaged) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_ADD);
else if (strcmp(name, WMNUnmanaged) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_REMOVE);
else if (strcmp(name, WMNChangedWorkspace) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
else if (strcmp(name, WMNChangedFocus) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE);
else if (strcmp(name, WMNChangedName) == 0)
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE);
else if (strcmp(name, WMNChangedState) == 0) {
if (strcmp((char *)data, "omnipresent") == 0) {
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
} else {
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE);
}
}
}
static void
wsobserver(void *self, WMNotification *notif)
static void wsobserver(void *self, WMNotification * notif)
{
WScreen *scr = (WScreen*)WMGetNotificationObject(notif);
const char *name = WMGetNotificationName(notif);
void *data = WMGetNotificationClientData(notif);
WScreen *scr = (WScreen *) WMGetNotificationObject(notif);
const char *name = WMGetNotificationName(notif);
void *data = WMGetNotificationClientData(notif);
if (strcmp(name, WMNWorkspaceNameChanged) == 0) {
UpdateSwitchMenuWorkspace(scr, (int)(uintptr_t)data);
} else if (strcmp(name, WMNWorkspaceChanged) == 0) {
if (strcmp(name, WMNWorkspaceNameChanged) == 0) {
UpdateSwitchMenuWorkspace(scr, (int)(uintptr_t) data);
} else if (strcmp(name, WMNWorkspaceChanged) == 0) {
}
}
}
#endif /* !LITE */
#endif /* !LITE */
+508 -550
View File
File diff suppressed because it is too large. Load diff
+325 -374
View File
@@ -42,7 +42,6 @@
(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#endif
#ifdef DEBUG
# define ENTER(X) fprintf(stderr,"Entering: %s()\n", X);
# define LEAVE(X) fprintf(stderr,"Leaving: %s()\n", X);
@@ -58,11 +57,11 @@ extern Cursor wCursor[WCUR_LAST];
/********************************************************************
* The event handler for the text-field: *
********************************************************************/
static void textEventHandler( WObjDescriptor *desc, XEvent *event );
static void textEventHandler(WObjDescriptor * desc, XEvent * event);
static void handleExpose( WObjDescriptor *desc, XEvent *event );
static void handleExpose(WObjDescriptor * desc, XEvent * event);
static void textInsert( WTextInput *wtext, char *txt );
static void textInsert(WTextInput * wtext, char *txt);
#if 0
static void blink(void *data);
#endif
@@ -81,113 +80,101 @@ static void blink(void *data);
* Global: modifier - the bitfield that keeps track of the modifier *
* keys that are down *
********************************************************************/
static int
handleKeyPress( WTextInput *wtext, XKeyEvent *event )
static int handleKeyPress(WTextInput * wtext, XKeyEvent * event)
{
KeySym ksym;
char buffer[32];
int count;
KeySym ksym;
char buffer[32];
int count;
count = XLookupString(event, buffer, 32, &ksym, NULL);
count = XLookupString(event, buffer, 32, &ksym, NULL);
/* Ignore these keys: */
if( IsFunctionKey(ksym) || IsKeypadKey(ksym) ||
IsMiscFunctionKey(ksym) || IsPFKey(ksym) ||
IsPrivateKeypadKey(ksym) )
/* If we don't handle it, make sure it isn't a key that
* the window manager needs to see */
return False;
/* Ignore these keys: */
if (IsFunctionKey(ksym) || IsKeypadKey(ksym) ||
IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsPrivateKeypadKey(ksym))
/* If we don't handle it, make sure it isn't a key that
* the window manager needs to see */
return False;
/* Take care of the cursor keys.. ignore up and down
* cursor keys */
else if( IsCursorKey(ksym) )
{
int length = wtext->text.length;
switch(ksym)
{
case XK_Home:
case XK_Begin:
wtext->text.endPos = 0;
break;
case XK_Left:
wtext->text.endPos--;
break;
case XK_Right:
wtext->text.endPos++;
break;
case XK_End:
wtext->text.endPos = length;
break;
default:
return False;
}
/* make sure that the startPos and endPos have values
* that make sense (ie the are in [0..length] ) */
if( wtext->text.endPos < 0 )
wtext->text.endPos = 0;
if( wtext->text.endPos > length )
wtext->text.endPos = length;
wtext->text.startPos = wtext->text.endPos;
}
else
{
switch(ksym)
{
/* Ignore these keys: */
case XK_Escape:
wtext->canceled = True;
case XK_Return:
wtext->done = True;
break;
case XK_Tab:
case XK_Num_Lock:
break;
/* Take care of the cursor keys.. ignore up and down
* cursor keys */
else if (IsCursorKey(ksym)) {
int length = wtext->text.length;
switch (ksym) {
case XK_Home:
case XK_Begin:
wtext->text.endPos = 0;
break;
case XK_Left:
wtext->text.endPos--;
break;
case XK_Right:
wtext->text.endPos++;
break;
case XK_End:
wtext->text.endPos = length;
break;
default:
return False;
}
/* make sure that the startPos and endPos have values
* that make sense (ie the are in [0..length] ) */
if (wtext->text.endPos < 0)
wtext->text.endPos = 0;
if (wtext->text.endPos > length)
wtext->text.endPos = length;
wtext->text.startPos = wtext->text.endPos;
} else {
switch (ksym) {
/* Ignore these keys: */
case XK_Escape:
wtext->canceled = True;
case XK_Return:
wtext->done = True;
break;
case XK_Tab:
case XK_Num_Lock:
break;
case XK_Delete:
/* delete after cursor */
if( (wtext->text.endPos == wtext->text.startPos) &&
(wtext->text.endPos < wtext->text.length) )
wtext->text.endPos++;
textInsert( wtext, "" );
break;
case XK_BackSpace:
/* delete before cursor */
if( (wtext->text.endPos == wtext->text.startPos) &&
(wtext->text.startPos > 0) )
wtext->text.startPos--;
textInsert( wtext, "" );
break;
default:
if (count==1 && !iscntrl(buffer[0])) {
buffer[count] = 0;
textInsert( wtext, buffer);
}
}
}
return True;
case XK_Delete:
/* delete after cursor */
if ((wtext->text.endPos == wtext->text.startPos) &&
(wtext->text.endPos < wtext->text.length))
wtext->text.endPos++;
textInsert(wtext, "");
break;
case XK_BackSpace:
/* delete before cursor */
if ((wtext->text.endPos == wtext->text.startPos) && (wtext->text.startPos > 0))
wtext->text.startPos--;
textInsert(wtext, "");
break;
default:
if (count == 1 && !iscntrl(buffer[0])) {
buffer[count] = 0;
textInsert(wtext, buffer);
}
}
}
return True;
}
/********************************************************************
* textXYtoPos *
* given X coord, return position in array *
********************************************************************/
static int
textXtoPos( WTextInput *wtext, int x )
static int textXtoPos(WTextInput * wtext, int x)
{
int pos;
x -= wtext->xOffset;
int pos;
x -= wtext->xOffset;
for( pos=0; wtext->text.txt[pos] != '\0'; pos++ )
{
if( x < 0 )
break;
else
x -= WMWidthOfString( wtext->font, &(wtext->text.txt[pos]), 1 );
}
for (pos = 0; wtext->text.txt[pos] != '\0'; pos++) {
if (x < 0)
break;
else
x -= WMWidthOfString(wtext->font, &(wtext->text.txt[pos]), 1);
}
return pos;
return pos;
}
/********************************************************************
@@ -198,80 +185,73 @@ textXtoPos( WTextInput *wtext, int x )
* Return: *
* Global: dpy - the display *
********************************************************************/
WTextInput *
wTextCreate( WCoreWindow *core, int x, int y, int width, int height )
WTextInput *wTextCreate(WCoreWindow * core, int x, int y, int width, int height)
{
WTextInput *wtext;
WTextInput *wtext;
ENTER("wTextCreate");
ENTER("wTextCreate");
wtext = wmalloc(sizeof(WTextInput));
wtext->core = wCoreCreate( core, x, y, width, height );
wtext->core->descriptor.handle_anything = &textEventHandler;
wtext->core->descriptor.handle_expose = &handleExpose;
wtext->core->descriptor.parent_type = WCLASS_TEXT_INPUT;
wtext->core->descriptor.parent = wtext;
wtext = wmalloc(sizeof(WTextInput));
wtext->core = wCoreCreate(core, x, y, width, height);
wtext->core->descriptor.handle_anything = &textEventHandler;
wtext->core->descriptor.handle_expose = &handleExpose;
wtext->core->descriptor.parent_type = WCLASS_TEXT_INPUT;
wtext->core->descriptor.parent = wtext;
wtext->font = core->screen_ptr->menu_entry_font;
wtext->font = core->screen_ptr->menu_entry_font;
XDefineCursor( dpy, wtext->core->window, wCursor[WCUR_TEXT] );
XDefineCursor(dpy, wtext->core->window, wCursor[WCUR_TEXT]);
/* setup the text: */
wtext->text.txt = (char *)wmalloc(sizeof(char));
wtext->text.txt[0] = '\0';
wtext->text.length = 0;
wtext->text.startPos = 0;
wtext->text.endPos = 0;
/* setup the text: */
wtext->text.txt = (char *)wmalloc(sizeof(char));
wtext->text.txt[0] = '\0';
wtext->text.length = 0;
wtext->text.startPos = 0;
wtext->text.endPos = 0;
{
XGCValues gcv;
{
XGCValues gcv;
gcv.foreground = core->screen_ptr->black_pixel;
gcv.background = core->screen_ptr->white_pixel;
gcv.line_width = 1;
gcv.function = GXcopy;
gcv.foreground = core->screen_ptr->black_pixel;
gcv.background = core->screen_ptr->white_pixel;
gcv.line_width = 1;
gcv.function = GXcopy;
wtext->gc = XCreateGC( dpy, wtext->core->window,
(GCForeground|GCBackground|
GCFunction|GCLineWidth),
&gcv );
wtext->gc = XCreateGC(dpy, wtext->core->window,
(GCForeground | GCBackground | GCFunction | GCLineWidth), &gcv);
/* set up the regular context */
gcv.foreground = core->screen_ptr->black_pixel;
gcv.background = core->screen_ptr->white_pixel;
gcv.line_width = 1;
gcv.function = GXcopy;
/* set up the regular context */
gcv.foreground = core->screen_ptr->black_pixel;
gcv.background = core->screen_ptr->white_pixel;
gcv.line_width = 1;
gcv.function = GXcopy;
wtext->regGC = XCreateGC( dpy, wtext->core->window,
(GCForeground|GCBackground|
GCFunction|GCLineWidth),
&gcv );
wtext->regGC = XCreateGC(dpy, wtext->core->window,
(GCForeground | GCBackground | GCFunction | GCLineWidth), &gcv);
/* set up the inverted context */
gcv.function = GXcopyInverted;
/* set up the inverted context */
gcv.function = GXcopyInverted;
wtext->invGC = XCreateGC( dpy, wtext->core->window,
(GCForeground|GCBackground|
GCFunction|GCLineWidth),
&gcv );
wtext->invGC = XCreateGC(dpy, wtext->core->window,
(GCForeground | GCBackground | GCFunction | GCLineWidth), &gcv);
/* and set the background! */
XSetWindowBackground( dpy, wtext->core->window, gcv.background );
}
/* and set the background! */
XSetWindowBackground(dpy, wtext->core->window, gcv.background);
}
/* Figure out the y-offset... */
wtext->yOffset = (height - WMFontHeight(wtext->font))/2;
wtext->xOffset = wtext->yOffset;
/* Figure out the y-offset... */
wtext->yOffset = (height - WMFontHeight(wtext->font)) / 2;
wtext->xOffset = wtext->yOffset;
wtext->canceled = False;
wtext->done = False; /* becomes True when the user *
* hits "Return" key */
wtext->canceled = False;
wtext->done = False; /* becomes True when the user *
* hits "Return" key */
XMapRaised(dpy, wtext->core->window);
XMapRaised(dpy, wtext->core->window);
LEAVE("wTextCreate");
LEAVE("wTextCreate");
return wtext;
return wtext;
}
/********************************************************************
@@ -281,27 +261,24 @@ wTextCreate( WCoreWindow *core, int x, int y, int width, int height )
* Return: *
* Global: dpy - the display *
********************************************************************/
void
wTextDestroy( WTextInput *wtext )
void wTextDestroy(WTextInput * wtext)
{
ENTER("wTextDestroy")
ENTER("wTextDestroy")
#if 0
if (wtext->magic)
wDeleteTimerHandler(wtext->magic);
wtext->magic = NULL;
if (wtext->magic)
wDeleteTimerHandler(wtext->magic);
wtext->magic = NULL;
#endif
XFreeGC( dpy, wtext->gc );
XFreeGC( dpy, wtext->regGC );
XFreeGC( dpy, wtext->invGC );
wfree( wtext->text.txt );
wCoreDestroy( wtext->core );
wfree( wtext );
XFreeGC(dpy, wtext->gc);
XFreeGC(dpy, wtext->regGC);
XFreeGC(dpy, wtext->invGC);
wfree(wtext->text.txt);
wCoreDestroy(wtext->core);
wfree(wtext);
LEAVE("wTextDestroy");
LEAVE("wTextDestroy");
}
/* The text-field consists of a frame drawn around the outside,
* and a textbox inside. The space between the frame and the
* text-box is the xOffset,yOffset. When the text needs refreshing,
@@ -310,7 +287,6 @@ wTextDestroy( WTextInput *wtext )
* need to redraw the frame, wTextPaint will redraw the frame, and
* then call wTextRefresh to redraw the text-box */
/********************************************************************
* textRefresh *
* Redraw the text field. Call this after messing with the text *
@@ -322,67 +298,60 @@ wTextDestroy( WTextInput *wtext )
* Return: none *
* Global: dpy - the display *
********************************************************************/
static void
textRefresh(WTextInput *wtext)
static void textRefresh(WTextInput * wtext)
{
WScreen *scr = wtext->core->screen_ptr;
char *ptr = wtext->text.txt;
int x1,x2,y1,y2;
WScreen *scr = wtext->core->screen_ptr;
char *ptr = wtext->text.txt;
int x1, x2, y1, y2;
/* x1,y1 is the upper left corner of the text box */
x1 = wtext->xOffset;
y1 = wtext->yOffset;
/* x2,y2 is the lower right corner of the text box */
x2 = wtext->core->width - wtext->xOffset;
y2 = wtext->core->height - wtext->yOffset;
/* x1,y1 is the upper left corner of the text box */
x1 = wtext->xOffset;
y1 = wtext->yOffset;
/* x2,y2 is the lower right corner of the text box */
x2 = wtext->core->width - wtext->xOffset;
y2 = wtext->core->height - wtext->yOffset;
/* Fill in the text field. Use the invGC to draw the rectangle,
* becuase then it will be the background color */
XFillRectangle(dpy, wtext->core->window, wtext->invGC,
x1, y1, x2-x1, y2-y1);
/* Fill in the text field. Use the invGC to draw the rectangle,
* becuase then it will be the background color */
XFillRectangle(dpy, wtext->core->window, wtext->invGC, x1, y1, x2 - x1, y2 - y1);
/* Draw the text normally */
WMDrawImageString(scr->wmscreen, wtext->core->window,
scr->black, scr->white, wtext->font, x1, y1, ptr,
wtext->text.length);
/* Draw the text normally */
WMDrawImageString(scr->wmscreen, wtext->core->window,
scr->black, scr->white, wtext->font, x1, y1, ptr, wtext->text.length);
/* Draw the selected text */
if (wtext->text.startPos != wtext->text.endPos) {
int sp,ep;
/* we need sp < ep */
if (wtext->text.startPos > wtext->text.endPos) {
sp = wtext->text.endPos;
ep = wtext->text.startPos;
} else {
sp = wtext->text.startPos;
ep = wtext->text.endPos;
}
/* Draw the selected text */
if (wtext->text.startPos != wtext->text.endPos) {
int sp, ep;
/* we need sp < ep */
if (wtext->text.startPos > wtext->text.endPos) {
sp = wtext->text.endPos;
ep = wtext->text.startPos;
} else {
sp = wtext->text.startPos;
ep = wtext->text.endPos;
}
/* x1,y1 is now the upper-left of the selected area */
x1 += WMWidthOfString(wtext->font, ptr, sp);
/* and x2,y2 is the lower-right of the selected area */
ptr += sp * sizeof(char);
x2 = x1 + WMWidthOfString(wtext->font, ptr, (ep - sp));
/* Fill in the area where the selected text will go: *
* use the regGC to draw the rectangle, becuase then it *
* will be the color of the non-selected text */
XFillRectangle(dpy, wtext->core->window, wtext->regGC,
x1, y1, x2-x1, y2-y1);
/* x1,y1 is now the upper-left of the selected area */
x1 += WMWidthOfString(wtext->font, ptr, sp);
/* and x2,y2 is the lower-right of the selected area */
ptr += sp * sizeof(char);
x2 = x1 + WMWidthOfString(wtext->font, ptr, (ep - sp));
/* Fill in the area where the selected text will go: *
* use the regGC to draw the rectangle, becuase then it *
* will be the color of the non-selected text */
XFillRectangle(dpy, wtext->core->window, wtext->regGC, x1, y1, x2 - x1, y2 - y1);
/* Draw the selected text. Inverse bg and fg colors for selection */
WMDrawImageString(scr->wmscreen, wtext->core->window,
scr->white, scr->black, wtext->font, x1, y1, ptr,
(ep - sp));
}
/* Draw the selected text. Inverse bg and fg colors for selection */
WMDrawImageString(scr->wmscreen, wtext->core->window,
scr->white, scr->black, wtext->font, x1, y1, ptr, (ep - sp));
}
/* And draw a quick little line for the cursor position */
x1 = WMWidthOfString(wtext->font, wtext->text.txt, wtext->text.endPos)
+ wtext->xOffset;
XDrawLine(dpy, wtext->core->window, wtext->regGC, x1, 2, x1,
wtext->core->height - 3);
/* And draw a quick little line for the cursor position */
x1 = WMWidthOfString(wtext->font, wtext->text.txt, wtext->text.endPos)
+ wtext->xOffset;
XDrawLine(dpy, wtext->core->window, wtext->regGC, x1, 2, x1, wtext->core->height - 3);
}
/********************************************************************
* wTextPaint *
* *
@@ -390,22 +359,19 @@ textRefresh(WTextInput *wtext)
* Return: *
* Global: dpy - the display *
********************************************************************/
void
wTextPaint( WTextInput *wtext )
void wTextPaint(WTextInput * wtext)
{
ENTER("wTextPaint");
ENTER("wTextPaint");
/* refresh */
textRefresh( wtext );
/* refresh */
textRefresh(wtext);
/* Draw box */
XDrawRectangle(dpy, wtext->core->window, wtext->gc, 0, 0,
wtext->core->width-1, wtext->core->height-1);
/* Draw box */
XDrawRectangle(dpy, wtext->core->window, wtext->gc, 0, 0, wtext->core->width - 1, wtext->core->height - 1);
LEAVE("wTextPaint");
LEAVE("wTextPaint");
}
/********************************************************************
* wTextGetText *
* return the string in the text field wText. DO NOT FREE THE *
@@ -415,13 +381,12 @@ wTextPaint( WTextInput *wtext )
* Return: the text in the text field (NULL terminated) *
* Global: *
********************************************************************/
char *
wTextGetText( WTextInput *wtext )
char *wTextGetText(WTextInput * wtext)
{
if (!wtext->canceled)
return wtext->text.txt;
else
return NULL;
if (!wtext->canceled)
return wtext->text.txt;
else
return NULL;
}
/********************************************************************
@@ -436,21 +401,20 @@ wTextGetText( WTextInput *wtext )
* Return: none *
* Global: *
********************************************************************/
void
wTextPutText( WTextInput *wtext, char *txt )
void wTextPutText(WTextInput * wtext, char *txt)
{
int length = strlen(txt);
int length = strlen(txt);
/* no memory leaks! free the old txt */
if( wtext->text.txt != NULL )
wfree( wtext->text.txt );
/* no memory leaks! free the old txt */
if (wtext->text.txt != NULL)
wfree(wtext->text.txt);
wtext->text.txt = (char *)wmalloc((length+1)*sizeof(char));
strcpy(wtext->text.txt, txt );
wtext->text.length = length;
/* By default No text is selected, and the cursor is at the end */
wtext->text.startPos = length;
wtext->text.endPos = length;
wtext->text.txt = (char *)wmalloc((length + 1) * sizeof(char));
strcpy(wtext->text.txt, txt);
wtext->text.length = length;
/* By default No text is selected, and the cursor is at the end */
wtext->text.startPos = length;
wtext->text.endPos = length;
}
/********************************************************************
@@ -464,52 +428,48 @@ wTextPutText( WTextInput *wtext, char *txt )
* Return: none *
* Global: *
********************************************************************/
static void
textInsert( WTextInput *wtext, char *txt )
static void textInsert(WTextInput * wtext, char *txt)
{
char *newTxt;
int newLen, txtLen, i,j;
int sp,ep;
char *newTxt;
int newLen, txtLen, i, j;
int sp, ep;
/* we need sp < ep */
if( wtext->text.startPos > wtext->text.endPos )
{
sp = wtext->text.endPos;
ep = wtext->text.startPos;
}
else
{
sp = wtext->text.startPos;
ep = wtext->text.endPos;
}
/* we need sp < ep */
if (wtext->text.startPos > wtext->text.endPos) {
sp = wtext->text.endPos;
ep = wtext->text.startPos;
} else {
sp = wtext->text.startPos;
ep = wtext->text.endPos;
}
txtLen = strlen(txt);
newLen = wtext->text.length + txtLen - (ep - sp) + 1;
txtLen = strlen(txt);
newLen = wtext->text.length + txtLen - (ep - sp) + 1;
newTxt = (char *)malloc(newLen*sizeof(char));
newTxt = (char *)malloc(newLen * sizeof(char));
/* copy the old text up to sp */
for( i=0; i<sp; i++ )
newTxt[i] = wtext->text.txt[i];
/* copy the old text up to sp */
for (i = 0; i < sp; i++)
newTxt[i] = wtext->text.txt[i];
/* insert new text */
for( j=0; j<txtLen; j++,i++ )
newTxt[i] = txt[j];
/* insert new text */
for (j = 0; j < txtLen; j++, i++)
newTxt[i] = txt[j];
/* copy old text after ep */
for( j=ep; j<wtext->text.length; j++,i++ )
newTxt[i] = wtext->text.txt[j];
/* copy old text after ep */
for (j = ep; j < wtext->text.length; j++, i++)
newTxt[i] = wtext->text.txt[j];
newTxt[i] = '\0';
newTxt[i] = '\0';
/* By default No text is selected, and the cursor is at the end
* of inserted text */
wtext->text.startPos = sp+txtLen;
wtext->text.endPos = sp+txtLen;
/* By default No text is selected, and the cursor is at the end
* of inserted text */
wtext->text.startPos = sp + txtLen;
wtext->text.endPos = sp + txtLen;
wfree(wtext->text.txt);
wtext->text.txt = newTxt;
wtext->text.length = newLen-1;
wfree(wtext->text.txt);
wtext->text.txt = newTxt;
wtext->text.length = newLen - 1;
}
/********************************************************************
@@ -526,38 +486,36 @@ textInsert( WTextInput *wtext, char *txt )
* Return: none *
* Global: *
********************************************************************/
void
wTextSelect( WTextInput *wtext, int start, int end )
void wTextSelect(WTextInput * wtext, int start, int end)
{
if( end == -1 )
wtext->text.endPos = wtext->text.length;
else
wtext->text.endPos = end;
wtext->text.startPos = start;
if (end == -1)
wtext->text.endPos = wtext->text.length;
else
wtext->text.endPos = end;
wtext->text.startPos = start;
}
#if 0
static void
blink(void *data)
static void blink(void *data)
{
int x;
WTextInput *wtext = (WTextInput*)data;
GC gc;
int x;
WTextInput *wtext = (WTextInput *) data;
GC gc;
/* And draw a quick little line for the cursor position */
if (wtext->blink_on) {
gc = wtext->regGC;
wtext->blink_on = 0;
} else {
gc = wtext->invGC;
wtext->blink_on = 1;
}
x = WMWidthOfString( wtext->font, wtext->text.txt, wtext->text.endPos )
+ wtext->xOffset;
XDrawLine( dpy, wtext->core->window, gc, x, 2, x, wtext->core->height-3);
/* And draw a quick little line for the cursor position */
if (wtext->blink_on) {
gc = wtext->regGC;
wtext->blink_on = 0;
} else {
gc = wtext->invGC;
wtext->blink_on = 1;
}
x = WMWidthOfString(wtext->font, wtext->text.txt, wtext->text.endPos)
+ wtext->xOffset;
XDrawLine(dpy, wtext->core->window, gc, x, 2, x, wtext->core->height - 3);
if (wtext->blinking)
wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, data);
if (wtext->blinking)
wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, data);
}
#endif
@@ -569,87 +527,80 @@ blink(void *data)
* Return: none *
* Global: *
********************************************************************/
static void
textEventHandler( WObjDescriptor *desc, XEvent *event )
static void textEventHandler(WObjDescriptor * desc, XEvent * event)
{
WTextInput *wtext = desc->parent;
int handled = False; /* has the event been handled */
WTextInput *wtext = desc->parent;
int handled = False; /* has the event been handled */
switch( event->type )
{
case MotionNotify:
/* If the button isn't down, we don't care about the
* event, but otherwise we want to adjust the selected
* text so we can wTextRefresh() */
if( event->xmotion.state & (Button1Mask|Button3Mask|Button2Mask) )
{
PDEBUG("MotionNotify");
handled = True;
wtext->text.endPos = textXtoPos( wtext, event->xmotion.x );
}
break;
switch (event->type) {
case MotionNotify:
/* If the button isn't down, we don't care about the
* event, but otherwise we want to adjust the selected
* text so we can wTextRefresh() */
if (event->xmotion.state & (Button1Mask | Button3Mask | Button2Mask)) {
PDEBUG("MotionNotify");
handled = True;
wtext->text.endPos = textXtoPos(wtext, event->xmotion.x);
}
break;
case ButtonPress:
PDEBUG("ButtonPress");
handled = True;
wtext->text.startPos = textXtoPos( wtext, event->xbutton.x );
wtext->text.endPos = wtext->text.startPos;
break;
case ButtonPress:
PDEBUG("ButtonPress");
handled = True;
wtext->text.startPos = textXtoPos(wtext, event->xbutton.x);
wtext->text.endPos = wtext->text.startPos;
break;
case ButtonRelease:
PDEBUG("ButtonRelease");
handled = True;
wtext->text.endPos = textXtoPos( wtext, event->xbutton.x );
break;
case ButtonRelease:
PDEBUG("ButtonRelease");
handled = True;
wtext->text.endPos = textXtoPos(wtext, event->xbutton.x);
break;
case KeyPress:
PDEBUG("KeyPress");
handled = handleKeyPress( wtext, &event->xkey );
break;
case KeyPress:
PDEBUG("KeyPress");
handled = handleKeyPress(wtext, &event->xkey);
break;
case EnterNotify:
PDEBUG("EnterNotify");
handled = True;
case EnterNotify:
PDEBUG("EnterNotify");
handled = True;
#if 0
if (!wtext->magic)
{
wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, wtext);
wtext->blink_on = !wtext->blink_on;
blink(wtext);
wtext->blinking = 1;
}
if (!wtext->magic) {
wtext->magic = wAddTimerHandler(CURSOR_BLINK_RATE, blink, wtext);
wtext->blink_on = !wtext->blink_on;
blink(wtext);
wtext->blinking = 1;
}
#endif
break;
break;
case LeaveNotify:
PDEBUG("LeaveNotify");
handled = True;
case LeaveNotify:
PDEBUG("LeaveNotify");
handled = True;
#if 0
wtext->blinking = 0;
if (wtext->blink_on)
blink(wtext);
if (wtext->magic)
wDeleteTimerHandler(wtext->magic);
wtext->magic = NULL;
wtext->blinking = 0;
if (wtext->blink_on)
blink(wtext);
if (wtext->magic)
wDeleteTimerHandler(wtext->magic);
wtext->magic = NULL;
#endif
break;
break;
default:
break;
}
default:
break;
}
if( handled )
textRefresh(wtext);
else
WMHandleEvent(event);
if (handled)
textRefresh(wtext);
else
WMHandleEvent(event);
return;
return;
}
static void
handleExpose(WObjDescriptor *desc, XEvent *event)
static void handleExpose(WObjDescriptor * desc, XEvent * event)
{
wTextPaint(desc->parent);
wTextPaint(desc->parent);
}
+503 -563
View File
File diff suppressed because it is too large. Load diff
+223 -235
View File
@@ -85,295 +85,283 @@
extern WPreferences wPreferences;
typedef struct {
WScreen *screen;
WShortKey *key;
int key_no;
WScreen *screen;
WShortKey *key;
int key_no;
} WUserMenuData;
static void
notifyClient(WMenu *menu, WMenuEntry *entry)
static void notifyClient(WMenu * menu, WMenuEntry * entry)
{
XEvent event;
WUserMenuData *data = entry->clientdata;
WScreen *scr = data->screen;
Window window;
int i;
XEvent event;
WUserMenuData *data = entry->clientdata;
WScreen *scr = data->screen;
Window window;
int i;
window=scr->focused_window->client_win;
window = scr->focused_window->client_win;
for(i=0;i<data->key_no;i++) {
event.xkey.type = KeyPress;
event.xkey.display = dpy;
event.xkey.window = window;
event.xkey.root = DefaultRootWindow(dpy);
event.xkey.subwindow = (Window)None;
event.xkey.x = 0x0;
event.xkey.y = 0x0;
event.xkey.x_root = 0x0;
event.xkey.y_root = 0x0;
event.xkey.keycode = data->key[i].keycode;
event.xkey.state = data->key[i].modifier;
event.xkey.same_screen = True;
event.xkey.time = CurrentTime;
if (XSendEvent(dpy, window, False, KeyPressMask, &event)) {
event.xkey.type = KeyRelease;
event.xkey.time = CurrentTime;
XSendEvent(dpy, window, True, KeyReleaseMask, &event);
}
}
for (i = 0; i < data->key_no; i++) {
event.xkey.type = KeyPress;
event.xkey.display = dpy;
event.xkey.window = window;
event.xkey.root = DefaultRootWindow(dpy);
event.xkey.subwindow = (Window) None;
event.xkey.x = 0x0;
event.xkey.y = 0x0;
event.xkey.x_root = 0x0;
event.xkey.y_root = 0x0;
event.xkey.keycode = data->key[i].keycode;
event.xkey.state = data->key[i].modifier;
event.xkey.same_screen = True;
event.xkey.time = CurrentTime;
if (XSendEvent(dpy, window, False, KeyPressMask, &event)) {
event.xkey.type = KeyRelease;
event.xkey.time = CurrentTime;
XSendEvent(dpy, window, True, KeyReleaseMask, &event);
}
}
}
static void
removeUserMenudata(void *menudata)
static void removeUserMenudata(void *menudata)
{
WUserMenuData *data = menudata;
if(data->key) wfree(data->key);
wfree(data);
WUserMenuData *data = menudata;
if (data->key)
wfree(data->key);
wfree(data);
}
static WUserMenuData*
convertShortcuts(WScreen *scr, WMPropList *shortcut)
static WUserMenuData *convertShortcuts(WScreen * scr, WMPropList * shortcut)
{
WUserMenuData *data;
KeySym ksym;
char *k;
char *buffer;
char buf[MAX_SHORTCUT_LENGTH], *b;
int keycount,i,j,mod;
WUserMenuData *data;
KeySym ksym;
char *k;
char *buffer;
char buf[MAX_SHORTCUT_LENGTH], *b;
int keycount, i, j, mod;
if (WMIsPLString(shortcut)) {
keycount = 1;
}
else if (WMIsPLArray(shortcut)) {
keycount = WMGetPropListItemCount(shortcut);
}
else return NULL;
/*for (i=0;i<keycount;i++){*/
if (WMIsPLString(shortcut)) {
keycount = 1;
} else if (WMIsPLArray(shortcut)) {
keycount = WMGetPropListItemCount(shortcut);
} else
return NULL;
/*for (i=0;i<keycount;i++){ */
data = wmalloc(sizeof(WUserMenuData));
if (!data) return NULL;
data->key = wmalloc(sizeof(WShortKey)*keycount);
if (!data->key) {
wfree(data);
return NULL;
}
data = wmalloc(sizeof(WUserMenuData));
if (!data)
return NULL;
data->key = wmalloc(sizeof(WShortKey) * keycount);
if (!data->key) {
wfree(data);
return NULL;
}
for (i = 0, j = 0; i < keycount; i++) {
data->key[j].modifier = 0;
if (WMIsPLArray(shortcut)) {
strncpy(buf, WMGetFromPLString(WMGetFromPLArray(shortcut, i)), MAX_SHORTCUT_LENGTH);
} else {
strncpy(buf, WMGetFromPLString(shortcut), MAX_SHORTCUT_LENGTH);
}
b = (char *)buf;
for (i=0,j=0;i<keycount;i++) {
data->key[j].modifier = 0;
if (WMIsPLArray(shortcut)) {
strncpy(buf, WMGetFromPLString(WMGetFromPLArray(shortcut, i)),
MAX_SHORTCUT_LENGTH);
} else {
strncpy(buf, WMGetFromPLString(shortcut), MAX_SHORTCUT_LENGTH);
}
b = (char*)buf;
while ((k = strchr(b, '+')) != NULL) {
*k = 0;
mod = wXModifierFromKey(b);
if (mod < 0) {
break;
}
data->key[j].modifier |= mod;
b = k + 1;
}
while ((k = strchr(b, '+'))!=NULL) {
*k = 0;
mod = wXModifierFromKey(b);
if (mod<0) {
break;
}
data->key[j].modifier |= mod;
b = k+1;
}
ksym = XStringToKeysym(b);
if (ksym == NoSymbol) {
continue;
}
ksym = XStringToKeysym(b);
if (ksym==NoSymbol) {
continue;
}
data->key[j].keycode = XKeysymToKeycode(dpy, ksym);
if (data->key[j].keycode) {
j++;
}
}
data->key[j].keycode = XKeysymToKeycode(dpy, ksym);
if (data->key[j].keycode) {
j++;
}
}
keyover:
keyover:
/* get key */
if (!j) {
puts("fatal j");
wfree(data->key);
wfree(data);
return NULL;
}
data->key_no = j;
data->screen = scr;
/* get key */
if (!j) {
puts("fatal j");
wfree(data->key);
wfree(data);
return NULL;
}
data->key_no = j;
data->screen = scr;
return data;
return data;
}
static WMenu*
configureUserMenu(WScreen *scr, WMPropList *plum)
static WMenu *configureUserMenu(WScreen * scr, WMPropList * plum)
{
char *mtitle;
WMenu *menu=NULL;
WMPropList *elem, *title, *command, *params;
int count,i;
WUserMenuData *data;
char *mtitle;
WMenu *menu = NULL;
WMPropList *elem, *title, *command, *params;
int count, i;
WUserMenuData *data;
if (!plum) return NULL;
if (!WMIsPLArray(plum)) {
return NULL;
}
if (!plum)
return NULL;
if (!WMIsPLArray(plum)) {
return NULL;
}
count = WMGetPropListItemCount(plum);
if (!count) return NULL;
count = WMGetPropListItemCount(plum);
if (!count)
return NULL;
elem = WMGetFromPLArray(plum, 0);
if (!WMIsPLString(elem)) {
return NULL;
}
elem = WMGetFromPLArray(plum, 0);
if (!WMIsPLString(elem)) {
return NULL;
}
mtitle = WMGetFromPLString(elem);
mtitle = WMGetFromPLString(elem);
menu=wMenuCreateForApp(scr, mtitle, True);
menu = wMenuCreateForApp(scr, mtitle, True);
for(i=1; i<count; i++) {
elem = WMGetFromPLArray(plum,i);
if(WMIsPLArray(WMGetFromPLArray(elem,1))) {
WMenu *submenu;
WMenuEntry *mentry;
for (i = 1; i < count; i++) {
elem = WMGetFromPLArray(plum, i);
if (WMIsPLArray(WMGetFromPLArray(elem, 1))) {
WMenu *submenu;
WMenuEntry *mentry;
submenu = configureUserMenu(scr,elem);
if (submenu)
mentry = wMenuAddCallback(menu, submenu->frame->title,
NULL, NULL);
wMenuEntrySetCascade(menu, mentry, submenu);
}
else {
int idx = 0;
WMPropList *instances=0;
submenu = configureUserMenu(scr, elem);
if (submenu)
mentry = wMenuAddCallback(menu, submenu->frame->title, NULL, NULL);
wMenuEntrySetCascade(menu, mentry, submenu);
} else {
int idx = 0;
WMPropList *instances = 0;
title = WMGetFromPLArray(elem,idx++);
command = WMGetFromPLArray(elem,idx++);
if (WMGetPropListItemCount(elem) >= 3)
params = WMGetFromPLArray(elem,idx++);
title = WMGetFromPLArray(elem, idx++);
command = WMGetFromPLArray(elem, idx++);
if (WMGetPropListItemCount(elem) >= 3)
params = WMGetFromPLArray(elem, idx++);
if (!title || !command)
return menu;
if (!title || !command)
return menu;
if (!strcmp("SHORTCUT",WMGetFromPLString(command))) {
WMenuEntry *entry;
if (!strcmp("SHORTCUT", WMGetFromPLString(command))) {
WMenuEntry *entry;
data = convertShortcuts(scr, params);
if (data){
entry = wMenuAddCallback(menu, WMGetFromPLString(title),
notifyClient, data);
data = convertShortcuts(scr, params);
if (data) {
entry = wMenuAddCallback(menu, WMGetFromPLString(title),
notifyClient, data);
if (entry) {
if (WMIsPLString(params)) {
entry->rtext = GetShortcutString(WMGetFromPLString(params));
}
entry->free_cdata = removeUserMenudata;
if (entry) {
if (WMIsPLString(params)) {
entry->rtext =
GetShortcutString(WMGetFromPLString(params));
}
entry->free_cdata = removeUserMenudata;
if (WMGetPropListItemCount(elem) >= 4) {
instances = WMGetFromPLArray(elem,idx++);
if(WMIsPLArray(instances))
if (instances && WMGetPropListItemCount(instances)
&& WMIsPLArray(instances)){
entry->instances = WMRetainPropList(instances);
}
}
}
}
}
if (WMGetPropListItemCount(elem) >= 4) {
instances = WMGetFromPLArray(elem, idx++);
if (WMIsPLArray(instances))
if (instances && WMGetPropListItemCount(instances)
&& WMIsPLArray(instances)) {
entry->instances =
WMRetainPropList(instances);
}
}
}
}
}
}
}
return menu;
}
}
return menu;
}
void
wUserMenuRefreshInstances(WMenu *menu, WWindow *wwin)
void wUserMenuRefreshInstances(WMenu * menu, WWindow * wwin)
{
WMenuEntry* entry;
int i,j,count,paintflag;
WMenuEntry *entry;
int i, j, count, paintflag;
paintflag=0;
paintflag = 0;
if(!menu) return;
if (!menu)
return;
for (i=0; i<menu->entry_no; i++) {
if (menu->entries[i]->instances){
WMPropList *ins;
int oldflag;
count = WMGetPropListItemCount(menu->entries[i]->instances);
for (i = 0; i < menu->entry_no; i++) {
if (menu->entries[i]->instances) {
WMPropList *ins;
int oldflag;
count = WMGetPropListItemCount(menu->entries[i]->instances);
oldflag = menu->entries[i]->flags.enabled;
menu->entries[i]->flags.enabled = 0;
for (j=0; j<count;j++) {
ins = WMGetFromPLArray(menu->entries[i]->instances,j);
if (!strcmp(wwin->wm_instance,WMGetFromPLString(ins))) {
menu->entries[i]->flags.enabled = 1;
break;
}
}
if (oldflag != menu->entries[i]->flags.enabled)
paintflag=1;
}
}
for (i=0; i < menu->cascade_no; i++) {
if (!menu->cascades[i]->flags.brother)
wUserMenuRefreshInstances(menu->cascades[i], wwin);
else
wUserMenuRefreshInstances(menu->cascades[i]->brother, wwin);
}
oldflag = menu->entries[i]->flags.enabled;
menu->entries[i]->flags.enabled = 0;
for (j = 0; j < count; j++) {
ins = WMGetFromPLArray(menu->entries[i]->instances, j);
if (!strcmp(wwin->wm_instance, WMGetFromPLString(ins))) {
menu->entries[i]->flags.enabled = 1;
break;
}
}
if (oldflag != menu->entries[i]->flags.enabled)
paintflag = 1;
}
}
for (i = 0; i < menu->cascade_no; i++) {
if (!menu->cascades[i]->flags.brother)
wUserMenuRefreshInstances(menu->cascades[i], wwin);
else
wUserMenuRefreshInstances(menu->cascades[i]->brother, wwin);
}
if (paintflag)
wMenuPaint(menu);
if (paintflag)
wMenuPaint(menu);
}
static WMenu*
readUserMenuFile(WScreen *scr, char *file_name)
static WMenu *readUserMenuFile(WScreen * scr, char *file_name)
{
WMenu *menu;
char *mtitle;
WMPropList *plum, *elem, *title, *command, *params;
int count,i;
WMenu *menu;
char *mtitle;
WMPropList *plum, *elem, *title, *command, *params;
int count, i;
menu=NULL;
plum = WMReadPropListFromFile(file_name);
/**/
if(plum){
menu = configureUserMenu(scr, plum);
WMReleasePropList(plum);
}
return menu;
menu = NULL;
plum = WMReadPropListFromFile(file_name);
/**/ if (plum) {
menu = configureUserMenu(scr, plum);
WMReleasePropList(plum);
}
return menu;
}
WMenu*
wUserMenuGet(WScreen *scr, WWindow *wwin)
WMenu *wUserMenuGet(WScreen * scr, WWindow * wwin)
{
WMenu *menu = NULL;
char buffer[100];
char *path = NULL;
char *tmp;
if (wwin->wm_instance && wwin->wm_class) {
int len = strlen(wwin->wm_instance)+strlen(wwin->wm_class)+7;
tmp=wmalloc(len);
snprintf(tmp,len,"%s.%s.menu",wwin->wm_instance,wwin->wm_class);
path = wfindfile(DEF_USER_MENU_PATHS,tmp);
wfree(tmp);
WMenu *menu = NULL;
char buffer[100];
char *path = NULL;
char *tmp;
if (wwin->wm_instance && wwin->wm_class) {
int len = strlen(wwin->wm_instance) + strlen(wwin->wm_class) + 7;
tmp = wmalloc(len);
snprintf(tmp, len, "%s.%s.menu", wwin->wm_instance, wwin->wm_class);
path = wfindfile(DEF_USER_MENU_PATHS, tmp);
wfree(tmp);
if (!path) return NULL;
if (!path)
return NULL;
if (wwin) {
menu = readUserMenuFile(scr, path);
}
if (wwin) {
menu = readUserMenuFile(scr, path);
}
wfree(path);
}
return menu;
wfree(path);
}
return menu;
}
#endif /* USER_MENU */
#endif /* USER_MENU */
+79 -95
View File
@@ -30,7 +30,6 @@
#include "WindowMaker.h"
#include "wcore.h"
/****** Global Variables ******/
extern WPreferences wPreferences;
@@ -39,7 +38,6 @@ extern Cursor wCursor[WCUR_LAST];
extern XContext wWinContext;
/*
*----------------------------------------------------------------------
* wCoreCreateTopLevel--
@@ -49,50 +47,45 @@ extern XContext wWinContext;
* The created window.
*----------------------------------------------------------------------
*/
WCoreWindow*
wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height,
int bwidth)
WCoreWindow *wCoreCreateTopLevel(WScreen * screen, int x, int y, int width, int height, int bwidth)
{
WCoreWindow *core;
int vmask;
XSetWindowAttributes attribs;
WCoreWindow *core;
int vmask;
XSetWindowAttributes attribs;
core = wmalloc(sizeof(WCoreWindow));
memset(core, 0, sizeof(WCoreWindow));
core = wmalloc(sizeof(WCoreWindow));
memset(core, 0, sizeof(WCoreWindow));
/* don't set CWBackPixel so that transparent XRender windows
are see-through */
vmask = /*CWBackPixmap|CWBackPixel|*/CWBorderPixel|CWCursor|CWEventMask
|CWOverrideRedirect;
attribs.override_redirect = True;
attribs.cursor = wCursor[WCUR_DEFAULT];
attribs.background_pixmap = None;
attribs.background_pixel = screen->black_pixel;
attribs.border_pixel = screen->frame_border_pixel;
attribs.event_mask = SubstructureRedirectMask | ButtonPressMask
| ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask
| LeaveWindowMask;
/* don't set CWBackPixel so that transparent XRender windows
are see-through */
vmask = /*CWBackPixmap|CWBackPixel| */ CWBorderPixel | CWCursor | CWEventMask
| CWOverrideRedirect;
attribs.override_redirect = True;
attribs.cursor = wCursor[WCUR_DEFAULT];
attribs.background_pixmap = None;
attribs.background_pixel = screen->black_pixel;
attribs.border_pixel = screen->frame_border_pixel;
attribs.event_mask = SubstructureRedirectMask | ButtonPressMask
| ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
vmask |= CWColormap;
attribs.colormap = screen->w_colormap;
vmask |= CWColormap;
attribs.colormap = screen->w_colormap;
core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height,
bwidth, screen->w_depth, CopyFromParent,
screen->w_visual, vmask, &attribs);
core->width = width;
core->height = height;
core->screen_ptr = screen;
core->window = XCreateWindow(dpy, screen->root_win, x, y, width, height,
bwidth, screen->w_depth, CopyFromParent, screen->w_visual, vmask, &attribs);
core->width = width;
core->height = height;
core->screen_ptr = screen;
core->descriptor.self = core;
core->descriptor.self = core;
XClearWindow(dpy, core->window);
XClearWindow(dpy, core->window);
XSaveContext(dpy, core->window, wWinContext, (XPointer)&core->descriptor);
XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor);
return core;
return core;
}
/*
*----------------------------------------------------------------------
* wCoreCreate--
@@ -110,78 +103,69 @@ wCoreCreateTopLevel(WScreen *screen, int x, int y, int width, int height,
*
*----------------------------------------------------------------------
*/
WCoreWindow*
wCoreCreate(WCoreWindow *parent, int x, int y, int width, int height)
WCoreWindow *wCoreCreate(WCoreWindow * parent, int x, int y, int width, int height)
{
WCoreWindow *core;
int vmask;
XSetWindowAttributes attribs;
WCoreWindow *core;
int vmask;
XSetWindowAttributes attribs;
core=wmalloc(sizeof(WCoreWindow));
memset(core, 0, sizeof(WCoreWindow));
core = wmalloc(sizeof(WCoreWindow));
memset(core, 0, sizeof(WCoreWindow));
vmask = /*CWBackPixmap|CWBackPixel|*/CWBorderPixel|CWCursor|CWEventMask;
attribs.cursor = wCursor[WCUR_DEFAULT];
attribs.background_pixmap = None;
attribs.background_pixel = parent->screen_ptr->black_pixel;
attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
| ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask
| LeaveWindowMask;
/*
vmask |= CWColormap;
attribs.colormap = parent->screen_ptr->w_colormap;
*/
core->window =
XCreateWindow(dpy, parent->window, x, y, width, height, 0,
parent->screen_ptr->w_depth, CopyFromParent,
parent->screen_ptr->w_visual, vmask, &attribs);
core->width=width;
core->height=height;
core->screen_ptr = parent->screen_ptr;
vmask = /*CWBackPixmap|CWBackPixel| */ CWBorderPixel | CWCursor | CWEventMask;
attribs.cursor = wCursor[WCUR_DEFAULT];
attribs.background_pixmap = None;
attribs.background_pixel = parent->screen_ptr->black_pixel;
attribs.event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask
| ButtonReleaseMask | ButtonMotionMask | ExposureMask | EnterWindowMask | LeaveWindowMask;
/*
vmask |= CWColormap;
attribs.colormap = parent->screen_ptr->w_colormap;
*/
core->window =
XCreateWindow(dpy, parent->window, x, y, width, height, 0,
parent->screen_ptr->w_depth, CopyFromParent,
parent->screen_ptr->w_visual, vmask, &attribs);
core->width = width;
core->height = height;
core->screen_ptr = parent->screen_ptr;
core->descriptor.self = core;
core->descriptor.self = core;
XSaveContext(dpy, core->window, wWinContext, (XPointer)&core->descriptor);
return core;
XSaveContext(dpy, core->window, wWinContext, (XPointer) & core->descriptor);
return core;
}
void
wCoreDestroy(WCoreWindow *core)
void wCoreDestroy(WCoreWindow * core)
{
if (core->stacking) {
wfree(core->stacking);
}
XDeleteContext(dpy, core->window, wWinContext);
XDestroyWindow(dpy, core->window);
wfree(core);
if (core->stacking) {
wfree(core->stacking);
}
XDeleteContext(dpy, core->window, wWinContext);
XDestroyWindow(dpy, core->window);
wfree(core);
}
void
wCoreConfigure(WCoreWindow *core, int req_x, int req_y, int req_w, int req_h)
void wCoreConfigure(WCoreWindow * core, int req_x, int req_y, int req_w, int req_h)
{
XWindowChanges xwc;
unsigned int mask;
XWindowChanges xwc;
unsigned int mask;
mask = CWX|CWY;
xwc.x = req_x;
xwc.y = req_y;
mask = CWX | CWY;
xwc.x = req_x;
xwc.y = req_y;
if (req_w <= 0)
req_w = core->width;
if (req_h <= 0)
req_h = core->height;
if (req_w <= 0)
req_w = core->width;
if (req_h <= 0)
req_h = core->height;
if (req_w != core->width || req_h != core->height) {
mask |= CWWidth | CWHeight;
xwc.width = req_w;
xwc.height = req_h;
core->width = req_w;
core->height = req_h;
}
XConfigureWindow(dpy, core->window, mask, &xwc);
if (req_w != core->width || req_h != core->height) {
mask |= CWWidth | CWHeight;
xwc.width = req_w;
xwc.height = req_h;
core->width = req_w;
core->height = req_h;
}
XConfigureWindow(dpy, core->window, mask, &xwc);
}
+343 -382
View File
@@ -34,7 +34,6 @@
#include <wraster.h>
#include "WindowMaker.h"
#include "window.h"
#include "screen.h"
@@ -43,7 +42,6 @@
#include "defaults.h"
#include "icon.h"
/* Global stuff */
extern WPreferences wPreferences;
@@ -52,15 +50,12 @@ extern WMPropList *wAttributeDomainName;
extern WDDomain *WDWindowAttributes;
/* Local stuff */
/* type converters */
static int getBool(WMPropList*, WMPropList*);
static char* getString(WMPropList*, WMPropList*);
static int getBool(WMPropList *, WMPropList *);
static char *getString(WMPropList *, WMPropList *);
static WMPropList *ANoTitlebar = NULL;
static WMPropList *ANoResizebar;
@@ -70,7 +65,7 @@ static WMPropList *ANoBorder;
static WMPropList *ANoHideOthers;
static WMPropList *ANoMouseBindings;
static WMPropList *ANoKeyBindings;
static WMPropList *ANoAppIcon; /* app */
static WMPropList *ANoAppIcon; /* app */
static WMPropList *AKeepOnTop;
static WMPropList *AKeepOnBottom;
static WMPropList *AOmnipresent;
@@ -80,11 +75,11 @@ static WMPropList *AUnfocusable;
static WMPropList *AAlwaysUserIcon;
static WMPropList *AStartMiniaturized;
static WMPropList *AStartMaximized;
static WMPropList *AStartHidden; /* app */
static WMPropList *ADontSaveSession; /* app */
static WMPropList *AStartHidden; /* app */
static WMPropList *ADontSaveSession; /* app */
static WMPropList *AEmulateAppIcon;
static WMPropList *AFullMaximize;
static WMPropList *ASharedAppIcon; /* app */
static WMPropList *ASharedAppIcon; /* app */
#ifdef XKB_BUTTON_HINT
static WMPropList *ANoLanguageButton;
#endif
@@ -93,94 +88,86 @@ static WMPropList *AStartWorkspace;
static WMPropList *AIcon;
static WMPropList *AnyWindow;
static WMPropList *No;
static void
init_wdefaults(WScreen *scr)
static void init_wdefaults(WScreen * scr)
{
AIcon = WMCreatePLString("Icon");
AIcon = WMCreatePLString("Icon");
ANoTitlebar = WMCreatePLString("NoTitlebar");
ANoResizebar = WMCreatePLString("NoResizebar");
ANoMiniaturizeButton = WMCreatePLString("NoMiniaturizeButton");
ANoCloseButton = WMCreatePLString("NoCloseButton");
ANoBorder = WMCreatePLString("NoBorder");
ANoHideOthers = WMCreatePLString("NoHideOthers");
ANoMouseBindings = WMCreatePLString("NoMouseBindings");
ANoKeyBindings = WMCreatePLString("NoKeyBindings");
ANoAppIcon = WMCreatePLString("NoAppIcon");
AKeepOnTop = WMCreatePLString("KeepOnTop");
AKeepOnBottom = WMCreatePLString("KeepOnBottom");
AOmnipresent = WMCreatePLString("Omnipresent");
ASkipWindowList = WMCreatePLString("SkipWindowList");
AKeepInsideScreen = WMCreatePLString("KeepInsideScreen");
AUnfocusable = WMCreatePLString("Unfocusable");
AAlwaysUserIcon = WMCreatePLString("AlwaysUserIcon");
AStartMiniaturized = WMCreatePLString("StartMiniaturized");
AStartHidden = WMCreatePLString("StartHidden");
AStartMaximized = WMCreatePLString("StartMaximized");
ADontSaveSession = WMCreatePLString("DontSaveSession");
AEmulateAppIcon = WMCreatePLString("EmulateAppIcon");
AFullMaximize = WMCreatePLString("FullMaximize");
ASharedAppIcon = WMCreatePLString("SharedAppIcon");
ANoTitlebar = WMCreatePLString("NoTitlebar");
ANoResizebar = WMCreatePLString("NoResizebar");
ANoMiniaturizeButton = WMCreatePLString("NoMiniaturizeButton");
ANoCloseButton = WMCreatePLString("NoCloseButton");
ANoBorder = WMCreatePLString("NoBorder");
ANoHideOthers = WMCreatePLString("NoHideOthers");
ANoMouseBindings = WMCreatePLString("NoMouseBindings");
ANoKeyBindings = WMCreatePLString("NoKeyBindings");
ANoAppIcon = WMCreatePLString("NoAppIcon");
AKeepOnTop = WMCreatePLString("KeepOnTop");
AKeepOnBottom = WMCreatePLString("KeepOnBottom");
AOmnipresent = WMCreatePLString("Omnipresent");
ASkipWindowList = WMCreatePLString("SkipWindowList");
AKeepInsideScreen = WMCreatePLString("KeepInsideScreen");
AUnfocusable = WMCreatePLString("Unfocusable");
AAlwaysUserIcon = WMCreatePLString("AlwaysUserIcon");
AStartMiniaturized = WMCreatePLString("StartMiniaturized");
AStartHidden = WMCreatePLString("StartHidden");
AStartMaximized = WMCreatePLString("StartMaximized");
ADontSaveSession = WMCreatePLString("DontSaveSession");
AEmulateAppIcon = WMCreatePLString("EmulateAppIcon");
AFullMaximize = WMCreatePLString("FullMaximize");
ASharedAppIcon = WMCreatePLString("SharedAppIcon");
#ifdef XKB_BUTTON_HINT
ANoLanguageButton = WMCreatePLString("NoLanguageButton");
ANoLanguageButton = WMCreatePLString("NoLanguageButton");
#endif
AStartWorkspace = WMCreatePLString("StartWorkspace");
AStartWorkspace = WMCreatePLString("StartWorkspace");
AnyWindow = WMCreatePLString("*");
No = WMCreatePLString("No");
/*
if (!scr->wattribs) {
scr->wattribs = PLGetDomain(wAttributeDomainName);
}*/
AnyWindow = WMCreatePLString("*");
No = WMCreatePLString("No");
/*
if (!scr->wattribs) {
scr->wattribs = PLGetDomain(wAttributeDomainName);
} */
}
static WMPropList*
get_value(WMPropList *dict_win, WMPropList *dict_class, WMPropList *dict_name,
WMPropList *dict_any, WMPropList *option, WMPropList *default_value,
Bool useGlobalDefault)
static WMPropList *get_value(WMPropList * dict_win, WMPropList * dict_class, WMPropList * dict_name,
WMPropList * dict_any, WMPropList * option, WMPropList * default_value,
Bool useGlobalDefault)
{
WMPropList *value;
WMPropList *value;
if (dict_win) {
value = WMGetFromPLDictionary(dict_win, option);
if (value)
return value;
}
if (dict_win) {
value = WMGetFromPLDictionary(dict_win, option);
if (value)
return value;
}
if (dict_name) {
value = WMGetFromPLDictionary(dict_name, option);
if (value)
return value;
}
if (dict_name) {
value = WMGetFromPLDictionary(dict_name, option);
if (value)
return value;
}
if (dict_class) {
value = WMGetFromPLDictionary(dict_class, option);
if (value)
return value;
}
if (dict_class) {
value = WMGetFromPLDictionary(dict_class, option);
if (value)
return value;
}
if (!useGlobalDefault)
return NULL;
if (!useGlobalDefault)
return NULL;
if (dict_any) {
value = WMGetFromPLDictionary(dict_any, option);
if (value)
return value;
}
if (dict_any) {
value = WMGetFromPLDictionary(dict_any, option);
if (value)
return value;
}
return default_value;
return default_value;
}
/*
*----------------------------------------------------------------------
* wDefaultFillAttributes--
@@ -193,419 +180,393 @@ get_value(WMPropList *dict_win, WMPropList *dict_class, WMPropList *dict_name,
*----------------------------------------------------------------------
*/
void
wDefaultFillAttributes(WScreen *scr, char *instance, char *class,
WWindowAttributes *attr,
WWindowAttributes *mask,
Bool useGlobalDefault)
wDefaultFillAttributes(WScreen * scr, char *instance, char *class,
WWindowAttributes * attr, WWindowAttributes * mask, Bool useGlobalDefault)
{
WMPropList *value, *key1, *key2, *key3, *dw, *dc, *dn, *da;
WMPropList *value, *key1, *key2, *key3, *dw, *dc, *dn, *da;
if (class && instance) {
char *buffer;
if (class && instance) {
char *buffer;
buffer = wmalloc(strlen(class) + strlen(instance) + 2);
sprintf(buffer, "%s.%s", instance, class);
key1 = WMCreatePLString(buffer);
wfree(buffer);
} else {
key1 = NULL;
}
buffer = wmalloc(strlen(class)+strlen(instance)+2);
sprintf(buffer, "%s.%s", instance, class);
key1 = WMCreatePLString(buffer);
wfree(buffer);
} else {
key1 = NULL;
}
if (instance)
key2 = WMCreatePLString(instance);
else
key2 = NULL;
if (instance)
key2 = WMCreatePLString(instance);
else
key2 = NULL;
if (class)
key3 = WMCreatePLString(class);
else
key3 = NULL;
if (class)
key3 = WMCreatePLString(class);
else
key3 = NULL;
if (!ANoTitlebar) {
init_wdefaults(scr);
}
if (!ANoTitlebar) {
init_wdefaults(scr);
}
WMPLSetCaseSensitive(True);
WMPLSetCaseSensitive(True);
if (WDWindowAttributes->dictionary) {
dw = key1 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key1) : NULL;
dn = key2 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key2) : NULL;
dc = key3 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key3) : NULL;
if (useGlobalDefault)
da = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow);
else
da = NULL;
} else {
dw = NULL;
dn = NULL;
dc = NULL;
da = NULL;
}
if (key1)
WMReleasePropList(key1);
if (key2)
WMReleasePropList(key2);
if (key3)
WMReleasePropList(key3);
if (WDWindowAttributes->dictionary) {
dw = key1 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key1) : NULL;
dn = key2 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key2) : NULL;
dc = key3 ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key3) : NULL;
if (useGlobalDefault)
da = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow);
else
da = NULL;
} else {
dw = NULL;
dn = NULL;
dc = NULL;
da = NULL;
}
if (key1)
WMReleasePropList(key1);
if (key2)
WMReleasePropList(key2);
if (key3)
WMReleasePropList(key3);
#define APPLY_VAL(value, flag, attrib) \
if (value) {attr->flag = getBool(attrib, value); \
if (mask) mask->flag = 1;}
/* get the data */
value = get_value(dw, dc, dn, da, ANoTitlebar, No, useGlobalDefault);
APPLY_VAL(value, no_titlebar, ANoTitlebar);
/* get the data */
value = get_value(dw, dc, dn, da, ANoTitlebar, No, useGlobalDefault);
APPLY_VAL(value, no_titlebar, ANoTitlebar);
value = get_value(dw, dc, dn, da, ANoResizebar, No, useGlobalDefault);
APPLY_VAL(value, no_resizebar, ANoResizebar);
value = get_value(dw, dc, dn, da, ANoResizebar, No, useGlobalDefault);
APPLY_VAL(value, no_resizebar, ANoResizebar);
value = get_value(dw, dc, dn, da, ANoMiniaturizeButton, No, useGlobalDefault);
APPLY_VAL(value, no_miniaturize_button, ANoMiniaturizeButton);
value = get_value(dw, dc, dn, da, ANoMiniaturizeButton, No, useGlobalDefault);
APPLY_VAL(value, no_miniaturize_button, ANoMiniaturizeButton);
value = get_value(dw, dc, dn, da, ANoCloseButton, No, useGlobalDefault);
APPLY_VAL(value, no_close_button, ANoCloseButton);
value = get_value(dw, dc, dn, da, ANoCloseButton, No, useGlobalDefault);
APPLY_VAL(value, no_close_button, ANoCloseButton);
value = get_value(dw, dc, dn, da, ANoBorder, No, useGlobalDefault);
APPLY_VAL(value, no_border, ANoBorder);
value = get_value(dw, dc, dn, da, ANoBorder, No, useGlobalDefault);
APPLY_VAL(value, no_border, ANoBorder);
value = get_value(dw, dc, dn, da, ANoHideOthers, No, useGlobalDefault);
APPLY_VAL(value, no_hide_others, ANoHideOthers);
value = get_value(dw, dc, dn, da, ANoHideOthers, No, useGlobalDefault);
APPLY_VAL(value, no_hide_others, ANoHideOthers);
value = get_value(dw, dc, dn, da, ANoMouseBindings, No, useGlobalDefault);
APPLY_VAL(value, no_bind_mouse, ANoMouseBindings);
value = get_value(dw, dc, dn, da, ANoMouseBindings, No, useGlobalDefault);
APPLY_VAL(value, no_bind_mouse, ANoMouseBindings);
value = get_value(dw, dc, dn, da, ANoKeyBindings, No, useGlobalDefault);
APPLY_VAL(value, no_bind_keys, ANoKeyBindings);
value = get_value(dw, dc, dn, da, ANoKeyBindings, No, useGlobalDefault);
APPLY_VAL(value, no_bind_keys, ANoKeyBindings);
value = get_value(dw, dc, dn, da, ANoAppIcon, No, useGlobalDefault);
APPLY_VAL(value, no_appicon, ANoAppIcon);
value = get_value(dw, dc, dn, da, ANoAppIcon, No, useGlobalDefault);
APPLY_VAL(value, no_appicon, ANoAppIcon);
value = get_value(dw, dc, dn, da, ASharedAppIcon, No, useGlobalDefault);
APPLY_VAL(value, shared_appicon, ASharedAppIcon);
value = get_value(dw, dc, dn, da, ASharedAppIcon, No, useGlobalDefault);
APPLY_VAL(value, shared_appicon, ASharedAppIcon);
value = get_value(dw, dc, dn, da, AKeepOnTop, No, useGlobalDefault);
APPLY_VAL(value, floating, AKeepOnTop);
value = get_value(dw, dc, dn, da, AKeepOnTop, No, useGlobalDefault);
APPLY_VAL(value, floating, AKeepOnTop);
value = get_value(dw, dc, dn, da, AKeepOnBottom, No, useGlobalDefault);
APPLY_VAL(value, sunken, AKeepOnBottom);
value = get_value(dw, dc, dn, da, AKeepOnBottom, No, useGlobalDefault);
APPLY_VAL(value, sunken, AKeepOnBottom);
value = get_value(dw, dc, dn, da, AOmnipresent, No, useGlobalDefault);
APPLY_VAL(value, omnipresent, AOmnipresent);
value = get_value(dw, dc, dn, da, AOmnipresent, No, useGlobalDefault);
APPLY_VAL(value, omnipresent, AOmnipresent);
value = get_value(dw, dc, dn, da, ASkipWindowList, No, useGlobalDefault);
APPLY_VAL(value, skip_window_list, ASkipWindowList);
value = get_value(dw, dc, dn, da, ASkipWindowList, No, useGlobalDefault);
APPLY_VAL(value, skip_window_list, ASkipWindowList);
value = get_value(dw, dc, dn, da, AKeepInsideScreen, No, useGlobalDefault);
APPLY_VAL(value, dont_move_off, AKeepInsideScreen);
value = get_value(dw, dc, dn, da, AKeepInsideScreen, No, useGlobalDefault);
APPLY_VAL(value, dont_move_off, AKeepInsideScreen);
value = get_value(dw, dc, dn, da, AUnfocusable, No, useGlobalDefault);
APPLY_VAL(value, no_focusable, AUnfocusable);
value = get_value(dw, dc, dn, da, AUnfocusable, No, useGlobalDefault);
APPLY_VAL(value, no_focusable, AUnfocusable);
value = get_value(dw, dc, dn, da, AAlwaysUserIcon, No, useGlobalDefault);
APPLY_VAL(value, always_user_icon, AAlwaysUserIcon);
value = get_value(dw, dc, dn, da, AAlwaysUserIcon, No, useGlobalDefault);
APPLY_VAL(value, always_user_icon, AAlwaysUserIcon);
value = get_value(dw, dc, dn, da, AStartMiniaturized, No, useGlobalDefault);
APPLY_VAL(value, start_miniaturized, AStartMiniaturized);
value = get_value(dw, dc, dn, da, AStartMiniaturized, No, useGlobalDefault);
APPLY_VAL(value, start_miniaturized, AStartMiniaturized);
value = get_value(dw, dc, dn, da, AStartHidden, No, useGlobalDefault);
APPLY_VAL(value, start_hidden, AStartHidden);
value = get_value(dw, dc, dn, da, AStartHidden, No, useGlobalDefault);
APPLY_VAL(value, start_hidden, AStartHidden);
value = get_value(dw, dc, dn, da, AStartMaximized, No, useGlobalDefault);
APPLY_VAL(value, start_maximized, AStartMaximized);
value = get_value(dw, dc, dn, da, AStartMaximized, No, useGlobalDefault);
APPLY_VAL(value, start_maximized, AStartMaximized);
value = get_value(dw, dc, dn, da, ADontSaveSession, No, useGlobalDefault);
APPLY_VAL(value, dont_save_session, ADontSaveSession);
value = get_value(dw, dc, dn, da, ADontSaveSession, No, useGlobalDefault);
APPLY_VAL(value, dont_save_session, ADontSaveSession);
value = get_value(dw, dc, dn, da, AEmulateAppIcon, No, useGlobalDefault);
APPLY_VAL(value, emulate_appicon, AEmulateAppIcon);
value = get_value(dw, dc, dn, da, AEmulateAppIcon, No, useGlobalDefault);
APPLY_VAL(value, emulate_appicon, AEmulateAppIcon);
value = get_value(dw, dc, dn, da, AFullMaximize, No, useGlobalDefault);
APPLY_VAL(value, full_maximize, AFullMaximize);
value = get_value(dw, dc, dn, da, AFullMaximize, No, useGlobalDefault);
APPLY_VAL(value, full_maximize, AFullMaximize);
#ifdef XKB_BUTTON_HINT
value = get_value(dw, dc, dn, da, ANoLanguageButton, No, useGlobalDefault);
APPLY_VAL(value, no_language_button, ANoLanguageButton);
value = get_value(dw, dc, dn, da, ANoLanguageButton, No, useGlobalDefault);
APPLY_VAL(value, no_language_button, ANoLanguageButton);
#endif
/* clean up */
WMPLSetCaseSensitive(False);
/* clean up */
WMPLSetCaseSensitive(False);
}
WMPropList*
get_generic_value(WScreen *scr, char *instance, char *class, WMPropList *option,
Bool noDefault)
WMPropList *get_generic_value(WScreen * scr, char *instance, char *class, WMPropList * option, Bool noDefault)
{
WMPropList *value, *key, *dict;
WMPropList *value, *key, *dict;
value = NULL;
value = NULL;
WMPLSetCaseSensitive(True);
WMPLSetCaseSensitive(True);
if (class && instance) {
char *buffer;
if (class && instance) {
char *buffer;
buffer = wmalloc(strlen(class)+strlen(instance)+2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
wfree(buffer);
buffer = wmalloc(strlen(class) + strlen(instance) + 2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
wfree(buffer);
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
if (!value && instance) {
key = WMCreatePLString(instance);
if (!value && instance) {
key = WMCreatePLString(instance);
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
if (!value && class) {
key = WMCreatePLString(class);
if (!value && class) {
key = WMCreatePLString(class);
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
if (!value && !noDefault) {
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow);
if (!value && !noDefault) {
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow);
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
if (dict) {
value = WMGetFromPLDictionary(dict, option);
}
}
WMPLSetCaseSensitive(False);
WMPLSetCaseSensitive(False);
return value;
return value;
}
char*
wDefaultGetIconFile(WScreen *scr, char *instance, char *class,
Bool noDefault)
char *wDefaultGetIconFile(WScreen * scr, char *instance, char *class, Bool noDefault)
{
WMPropList *value;
char *tmp;
WMPropList *value;
char *tmp;
if (!ANoTitlebar) {
init_wdefaults(scr);
}
if (!ANoTitlebar) {
init_wdefaults(scr);
}
if (!WDWindowAttributes->dictionary)
return NULL;
if (!WDWindowAttributes->dictionary)
return NULL;
value = get_generic_value(scr, instance, class, AIcon, noDefault);
value = get_generic_value(scr, instance, class, AIcon, noDefault);
if (!value)
return NULL;
if (!value)
return NULL;
tmp = getString(AIcon, value);
tmp = getString(AIcon, value);
return tmp;
return tmp;
}
RImage*
wDefaultGetImage(WScreen *scr, char *winstance, char *wclass)
RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass)
{
char *file_name;
char *path;
RImage *image;
char *file_name;
char *path;
RImage *image;
file_name = wDefaultGetIconFile(scr, winstance, wclass, False);
if (!file_name)
return NULL;
file_name = wDefaultGetIconFile(scr, winstance, wclass, False);
if (!file_name)
return NULL;
path = FindImage(wPreferences.icon_path, file_name);
path = FindImage(wPreferences.icon_path, file_name);
if (!path) {
wwarning(_("could not find icon file \"%s\""), file_name);
return NULL;
}
if (!path) {
wwarning(_("could not find icon file \"%s\""), file_name);
return NULL;
}
image = RLoadImage(scr->rcontext, path, 0);
if (!image) {
wwarning(_("error loading image file \"%s\""), path, RMessageForError(RErrorCode));
}
wfree(path);
image = RLoadImage(scr->rcontext, path, 0);
if (!image) {
wwarning(_("error loading image file \"%s\""), path, RMessageForError(RErrorCode));
}
wfree(path);
image = wIconValidateIconSize(scr, image);
image = wIconValidateIconSize(scr, image);
return image;
return image;
}
int
wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class)
int wDefaultGetStartWorkspace(WScreen * scr, char *instance, char *class)
{
WMPropList *value;
int w, i;
char *tmp;
WMPropList *value;
int w, i;
char *tmp;
if (!ANoTitlebar) {
init_wdefaults(scr);
}
if (!ANoTitlebar) {
init_wdefaults(scr);
}
if (!WDWindowAttributes->dictionary)
return -1;
if (!WDWindowAttributes->dictionary)
return -1;
value = get_generic_value(scr, instance, class, AStartWorkspace,
False);
value = get_generic_value(scr, instance, class, AStartWorkspace, False);
if (!value)
return -1;
if (!value)
return -1;
tmp = getString(AStartWorkspace, value);
tmp = getString(AStartWorkspace, value);
if (!tmp || strlen(tmp)==0)
return -1;
if (!tmp || strlen(tmp) == 0)
return -1;
if (sscanf(tmp, "%i", &w)!=1) {
w = -1;
for (i=0; i < scr->workspace_count; i++) {
if (strcmp(scr->workspaces[i]->name, tmp)==0) {
w = i;
break;
}
}
} else {
w--;
}
if (sscanf(tmp, "%i", &w) != 1) {
w = -1;
for (i = 0; i < scr->workspace_count; i++) {
if (strcmp(scr->workspaces[i]->name, tmp) == 0) {
w = i;
break;
}
}
} else {
w--;
}
return w;
return w;
}
void
wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file)
void wDefaultChangeIcon(WScreen * scr, char *instance, char *class, char *file)
{
WDDomain *db = WDWindowAttributes;
WMPropList *icon_value=NULL, *value, *attr, *key, *def_win, *def_icon=NULL;
WMPropList *dict = db->dictionary;
int same = 0;
WDDomain *db = WDWindowAttributes;
WMPropList *icon_value = NULL, *value, *attr, *key, *def_win, *def_icon = NULL;
WMPropList *dict = db->dictionary;
int same = 0;
if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL);
if (dict) {
db->dictionary = dict;
} else {
return;
}
}
if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL);
if (dict) {
db->dictionary = dict;
} else {
return;
}
}
WMPLSetCaseSensitive(True);
WMPLSetCaseSensitive(True);
if (instance && class) {
char *buffer;
buffer = wmalloc(strlen(instance) + strlen(class) + 2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
wfree(buffer);
} else if (instance) {
key = WMCreatePLString(instance);
} else if (class) {
key = WMCreatePLString(class);
} else {
key = WMRetainPropList(AnyWindow);
}
if (instance && class) {
char *buffer;
buffer = wmalloc(strlen(instance) + strlen(class) + 2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
wfree(buffer);
} else if (instance) {
key = WMCreatePLString(instance);
} else if (class) {
key = WMCreatePLString(class);
} else {
key = WMRetainPropList(AnyWindow);
}
if (file) {
value = WMCreatePLString(file);
icon_value = WMCreatePLDictionary(AIcon, value, NULL);
WMReleasePropList(value);
if (file) {
value = WMCreatePLString(file);
icon_value = WMCreatePLDictionary(AIcon, value, NULL);
WMReleasePropList(value);
if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL) {
def_icon = WMGetFromPLDictionary(def_win, AIcon);
}
if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL) {
def_icon = WMGetFromPLDictionary(def_win, AIcon);
}
if (def_icon && !strcmp(WMGetFromPLString(def_icon), file))
same = 1;
}
if (def_icon && !strcmp(WMGetFromPLString(def_icon), file))
same = 1;
}
if ((attr = WMGetFromPLDictionary(dict, key)) != NULL) {
if (WMIsPLDictionary(attr)) {
if (icon_value!=NULL && !same)
WMMergePLDictionaries(attr, icon_value, False);
else
WMRemoveFromPLDictionary(attr, AIcon);
}
} else if (icon_value!=NULL && !same) {
WMPutInPLDictionary(dict, key, icon_value);
}
if (!wPreferences.flags.noupdates) {
UpdateDomainFile(db);
}
if ((attr = WMGetFromPLDictionary(dict, key)) != NULL) {
if (WMIsPLDictionary(attr)) {
if (icon_value != NULL && !same)
WMMergePLDictionaries(attr, icon_value, False);
else
WMRemoveFromPLDictionary(attr, AIcon);
}
} else if (icon_value != NULL && !same) {
WMPutInPLDictionary(dict, key, icon_value);
}
if (!wPreferences.flags.noupdates) {
UpdateDomainFile(db);
}
WMReleasePropList(key);
if(icon_value)
WMReleasePropList(icon_value);
WMReleasePropList(key);
if (icon_value)
WMReleasePropList(icon_value);
WMPLSetCaseSensitive(False);
WMPLSetCaseSensitive(False);
}
/* --------------------------- Local ----------------------- */
static int
getBool(WMPropList *key, WMPropList *value)
static int getBool(WMPropList * key, WMPropList * value)
{
char *val;
char *val;
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."),
WMGetFromPLString(key), "Boolean");
return 0;
}
val = WMGetFromPLString(value);
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."),
WMGetFromPLString(key), "Boolean");
return 0;
}
val = WMGetFromPLString(value);
if ((val[1]=='\0' && (val[0]=='y' || val[0]=='Y' || val[0]=='T'
|| val[0]=='t' || val[0]=='1'))
|| (strcasecmp(val, "YES")==0 || strcasecmp(val, "TRUE")==0)) {
if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' || val[0] == 't' || val[0] == '1'))
|| (strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) {
return 1;
} else if ((val[1]=='\0'
&& (val[0]=='n' || val[0]=='N' || val[0]=='F'
|| val[0]=='f' || val[0]=='0'))
|| (strcasecmp(val, "NO")==0 || strcasecmp(val, "FALSE")==0)) {
return 1;
} else if ((val[1] == '\0'
&& (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' || val[0] == 'f' || val[0] == '0'))
|| (strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") == 0)) {
return 0;
} else {
wwarning(_("can't convert \"%s\" to boolean"), val);
/* We return False if we can't convert to BOOLEAN.
* This is because all options defaults to False.
* -1 is not checked and thus is interpreted as True,
* which is not good.*/
return 0;
}
return 0;
} else {
wwarning(_("can't convert \"%s\" to boolean"), val);
/* We return False if we can't convert to BOOLEAN.
* This is because all options defaults to False.
* -1 is not checked and thus is interpreted as True,
* which is not good.*/
return 0;
}
}
/* WARNING: Do not free the value returned by this function!! */
static char*
getString(WMPropList *key, WMPropList *value)
static char *getString(WMPropList * key, WMPropList * value)
{
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."),
WMGetFromPLString(key), "String");
return NULL;
}
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."), WMGetFromPLString(key), "String");
return NULL;
}
return WMGetFromPLString(value);
return WMGetFromPLString(value);
}
+2314 -2507
View File
File diff suppressed because it is too large. Load diff
+439 -475
View File
File diff suppressed because it is too large. Load diff
+1195 -1325
View File
File diff suppressed because it is too large. Load diff
+1161 -1259
View File
File diff suppressed because it is too large. Load diff
+1013 -1118
View File
File diff suppressed because it is too large. Load diff
+46 -59
View File
@@ -2,95 +2,82 @@
#include "WindowMaker.h"
#include "window.h"
typedef struct {
WWindow *wwin;
WMLabel *mini;
WWindow *wwin;
WMLabel *mini;
} WSMWindow;
typedef struct {
WScreen *scr;
WScreen *scr;
WMWindow *win;
WMWindow *win;
WSMWindow *windows;
int windowCount;
WSMWindow *windows;
int windowCount;
int xcount, ycount;
int wswidth, wsheight;
int xcount, ycount;
int wswidth, wsheight;
} WWorkspaceMap;
#define WSMAP_DEFAULT_WIDTH 150
static WWorkspaceMap *createWorkspaceMap(WMScreen *scr, int xcount, int ycount)
static WWorkspaceMap *createWorkspaceMap(WMScreen * scr, int xcount, int ycount)
{
WWorkspaceMap *wsm= wnew0(WWorkspaceMap, 1);
WMRect rect;
//
rect.width= 1024;
rect.height= 768;
WWorkspaceMap *wsm = wnew0(WWorkspaceMap, 1);
WMRect rect;
//
rect.width = 1024;
rect.height = 768;
wsm->win= WMCreateWindow(scr, "wsmap");
/* find out the ideal size of the mini-workspaces */
wsm->win = WMCreateWindow(scr, "wsmap");
wsm->wswidth = WSMAP_DEFAULT_WIDTH;
wsm->wsheight = (wsm->wswidth*rect.height) / rect.width;
/* find out the ideal size of the mini-workspaces */
// check if it fits screen
wsm->wswidth = WSMAP_DEFAULT_WIDTH;
wsm->wsheight = (wsm->wswidth * rect.height) / rect.width;
wsm->xcount = xcount;
wsm->ycount = ycount;
// check if it fits screen
return wsm;
wsm->xcount = xcount;
wsm->ycount = ycount;
return wsm;
}
static void handleEvent(WWorkspaceMap *map, XEvent *event)
static void handleEvent(WWorkspaceMap * map, XEvent * event)
{
switch (event->type)
{
}
switch (event->type) {
}
}
void wShowWorkspaceMap(WScreen *scr)
void wShowWorkspaceMap(WScreen * scr)
{
}
Display *dpy;
int main(int argc, char **argv)
{
WWorkspaceMap *wsmap;
WMScreen *scr;
WMInitializeApplication("WSMap", &argc, argv);
WWorkspaceMap *wsmap;
WMScreen *scr;
dpy = XOpenDisplay("");
if (!dpy) {
wfatal("cant open display");
exit(0);
}
WMInitializeApplication("WSMap", &argc, argv);
scr = WMCreateSimpleApplicationScreen(dpy);
wsmap= createWorkspaceMap(scr);
WMRealizeWidget(wsmap->win);
WMMapWidget(wsmap->win);
WMScreenMainLoop(scr);
dpy = XOpenDisplay("");
if (!dpy) {
wfatal("cant open display");
exit(0);
}
return 0;
scr = WMCreateSimpleApplicationScreen(dpy);
wsmap = createWorkspaceMap(scr);
WMRealizeWidget(wsmap->win);
WMMapWidget(wsmap->win);
WMScreenMainLoop(scr);
return 0;
}
+17 -23
View File
@@ -11,33 +11,27 @@
#include "funcs.h"
#include "wsound.h"
extern WPreferences wPreferences;
void
wSoundPlay(long event_sound)
void wSoundPlay(long event_sound)
{
static Atom atom = 0;
XEvent sound_event;
static Atom atom = 0;
XEvent sound_event;
if (!atom) {
atom = XInternAtom(dpy, "_WINDOWMAKER_EVENT", False);
}
if (!atom) {
atom = XInternAtom(dpy, "_WINDOWMAKER_EVENT", False);
}
if(!wPreferences.no_sound) {
Window win = wScreenWithNumber(0)->info_window;
if (!wPreferences.no_sound) {
Window win = wScreenWithNumber(0)->info_window;
sound_event.xclient.type = ClientMessage;
sound_event.xclient.message_type = atom;
sound_event.xclient.format = 32;
sound_event.xclient.display = dpy;
sound_event.xclient.window = win;
sound_event.xclient.data.l[0] = event_sound;
XSendEvent(dpy, win, False, StructureNotifyMask, &sound_event);
XFlush(dpy);
}
sound_event.xclient.type = ClientMessage;
sound_event.xclient.message_type = atom;
sound_event.xclient.format = 32;
sound_event.xclient.display = dpy;
sound_event.xclient.window = win;
sound_event.xclient.data.l[0] = event_sound;
XSendEvent(dpy, win, False, StructureNotifyMask, &sound_event);
XFlush(dpy);
}
}
+233 -242
View File
@@ -18,7 +18,6 @@
#include <X11/Xatom.h>
#define XDND_VERSION 3L
Atom _XA_XdndAware;
@@ -39,37 +38,34 @@ Atom _XA_WINDOWMAKER_XDNDEXCHANGE;
Atom atom_support;
void
wXDNDInitializeAtoms()
void wXDNDInitializeAtoms()
{
_XA_XdndAware = XInternAtom(dpy, "XdndAware", False);
_XA_XdndEnter = XInternAtom(dpy, "XdndEnter", False);
_XA_XdndLeave = XInternAtom(dpy, "XdndLeave", False);
_XA_XdndDrop = XInternAtom(dpy, "XdndDrop", False);
_XA_XdndPosition = XInternAtom(dpy, "XdndPosition", False);
_XA_XdndStatus = XInternAtom(dpy, "XdndStatus", False);
_XA_XdndActionCopy = XInternAtom(dpy, "XdndActionCopy", False);
_XA_XdndSelection = XInternAtom(dpy, "XdndSelection", False);
_XA_XdndFinished = XInternAtom(dpy, "XdndFinished", False);
_XA_XdndAware = XInternAtom(dpy, "XdndAware", False);
_XA_XdndEnter = XInternAtom(dpy, "XdndEnter", False);
_XA_XdndLeave = XInternAtom(dpy, "XdndLeave", False);
_XA_XdndDrop = XInternAtom(dpy, "XdndDrop", False);
_XA_XdndPosition = XInternAtom(dpy, "XdndPosition", False);
_XA_XdndStatus = XInternAtom(dpy, "XdndStatus", False);
_XA_XdndActionCopy = XInternAtom(dpy, "XdndActionCopy", False);
_XA_XdndSelection = XInternAtom(dpy, "XdndSelection", False);
_XA_XdndFinished = XInternAtom(dpy, "XdndFinished", False);
_XA_WINDOWMAKER_XDNDEXCHANGE = XInternAtom(dpy, "_WINDOWMAKER_XDNDEXCHANGE", False);
_XA_WINDOWMAKER_XDNDEXCHANGE = XInternAtom(dpy, "_WINDOWMAKER_XDNDEXCHANGE", False);
/*
_XA_MOTIF_DRAG_RECEIVER_INFO = XInternAtom(dpy, "_MOTIF_DRAG_RECEIVER_INFO",False);
_XA_MOTIF_DRAG_AND_DROP_MESSAGE = XInternAtom(dpy, "_MOTIF_DRAG_AND_DROP_MESSAGE", False);
*/
/*
_XA_MOTIF_DRAG_RECEIVER_INFO = XInternAtom(dpy, "_MOTIF_DRAG_RECEIVER_INFO",False);
_XA_MOTIF_DRAG_AND_DROP_MESSAGE = XInternAtom(dpy, "_MOTIF_DRAG_AND_DROP_MESSAGE", False);
*/
}
void
wXDNDMakeAwareness(Window window)
void wXDNDMakeAwareness(Window window)
{
long int xdnd_version = 3;
/*
MotifDragReceiverInfo info;
*/
XChangeProperty (dpy, window, _XA_XdndAware, XA_ATOM,
32, PropModeAppend, (char *)&xdnd_version, 1);
long int xdnd_version = 3;
/*
MotifDragReceiverInfo info;
*/
XChangeProperty(dpy, window, _XA_XdndAware, XA_ATOM, 32, PropModeAppend, (char *)&xdnd_version, 1);
/*** MOTIF ***
info.byte_order = '\0';
@@ -88,253 +84,248 @@ wXDNDMakeAwareness(Window window)
*/
}
void
wXDNDClearAwareness(Window window)
void wXDNDClearAwareness(Window window)
{
XDeleteProperty (dpy, window, _XA_XdndAware);
XDeleteProperty(dpy, window, _XA_XdndAware);
}
Bool
wXDNDProcessSelection(XEvent *event)
Bool wXDNDProcessSelection(XEvent * event)
{
WScreen *scr = wScreenForWindow(event->xselection.requestor);
char *retain;
Atom ret_type;
int ret_format;
unsigned long ret_item;
unsigned long remain_byte;
char * delme;
XEvent xevent;
Window selowner = XGetSelectionOwner(dpy,_XA_XdndSelection);
WMArray *items;
WScreen *scr = wScreenForWindow(event->xselection.requestor);
char *retain;
Atom ret_type;
int ret_format;
unsigned long ret_item;
unsigned long remain_byte;
char *delme;
XEvent xevent;
Window selowner = XGetSelectionOwner(dpy, _XA_XdndSelection);
WMArray *items;
XGetWindowProperty(dpy, event->xselection.requestor,
_XA_WINDOWMAKER_XDNDEXCHANGE,
0, 65536, True, atom_support, &ret_type, &ret_format,
&ret_item, &remain_byte, (unsigned char **)&delme);
if (delme) {
scr->xdestring = delme;
}
XGetWindowProperty(dpy, event->xselection.requestor,
_XA_WINDOWMAKER_XDNDEXCHANGE,
0, 65536, True, atom_support, &ret_type, &ret_format,
&ret_item, &remain_byte, (unsigned char **)&delme);
if (delme){
scr->xdestring=delme;
}
/*send finished */
memset(&xevent, 0, sizeof(xevent));
xevent.xany.type = ClientMessage;
xevent.xany.display = dpy;
xevent.xclient.window = selowner;
xevent.xclient.message_type = _XA_XdndFinished;
xevent.xclient.format = 32;
XDND_FINISHED_TARGET_WIN(&xevent) = event->xselection.requestor;
XSendEvent(dpy, selowner, 0, 0, &xevent);
/*send finished*/
memset (&xevent, 0, sizeof(xevent));
xevent.xany.type = ClientMessage;
xevent.xany.display = dpy;
xevent.xclient.window = selowner;
xevent.xclient.message_type = _XA_XdndFinished;
xevent.xclient.format = 32;
XDND_FINISHED_TARGET_WIN(&xevent) = event->xselection.requestor;
XSendEvent(dpy, selowner, 0, 0, &xevent);
/*process dropping */
if (scr->xdestring) {
WMArrayIterator iter;
int length, str_size;
int total_size = 0;
char *tmp;
/*process dropping*/
if (scr->xdestring) {
WMArrayIterator iter;
int length, str_size;
int total_size = 0;
char *tmp;
items = WMCreateArray(4);
retain = wstrdup(scr->xdestring);
XFree(scr->xdestring); /* since xdestring was created by Xlib */
items = WMCreateArray(4);
retain = wstrdup(scr->xdestring);
XFree(scr->xdestring); /* since xdestring was created by Xlib */
length = strlen(retain);
length = strlen(retain);
/* search in string */
while (length--) {
if (retain[length] == '\r') { /* useless char, nuke it */
retain[length] = 0;
}
if (retain[length] == '\n') {
str_size = strlen(&retain[length + 1]);
if (str_size) {
WMAddToArray(items, wstrdup(&retain[length + 1]));
total_size += str_size + 3; /* reserve for " \"\"" */
/* this is nonsense -- if (length)
WMAppendArray(items, WMCreateArray(1)); */
}
retain[length] = 0;
}
}
/* final one */
WMAddToArray(items, wstrdup(retain));
total_size += strlen(retain) + 3;
wfree(retain);
/* search in string */
while (length--) {
if (retain[length] == '\r') { /* useless char, nuke it */
retain[length] = 0;
}
if (retain[length] == '\n') {
str_size = strlen(&retain[length + 1]);
if(str_size) {
WMAddToArray(items, wstrdup(&retain[length + 1]));
total_size += str_size + 3; /* reserve for " \"\"" */
/* this is nonsense -- if (length)
WMAppendArray(items, WMCreateArray(1));*/
}
retain[length] = 0;
}
}
/* final one */
WMAddToArray(items, wstrdup(retain));
total_size += strlen(retain) + 3;
wfree(retain);
/* now pack new string */
scr->xdestring = wmalloc(total_size);
scr->xdestring[0] = 0; /* empty string */
WM_ETARETI_ARRAY(items, tmp, iter) {
if (!strncmp(tmp, "file:", 5)) {
/* add more 2 chars while removing 5 is harmless */
strcat(scr->xdestring, " \"");
strcat(scr->xdestring, &tmp[5]);
strcat(scr->xdestring, "\"");
} else {
/* unsupport object, still need more " ? tell ]d */
strcat(scr->xdestring, &tmp[5]);
}
wfree(tmp);
}
WMFreeArray(items);
wDockReceiveDNDDrop(scr, event);
/*
printf("free ");
puts(scr->xdestring);
*/
wfree(scr->xdestring); /* this xdestring is not from Xlib (no XFree) */
}
/* now pack new string */
scr->xdestring = wmalloc(total_size);
scr->xdestring[0]=0; /* empty string */
WM_ETARETI_ARRAY(items, tmp, iter) {
if (!strncmp(tmp,"file:",5)) {
/* add more 2 chars while removing 5 is harmless */
strcat(scr->xdestring, " \"");
strcat(scr->xdestring, &tmp[5]);
strcat(scr->xdestring, "\"");
} else {
/* unsupport object, still need more " ? tell ]d */
strcat(scr->xdestring, &tmp[5]);
}
wfree(tmp);
}
WMFreeArray(items);
wDockReceiveDNDDrop(scr,event);
/*
printf("free ");
puts(scr->xdestring);
*/
wfree(scr->xdestring); /* this xdestring is not from Xlib (no XFree) */
}
/* why doesn't this function return anything ? -Dan */
/* why doesn't this function return anything ? -Dan */
}
Bool
isAwareXDND(Window window)
Bool isAwareXDND(Window window)
{
Atom actual;
int format;
unsigned long count, remaining;
unsigned char *data=0;
Atom actual;
int format;
unsigned long count, remaining;
unsigned char *data = 0;
if (!window) return False;
XGetWindowProperty (dpy, window, _XA_XdndAware,
0, 0x8000000L, False, XA_ATOM,
&actual, &format,
&count, &remaining, &data);
if (actual != XA_ATOM || format != 32 || count == 0 || !data) {
if (data)
XFree (data);
return False;
}
if (data)
XFree (data);
return True;
if (!window)
return False;
XGetWindowProperty(dpy, window, _XA_XdndAware,
0, 0x8000000L, False, XA_ATOM, &actual, &format, &count, &remaining, &data);
if (actual != XA_ATOM || format != 32 || count == 0 || !data) {
if (data)
XFree(data);
return False;
}
if (data)
XFree(data);
return True;
}
Bool
acceptXDND(Window window)
Bool acceptXDND(Window window)
{
WScreen *scr = wScreenForWindow(window);
WDock *dock;
int icon_pos,i;
WScreen *scr = wScreenForWindow(window);
WDock *dock;
int icon_pos, i;
icon_pos = -1;
if ((dock = scr->dock)!=NULL) {
for (i=0; i<dock->max_icons; i++) {
if (dock->icon_array[i]
&& dock->icon_array[i]->icon->core->window==window) {
icon_pos = i;
break;
}
}
}
if (icon_pos<0 && (dock = scr->workspaces[scr->current_workspace]->clip)!=NULL) {
for (i=0; i<dock->max_icons; i++) {
if (dock->icon_array[i]
&& dock->icon_array[i]->icon->core->window==window) {
icon_pos = i;
break;
}
}
}
if (icon_pos<0) return False;
if (!dock) return False;
if (isAwareXDND(dock->icon_array[icon_pos]->icon->icon_win)) return False;
icon_pos = -1;
if ((dock = scr->dock) != NULL) {
for (i = 0; i < dock->max_icons; i++) {
if (dock->icon_array[i]
&& dock->icon_array[i]->icon->core->window == window) {
icon_pos = i;
break;
}
}
}
if (icon_pos < 0 && (dock = scr->workspaces[scr->current_workspace]->clip) != NULL) {
for (i = 0; i < dock->max_icons; i++) {
if (dock->icon_array[i]
&& dock->icon_array[i]->icon->core->window == window) {
icon_pos = i;
break;
}
}
}
if (icon_pos < 0)
return False;
if (!dock)
return False;
if (isAwareXDND(dock->icon_array[icon_pos]->icon->icon_win))
return False;
if (dock->icon_array[icon_pos]->dnd_command!=NULL) return True;
if (dock->icon_array[icon_pos]->dnd_command != NULL)
return True;
return False;
return False;
}
Bool
wXDNDProcessClientMessage(XClientMessageEvent *event)
Bool wXDNDProcessClientMessage(XClientMessageEvent * event)
{
/* test */
{
char * name = XGetAtomName(dpy, event->message_type);
/*
printf("Get %s\n",name);
*/
XFree(name);
}
/* test */
{
char *name = XGetAtomName(dpy, event->message_type);
/*
printf("Get %s\n",name);
*/
XFree(name);
}
/*
if (event->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
printf("motif dnd msg %d\n",event->data.b[0]);
if (event->data.b[0] == XmDROP_START){
unsigned x_root, y_root, flags;
unsigned char reason;
unsigned long timestamp;
Atom atom;
Window source_window;
MotifDragInitiatorInfo *initiator_info;
Atom ret_type;
int ret_format;
unsigned long ret_item;
unsigned long remain_byte;
/*
if (event->message_type == _XA_MOTIF_DRAG_AND_DROP_MESSAGE) {
printf("motif dnd msg %d\n",event->data.b[0]);
if (event->data.b[0] == XmDROP_START){
unsigned x_root, y_root, flags;
unsigned char reason;
unsigned long timestamp;
Atom atom;
Window source_window;
MotifDragInitiatorInfo *initiator_info;
Atom ret_type;
int ret_format;
unsigned long ret_item;
unsigned long remain_byte;
reason = event->data.b[0];
flags = event->data.s[1];
timestamp = event->data.l[1];
x_root = event->data.s[4];
y_root = event->data.s[5];
atom = event->data.l[3];
source_window = event->data.l[4];
reason = event->data.b[0];
flags = event->data.s[1];
timestamp = event->data.l[1];
x_root = event->data.s[4];
y_root = event->data.s[5];
atom = event->data.l[3];
source_window = event->data.l[4];
XGetWindowProperty(dpy, source_window, atom,
0, sizeof(*initiator_info), True, atom_support,
&ret_type, &ret_format,
&ret_item, &remain_byte, (unsigned char **)&initiator_info);
}
}
else */
if (event->message_type == _XA_XdndEnter) {
if ((event->data.l[1] & 1) == 0){
atom_support = event->data.l[2];
}
/*
else puts("enter more than 3 types");
*/
return True;
} else if (event->message_type == _XA_XdndLeave) {
return True;
} else if (event->message_type == _XA_XdndDrop) {
if (event->data.l[0] == XGetSelectionOwner(dpy, _XA_XdndSelection)){
XConvertSelection(dpy, _XA_XdndSelection, atom_support,
_XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime);
}
else {
puts("wierd selection owner? QT?");
XConvertSelection(dpy, _XA_XdndSelection, atom_support,
_XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime);
}
return True;
} else if (event->message_type == _XA_XdndPosition) {
XEvent xevent;
Window srcwin = event->data.l[0];
if (atom_support != XInternAtom(dpy, "text/uri-list", False)) {
return True;
}
{
memset (&xevent, 0, sizeof(xevent));
xevent.xany.type = ClientMessage;
xevent.xany.display = dpy;
xevent.xclient.window = srcwin;
xevent.xclient.message_type = _XA_XdndStatus;
xevent.xclient.format = 32;
XGetWindowProperty(dpy, source_window, atom,
0, sizeof(*initiator_info), True, atom_support,
&ret_type, &ret_format,
&ret_item, &remain_byte, (unsigned char **)&initiator_info);
}
}
else */
if (event->message_type == _XA_XdndEnter) {
if ((event->data.l[1] & 1) == 0) {
atom_support = event->data.l[2];
}
/*
else puts("enter more than 3 types");
*/
return True;
} else if (event->message_type == _XA_XdndLeave) {
return True;
} else if (event->message_type == _XA_XdndDrop) {
if (event->data.l[0] == XGetSelectionOwner(dpy, _XA_XdndSelection)) {
XConvertSelection(dpy, _XA_XdndSelection, atom_support,
_XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime);
} else {
puts("wierd selection owner? QT?");
XConvertSelection(dpy, _XA_XdndSelection, atom_support,
_XA_WINDOWMAKER_XDNDEXCHANGE, event->window, CurrentTime);
}
return True;
} else if (event->message_type == _XA_XdndPosition) {
XEvent xevent;
Window srcwin = event->data.l[0];
if (atom_support != XInternAtom(dpy, "text/uri-list", False)) {
return True;
}
{
memset(&xevent, 0, sizeof(xevent));
xevent.xany.type = ClientMessage;
xevent.xany.display = dpy;
xevent.xclient.window = srcwin;
xevent.xclient.message_type = _XA_XdndStatus;
xevent.xclient.format = 32;
XDND_STATUS_TARGET_WIN (&xevent) = event->window;
XDND_STATUS_WILL_ACCEPT_SET (&xevent, acceptXDND(event->window));
XDND_STATUS_WANT_POSITION_SET(&xevent, True);
XDND_STATUS_RECT_SET(&xevent, 0, 0, 1024,768);
XDND_STATUS_ACTION(&xevent) = _XA_XdndActionCopy;
XDND_STATUS_TARGET_WIN(&xevent) = event->window;
XDND_STATUS_WILL_ACCEPT_SET(&xevent, acceptXDND(event->window));
XDND_STATUS_WANT_POSITION_SET(&xevent, True);
XDND_STATUS_RECT_SET(&xevent, 0, 0, 1024, 768);
XDND_STATUS_ACTION(&xevent) = _XA_XdndActionCopy;
XSendEvent(dpy, srcwin, 0, 0, &xevent);
}
return True;
}
return False;
XSendEvent(dpy, srcwin, 0, 0, &xevent);
}
return True;
}
return False;
}
#endif
+186 -214
View File
@@ -19,10 +19,8 @@
* USA.
*/
#include "wconfig.h"
#include "xinerama.h"
#include "screen.h"
@@ -32,7 +30,7 @@
#include "funcs.h"
#ifdef XINERAMA
# ifdef SOLARIS_XINERAMA /* sucks */
# ifdef SOLARIS_XINERAMA /* sucks */
# include <X11/extensions/xinerama.h>
# else
# include <X11/extensions/Xinerama.h>
@@ -41,200 +39,187 @@
extern WPreferences wPreferences;
void
wInitXinerama(WScreen *scr)
void wInitXinerama(WScreen * scr)
{
scr->xine_info.primary_head = 0;
scr->xine_info.screens = NULL;
scr->xine_info.count = 0;
scr->xine_info.primary_head = 0;
scr->xine_info.screens = NULL;
scr->xine_info.count = 0;
#ifdef XINERAMA
# ifdef SOLARIS_XINERAMA
if (XineramaGetState(dpy, scr->screen)) {
WXineramaInfo *info = &scr->xine_info;
XRectangle head[MAXFRAMEBUFFERS];
unsigned char hints[MAXFRAMEBUFFERS];
int i;
if (XineramaGetState(dpy, scr->screen)) {
WXineramaInfo *info = &scr->xine_info;
XRectangle head[MAXFRAMEBUFFERS];
unsigned char hints[MAXFRAMEBUFFERS];
int i;
if (XineramaGetInfo(dpy, scr->screen, head, hints, &info->count)) {
if (XineramaGetInfo(dpy, scr->screen, head, hints, &info->count)) {
info->screens = wmalloc(sizeof(WMRect)*(info->count+1));
info->screens = wmalloc(sizeof(WMRect) * (info->count + 1));
for (i=0; i<info->count; i++) {
info->screens[i].pos.x = head[i].x;
info->screens[i].pos.y = head[i].y;
info->screens[i].size.width = head[i].width;
info->screens[i].size.height = head[i].height;
}
}
}
# else /* !SOLARIS_XINERAMA */
if (XineramaIsActive(dpy)) {
XineramaScreenInfo *xine_screens;
WXineramaInfo *info = &scr->xine_info;
int i;
for (i = 0; i < info->count; i++) {
info->screens[i].pos.x = head[i].x;
info->screens[i].pos.y = head[i].y;
info->screens[i].size.width = head[i].width;
info->screens[i].size.height = head[i].height;
}
}
}
# else /* !SOLARIS_XINERAMA */
if (XineramaIsActive(dpy)) {
XineramaScreenInfo *xine_screens;
WXineramaInfo *info = &scr->xine_info;
int i;
xine_screens = XineramaQueryScreens(dpy, &info->count);
xine_screens = XineramaQueryScreens(dpy, &info->count);
info->screens = wmalloc(sizeof(WMRect)*(info->count+1));
info->screens = wmalloc(sizeof(WMRect) * (info->count + 1));
for (i=0; i<info->count; i++) {
info->screens[i].pos.x = xine_screens[i].x_org;
info->screens[i].pos.y = xine_screens[i].y_org;
info->screens[i].size.width = xine_screens[i].width;
info->screens[i].size.height = xine_screens[i].height;
}
XFree(xine_screens);
}
# endif /* !SOLARIS_XINERAMA */
#endif /* XINERAMA */
for (i = 0; i < info->count; i++) {
info->screens[i].pos.x = xine_screens[i].x_org;
info->screens[i].pos.y = xine_screens[i].y_org;
info->screens[i].size.width = xine_screens[i].width;
info->screens[i].size.height = xine_screens[i].height;
}
XFree(xine_screens);
}
# endif /* !SOLARIS_XINERAMA */
#endif /* XINERAMA */
}
int
wGetRectPlacementInfo(WScreen *scr, WMRect rect, int *flags)
int wGetRectPlacementInfo(WScreen * scr, WMRect rect, int *flags)
{
int best;
unsigned long area, totalArea;
int i;
int rx = rect.pos.x;
int ry = rect.pos.y;
int rw = rect.size.width;
int rh = rect.size.height;
int best;
unsigned long area, totalArea;
int i;
int rx = rect.pos.x;
int ry = rect.pos.y;
int rw = rect.size.width;
int rh = rect.size.height;
wassertrv(flags!=NULL, 0);
wassertrv(flags != NULL, 0);
best = -1;
area = 0;
totalArea = 0;
best = -1;
area = 0;
totalArea = 0;
*flags = XFLAG_NONE;
*flags = XFLAG_NONE;
if (scr->xine_info.count <= 1) {
unsigned long a;
if (scr->xine_info.count <= 1) {
unsigned long a;
a = calcIntersectionArea(rx, ry, rw, rh,
0, 0, scr->scr_width, scr->scr_height);
a = calcIntersectionArea(rx, ry, rw, rh, 0, 0, scr->scr_width, scr->scr_height);
if (a == 0) {
*flags |= XFLAG_DEAD;
} else if (a != rw*rh) {
*flags |= XFLAG_PARTIAL;
}
if (a == 0) {
*flags |= XFLAG_DEAD;
} else if (a != rw * rh) {
*flags |= XFLAG_PARTIAL;
}
return scr->xine_info.primary_head;
}
return scr->xine_info.primary_head;
}
for (i = 0; i < wXineramaHeads(scr); i++) {
unsigned long a;
for (i = 0; i < wXineramaHeads(scr); i++) {
unsigned long a;
a = calcIntersectionArea(rx, ry, rw, rh,
scr->xine_info.screens[i].pos.x,
scr->xine_info.screens[i].pos.y,
scr->xine_info.screens[i].size.width,
scr->xine_info.screens[i].size.height);
a = calcIntersectionArea(rx, ry, rw, rh,
scr->xine_info.screens[i].pos.x,
scr->xine_info.screens[i].pos.y,
scr->xine_info.screens[i].size.width,
scr->xine_info.screens[i].size.height);
totalArea += a;
if (a > area) {
if (best != -1)
*flags |= XFLAG_MULTIPLE;
area = a;
best = i;
}
}
totalArea += a;
if (a > area) {
if (best != -1)
*flags |= XFLAG_MULTIPLE;
area = a;
best = i;
}
}
if (best == -1) {
*flags |= XFLAG_DEAD;
best = wGetHeadForPointerLocation(scr);
} else if (totalArea != rw*rh)
*flags |= XFLAG_PARTIAL;
if (best == -1) {
*flags |= XFLAG_DEAD;
best = wGetHeadForPointerLocation(scr);
} else if (totalArea != rw * rh)
*flags |= XFLAG_PARTIAL;
return best;
return best;
}
/* get the head that covers most of the rectangle */
int
wGetHeadForRect(WScreen *scr, WMRect rect)
int wGetHeadForRect(WScreen * scr, WMRect rect)
{
int best;
unsigned long area;
int i;
int rx = rect.pos.x;
int ry = rect.pos.y;
int rw = rect.size.width;
int rh = rect.size.height;
int best;
unsigned long area;
int i;
int rx = rect.pos.x;
int ry = rect.pos.y;
int rw = rect.size.width;
int rh = rect.size.height;
if (!scr->xine_info.count)
return scr->xine_info.primary_head;
if (!scr->xine_info.count)
return scr->xine_info.primary_head;
best = -1;
area = 0;
best = -1;
area = 0;
for (i = 0; i < wXineramaHeads(scr); i++) {
unsigned long a;
for (i = 0; i < wXineramaHeads(scr); i++) {
unsigned long a;
a = calcIntersectionArea(rx, ry, rw, rh,
scr->xine_info.screens[i].pos.x,
scr->xine_info.screens[i].pos.y,
scr->xine_info.screens[i].size.width,
scr->xine_info.screens[i].size.height);
a = calcIntersectionArea(rx, ry, rw, rh,
scr->xine_info.screens[i].pos.x,
scr->xine_info.screens[i].pos.y,
scr->xine_info.screens[i].size.width,
scr->xine_info.screens[i].size.height);
if (a > area) {
area = a;
best = i;
}
}
if (a > area) {
area = a;
best = i;
}
}
/*
* in case rect is in dead space, return valid head
*/
if (best == -1)
best = wGetHeadForPointerLocation(scr);
/*
* in case rect is in dead space, return valid head
*/
if (best == -1)
best = wGetHeadForPointerLocation(scr);
return best;
return best;
}
Bool
wWindowTouchesHead(WWindow *wwin, int head)
Bool wWindowTouchesHead(WWindow * wwin, int head)
{
WScreen * scr;
WMRect rect;
int a;
WScreen *scr;
WMRect rect;
int a;
if (!wwin || !wwin->frame)
return False;
if (!wwin || !wwin->frame)
return False;
scr = wwin->screen_ptr;
rect = wGetRectForHead(scr, head);
a = calcIntersectionArea(wwin->frame_x, wwin->frame_y,
wwin->frame->core->width,
wwin->frame->core->height,
rect.pos.x, rect.pos.y,
rect.size.width, rect.size.height);
scr = wwin->screen_ptr;
rect = wGetRectForHead(scr, head);
a = calcIntersectionArea(wwin->frame_x, wwin->frame_y,
wwin->frame->core->width,
wwin->frame->core->height,
rect.pos.x, rect.pos.y, rect.size.width, rect.size.height);
return (a != 0);
return (a != 0);
}
int
wGetHeadForWindow(WWindow *wwin)
int wGetHeadForWindow(WWindow * wwin)
{
WMRect rect;
WMRect rect;
if (wwin == NULL || wwin->frame == NULL)
return 0;
if (wwin == NULL || wwin->frame == NULL)
return 0;
rect.pos.x = wwin->frame_x;
rect.pos.y = wwin->frame_y;
rect.size.width = wwin->frame->core->width;
rect.size.height = wwin->frame->core->height;
rect.pos.x = wwin->frame_x;
rect.pos.y = wwin->frame_y;
rect.size.width = wwin->frame->core->width;
rect.size.height = wwin->frame->core->height;
return wGetHeadForRect(wwin->screen_ptr, rect);
return wGetHeadForRect(wwin->screen_ptr, rect);
}
/*
int
wGetHeadForPoint(WScreen *scr, WMPoint point, int *flags)
@@ -274,97 +259,84 @@ wGetHeadForPoint(WScreen *scr, WMPoint point, int *flags)
}
*/
int
wGetHeadForPoint(WScreen *scr, WMPoint point)
int wGetHeadForPoint(WScreen * scr, WMPoint point)
{
int i;
int i;
for (i = 0; i < scr->xine_info.count; i++) {
WMRect *rect = &scr->xine_info.screens[i];
for (i = 0; i < scr->xine_info.count; i++) {
WMRect *rect = &scr->xine_info.screens[i];
if ((unsigned)(point.x - rect->pos.x) < rect->size.width &&
(unsigned)(point.y - rect->pos.y) < rect->size.height)
return i;
}
return scr->xine_info.primary_head;
if ((unsigned)(point.x - rect->pos.x) < rect->size.width &&
(unsigned)(point.y - rect->pos.y) < rect->size.height)
return i;
}
return scr->xine_info.primary_head;
}
int
wGetHeadForPointerLocation(WScreen *scr)
int wGetHeadForPointerLocation(WScreen * scr)
{
WMPoint point;
Window bla;
int ble;
unsigned int blo;
WMPoint point;
Window bla;
int ble;
unsigned int blo;
if (!scr->xine_info.count)
return scr->xine_info.primary_head;
if (!scr->xine_info.count)
return scr->xine_info.primary_head;
if (!XQueryPointer(dpy, scr->root_win, &bla, &bla,
&point.x, &point.y,
&ble, &ble,
&blo))
return scr->xine_info.primary_head;
if (!XQueryPointer(dpy, scr->root_win, &bla, &bla, &point.x, &point.y, &ble, &ble, &blo))
return scr->xine_info.primary_head;
return wGetHeadForPoint(scr, point);
return wGetHeadForPoint(scr, point);
}
/* get the dimensions of the head */
WMRect
wGetRectForHead(WScreen *scr, int head)
WMRect wGetRectForHead(WScreen * scr, int head)
{
WMRect rect;
WMRect rect;
if (head < scr->xine_info.count) {
rect.pos.x = scr->xine_info.screens[head].pos.x;
rect.pos.y = scr->xine_info.screens[head].pos.y;
rect.size.width = scr->xine_info.screens[head].size.width;
rect.size.height = scr->xine_info.screens[head].size.height;
} else {
rect.pos.x = 0;
rect.pos.y = 0;
rect.size.width = scr->scr_width;
rect.size.height = scr->scr_height;
}
if (head < scr->xine_info.count) {
rect.pos.x = scr->xine_info.screens[head].pos.x;
rect.pos.y = scr->xine_info.screens[head].pos.y;
rect.size.width = scr->xine_info.screens[head].size.width;
rect.size.height = scr->xine_info.screens[head].size.height;
} else {
rect.pos.x = 0;
rect.pos.y = 0;
rect.size.width = scr->scr_width;
rect.size.height = scr->scr_height;
}
return rect;
return rect;
}
WArea
wGetUsableAreaForHead(WScreen *scr, int head, WArea *totalAreaPtr, Bool noicons)
WArea wGetUsableAreaForHead(WScreen * scr, int head, WArea * totalAreaPtr, Bool noicons)
{
WArea totalArea, usableArea;
WMRect rect = wGetRectForHead(scr, head);
WArea totalArea, usableArea;
WMRect rect = wGetRectForHead(scr, head);
totalArea.x1 = rect.pos.x;
totalArea.y1 = rect.pos.y;
totalArea.x2 = totalArea.x1 + rect.size.width;
totalArea.y2 = totalArea.y1 + rect.size.height;
totalArea.x1 = rect.pos.x;
totalArea.y1 = rect.pos.y;
totalArea.x2 = totalArea.x1 + rect.size.width;
totalArea.y2 = totalArea.y1 + rect.size.height;
if (totalAreaPtr != NULL) *totalAreaPtr = totalArea;
if (totalAreaPtr != NULL)
*totalAreaPtr = totalArea;
if (head < wXineramaHeads(scr)) {
usableArea = noicons ? scr->totalUsableArea[head] : scr->usableArea[head];
} else
usableArea = totalArea;
if (head < wXineramaHeads(scr)) {
usableArea = noicons ? scr->totalUsableArea[head] : scr->usableArea[head];
} else
usableArea = totalArea;
return usableArea;
return usableArea;
}
WMPoint
wGetPointToCenterRectInHead(WScreen *scr, int head, int width, int height)
WMPoint wGetPointToCenterRectInHead(WScreen * scr, int head, int width, int height)
{
WMPoint p;
WMRect rect = wGetRectForHead(scr, head);
WMPoint p;
WMRect rect = wGetRectForHead(scr, head);
p.x = rect.pos.x + (rect.size.width - width)/2;
p.y = rect.pos.y + (rect.size.height - height)/2;
p.x = rect.pos.x + (rect.size.width - width) / 2;
p.y = rect.pos.y + (rect.size.height - height) / 2;
return p;
return p;
}
+181 -148
View File
@@ -35,7 +35,6 @@ Perpetrator: Sudish Joseph <sj@eng.mindspring.net>, Sept. 1997. */
#include <WINGs/WUtil.h>
extern Display *dpy;
/************************************************************************/
@@ -84,36 +83,42 @@ extern Display *dpy;
static int MetaMask, HyperMask, SuperMask, AltMask, ModeMask;
static const char *
index_to_name (int indice)
static const char *index_to_name(int indice)
{
switch (indice)
{
case ShiftMapIndex: return "ModShift";
case LockMapIndex: return "ModLock";
case ControlMapIndex: return "ModControl";
case Mod1MapIndex: return "Mod1";
case Mod2MapIndex: return "Mod2";
case Mod3MapIndex: return "Mod3";
case Mod4MapIndex: return "Mod4";
case Mod5MapIndex: return "Mod5";
default: return "???";
}
switch (indice) {
case ShiftMapIndex:
return "ModShift";
case LockMapIndex:
return "ModLock";
case ControlMapIndex:
return "ModControl";
case Mod1MapIndex:
return "Mod1";
case Mod2MapIndex:
return "Mod2";
case Mod3MapIndex:
return "Mod3";
case Mod4MapIndex:
return "Mod4";
case Mod5MapIndex:
return "Mod5";
default:
return "???";
}
}
static void
x_reset_modifier_mapping (Display *display)
static void x_reset_modifier_mapping(Display * display)
{
int modifier_index, modifier_key, column, mkpm;
int warned_about_overlapping_modifiers = 0;
int warned_about_predefined_modifiers = 0;
int warned_about_duplicate_modifiers = 0;
int meta_bit = 0;
int hyper_bit = 0;
int super_bit = 0;
int alt_bit = 0;
int mode_bit = 0;
XModifierKeymap *x_modifier_keymap = XGetModifierMapping (display);
int modifier_index, modifier_key, column, mkpm;
int warned_about_overlapping_modifiers = 0;
int warned_about_predefined_modifiers = 0;
int warned_about_duplicate_modifiers = 0;
int meta_bit = 0;
int hyper_bit = 0;
int super_bit = 0;
int alt_bit = 0;
int mode_bit = 0;
XModifierKeymap *x_modifier_keymap = XGetModifierMapping(display);
#define modwarn(name,old,other) \
wwarning ("%s (0x%x) generates %s, which is generated by %s.\n\n", \
@@ -153,147 +158,175 @@ x_reset_modifier_mapping (Display *display)
else \
old = modifier_index;
mkpm = x_modifier_keymap->max_keypermod;
for (modifier_index = 0; modifier_index < 8; modifier_index++)
for (modifier_key = 0; modifier_key < mkpm; modifier_key++) {
KeySym last_sym = 0;
for (column = 0; column < 4; column += 2) {
KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm
+ modifier_key];
KeySym sym = (code ? XKeycodeToKeysym (display, code, column) : 0);
if (sym == last_sym) continue;
last_sym = sym;
switch (sym) {
case XK_Mode_switch:store_modifier ("Mode_switch", mode_bit); break;
case XK_Meta_L: store_modifier ("Meta_L", meta_bit); break;
case XK_Meta_R: store_modifier ("Meta_R", meta_bit); break;
case XK_Super_L: store_modifier ("Super_L", super_bit); break;
case XK_Super_R: store_modifier ("Super_R", super_bit); break;
case XK_Hyper_L: store_modifier ("Hyper_L", hyper_bit); break;
case XK_Hyper_R: store_modifier ("Hyper_R", hyper_bit); break;
case XK_Alt_L: store_modifier ("Alt_L", alt_bit); break;
case XK_Alt_R: store_modifier ("Alt_R", alt_bit); break;
case XK_Control_L: check_modifier ("Control_L", ControlMask); break;
case XK_Control_R: check_modifier ("Control_R", ControlMask); break;
case XK_Shift_L: check_modifier ("Shift_L", ShiftMask); break;
case XK_Shift_R: check_modifier ("Shift_R", ShiftMask); break;
case XK_Shift_Lock: check_modifier ("Shift_Lock", LockMask); break;
case XK_Caps_Lock: check_modifier ("Caps_Lock", LockMask); break;
mkpm = x_modifier_keymap->max_keypermod;
for (modifier_index = 0; modifier_index < 8; modifier_index++)
for (modifier_key = 0; modifier_key < mkpm; modifier_key++) {
KeySym last_sym = 0;
for (column = 0; column < 4; column += 2) {
KeyCode code = x_modifier_keymap->modifiermap[modifier_index * mkpm
+ modifier_key];
KeySym sym = (code ? XKeycodeToKeysym(display, code, column) : 0);
if (sym == last_sym)
continue;
last_sym = sym;
switch (sym) {
case XK_Mode_switch:
store_modifier("Mode_switch", mode_bit);
break;
case XK_Meta_L:
store_modifier("Meta_L", meta_bit);
break;
case XK_Meta_R:
store_modifier("Meta_R", meta_bit);
break;
case XK_Super_L:
store_modifier("Super_L", super_bit);
break;
case XK_Super_R:
store_modifier("Super_R", super_bit);
break;
case XK_Hyper_L:
store_modifier("Hyper_L", hyper_bit);
break;
case XK_Hyper_R:
store_modifier("Hyper_R", hyper_bit);
break;
case XK_Alt_L:
store_modifier("Alt_L", alt_bit);
break;
case XK_Alt_R:
store_modifier("Alt_R", alt_bit);
break;
case XK_Control_L:
check_modifier("Control_L", ControlMask);
break;
case XK_Control_R:
check_modifier("Control_R", ControlMask);
break;
case XK_Shift_L:
check_modifier("Shift_L", ShiftMask);
break;
case XK_Shift_R:
check_modifier("Shift_R", ShiftMask);
break;
case XK_Shift_Lock:
check_modifier("Shift_Lock", LockMask);
break;
case XK_Caps_Lock:
check_modifier("Caps_Lock", LockMask);
break;
/* It probably doesn't make any sense for a modifier bit to be
assigned to a key that is not one of the above, but OpenWindows
assigns modifier bits to a couple of random function keys for
no reason that I can discern, so printing a warning here would
be annoying. */
}
}
}
/* It probably doesn't make any sense for a modifier bit to be
assigned to a key that is not one of the above, but OpenWindows
assigns modifier bits to a couple of random function keys for
no reason that I can discern, so printing a warning here would
be annoying. */
}
}
}
#undef store_modifier
#undef check_modifier
#undef modwarn
#undef modbarf
/* If there was no Meta key, then try using the Alt key instead.
If there is both a Meta key and an Alt key, then the Alt key
is not disturbed and remains an Alt key. */
if (! meta_bit && alt_bit)
meta_bit = alt_bit, alt_bit = 0;
/* If there was no Meta key, then try using the Alt key instead.
If there is both a Meta key and an Alt key, then the Alt key
is not disturbed and remains an Alt key. */
if (!meta_bit && alt_bit)
meta_bit = alt_bit, alt_bit = 0;
/* mode_bit overrides everything, since it's processed down inside of
XLookupString() instead of by us. If Meta and Mode_switch both
generate the same modifier bit (which is an error), then we don't
interpret that bit as Meta, because we can't make XLookupString()
not interpret it as Mode_switch; and interpreting it as both would
be totally wrong. */
if (mode_bit)
{
const char *warn = 0;
if (mode_bit == meta_bit) warn = "Meta", meta_bit = 0;
else if (mode_bit == hyper_bit) warn = "Hyper", hyper_bit = 0;
else if (mode_bit == super_bit) warn = "Super", super_bit = 0;
else if (mode_bit == alt_bit) warn = "Alt", alt_bit = 0;
if (warn)
{
wwarning
("%s is being used for both Mode_switch and %s.\n\n",
index_to_name (mode_bit), warn),
warned_about_overlapping_modifiers = 1;
}
}
/* mode_bit overrides everything, since it's processed down inside of
XLookupString() instead of by us. If Meta and Mode_switch both
generate the same modifier bit (which is an error), then we don't
interpret that bit as Meta, because we can't make XLookupString()
not interpret it as Mode_switch; and interpreting it as both would
be totally wrong. */
if (mode_bit) {
const char *warn = 0;
if (mode_bit == meta_bit)
warn = "Meta", meta_bit = 0;
else if (mode_bit == hyper_bit)
warn = "Hyper", hyper_bit = 0;
else if (mode_bit == super_bit)
warn = "Super", super_bit = 0;
else if (mode_bit == alt_bit)
warn = "Alt", alt_bit = 0;
if (warn) {
wwarning
("%s is being used for both Mode_switch and %s.\n\n",
index_to_name(mode_bit), warn), warned_about_overlapping_modifiers = 1;
}
}
MetaMask = (meta_bit ? (1 << meta_bit) : 0);
HyperMask = (hyper_bit ? (1 << hyper_bit) : 0);
SuperMask = (super_bit ? (1 << super_bit) : 0);
AltMask = (alt_bit ? (1 << alt_bit) : 0);
ModeMask = (mode_bit ? (1 << mode_bit) : 0); /* unused */
MetaMask = (meta_bit ? (1 << meta_bit) : 0);
HyperMask = (hyper_bit ? (1 << hyper_bit) : 0);
SuperMask = (super_bit ? (1 << super_bit) : 0);
AltMask = (alt_bit ? (1 << alt_bit) : 0);
ModeMask = (mode_bit ? (1 << mode_bit) : 0); /* unused */
#if 0
if (warned_about_overlapping_modifiers)
wwarning ("\n"
" Two distinct modifier keys (such as Meta and Hyper) cannot generate\n"
" the same modifier bit, because Emacs won't be able to tell which\n"
" modifier was actually held down when some other key is pressed. It\n"
" won't be able to tell Meta-x and Hyper-x apart, for example. Change\n"
" one of these keys to use some other modifier bit. If you intend for\n"
" these keys to have the same behavior, then change them to have the\n"
" same keysym as well as the same modifier bit.\n");
if (warned_about_overlapping_modifiers)
wwarning("\n"
" Two distinct modifier keys (such as Meta and Hyper) cannot generate\n"
" the same modifier bit, because Emacs won't be able to tell which\n"
" modifier was actually held down when some other key is pressed. It\n"
" won't be able to tell Meta-x and Hyper-x apart, for example. Change\n"
" one of these keys to use some other modifier bit. If you intend for\n"
" these keys to have the same behavior, then change them to have the\n"
" same keysym as well as the same modifier bit.\n");
if (warned_about_predefined_modifiers)
wwarning ("\n"
" The semantics of the modifier bits ModShift, ModLock, and ModControl\n"
" are predefined. It does not make sense to assign ModControl to any\n"
" keysym other than Control_L or Control_R, or to assign any modifier\n"
" bits to the \"control\" keysyms other than ModControl. You can't\n"
" turn a \"control\" key into a \"meta\" key (or vice versa) by simply\n"
" assigning the key a different modifier bit. You must also make that\n"
" key generate an appropriate keysym (Control_L, Meta_L, etc).\n");
if (warned_about_predefined_modifiers)
wwarning("\n"
" The semantics of the modifier bits ModShift, ModLock, and ModControl\n"
" are predefined. It does not make sense to assign ModControl to any\n"
" keysym other than Control_L or Control_R, or to assign any modifier\n"
" bits to the \"control\" keysyms other than ModControl. You can't\n"
" turn a \"control\" key into a \"meta\" key (or vice versa) by simply\n"
" assigning the key a different modifier bit. You must also make that\n"
" key generate an appropriate keysym (Control_L, Meta_L, etc).\n");
/* No need to say anything more for warned_about_duplicate_modifiers. */
/* No need to say anything more for warned_about_duplicate_modifiers. */
if (warned_about_overlapping_modifiers || warned_about_predefined_modifiers)
wwarning ("\n"
" The meanings of the modifier bits Mod1 through Mod5 are determined\n"
" by the keysyms used to control those bits. Mod1 does NOT always\n"
" mean Meta, although some non-ICCCM-compliant programs assume that.\n");
if (warned_about_overlapping_modifiers || warned_about_predefined_modifiers)
wwarning("\n"
" The meanings of the modifier bits Mod1 through Mod5 are determined\n"
" by the keysyms used to control those bits. Mod1 does NOT always\n"
" mean Meta, although some non-ICCCM-compliant programs assume that.\n");
#endif
XFreeModifiermap(x_modifier_keymap);
XFreeModifiermap(x_modifier_keymap);
}
int
wXModifierFromKey(char *key)
int wXModifierFromKey(char *key)
{
if (strcasecmp(key, "SHIFT")==0 && ShiftMask!=0)
return ShiftMask;
else if (strcasecmp(key, "CONTROL")==0 && ControlMask!=0)
return ControlMask;
else if (strcasecmp(key, "ALT")==0 && AltMask!=0)
return AltMask;
else if (strcasecmp(key, "META")==0 && MetaMask!=0)
return MetaMask;
else if (strcasecmp(key, "SUPER")==0 && SuperMask!=0)
return SuperMask;
else if (strcasecmp(key, "HYPER")==0 && HyperMask!=0)
return HyperMask;
else if (strcasecmp(key, "MOD1")==0 && Mod1Mask!=0)
return Mod1Mask;
else if (strcasecmp(key, "MOD2")==0 && Mod2Mask!=0)
return Mod2Mask;
else if (strcasecmp(key, "MOD3")==0 && Mod3Mask!=0)
return Mod3Mask;
else if (strcasecmp(key, "MOD4")==0 && Mod4Mask!=0)
return Mod4Mask;
else if (strcasecmp(key, "MOD5")==0 && Mod5Mask!=0)
return Mod5Mask;
else
return -1;
if (strcasecmp(key, "SHIFT") == 0 && ShiftMask != 0)
return ShiftMask;
else if (strcasecmp(key, "CONTROL") == 0 && ControlMask != 0)
return ControlMask;
else if (strcasecmp(key, "ALT") == 0 && AltMask != 0)
return AltMask;
else if (strcasecmp(key, "META") == 0 && MetaMask != 0)
return MetaMask;
else if (strcasecmp(key, "SUPER") == 0 && SuperMask != 0)
return SuperMask;
else if (strcasecmp(key, "HYPER") == 0 && HyperMask != 0)
return HyperMask;
else if (strcasecmp(key, "MOD1") == 0 && Mod1Mask != 0)
return Mod1Mask;
else if (strcasecmp(key, "MOD2") == 0 && Mod2Mask != 0)
return Mod2Mask;
else if (strcasecmp(key, "MOD3") == 0 && Mod3Mask != 0)
return Mod3Mask;
else if (strcasecmp(key, "MOD4") == 0 && Mod4Mask != 0)
return Mod4Mask;
else if (strcasecmp(key, "MOD5") == 0 && Mod5Mask != 0)
return Mod5Mask;
else
return -1;
}
/* Wrapper so that we may fit the WM naming conventions, yet leave the
original XEmacs function name in place. */
void
wXModifierInitialize(void)
void wXModifierInitialize(void)
{
x_reset_modifier_mapping(dpy);
x_reset_modifier_mapping(dpy);
}
+151 -156
View File
@@ -18,7 +18,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <X11/Xlib.h>
#include <stdlib.h>
#include <X11/Xutil.h>
@@ -32,166 +31,162 @@
#include <WINGs/WUtil.h>
#if 0
static Atom Clipboard=0;
static Atom Clipboard = 0;
#endif
static char *requestCodes[] = {
"DUMMY",
"X_CreateWindow",
"X_ChangeWindowAttributes",
"X_GetWindowAttributes",
"X_DestroyWindow",
"X_DestroySubwindows",
"X_ChangeSaveSet",
"X_ReparentWindow",
"X_MapWindow",
"X_MapSubwindows",
"X_UnmapWindow",
"X_UnmapSubwindows",
"X_ConfigureWindow",
"X_CirculateWindow",
"X_GetGeometry",
"X_QueryTree",
"X_InternAtom",
"X_GetAtomName",
"X_ChangeProperty",
"X_DeleteProperty",
"X_GetProperty",
"X_ListProperties",
"X_SetSelectionOwner",
"X_GetSelectionOwner",
"X_ConvertSelection",
"X_SendEvent",
"X_GrabPointer",
"X_UngrabPointer",
"X_GrabButton",
"X_UngrabButton",
"X_ChangeActivePointerGrab",
"X_GrabKeyboard",
"X_UngrabKeyboard",
"X_GrabKey",
"X_UngrabKey",
"X_AllowEvents",
"X_GrabServer",
"X_UngrabServer",
"X_QueryPointer",
"X_GetMotionEvents",
"X_TranslateCoords",
"X_WarpPointer",
"X_SetInputFocus",
"X_GetInputFocus",
"X_QueryKeymap",
"X_OpenFont",
"X_CloseFont",
"X_QueryFont",
"X_QueryTextExtents",
"X_ListFonts",
"X_ListFontsWithInfo",
"X_SetFontPath",
"X_GetFontPath",
"X_CreatePixmap",
"X_FreePixmap",
"X_CreateGC",
"X_ChangeGC",
"X_CopyGC",
"X_SetDashes",
"X_SetClipRectangles",
"X_FreeGC",
"X_ClearArea",
"X_CopyArea",
"X_CopyPlane",
"X_PolyPoint",
"X_PolyLine",
"X_PolySegment",
"X_PolyRectangle",
"X_PolyArc",
"X_FillPoly",
"X_PolyFillRectangle",
"X_PolyFillArc",
"X_PutImage",
"X_GetImage",
"X_PolyText8",
"X_PolyText16",
"X_ImageText8",
"X_ImageText16",
"X_CreateColormap",
"X_FreeColormap",
"X_CopyColormapAndFree",
"X_InstallColormap",
"X_UninstallColormap",
"X_ListInstalledColormaps",
"X_AllocColor",
"X_AllocNamedColor",
"X_AllocColorCells",
"X_AllocColorPlanes",
"X_FreeColors",
"X_StoreColors",
"X_StoreNamedColor",
"X_QueryColors",
"X_LookupColor",
"X_CreateCursor",
"X_CreateGlyphCursor",
"X_FreeCursor",
"X_RecolorCursor",
"X_QueryBestSize",
"X_QueryExtension",
"X_ListExtensions",
"X_ChangeKeyboardMapping",
"X_GetKeyboardMapping",
"X_ChangeKeyboardControl",
"X_GetKeyboardControl",
"X_Bell",
"X_ChangePointerControl",
"X_GetPointerControl",
"X_SetScreenSaver",
"X_GetScreenSaver",
"X_ChangeHosts",
"X_ListHosts",
"X_SetAccessControl",
"X_SetCloseDownMode",
"X_KillClient",
"X_RotateProperties",
"X_ForceScreenSaver",
"X_SetPointerMapping",
"X_GetPointerMapping",
"X_SetModifierMapping",
"X_GetModifierMapping",
"X_NoOperation"
"DUMMY",
"X_CreateWindow",
"X_ChangeWindowAttributes",
"X_GetWindowAttributes",
"X_DestroyWindow",
"X_DestroySubwindows",
"X_ChangeSaveSet",
"X_ReparentWindow",
"X_MapWindow",
"X_MapSubwindows",
"X_UnmapWindow",
"X_UnmapSubwindows",
"X_ConfigureWindow",
"X_CirculateWindow",
"X_GetGeometry",
"X_QueryTree",
"X_InternAtom",
"X_GetAtomName",
"X_ChangeProperty",
"X_DeleteProperty",
"X_GetProperty",
"X_ListProperties",
"X_SetSelectionOwner",
"X_GetSelectionOwner",
"X_ConvertSelection",
"X_SendEvent",
"X_GrabPointer",
"X_UngrabPointer",
"X_GrabButton",
"X_UngrabButton",
"X_ChangeActivePointerGrab",
"X_GrabKeyboard",
"X_UngrabKeyboard",
"X_GrabKey",
"X_UngrabKey",
"X_AllowEvents",
"X_GrabServer",
"X_UngrabServer",
"X_QueryPointer",
"X_GetMotionEvents",
"X_TranslateCoords",
"X_WarpPointer",
"X_SetInputFocus",
"X_GetInputFocus",
"X_QueryKeymap",
"X_OpenFont",
"X_CloseFont",
"X_QueryFont",
"X_QueryTextExtents",
"X_ListFonts",
"X_ListFontsWithInfo",
"X_SetFontPath",
"X_GetFontPath",
"X_CreatePixmap",
"X_FreePixmap",
"X_CreateGC",
"X_ChangeGC",
"X_CopyGC",
"X_SetDashes",
"X_SetClipRectangles",
"X_FreeGC",
"X_ClearArea",
"X_CopyArea",
"X_CopyPlane",
"X_PolyPoint",
"X_PolyLine",
"X_PolySegment",
"X_PolyRectangle",
"X_PolyArc",
"X_FillPoly",
"X_PolyFillRectangle",
"X_PolyFillArc",
"X_PutImage",
"X_GetImage",
"X_PolyText8",
"X_PolyText16",
"X_ImageText8",
"X_ImageText16",
"X_CreateColormap",
"X_FreeColormap",
"X_CopyColormapAndFree",
"X_InstallColormap",
"X_UninstallColormap",
"X_ListInstalledColormaps",
"X_AllocColor",
"X_AllocNamedColor",
"X_AllocColorCells",
"X_AllocColorPlanes",
"X_FreeColors",
"X_StoreColors",
"X_StoreNamedColor",
"X_QueryColors",
"X_LookupColor",
"X_CreateCursor",
"X_CreateGlyphCursor",
"X_FreeCursor",
"X_RecolorCursor",
"X_QueryBestSize",
"X_QueryExtension",
"X_ListExtensions",
"X_ChangeKeyboardMapping",
"X_GetKeyboardMapping",
"X_ChangeKeyboardControl",
"X_GetKeyboardControl",
"X_Bell",
"X_ChangePointerControl",
"X_GetPointerControl",
"X_SetScreenSaver",
"X_GetScreenSaver",
"X_ChangeHosts",
"X_ListHosts",
"X_SetAccessControl",
"X_SetCloseDownMode",
"X_KillClient",
"X_RotateProperties",
"X_ForceScreenSaver",
"X_SetPointerMapping",
"X_GetPointerMapping",
"X_SetModifierMapping",
"X_GetModifierMapping",
"X_NoOperation"
};
void
FormatXError(Display *dpy, XErrorEvent *error, char *buffer, int size)
void FormatXError(Display * dpy, XErrorEvent * error, char *buffer, int size)
{
int i, p;
int i, p;
XGetErrorText(dpy, error->error_code, buffer, size);
i = strlen(buffer);
if (i > size-100)
return;
buffer += i;
if (error->request_code >= sizeof(requestCodes)/sizeof(char*)) {
sprintf(buffer, "\n Request code: %i\n",
error->request_code);
} else {
sprintf(buffer, "\n Request code: %i %s\n", error->request_code,
requestCodes[error->request_code]);
}
i += p = strlen(buffer);
if (i > size - 40)
return;
buffer += p;
sprintf(buffer, " Request minor code: %i\n", error->minor_code);
i += p = strlen(buffer);
if (i > size - 30)
return;
buffer += p;
sprintf(buffer, " Resource ID: 0x%x\n", (unsigned int)error->resourceid);
i += p = strlen(buffer);
if (i > size - 30)
return;
buffer += p;
sprintf(buffer, " Error serial: %li\n", error->serial);
return;
XGetErrorText(dpy, error->error_code, buffer, size);
i = strlen(buffer);
if (i > size - 100)
return;
buffer += i;
if (error->request_code >= sizeof(requestCodes) / sizeof(char *)) {
sprintf(buffer, "\n Request code: %i\n", error->request_code);
} else {
sprintf(buffer, "\n Request code: %i %s\n", error->request_code,
requestCodes[error->request_code]);
}
i += p = strlen(buffer);
if (i > size - 40)
return;
buffer += p;
sprintf(buffer, " Request minor code: %i\n", error->minor_code);
i += p = strlen(buffer);
if (i > size - 30)
return;
buffer += p;
sprintf(buffer, " Resource ID: 0x%x\n", (unsigned int)error->resourceid);
i += p = strlen(buffer);
if (i > size - 30)
return;
buffer += p;
sprintf(buffer, " Error serial: %li\n", error->serial);
return;
}