1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-29 09:52:29 +01:00

*** empty log message ***

This commit is contained in:
kojima
1999-04-10 18:27:21 +00:00
parent 9df0e16707
commit 4a473b8ad7
19 changed files with 441 additions and 331 deletions

View File

@@ -1405,7 +1405,8 @@ wHideApplication(WApplication *wapp)
wArrangeIcons(scr, True);
}
#ifdef HIDDENDOT
wAppIconPaint(wapp->app_icon);
if (wapp->app_icon)
wAppIconPaint(wapp->app_icon);
#endif
}

View File

@@ -1702,11 +1702,20 @@ handleKeyPress(XEvent *event)
break;
#ifdef KEEP_XKB_LOCK_STATUS
case WKBD_TOGGLE:
if(wPreferences.modelock){
XkbGetState(dpy,XkbUseCoreKbd,&staterec);
/*toggle*/
XkbLockGroup(dpy,XkbUseCoreKbd,
wwin->frame->languagemode=staterec.compat_state&32?0:1);
if(wPreferences.modelock) {
/*toggle*/
wwin = scr->focused_window;
if (wwin && wwin->flags.mapped
&& wwin->frame->workspace == wwin->screen_ptr->current_workspace
&& !wwin->flags.miniaturized && !wwin->flags.hidden) {
XkbGetState(dpy,XkbUseCoreKbd,&staterec);
wwin->frame->languagemode = staterec.compat_state&32
? 0 : 1;
XkbLockGroup(dpy,XkbUseCoreKbd, wwin->frame->languagemode);
}
}
break;
#endif /* KEEP_XKB_LOCK_STATUS */

View File

@@ -75,8 +75,12 @@ appearanceObserver(void *self, WMNotification *notif)
if (flags & WColorSettings) {
}
*/
wIconPaint(icon);
/* so that the appicon expose handlers will paint the appicon specific
* stuff */
XClearArea(dpy, icon->core->window, 0, 0, 1, 1, True);
/* wIconPaint(icon);*/
}
@@ -86,8 +90,9 @@ tileObserver(void *self, WMNotification *notif)
WIcon *icon = (WIcon*)self;
icon->force_paint = 1;
wIconPaint(icon);
XClearArea(dpy, icon->core->window, 0, 0, 1, 1, True);
/* wIconPaint(icon);*/
}
/************************************/

166
src/kwm.c
View File

