mirror of
https://github.com/gryf/wmaker.git
synced 2026-03-25 14:13:31 +01:00
Compare commits
6 Commits
0aeba6064b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
329f82f6e7 | ||
|
|
60a900be28 | ||
|
|
c7c736e283 | ||
|
|
752a949492 | ||
|
|
be495bedbc | ||
| 412b3eace2 |
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "WPrefs.h"
|
#include "WPrefs.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#ifdef HAVE_STDNORETURN
|
#ifdef HAVE_STDNORETURN
|
||||||
#include <stdnoreturn.h>
|
#include <stdnoreturn.h>
|
||||||
@@ -516,6 +517,9 @@ void Initialize(WMScreen * scr)
|
|||||||
char **list;
|
char **list;
|
||||||
int i;
|
int i;
|
||||||
char *path;
|
char *path;
|
||||||
|
long pid;
|
||||||
|
Atom net_wm_pid;
|
||||||
|
Display *dpy = WMScreenDisplay(scr);
|
||||||
|
|
||||||
list = RSupportedFileFormats();
|
list = RSupportedFileFormats();
|
||||||
for (i = 0; list[i] != NULL; i++) {
|
for (i = 0; list[i] != NULL; i++) {
|
||||||
@@ -547,6 +551,11 @@ void Initialize(WMScreen * scr)
|
|||||||
|
|
||||||
WMRealizeWidget(WPrefs.win);
|
WMRealizeWidget(WPrefs.win);
|
||||||
|
|
||||||
|
net_wm_pid = XInternAtom(dpy, "_NET_WM_PID", False);
|
||||||
|
pid = (long)getpid();
|
||||||
|
XChangeProperty(dpy, WMWidgetXID(WPrefs.win), net_wm_pid, XA_CARDINAL,
|
||||||
|
32, PropModeReplace, (unsigned char *)&pid, 1);
|
||||||
|
|
||||||
WMSetWindowMiniwindowImage(WPrefs.win, WMGetApplicationIconImage(scr));
|
WMSetWindowMiniwindowImage(WPrefs.win, WMGetApplicationIconImage(scr));
|
||||||
|
|
||||||
WMMapWidget(WPrefs.win);
|
WMMapWidget(WPrefs.win);
|
||||||
|
|||||||
@@ -505,6 +505,7 @@ extern struct WPreferences {
|
|||||||
Cursor cursor[WCUR_LAST];
|
Cursor cursor[WCUR_LAST];
|
||||||
|
|
||||||
int switch_panel_icon_size; /* icon size in switch panel */
|
int switch_panel_icon_size; /* icon size in switch panel */
|
||||||
|
char *screenshot_filename_template; /* strftime format for screenshot filenames */
|
||||||
|
|
||||||
} wPreferences;
|
} wPreferences;
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ typedef struct {
|
|||||||
/* type converters */
|
/* type converters */
|
||||||
static WDECallbackConvert getBool;
|
static WDECallbackConvert getBool;
|
||||||
static WDECallbackConvert getInt;
|
static WDECallbackConvert getInt;
|
||||||
|
static WDECallbackConvert getString;
|
||||||
static WDECallbackConvert getCoord;
|
static WDECallbackConvert getCoord;
|
||||||
static WDECallbackConvert getPathList;
|
static WDECallbackConvert getPathList;
|
||||||
static WDECallbackConvert getEnum;
|
static WDECallbackConvert getEnum;
|
||||||
@@ -540,6 +541,8 @@ WDefaultEntry optionList[] = {
|
|||||||
&wPreferences.mouse_wheel_focus, getBool, NULL, NULL, NULL},
|
&wPreferences.mouse_wheel_focus, getBool, NULL, NULL, NULL},
|
||||||
{"KeychainTimeoutDelay", "500", NULL,
|
{"KeychainTimeoutDelay", "500", NULL,
|
||||||
&wPreferences.keychain_timeout_delay, getInt, NULL, NULL, NULL},
|
&wPreferences.keychain_timeout_delay, getInt, NULL, NULL, NULL},
|
||||||
|
{"ScreenshotFilenameTemplate", DEF_SCREENSHOT_FILENAME_TEMPLATE, NULL,
|
||||||
|
&wPreferences.screenshot_filename_template, getString, NULL, NULL, NULL},
|
||||||
|
|
||||||
/* style options */
|
/* style options */
|
||||||
|
|
||||||
@@ -1496,6 +1499,29 @@ static int string2index(WMPropList *key, WMPropList *val, const char *def, WOpti
|
|||||||
* ret - is the address to store a pointer to a temporary buffer. ret
|
* ret - is the address to store a pointer to a temporary buffer. ret
|
||||||
* must not be freed and is used by the set functions
|
* must not be freed and is used by the set functions
|
||||||
*/
|
*/
|
||||||
|
static int getString(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
|
||||||
|
{
|
||||||
|
const char *val;
|
||||||
|
char **sptr;
|
||||||
|
|
||||||
|
/* Parameter not used, but tell the compiler that it is ok */
|
||||||
|
(void) scr;
|
||||||
|
|
||||||
|
GET_STRING_OR_DEFAULT("String", val);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
*ret = (void *)val;
|
||||||
|
|
||||||
|
if (addr) {
|
||||||
|
sptr = (char **)addr;
|
||||||
|
if (*sptr)
|
||||||
|
wfree(*sptr);
|
||||||
|
*sptr = wstrdup(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
|
static int getBool(WScreen * scr, WDefaultEntry * entry, WMPropList * value, void *addr, void **ret)
|
||||||
{
|
{
|
||||||
static char data;
|
static char data;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ static void allocFrameBorderPixel(WFrameWindow *fwin, const char *color_name, un
|
|||||||
|
|
||||||
*pixel = wmalloc(sizeof(unsigned long));
|
*pixel = wmalloc(sizeof(unsigned long));
|
||||||
if (*pixel)
|
if (*pixel)
|
||||||
**pixel = xcol.pixel;
|
**pixel = xcol.pixel |= 0xff << 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
|
WFrameWindow *wFrameWindowCreate(WScreen * scr, int wlevel, int x, int y,
|
||||||
|
|||||||
@@ -1270,7 +1270,14 @@ void ScreenCapture(WScreen *scr, int mode)
|
|||||||
|
|
||||||
s = time(NULL);
|
s = time(NULL);
|
||||||
tm_info = localtime(&s);
|
tm_info = localtime(&s);
|
||||||
strftime(filename_date_part, sizeof(filename_date_part), "screenshot_%Y-%m-%d_at_%H:%M:%S", tm_info);
|
strftime(filename_date_part, sizeof(filename_date_part), wPreferences.screenshot_filename_template, tm_info);
|
||||||
|
|
||||||
|
if (strchr(filename_date_part, '/') != NULL) {
|
||||||
|
wfree(screenshot_dir);
|
||||||
|
werror(_("Unsafe screenshot filename template, it should not contain a path separator"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(filename, filename_date_part);
|
strcpy(filename, filename_date_part);
|
||||||
|
|
||||||
filepath = wstrconcat(screenshot_dir, strcat(filename, filetype));
|
filepath = wstrconcat(screenshot_dir, strcat(filename, filetype));
|
||||||
|
|||||||
@@ -181,8 +181,11 @@ static WMPropList *makeWindowState(WWindow * wwin, WApplication * wapp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PropGetWMClass(win, &class, &instance)) {
|
if (PropGetWMClass(win, &class, &instance)) {
|
||||||
if (class && instance)
|
if (class && instance) {
|
||||||
snprintf(buffer, sizeof(buffer), "%s.%s", instance, class);
|
if (class[0] == '\0' && wwin->wm_class && wwin->wm_class[0] != '\0')
|
||||||
|
class = strdup(wwin->wm_class);
|
||||||
|
snprintf(buffer, sizeof(buffer), "%s%s%s", instance, class[0] ? "." : "", class);
|
||||||
|
}
|
||||||
else if (instance)
|
else if (instance)
|
||||||
snprintf(buffer, sizeof(buffer), "%s", instance);
|
snprintf(buffer, sizeof(buffer), "%s", instance);
|
||||||
else if (class)
|
else if (class)
|
||||||
|
|||||||
@@ -191,6 +191,9 @@
|
|||||||
#define DEF_APPMENU_X 10
|
#define DEF_APPMENU_X 10
|
||||||
#define DEF_APPMENU_Y 10
|
#define DEF_APPMENU_Y 10
|
||||||
|
|
||||||
|
/* default strftime format for screenshot filenames */
|
||||||
|
#define DEF_SCREENSHOT_FILENAME_TEMPLATE "\"screenshot_%Y-%m-%d_at_%H:%M:%S\""
|
||||||
|
|
||||||
/* calculate window edge resistance from edge resistance */
|
/* calculate window edge resistance from edge resistance */
|
||||||
#define WIN_RESISTANCE(x) (((x)*20)/30)
|
#define WIN_RESISTANCE(x) (((x)*20)/30)
|
||||||
|
|
||||||
|
|||||||
38
src/window.c
38
src/window.c
@@ -688,15 +688,6 @@ WWindow *wManageWindow(WScreen *scr, Window window)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some applications create placeholder windows with 1x1 size
|
|
||||||
* (e.g. VirtualBox internal windows). Don't manage those initial
|
|
||||||
* 1x1 windows — wait for a proper ConfigureNotify/MapRequest with
|
|
||||||
* a real size. */
|
|
||||||
if (wattribs.width <= 1 && wattribs.height <= 1) {
|
|
||||||
XUngrabServer(dpy);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
wm_state = PropGetWindowState(window);
|
wm_state = PropGetWindowState(window);
|
||||||
|
|
||||||
/* if it's startup and the window is unmapped, don't manage it */
|
/* if it's startup and the window is unmapped, don't manage it */
|
||||||
@@ -810,6 +801,15 @@ WWindow *wManageWindow(WScreen *scr, Window window)
|
|||||||
/* get geometry stuff */
|
/* get geometry stuff */
|
||||||
wClientGetNormalHints(wwin, &wattribs, True, &x, &y, &width, &height);
|
wClientGetNormalHints(wwin, &wattribs, True, &x, &y, &width, &height);
|
||||||
|
|
||||||
|
/* Some applications create placeholder windows with 1x1 size
|
||||||
|
* (e.g. VirtualBox internal windows). Don't manage those initial
|
||||||
|
* 1x1 windows. */
|
||||||
|
if (width <= 1 && height <= 1 && !wwin->flags.is_dockapp) {
|
||||||
|
wWindowDestroy(wwin);
|
||||||
|
XUngrabServer(dpy);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* get colormap windows */
|
/* get colormap windows */
|
||||||
GetColormapWindows(wwin);
|
GetColormapWindows(wwin);
|
||||||
|
|
||||||
@@ -1051,8 +1051,28 @@ WWindow *wManageWindow(WScreen *scr, Window window)
|
|||||||
Bool dontBring = False;
|
Bool dontBring = False;
|
||||||
|
|
||||||
if (win_state && win_state->state->w > 0) {
|
if (win_state && win_state->state->w > 0) {
|
||||||
|
WMRect rect;
|
||||||
|
int head, flags;
|
||||||
|
|
||||||
x = win_state->state->x;
|
x = win_state->state->x;
|
||||||
y = win_state->state->y;
|
y = win_state->state->y;
|
||||||
|
|
||||||
|
/* If the saved position falls in dead space (for example a monitor that no longer
|
||||||
|
* exists), clamp the window to the nearest active head. */
|
||||||
|
rect.pos.x = x;
|
||||||
|
rect.pos.y = y;
|
||||||
|
rect.size.width = width;
|
||||||
|
rect.size.height = height;
|
||||||
|
|
||||||
|
head = wGetRectPlacementInfo(scr, rect, &flags);
|
||||||
|
if (flags & XFLAG_DEAD) {
|
||||||
|
rect = wGetRectForHead(scr, head);
|
||||||
|
|
||||||
|
x = rect.pos.x + (x * rect.size.width) / scr->scr_width;
|
||||||
|
y = rect.pos.y + (y * rect.size.height) / scr->scr_height;
|
||||||
|
|
||||||
|
wScreenBringInside(scr, &x, &y, width, height);
|
||||||
|
}
|
||||||
} else if ((wwin->transient_for == None || wPreferences.window_placement != WPM_MANUAL)
|
} else if ((wwin->transient_for == None || wPreferences.window_placement != WPM_MANUAL)
|
||||||
&& !scr->flags.startup
|
&& !scr->flags.startup
|
||||||
&& !wwin->flags.miniaturized
|
&& !wwin->flags.miniaturized
|
||||||
|
|||||||
Reference in New Issue
Block a user