Beispiel #1
0
void
check_defaults()
{
    char *path;

    path = wdefaultspathfordomain("WindowMaker");

    if (access(path, R_OK)!=0) {
#if 0
        wfatal(_("could not find user GNUstep directory (%s).\n"
                 "Make sure you have installed Window Maker correctly and run wmaker.inst"),
               path);
        exit(1);
#else
        wwarning(_("could not find user GNUstep directory (%s)."), path);

        if (system("wmaker.inst --batch") != 0) {
            wwarning(_("There was an error while creating GNUstep directory, please "
                       "make sure you have installed Window Maker correctly and run wmaker.inst"));
        } else {
            wwarning(_("%s directory created with default configuration."), path);
        }
#endif
    }

    wfree(path);
}
Beispiel #2
0
static void showData(_Panel * panel)
{
	char *str;
	int i;
	char buffer[32];

	str = GetStringForKey("FocusMode");
	if (!str)
		str = "manual";
	if (strcasecmp(str, "manual") == 0 || strcasecmp(str, "clicktofocus") == 0)
		WMSetButtonSelected(panel->kfocB[0], 1);
	else if (strcasecmp(str, "auto") == 0 || strcasecmp(str, "semiauto") == 0
		 || strcasecmp(str, "sloppy") == 0)
		WMSetButtonSelected(panel->kfocB[1], 1);
	else {
		wwarning(_("bad option value %s for option FocusMode. Using default Manual"), str);
		WMSetButtonSelected(panel->kfocB[0], 1);
	}

	 /**/ str = GetStringForKey("ColormapMode");
	if (!str)
		str = "auto";
	if (strcasecmp(str, "manual") == 0 || strcasecmp(str, "clicktofocus") == 0) {
		WMPerformButtonClick(panel->manB);
	} else if (strcasecmp(str, "auto") == 0 || strcasecmp(str, "focusfollowsmouse") == 0) {
		WMPerformButtonClick(panel->autB);
	} else {
		wwarning(_("bad option value %s for option ColormapMode. Using default Auto"), str);
		WMPerformButtonClick(panel->manB);
	}

	 /**/ i = GetIntegerForKey("RaiseDelay");
	sprintf(buffer, "%i", i);
	WMSetTextFieldText(panel->raisT, buffer);

	switch (i) {
	case 0:
		WMPerformButtonClick(panel->raisB[0]);
		break;
	case 10:
		WMPerformButtonClick(panel->raisB[1]);
		break;
	case 100:
		WMPerformButtonClick(panel->raisB[2]);
		break;
	case 350:
		WMPerformButtonClick(panel->raisB[3]);
		break;
	case 800:
		WMPerformButtonClick(panel->raisB[4]);
		break;
	}

	 /**/ WMSetButtonSelected(panel->ignB, GetBoolForKey("IgnoreFocusClick"));

	WMSetButtonSelected(panel->newB, GetBoolForKey("AutoFocus"));
	WMSetButtonSelected(panel->craisB, GetBoolForKey("CirculateRaise"));
}
Beispiel #3
0
static WMenu *makeOptionsMenu(WScreen * scr)
{
	WMenu *menu;
	WMenuEntry *entry;
	int i;

	menu = wMenuCreate(scr, NULL, False);
	if (!menu) {
		wwarning(_("could not create submenu for window menu"));
		return NULL;
	}

	for (i = 0; i < wlengthof(menu_options_entries); i++) {
		entry = wMenuAddCallback(menu, _(menu_options_entries[i]), execWindowOptionCommand, NULL);
		entry->flags.indicator = 1;
		entry->flags.indicator_type = MI_CHECK;
	}

	for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
		entry = wMenuAddCallback(menu, "", makeShortcutCommand, NULL);
		entry->flags.indicator = 1;
	}

	return menu;
}
Beispiel #4
0
static void selectWindow(WMWidget *bPtr, void *data)
{
	InspectorPanel *panel = (InspectorPanel *) data;
	WWindow *wwin = panel->inspected;
	WScreen *scr = wwin->screen_ptr;
	XEvent event;
	WWindow *iwin;

	/* Parameter not used, but tell the compiler that it is ok */
	(void) bPtr;

	if (XGrabPointer(dpy, scr->root_win, True,
			 ButtonPressMask, GrabModeAsync, GrabModeAsync, None,
			 wPreferences.cursor[WCUR_SELECT], CurrentTime) != GrabSuccess) {
		wwarning("could not grab mouse pointer");
		return;
	}

	WMSetLabelText(panel->specLbl, _("Click in the window you wish to inspect."));
	WMMaskEvent(dpy, ButtonPressMask, &event);
	XUngrabPointer(dpy, CurrentTime);

	iwin = wWindowFor(event.xbutton.subwindow);
	if (iwin && !iwin->flags.internal_window && iwin != wwin && !iwin->flags.inspector_open) {
		iwin->flags.inspector_open = 1;
		iwin->inspector = createInspectorForWindow(iwin,
							   panel->frame->frame_x, panel->frame->frame_y, True);
		wCloseInspectorForWindow(wwin);
	} else {
		WMSetLabelText(panel->specLbl, spec_text);
	}
}
Beispiel #5
0
static void initMotionProcess(WMView * view, WMDraggingInfo * info, XEvent * event, WMPoint * startLocation)
{
	WMScreen *scr = W_VIEW_SCREEN(view);

	/* take ownership of XdndSelection */
	XDND_SELECTION_PROCS(info) = (WMSelectionProcs *) wmalloc(sizeof(WMSelectionProcs));
	XDND_SELECTION_PROCS(info)->convertSelection = convertSelection;
	XDND_SELECTION_PROCS(info)->selectionLost = selectionLost;
	XDND_SELECTION_PROCS(info)->selectionDone = selectionDone;
	XDND_TIMESTAMP(info) = event->xmotion.time;

	if (!WMCreateSelectionHandler(view, scr->xdndSelectionAtom, CurrentTime, XDND_SELECTION_PROCS(info), NULL)) {
		wwarning("could not get ownership or DND selection");
		return;
	}

	registerDropTypes(scr, view, info);

	if (XDND_SOURCE_ACTION(info) == W_VIEW_SCREEN(view)->xdndActionAsk)
		registerSupportedOperations(view);

	if (view->dragSourceProcs->beganDrag != NULL) {
		view->dragSourceProcs->beganDrag(view, startLocation);
	}
}
Beispiel #6
0
static void appicon_handle_menubutton(WAppIcon *aicon, XEvent *event)
{
	WMenu *menu;
	WObjDescriptor *desc;
	WApplication *wapp;

	wapp = wApplicationOf(aicon->icon->owner->main_window);
	if (!wapp)
		return;

	if (event->xbutton.send_event &&
	    XGrabPointer(dpy, aicon->icon->core->window, True, ButtonMotionMask
			 | ButtonReleaseMask | ButtonPressMask, GrabModeAsync,
			 GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
		wwarning("pointer grab failed for appicon menu");

		return;
	}

	menu = openApplicationMenu(wapp, event->xbutton.x_root, event->xbutton.y_root);

	/* allow drag select of menu */
	desc = &menu->core->descriptor;
	event->xbutton.send_event = True;
	(*desc->handle_mousedown) (desc, event);

	wMenuDestroy(menu);
}
Beispiel #7
0
static int catchXError(Display * dpy, XErrorEvent * error)
{
	char buffer[MAXLINE];

	/* ignore some errors */
	if (error->resourceid != None
	    && ((error->error_code == BadDrawable && error->request_code == X_GetGeometry)
		|| (error->error_code == BadMatch && (error->request_code == X_SetInputFocus))
		|| (error->error_code == BadWindow)
		/*
		   && (error->request_code == X_GetWindowAttributes
		   || error->request_code == X_SetInputFocus
		   || error->request_code == X_ChangeWindowAttributes
		   || error->request_code == X_GetProperty
		   || error->request_code == X_ChangeProperty
		   || error->request_code == X_QueryTree
		   || error->request_code == X_GrabButton
		   || error->request_code == X_UngrabButton
		   || error->request_code == X_SendEvent
		   || error->request_code == X_ConfigureWindow))
		 */
		|| (error->request_code == X_InstallColormap))) {
		return 0;
	}
	FormatXError(dpy, error, buffer, MAXLINE);
	wwarning(_("internal X error: %s"), buffer);
	return -1;
}
Beispiel #8
0
static void *idleState(WMView * view, XClientMessageEvent * event, WMDraggingInfo * info)
{
	WMScreen *scr;
	Atom destMsg = event->message_type;

	scr = W_VIEW_SCREEN(view);

	if (destMsg == scr->xdndStatusAtom) {
		storeStatusMessageInfos(info, event);

		if (XDND_DEST_ACTION(info) != None) {
			recolorCursor(info, True);
			W_DragSourceStartTimer(info);
			return dropAllowedState;
		} else {
			/* drop denied */
			recolorCursor(info, False);
			return idleState;
		}
	}

	if (destMsg == scr->xdndFinishedAtom) {
		wwarning("received xdndFinishedAtom before drop began");
	}

	W_DragSourceStartTimer(info);
	return idleState;
}
Beispiel #9
0
void W_DragSourceStateHandler(WMDraggingInfo * info, XClientMessageEvent * event)
{
	WMView *view;
	W_DndState *newState;

	if (XDND_SOURCE_VIEW_STORED(info)) {
		if (XDND_SOURCE_STATE(info) != NULL) {
			view = XDND_SOURCE_VIEW(info);
#ifdef XDND_DEBUG

			printf("current source state: %s\n", stateName(XDND_SOURCE_STATE(info)));
#endif

			newState = (W_DndState *) XDND_SOURCE_STATE(info) (view, event, info);

#ifdef XDND_DEBUG

			printf("new source state: %s\n", stateName(newState));
#endif

			if (newState != NULL)
				XDND_SOURCE_STATE(info) = newState;
			/* else drop finished, and info has been flushed */
		}

	} else {
		wwarning("received DnD message without having a target");
	}
}
Beispiel #10
0
static int getBool(WMPropList *value)
{
	char *val;

	if (!WMIsPLString(value))
		return 0;

	if (!(val = WMGetFromPLString(value)))
		return 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 0;
	} else {
		wwarning(_("can't convert \"%s\" to boolean"), val);
		return 0;
	}
}
Beispiel #11
0
static WMPropList *retainPropListByCount(WMPropList * plist, int count)
{
	WMPropList *key, *value;
	WMHashEnumerator e;
	int i;

	plist->retainCount += count;

	switch (plist->type) {
	case WPLString:
	case WPLData:
		break;
	case WPLArray:
		for (i = 0; i < WMGetArrayItemCount(plist->d.array); i++) {
			retainPropListByCount(WMGetFromArray(plist->d.array, i), count);
		}
		break;
	case WPLDictionary:
		e = WMEnumerateHashTable(plist->d.dict);
		while (WMNextHashEnumeratorItemAndKey(&e, (void **)&value, (void **)&key)) {
			retainPropListByCount(key, count);
			retainPropListByCount(value, count);
		}
		break;
	default:
		wwarning(_("Used proplist functions on non-WMPropLists objects"));
		wassertrv(False, NULL);
		break;
	}

	return plist;
}
Beispiel #12
0
Bool GetCommandForPid(int pid, char ***argv, int *argc)
{
	static int notified = 0;

	if (!notified) {
		struct utsname un;

		/* The comment below is placed in the PO file by xgettext to help translator */
		if (uname(&un) != -1) {
			/*
			 *  1st %s is a function name
			 *  2nd %s is an email address
			 *  3rd %s is the name of the operating system
			 */
			wwarning(_("%s is not implemented on this platform; "
			           "tell %s you are running %s release %s version %s"),
			         __FUNCTION__, PACKAGE_BUGREPORT,
				un.sysname, un.release, un.version);
			notified = 1;
		}

	}

	*argv = NULL;
	*argc = 0;

	return False;
}
Beispiel #13
0
WMenu *wAppMenuGet(WScreen * scr, Window window)
{
	XTextProperty text_prop;
	int count, i;
	char **slist;
	WMenu *menu;

	if (!XGetTextProperty(dpy, window, &text_prop, w_global.atom.wmaker.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 %lx: %s", window, slist[0]);
		XFreeStringList(slist);
		return NULL;
	}

	i = 1;
	menu = parseMenuCommand(scr, window, slist, count, &i);
	if (menu)
		menu->parent = NULL;

	XFreeStringList(slist);

	return menu;
}
Beispiel #14
0
static void
iconDblClick(WObjDescriptor *desc, XEvent *event)
{
    WAppIcon *aicon = desc->parent;
    WApplication *wapp;
    WScreen *scr = aicon->icon->core->screen_ptr;
    int unhideHere;

    assert(aicon->icon->owner!=NULL);

    wapp = wApplicationOf(aicon->icon->owner->main_window);
#ifdef DEBUG0
    if (!wapp) {
        wwarning("could not find application descriptor for app icon!!");
        return;
    }
#endif

    unhideHere = (event->xbutton.state & ShiftMask);

    /* go to the last workspace that the user worked on the app */
    if (!unhideHere && wapp->last_workspace != scr->current_workspace)
        wWorkspaceChange(scr, wapp->last_workspace);

    wUnhideApplication(wapp, event->xbutton.button==Button2, unhideHere);

    if (event->xbutton.state & MOD_MASK) {
        wHideOtherApplications(aicon->icon->owner);
    }
}
Beispiel #15
0
int wcopy_file(const char *dir, const char *src_file, const char *dest_file)
{
	FILE *src, *dst;
	size_t nread, nwritten;
	char *dstpath;
	struct stat st;
	char buf[4096];

	/* only to a directory */
	if (stat(dir, &st) != 0 || !S_ISDIR(st.st_mode))
		return -1;
	/* only copy files */
	if (stat(src_file, &st) != 0 || !S_ISREG(st.st_mode))
		return -1;

	do {
		src = fopen(src_file, "rb");
	} while ((src == NULL) && (errno == EINTR));
	if (src == NULL) {
		werror(_("Could not open input file \"%s\""), src_file);
		return -1;
	}

	dstpath = wstrconcat(dir, dest_file);
	do {
		dst = fopen(dstpath, "wb");
	} while ((dst == NULL) && (errno == EINTR));
	if (dst == NULL) {
		werror(_("Could not create target file \"%s\""), dstpath);
		wfree(dstpath);
		fclose(src);
		return -1;
	}

	do {
		nread = fread(buf, 1, sizeof(buf), src);
		if (ferror(src))
			break;

		nwritten = fwrite(buf, 1, nread, dst);
		if (ferror(dst) || feof(src) || nread != nwritten)
			break;

	} while (1);

	if (ferror(src) || ferror(dst))
		unlink(dstpath);

	fclose(src);
	fchmod(fileno(dst), st.st_mode);
	fsync(fileno(dst));
	if (fclose(dst))
		wwarning("error occured during fclose(\"%s\")", dstpath);
	wfree(dstpath);

	return 0;
}
Beispiel #16
0
static void selectionLost(WMView * view, Atom selection, void *cdata)
{
	/* Parameter not used, but tell the compiler that it is ok */
	(void) view;
	(void) selection;
	(void) cdata;

	wwarning("DND selection lost during drag operation...");
}
Beispiel #17
0
static void
putdef(char *line, char *name, char *value)
{
    if (!value) {
        wwarning(_("could not define value for %s for cpp"), name);
        return;
    }
    strcat(line, name);
    strcat(line, value);
}
Beispiel #18
0
void ParseWindowName(WMPropList *value, char **winstance, char **wclass, const char *where)
{
	char *name;

	*winstance = *wclass = NULL;

	if (!WMIsPLString(value)) {
		wwarning(_("bad window name value in %s state info"), where);
		return;
	}

	name = WMGetFromPLString(value);
	if (!name || strlen(name) == 0) {
		wwarning(_("bad window name value in %s state info"), where);
		return;
	}

	UnescapeWM_CLASS(name, winstance, wclass);
}
Beispiel #19
0
static RImage * get_texture_image(WScreen *scr, const char *pixmap_file)
{
	char *file;
	RImage *image;

	file = FindImage(wPreferences.pixmap_path, pixmap_file);
	if (!file) {
		wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file);
		return NULL;
	}
	image = RLoadImage(scr->rcontext, file, 0);
	if (!image) {
		wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode));
		wfree(file);
		return NULL;
	}
	wfree(file);

	return image;
}
Beispiel #20
0
WMScreen *WMOpenScreen(const char *display)
{
	Display *dpy = XOpenDisplay(display);

	if (!dpy) {
		wwarning(_("WINGs: could not open display %s"), XDisplayName(display));
		return NULL;
	}

	return WMCreateSimpleApplicationScreen(dpy);
}
Beispiel #21
0
/*
 *----------------------------------------------------------------------
 * handleExitSig--
 * 	User generated exit signal handler.
 *----------------------------------------------------------------------
 */
