1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

*** empty log message ***

This commit is contained in:
id
1999-04-16 19:56:08 +00:00
parent 4b609a4ddc
commit 6c22352007
4 changed files with 345 additions and 303 deletions

View File

@@ -207,7 +207,7 @@ WMCreateTextField(WMWidget *parent)
WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1); WMAX((tPtr->view->size.height - WMFontHeight(tPtr->font))/2, 1);
WMCreateEventHandler(tPtr->view, EnterWindowMask|LeaveWindowMask WMCreateEventHandler(tPtr->view, EnterWindowMask|LeaveWindowMask
|ButtonPressMask|KeyPressMask|Button1MotionMask, |ButtonReleaseMask|ButtonPressMask|KeyPressMask|Button1MotionMask,
handleTextFieldActionEvents, tPtr); handleTextFieldActionEvents, tPtr);
tPtr->flags.cursorOn = 1; tPtr->flags.cursorOn = 1;
@@ -562,6 +562,7 @@ paintCursor(TextField *tPtr)
XDrawRectangle(screen->display, tPtr->view->window, screen->xorGC, XDrawRectangle(screen->display, tPtr->view->window, screen->xorGC,
cx, tPtr->offsetWidth, 1, cx, tPtr->offsetWidth, 1,
tPtr->view->size.height - 2*tPtr->offsetWidth - 1); tPtr->view->size.height - 2*tPtr->offsetWidth - 1);
printf("%d %d\n",cx,tPtr->cursorPosition);
*/ */
XDrawLine(screen->display, tPtr->view->window, screen->xorGC, XDrawLine(screen->display, tPtr->view->window, screen->xorGC,
cx, tPtr->offsetWidth, cx, cx, tPtr->offsetWidth, cx,
@@ -677,9 +678,15 @@ paintTextField(TextField *tPtr)
? tPtr->selection.position + tPtr->selection.count ? tPtr->selection.position + tPtr->selection.count
: tPtr->selection.position; : tPtr->selection.position;
/*
rx = tx + WMWidthOfString(tPtr->font, rx = tx + WMWidthOfString(tPtr->font,
&(tPtr->text[tPtr->viewPosition]), &(tPtr->text[tPtr->viewPosition]),
count); count)
- WMWidthOfString(tPtr->font,
tPtr->text,tPtr->viewPosition);
*/
rx = tPtr->offsetWidth + 1 + WMWidthOfString(tPtr->font,tPtr->text,count)
- WMWidthOfString(tPtr->font,tPtr->text,tPtr->viewPosition);
XSetBackground(screen->display, screen->textFieldGC, XSetBackground(screen->display, screen->textFieldGC,
screen->gray->color.pixel); screen->gray->color.pixel);
@@ -1067,21 +1074,69 @@ handleTextFieldActionEvents(XEvent *event, void *data)
case MotionNotify: case MotionNotify:
if (tPtr->flags.enabled && (event->xmotion.state & Button1Mask)) { if (tPtr->flags.enabled && (event->xmotion.state & Button1Mask)) {
if (tPtr->viewPosition < tPtr->textLen && event->xmotion.x >
tPtr->usableWidth) {
if (WMWidthOfString(tPtr->font,
&(tPtr->text[tPtr->viewPosition]),
tPtr->cursorPosition-tPtr->viewPosition)
> tPtr->usableWidth) {
tPtr->viewPosition++;
}
}
else if (tPtr->viewPosition > 0 && event->xmotion.x < 0) {
paintCursor(tPtr);
tPtr->viewPosition--;
}
if (!tPtr->selection.count) { if (!tPtr->selection.count) {
tPtr->selection.position = tPtr->cursorPosition; tPtr->selection.position = tPtr->cursorPosition;
} }
tPtr->cursorPosition = pointToCursorPosition(tPtr, tPtr->cursorPosition = pointToCursorPosition(tPtr, event->xmotion.x);
event->xmotion.x);
tPtr->selection.count = tPtr->cursorPosition tPtr->selection.count = tPtr->cursorPosition - tPtr->selection.position;
- tPtr->selection.position;
/*
printf("notify %d %d\n",event->xmotion.x,tPtr->usableWidth);
*/
paintCursor(tPtr);
paintTextField(tPtr); paintTextField(tPtr);
} }
break; break;
case ButtonPress: case ButtonPress:
switch (tPtr->flags.alignment) {
int textWidth;
case WARight:
textWidth = WMWidthOfString(tPtr->font, tPtr->text, tPtr->textLen);
if (tPtr->flags.enabled && !tPtr->flags.focused) {
WMSetFocusToWidget(tPtr);
} else if (tPtr->flags.focused) {
tPtr->selection.count = 0;
}
if(textWidth < tPtr->usableWidth){
tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xbutton.x - tPtr->usableWidth
+ textWidth);
}
else tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xbutton.x);
/*
tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xbutton.x);
tPtr->cursorPosition += tPtr->usableWidth - textWidth;
}
tPtr->cursorPosition = pointToCursorPosition(tPtr,
event->xbutton.x);
*/
paintTextField(tPtr);
break;
case WALeft:
if (tPtr->flags.enabled && !tPtr->flags.focused) { if (tPtr->flags.enabled && !tPtr->flags.focused) {
WMSetFocusToWidget(tPtr); WMSetFocusToWidget(tPtr);
tPtr->cursorPosition = pointToCursorPosition(tPtr, tPtr->cursorPosition = pointToCursorPosition(tPtr,
@@ -1104,14 +1159,24 @@ handleTextFieldActionEvents(XEvent *event, void *data)
if (text) { if (text) {
WMInsertTextFieldText(tPtr, text, tPtr->cursorPosition); WMInsertTextFieldText(tPtr, text, tPtr->cursorPosition);
XFree(text); XFree(text);
WMPostNotificationName(WMTextDidChangeNotification, tPtr, WMPostNotificationName(WMTextDidChangeNotification, tPtr, NULL);
NULL);
} }
} }
break; break;
}
break;
case ButtonRelease: case ButtonRelease:
{
int count;
XSetSelectionOwner(tPtr->view->screen->display,
XA_PRIMARY, None, CurrentTime);
count = tPtr->selection.count < 0
? tPtr->selection.position + tPtr->selection.count
: tPtr->selection.position;
XStoreBuffer(tPtr->view->screen->display,
&tPtr->text[count] , abs(tPtr->selection.count), 0);
}
break; break;
} }
} }