@@ -24,6 +24,9 @@
*
* Supported stuff:
* ================
*
* kfm icon selection from krootbgwm
*
* kwm.h function/method Notes
*----------------------------------------------------------------------------
* setUnsavedDataHint() currently, only gives visual clue that
@@ -115,6 +118,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <signal.h>
#include "WindowMaker.h"
@@ -130,6 +139,7 @@
#include "actions.h"
#include "workspace.h"
#include "dialog.h"
#include "stacking.h"
#include "kwm.h"
@@ -1636,16 +1646,30 @@ wKWMSendEventMessage(WWindow *wwin, WKWMEventMessage message)
sendToModules(wwin ? wwin->screen_ptr : NULL, msg, wwin, 0);
}
#if 0
static void
writeSocket(int sock, char *data)
{
char buffer[128];
sprintf(buffer, "%i ", strlen(data));
write(sock, buffer, strlen(buffer));
write(sock, data, strlen(data));
}
static int
connectKFM(WScreen *scr)
{
char *pidf;
char *path;
char buffer[128];
char *ptr;
FILE *f;
pidf = wstrappend(whomedir(), "/.kde/share/apps/kfm/pid");
int pid;
int sock = 0;
struct sockaddr_un addr;
path = wstrappend(wgethomedir(), "/.kde/share/apps/kfm/pid");
strcpy(buffer, getenv("DISPLAY"));
ptr = strchr(buffer, ':');
@@ -1661,98 +1685,80 @@ connectKFM(WScreen *scr)
sprintf(b, ".%i", scr->screen);
strcat(buffer, b);
}
ptr = pidf;
pidf = wstrappend(ptr, buffer);
ptr = path;
path = wstrappend(ptr, buffer);
free(ptr);
/* pid file */
f = fopen(pidf, "r");
char buffer[ 1024 ];
f = fopen(path, "r");
free(path);
if (!f)
return -1;
buffer[0] = 0;
fgets( buffer, 1023, f );
int pid = atoi( buffer );
if ( pid <= 0 )
{
warning("ERROR: Invalid PID");
fclose( f );
return;
}
fgets(buffer, 123, f);
pid = atoi(buffer);
if (pid <= 0)
return -1;
// Is the PID ok ?
if ( kill( pid, 0 ) != 0 )
{
// Did we already try to start a new kfm ?
if ( flag == 0 && allowRestart )
{
flag = 1;
// Try to start a new kfm
system( "kfm -d &" );
sleep( 10 );
fclose( f );
init();
return;
}
if (kill(pid, 0) != 0)
return -1;
warning("ERROR: KFM crashed");
fclose( f );
return;
}
// Read the socket's name
buffer[0] = 0;
fscanf(f, "%s", buffer);
fclose( f );
char * slot = strdup( buffer );
if ( slot == (void *) 0 )
{
warning("ERROR: Invalid Slot");
return;
}
// Connect to KFM
ipc = new KfmIpc( slot );
free(slot);
fscanf(f, "%s", buffer);
fclose(f);
connect( ipc, SIGNAL( finished() ), this, SLOT( slotFinished() ) );
connect( ipc, SIGNAL( error( int, const char* ) ),
this, SLOT( slotError( int, const char* ) ) );
connect( ipc, SIGNAL( dirEntry( const char*, const char*, const char*, const char*, const char*, int ) ),
this, SLOT( slotDirEntry( const char*, const char*, const char*, const char*, const char*, int ) ) );
sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0)
return -1;
addr.sun_family = AF_UNIX;
strcpy(addr.sun_path, buffer);
// Read the password
QString fn = KApplication::localkdedir() + "/share/apps/kfm/magic";
f = fopen( fn.data(), "rb" );
if ( f == 0L )
{
QString ErrorMessage;
ksprintf(&ErrorMessage, i18n("You dont have the file %s\n"
"Could not do Authorization"), fn.data());
QMessageBox::message( i18n("KFM Error"), ErrorMessage );
return;
}
char *p = fgets( buffer, 1023, f );
fclose( f );
if ( p == 0L )
{
QString ErrorMessage;
ksprintf(&ErrorMessage, i18n("The file %s is corrupted\n"
"Could not do Authorization"), fn.data());
QMessageBox::message( i18n("KFM Error"), ErrorMessage );
return;
if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
close(sock);
return -1;
}
ipc->auth( buffer );
ok = TRUE;
path = wstrappend(wgethomedir(), "/.kde/share/apps/kfm/magic");
f = fopen(path, "r");
if (!f) {
return -1;
}
ptr = fgets(buffer, 123, f);
fclose(f);
if (!ptr) {
return -1;
}
puts(buffer);
ptr = wstrappend("auth", buffer);
writeSocket(sock, ptr);
free(ptr);
return sock;
}
void
wKWMSendRootSelection(WScreen *scr, int x, int y, int w, int h, Bool control)
wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h, Bool control)
{
char buffer[128];
int sock;
puts("CONNECTING");
sock = connectKFM(scr);
if (sock < 0)
return;
puts("SENDING DATA");
writeSocket(sock, "refreshDesktop");
sprintf(buffer, "selectRootIcons %i %i %i %i %c", x, y, w, h, control);
writeSocket(sock, buffer);
close(sock);
}
#endif
#endif /* KWM_HINTS */

View File

@@ -95,5 +95,8 @@ char *wKWMGetWorkspaceName(WScreen *scr, int workspace);
Bool wKWMGetIconGeometry(WWindow *wwin, WArea *area);
void wKWMSelectRootRegion(WScreen *scr, int x, int y, int w, int h,
Bool control);
#endif

View File