static RETSIGTYPE handleExitSig(int sig)
{
	sigset_t sigs;

	sigfillset(&sigs);
	sigprocmask(SIG_BLOCK, &sigs, NULL);

	if (sig == SIGUSR1) {
		wwarning("got signal %i - restarting", sig);
		SIG_WCHANGE_STATE(WSTATE_NEED_RESTART);
	} else if (sig == SIGUSR2) {
		wwarning("got signal %i - rereading defaults", sig);
		SIG_WCHANGE_STATE(WSTATE_NEED_REREAD);
	} else if (sig == SIGTERM || sig == SIGINT || sig == SIGHUP) {
		wwarning("got signal %i - exiting...", sig);
		SIG_WCHANGE_STATE(WSTATE_NEED_EXIT);
	}

	sigprocmask(SIG_UNBLOCK, &sigs, NULL);
	DispatchEvent(NULL);	/* Dispatch events imediately. */
}
Beispiel #22
0
static RImage *loadImage(RContext * rc, const char *file)
{
	char *path;
	RImage *image;

	if (access(file, F_OK) != 0) {
		path = wfindfile(PixmapPath, file);
		if (!path) {
			wwarning("%s:could not find image file used in texture", file);
			return NULL;
		}
	} else {
		path = wstrdup(file);
	}

	image = RLoadImage(rc, path, 0);
	if (!image) {
		wwarning("%s:could not load image file used in texture:%s", path, RMessageForError(RErrorCode));
	}
	wfree(path);

	return image;
}
Beispiel #23
0
static void findCopyFile(const char *dir, const char *file)
{
	char *fullPath;

	fullPath = wfindfileinarray(PixmapPath, file);
	if (!fullPath) {
		wwarning("Could not find file %s", file);
		if (ThemePath)
			(void)wrmdirhier(ThemePath);
		return;
	}
	wcopy_file(dir, fullPath, file);
	wfree(fullPath);
}
Beispiel #24
0
static void
showData(_Panel *panel)
{
    WMPropList *array, *val;
    int i;

    array = GetObjectForKey("IconPath");
    if (!array || !WMIsPLArray(array)) {
        if (array)
            wwarning(_("bad value in option IconPath. Using default path list"));
        addPathToList(panel->icoL, -1, "~/pixmaps");
        addPathToList(panel->icoL, -1, "~/GNUstep/Library/Icons");
        addPathToList(panel->icoL, -1, "/usr/include/X11/pixmaps");
        addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Icons");
        addPathToList(panel->icoL, -1, "/usr/local/share/WindowMaker/Pixmaps");
        addPathToList(panel->icoL, -1, "/usr/share/WindowMaker/Icons");
    } else {
        for (i=0; i<WMGetPropListItemCount(array); i++) {
            val = WMGetFromPLArray(array, i);
            addPathToList(panel->icoL, -1, WMGetFromPLString(val));
        }
    }

    array = GetObjectForKey("PixmapPath");
    if (!array || !WMIsPLArray(array)) {
        if (array)
            wwarning(_("bad value in option PixmapPath. Using default path list"));
        addPathToList(panel->pixL, -1, "~/pixmaps");
        addPathToList(panel->pixL, -1, "~/GNUstep/Library/WindowMaker/Pixmaps");
        addPathToList(panel->pixL, -1, "/usr/local/share/WindowMaker/Pixmaps");
    } else {
        for (i=0; i<WMGetPropListItemCount(array); i++) {
            val = WMGetFromPLArray(array, i);
            addPathToList(panel->pixL, -1, WMGetFromPLString(val));
        }
    }
}
Beispiel #25
0
void PropSetIconTileHint(virtual_screen *vscr, RImage *image)
{
	static Atom imageAtom = 0;
	unsigned char *tmp;
	int x, y;

	if (vscr->screen_ptr->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);
	}

	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;

	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;
			}
		}
	}

	XChangeProperty(dpy, vscr->screen_ptr->info_window, w_global.atom.wmaker.icon_tile,
			imageAtom, 8, PropModeReplace, tmp, image->width * image->height * 4 + 4);
	wfree(tmp);

}
Beispiel #26
0
void WMSetTextFieldAlignment(WMTextField * tPtr, WMAlignment alignment)
{
	CHECK_CLASS(tPtr, WC_TextField);

	tPtr->flags.alignment = alignment;

	if (alignment != WALeft) {
		wwarning("only left alignment is supported in textfields");
		return;
	}

	if (tPtr->view->flags.realized) {
		paintTextField(tPtr);
	}
}
Beispiel #27
0
static WMenu *makeMaximizeMenu(WScreen * scr)
{
	WMenu *menu;
	int i;

	menu = wMenuCreate(scr, NULL, False);
	if (!menu) {
		wwarning(_("could not create submenu for window menu"));
		return NULL;
	}

	for (i = 0; i < wlengthof(menu_maximize_entries); i++)
		wMenuAddCallback(menu, _(menu_maximize_entries[i].label), execMaximizeCommand, NULL);

	return menu;
}
Beispiel #28
0
static void releasePropListByCount(WMPropList * plist, int count)
{
	WMPropList *key, *value;
	WMHashEnumerator e;
	int i;

	plist->retainCount -= count;

	switch (plist->type) {
	case WPLString:
		if (plist->retainCount < 1) {
			wfree(plist->d.string);
			wfree(plist);
		}
		break;
	case WPLData:
		if (plist->retainCount < 1) {
			WMReleaseData(plist->d.data);
			wfree(plist);
		}
		break;
	case WPLArray:
		for (i = 0; i < WMGetArrayItemCount(plist->d.array); i++) {
			releasePropListByCount(WMGetFromArray(plist->d.array, i), count);
		}
		if (plist->retainCount < 1) {
			WMFreeArray(plist->d.array);
			wfree(plist);
		}
		break;
	case WPLDictionary:
		e = WMEnumerateHashTable(plist->d.dict);
		while (WMNextHashEnumeratorItemAndKey(&e, (void **)&value, (void **)&key)) {
			releasePropListByCount(key, count);
			releasePropListByCount(value, count);
		}
		if (plist->retainCount < 1) {
			WMFreeHashTable(plist->d.dict);
			wfree(plist);
		}
		break;
	default:
		wwarning(_("Used proplist functions on non-WMPropLists objects"));
		wassertr(False);
		break;
	}
}
Beispiel #29
0
/* ----- source timer ----- */
static void dragSourceResponseTimeOut(void *source)
{
	WMView *view = (WMView *) source;
	WMDraggingInfo *info = &(W_VIEW_SCREEN(view)->dragInfo);

	wwarning("delay for drag destination response expired");
	sendLeaveMessage(info);

	recolorCursor(info, False);
	if (XDND_SOURCE_STATE(info) == finishDropState) {
		/* drop failed */
		endDragImage(info, True);
		endDragProcess(info, False);
	} else {
		XDND_SOURCE_STATE(info) = idleState;
	}
}
Beispiel #30
-1
void
WMDrawImageString(WMScreen *scr, Drawable d, WMColor *color, WMColor *background,
                  WMFont *font, int x, int y, char *text, int length)
{
    XftColor textColor;
    XftColor bgColor;

    wassertr(font!=NULL);

    textColor.color.red = color->color.red;
    textColor.color.green = color->color.green;
    textColor.color.blue = color->color.blue;
    textColor.color.alpha = color->alpha;;
    textColor.pixel = W_PIXEL(color);

    bgColor.color.red = background->color.red;
    bgColor.color.green = background->color.green;
    bgColor.color.blue = background->color.blue;
    bgColor.color.alpha = background->alpha;;
    bgColor.pixel = W_PIXEL(background);

    XftDrawChange(scr->xftdraw, d);

    XftDrawRect(scr->xftdraw, &bgColor, x, y,
                WMWidthOfString(font, text, length),
                font->height);

    if (font->screen->useWideChar) {
        wchar_t *wtext;
        const char *mtext;
        int len;

        mtext = text;
        wtext = (wchar_t *)wmalloc(sizeof(wchar_t)*(length+1));
        len = wmbsnrtowcs(wtext, &mtext, length, length);
        if (len>0) {
            XftDrawString32(scr->xftdraw, &textColor, font->font,
                            x, y + font->y, (XftChar32*)wtext, len);
        } else if (len==-1) {
            wwarning(_("Conversion to widechar failed (possible invalid "
                       "multibyte sequence): '%s':(pos %d)\n"),
                     text, mtext-text+1);
            /* we can draw normal text, or we can draw as much widechar
             * text as was already converted until the error. go figure */
            /*XftDrawString8(scr->xftdraw, &textColor, font->font,
             x, y + font->y, (XftChar8*)text, length);*/
        }
        wfree(wtext);
    } else if (font->screen->useMultiByte) {
        XftDrawStringUtf8(scr->xftdraw, &textColor, font->font,
                          x, y + font->y, (XftChar8*)text, length);
    } else {
        XftDrawString8(scr->xftdraw, &textColor, font->font,
                       x, y + font->y, (XftChar8*)text, length);
    }
}