View File

@@ -106,6 +106,14 @@ wAppIconCreateForDock(WScreen *scr, char *command, char *wm_instance,
#ifdef REDUCE_APPICONS #ifdef REDUCE_APPICONS
dicon->num_apps = 0; dicon->num_apps = 0;
#endif #endif
#ifdef DEMATERIALIZE_ICON
{
XSetWindowAttributes attribs;
attribs.save_under = True;
XChangeWindowAttributes(dpy, dicon->icon->core->window,
CWSaveUnder, &attribs);
}
#endif
/* will be overriden by dock */ /* will be overriden by dock */
dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown; dicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;
@@ -203,6 +211,14 @@ wAppIconCreate(WWindow *leader_win)
#endif #endif
aicon->icon = wIconCreate(leader_win); aicon->icon = wIconCreate(leader_win);
#ifdef DEMATERIALIZE_ICON
{
XSetWindowAttributes attribs;
attribs.save_under = True;
XChangeWindowAttributes(dpy, aicon->icon->core->window,
CWSaveUnder, &attribs);
}
#endif
/* will be overriden if docked */ /* will be overriden if docked */
aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown; aicon->icon->core->descriptor.handle_mousedown = appIconMouseDown;

View File

@@ -92,64 +92,16 @@ notifyClient(WMenu *menu, WMenuEntry *entry){
event.xkey.same_screen = YES; event.xkey.same_screen = YES;
XSendEvent(dpy, window, False, NoEventMask, &event); XSendEvent(dpy, window, False, NoEventMask, &event);
XFlush(dpy); XFlush(dpy);
/* should i release key too? */
} }
} }
static void static void
removeUserMenudata(void *menudata){ removeUserMenudata(void *menudata){
WUserMenuData *data = menudata; WUserMenuData *data = menudata;
free(data->key); if(data->key) free(data->key);
free(data); free(data);
} }
static WUserMenuData*
convertShortcut(WScreen *scr, proplist_t shortcut){
WUserMenuData *data;
KeySym ksym;
char *k;
char buf[128], *b;
data = malloc(sizeof(WUserMenuData));
data->key = malloc(sizeof(WUserMenuData));
data->key[0].modifier = 0;
strcpy(buf, PLGetString(shortcut));
b = (char*)buf;
/* get modifiers */
while ((k = strchr(b, '+'))!=NULL) {
int mod;
*k = 0;
mod = wXModifierFromKey(b);
if (mod<0) {
free(data);
return NULL;
}
data->key[0].modifier |= mod;
b = k+1;
}
/* get key */
ksym = XStringToKeysym(b);
if (ksym==NoSymbol) {
free(data);
return NULL;
}
data->key[0].keycode = XKeysymToKeycode(dpy, ksym);
if (data->key[0].keycode==0) {
free(data);
return NULL;
}
data->screen = scr;
data->key_no = 1;
return data;
}
static WUserMenuData* static WUserMenuData*
convertShortcuts(WScreen *scr, proplist_t shortcut){ convertShortcuts(WScreen *scr, proplist_t shortcut){
@@ -169,8 +121,14 @@ convertShortcuts(WScreen *scr, proplist_t shortcut){
else return NULL; else return NULL;
/*for (i=0;i<keycount;i++){*/ /*for (i=0;i<keycount;i++){*/
data = malloc(sizeof(WUserMenuData)); data = wmalloc(sizeof(WUserMenuData));
data->key = malloc(sizeof(WShortKey)*keycount); if (!data) return NULL;
data->key = wmalloc(sizeof(WShortKey)*keycount);
if (!data->key) {
free(data);
return NULL;
}
for (i=0,j=0;i<keycount;i++) { for (i=0,j=0;i<keycount;i++) {
data->key[j].modifier = 0; data->key[j].modifier = 0;
@@ -191,9 +149,6 @@ convertShortcuts(WScreen *scr, proplist_t shortcut){
data->key[j].modifier |= mod; data->key[j].modifier |= mod;
b = k+1; b = k+1;
} }
if (mod<0) {
continue;
}
ksym = XStringToKeysym(b); ksym = XStringToKeysym(b);
if (ksym==NoSymbol) { if (ksym==NoSymbol) {
@@ -210,8 +165,10 @@ keyover:
/* get key */ /* get key */
if (!j) { if (!j) {
puts("fatal j");
free(data->key); free(data->key);
free(data); free(data);
return NULL;
} }
data->key_no = j; data->key_no = j;
data->screen = scr; data->screen = scr;
@@ -228,8 +185,7 @@ configureUserMenu(WScreen *scr, proplist_t plum){
WUserMenuData *data; WUserMenuData *data;
if (!plum) return NULL; if (!plum) return NULL;
else if (!PLIsArray(plum)){ if (!PLIsArray(plum)){
PLRelease(plum);
return NULL; return NULL;
} }
@@ -253,7 +209,8 @@ configureUserMenu(WScreen *scr, proplist_t plum){
submenu = configureUserMenu(scr,elem); submenu = configureUserMenu(scr,elem);
if (submenu) if (submenu)
mentry = wMenuAddCallback(menu, submenu->frame->title,NULL,NULL); mentry = wMenuAddCallback(menu, submenu->frame->title,
NULL, NULL);
wMenuEntrySetCascade(menu, mentry, submenu); wMenuEntrySetCascade(menu, mentry, submenu);
} }
else { else {
@@ -270,14 +227,16 @@ configureUserMenu(WScreen *scr, proplist_t plum){
if (!strcmp("SHORTCUT",PLGetString(command))){ if (!strcmp("SHORTCUT",PLGetString(command))){
WMenuEntry *entry; WMenuEntry *entry;
data = convertShortcuts(scr, params); data = convertShortcuts(scr, params);
if (data){ if (data){
entry = wMenuAddCallback(menu, PLGetString(title), entry = wMenuAddCallback(menu, PLGetString(title),
notifyClient, data); notifyClient, data);
if (entry) {
if (PLIsString(params)) { if (PLIsString(params)) {
entry->rtext = GetShortcutString(PLGetString(params)); entry->rtext = GetShortcutString(PLGetString(params));
} }
if (entry) {
entry->free_cdata = removeUserMenudata; entry->free_cdata = removeUserMenudata;
if (PLGetNumberOfElements(elem) >= 4){ if (PLGetNumberOfElements(elem) >= 4){
@@ -291,7 +250,7 @@ configureUserMenu(WScreen *scr, proplist_t plum){
} }
} }
} }
/* else if */
} }
} }
@@ -342,13 +301,12 @@ wUserMenuRefreshInstances(WMenu *menu, WWindow *wwin)
static WMenu* static WMenu*
readUserMenuFile(WScreen *scr, char *file_name) readUserMenuFile(WScreen *scr, char *file_name)
{ {
WMenu *menu=NULL; WMenu *menu;
char *mtitle; char *mtitle;
proplist_t plum, elem, title, command, params; proplist_t plum, elem, title, command, params;
int count,i; int count,i;
menu=NULL;
plum = ReadProplistFromFile(file_name); plum = ReadProplistFromFile(file_name);
/**/ /**/
@@ -369,12 +327,13 @@ wUserMenuGet(WScreen *scr, WWindow *wwin){
prefix = getenv("HOME"); prefix = getenv("HOME");
if (!prefix) if (!prefix)
prefix = "."; prefix = ".";
menufile = malloc(strlen(prefix)+64); /* this file/path code will be replaced :D - ]d */
menufile = malloc(strlen(prefix)+128);
if (!menufile) return NULL; if (!menufile) return NULL;
if (wwin) { if (wwin) {
FILE *f; FILE *f;
sprintf(menufile, "%s/%s.%s.menu", sprintf(menufile, "%s/GNUstep/Library/WindowMaker/UserMenus/%s.%s.menu",
prefix, wwin->wm_instance, wwin->wm_class); prefix, wwin->wm_instance, wwin->wm_class);
f = fopen(menufile, "r"); f = fopen(menufile, "r");
if (f) { if (f) {

View File

@@ -207,6 +207,8 @@
/* /*
* Define DEMATERIALIZE_ICON if you want the undocked icon animation * Define DEMATERIALIZE_ICON if you want the undocked icon animation
* to be a progressive disaparison animation. * to be a progressive disaparison animation.
* This will cause all application icons to be created with Save Under
* enable.
*/ */
#undef DEMATERIALIZE_ICON #undef DEMATERIALIZE_ICON