@@ -41,6 +41,10 @@
#include "list.h"
#ifdef KWM_HINTS
#include "kwm.h"
#endif
/* How many different types of geometry/position
display thingies are there? */
#define NUM_DISPLAYS 4
@@ -1395,24 +1399,30 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
XUngrabKeyboard(dpy, CurrentTime);
XUngrabPointer(dpy, CurrentTime);
XUngrabServer(dpy);
if(done==2){
if(done==2) {
if (wwin->flags.shaded || scr->selected_windows) {
LinkedList *list;
list=scr->selected_windows;
if(!scr->selected_windows){
if (!scr->selected_windows) {
wWindowMove(wwin, src_x+off_x, src_y+off_y);
wWindowSynthConfigureNotify(wwin);
} else {
doWindowMove(wwin,scr->selected_windows,off_x,off_y);
while (list) {
wWindowSynthConfigureNotify(list->head);
list = list->tail;
}
}
else {
doWindowMove(wwin,scr->selected_windows,off_x,off_y);
while (list) {
wWindowSynthConfigureNotify(list->head);
list = list->tail;
}
}
}
else {
wWindowConfigure(wwin, src_x+off_x, src_y+off_y, ww, wh - vert_border);
} else {
if (wwin->client.width != ww)
wwin->flags.user_changed_width = 1;
if (wwin->client.height != wh - vert_border)
wwin->flags.user_changed_height = 1;
wWindowConfigure(wwin, src_x+off_x, src_y+off_y,
ww, wh - vert_border);
wWindowSynthConfigureNotify(wwin);
}
wWindowChangeWorkspace(wwin, scr->current_workspace);
@@ -1530,10 +1540,11 @@ wMouseMoveWindow(WWindow *wwin, XEvent *ev)
if (!warped && !wPreferences.no_autowrap) {
int oldWorkspace = scr->current_workspace;
drawFrames(wwin, scr->selected_windows,
moveData.realX - wwin->frame_x,
moveData.realY - wwin->frame_y);
if (!opaqueMove) {
drawFrames(wwin, scr->selected_windows,
moveData.realX - wwin->frame_x,
moveData.realY - wwin->frame_y);
}
if (checkWorkspaceChange(wwin, &moveData, opaqueMove)) {
if (scr->current_workspace != oldWorkspace
&& wPreferences.edge_resistance > 0
@@ -1542,9 +1553,11 @@ wMouseMoveWindow(WWindow *wwin, XEvent *ev)
warped = 1;
}
drawFrames(wwin, scr->selected_windows,
moveData.realX - wwin->frame_x,
moveData.realY - wwin->frame_y);
if (!opaqueMove) {
drawFrames(wwin, scr->selected_windows,
moveData.realX - wwin->frame_x,
moveData.realY - wwin->frame_y);
}
} else {
warped = 0;
}
@@ -1859,12 +1872,19 @@ wMouseResizeWindow(WWindow *wwin, XEvent *ev)
if (started) {
showGeometry(wwin, fx, fy, fx + fw, fy + fh, res);
drawTransparentFrame(wwin, fx, fy, fw, fh);
XUngrabKeyboard(dpy, CurrentTime);
unmapGeometryDisplay(wwin);
XUngrabServer(dpy);
if (wwin->client.width != fw)
wwin->flags.user_changed_width = 1;
if (wwin->client.height != fh - vert_border)
wwin->flags.user_changed_height = 1;
wWindowConfigure(wwin, fx, fy, fw, fh - vert_border);
}
#ifdef DEBUG
@@ -1984,6 +2004,12 @@ wSelectWindows(WScreen *scr, XEvent *ev)
XUngrabServer(dpy);
XUngrabPointer(dpy, CurrentTime);
selectWindowsInside(scr, x, y, x + w, y + h);
#ifdef KWM_HINTS
wKWMSelectRootRegion(scr, x, y, w, h,
event.xbutton.state & ControlMask);
#endif /* KWM_HINTS */
#ifdef DEBUG
puts("End window selection");
#endif

View File

@@ -682,15 +682,35 @@ wSessionSendSaveYourself(WScreen *scr)
*/
static char*
getWindowRole(Window window)
{
XTextProperty prop;
static Atom atom = 0;
if (!atom)
atom = XInternAtom(dpy, "WM_WINDOW_ROLE", False);
if (XGetTextProperty(dpy, window, &prop, atom)) {
if (prop.encoding == XA_STRING && prop.format == 8 && prop.nitems > 0)
return prop.value;
}
return NULL;
}
/*
* Windows are identified as:
* WM_CLASS(instance.class).WM_WINDOW_ROLE
*
* Saved Info:
*
* WM_CLASS.instance
* WM_CLASSS.class
*
* WM_WINDOW_ROLE
*
* WM_CLASS.instance
* WM_CLASS.class
* WM_NAME
* WM_COMMAND
*
* geometry
* state = (miniaturized, shaded, etc)
* attribute
@@ -736,6 +756,64 @@ makeAppState(WWindow *wwin)
}
Bool
wSessionGetStateFor(WWindow *wwin, WSessionData *state)
{
char *str;
proplist_t slist;
proplist_t elem;
proplist_t value;
int index = 0;
index = 3;
/* geometry */
value = PLGetArrayElement(slist, index++);
str = PLGetString(value);
sscanf(str, "%i %i %i %i %i %i", &state->x, &state->y,
&state->width, &state->height,
&state->user_changed_width, &state->user_changed_height);
/* state */
value = PLGetArrayElement(slist, index++);
str = PLGetString(value);
sscanf(str, "%i %i %i", &state->miniaturized, &state->shaded,
&state->maximized);
/* attributes */
value = PLGetArrayElement(slist, index++);
str = PLGetString(value);
getAttributeState(str, &state->mflags, &state->flags);
/* workspace */
value = PLGetArrayElement(slist, index++);
str = PLGetString(value);
sscanf(str, "%i", &state->workspace);
/* app state (repeated for all windows of the app) */
value = PLGetArrayElement(slist, index++);
str = PLGetString(value);
/* ???? */
/* shortcuts */
value = PLGetArrayElement(slist, index++);
str = PLGetString(value);
sscanf(str, "%i", &state->shortcuts);
}
static proplist_t
makeAttributeState(WWindow *wwin)
{
@@ -745,7 +823,8 @@ makeAttributeState(WWindow *wwin)
#define W_FLAG(wwin, FLAG) ((wwin)->defined_user_flags.FLAG \
? (wwin)->user_flags.FLAG : -1)
sprintf(buffer, "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
sprintf(buffer,
"%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
W_FLAG(no_titlebar),
W_FLAG(no_resizable),
W_FLAG(no_closable),
@@ -779,6 +858,17 @@ makeAttributeState(WWindow *wwin)
}
static void
appendStringInArray(proplist_t array, char *str)
{
proplist_t val;
val = PLMakeString(str);
PLAppendArrayElement(array, val);
PLRelease(val);
}
static proplist_t
makeClientState(WWindow *wwin)
{
@@ -787,47 +877,62 @@ makeClientState(WWindow *wwin)
char *str;
char buffer[256];
int i;
unsigned shortcuts;
state = PLMakeArrayWithElements(NULL, NULL);
/* spec */
PLAppendArrayElement(state, PLMakeString(wwin->wm_instance));
PLAppendArrayElement(state, PLMakeString(wwin->wm_class));
/* WM_WINDOW_ROLE */
str = getWindowRole(wwin->client_win);
if (!str)
appendStringInArray(state, "");
else {
appendStringInArray(state, str);
XFree(str);
}
PLAppendArrayElement(state, PLMakeString(str));
/* WM_CLASS.instance */
appendStringInArray(state, wwin->wm_instance);
/* WM_CLASS.class */
appendStringInArray(state, wwin->wm_class);
/* WM_NAME */
/* geometry */
sprintf(buffer, "%i %i %i %i", wwin->frame_x, wwin->frame_y,
wwin->frame->core->width, wwin->frame->core->height);
PLAppendArrayElement(state, PLMakeString(buffer));
sprintf(buffer, "%i %i %i %i %i %i", wwin->frame_x, wwin->frame_y,
wwin->client.width, wwin->client.height,
wwin->flags.user_changed_width, wwin->flags.user_changed_height);
appendStringInArray(state, buffer);
/* state */
sprintf(buffer, "%i %i %i", wwin->flags.miniaturized,
wwin->flags.shaded, wwin->flags.maximized);
PLAppendArrayElement(state, PLMakeString(buffer));
appendStringInArray(state, buffer);
/* attributes */
PLAppendArrayElement(state, makeAttributeState(wwin));
tmp = makeAttributeState(wwin);
PLAppendArrayElement(state, tmp);
PLRelease(tmp);
/* workspace */
sprintf(buffer, "%i", wwin->frame->workspace);
PLAppendArrayElement(state, PLMakeString(buffer));
appendStringInArray(state, buffer);
/* app state (repeated for all windows of the app) */
PLAppendArrayElement(state, makeAppState(wwin));
tmp = makeAppState(wwin);
PLAppendArrayElement(state, tmp);
PLRelease(tmp);
/* shortcuts */
tmp = PLMakeArrayWithElements(NULL, NULL);
shortcuts = 0;
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (scr->shortcutWindow[i] == wwin) {
sprintf(buffer, "%i", i);
PLAppendArrayElement(tmp, PLMakeString(buffer));
shortcuts |= 1 << i;
}
}
PLAppendArrayElement(state, tmp);
sprintf(buffer, "%ui", shortcuts);
appendStringInArray(tmp, buffer);
return state;
}

View File

@@ -23,6 +23,28 @@
#ifndef WMSESSION_H_
#define WMSESSION_H_
typedef struct {
int x;
int y;
unsigned int w; /* client size */
unsigned int h;
int workspace;
unsigned shortcuts; /* mask like 1<<shortcut_number */
WWindowAttributes mflags;
WWindowAttributes flags;
char miniaturized;
char shaded;
char maximized;
char user_changed_width;
char user_changed_height;
} WSessionData;
void wSessionSaveState(WScreen *scr);
void wSessionSaveClients(WScreen *scr);

View File

@@ -447,14 +447,14 @@ wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class)
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--;

View File

@@ -268,6 +268,10 @@ typedef struct WWindow {
unsigned int obscured:1; /* window is obscured */
unsigned int dragged_while_fmaximized;
unsigned int user_changed_width:1;
unsigned int user_changed_height:1;
#ifdef KWM_HINTS
unsigned int kwm_hidden_for_modules:1;
unsigned int kwm_managed:1;

View File

@@ -1295,7 +1295,7 @@ createInspectorForWindow(WWindow *wwin)
i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,
wwin->wm_class);
if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {
WMSetPopUpButtonSelectedItem(panel->wsP, i);
WMSetPopUpButtonSelectedItem(panel->wsP, i + 1);
} else {
WMSetPopUpButtonSelectedItem(panel->wsP, 0);
}