void WMScreenMainLoop(WMScreen * scr) { XEvent event; while (1) { WMNextEvent(scr->display, &event); WMHandleEvent(&event); } }
static char* captureShortcut(Display *dpy, _Panel *panel) { XEvent ev; KeySym ksym; char buffer[64]; char *key = NULL; while (panel->capturing) { XAllowEvents(dpy, AsyncKeyboard, CurrentTime); WMNextEvent(dpy, &ev); if (ev.type==KeyPress && ev.xkey.keycode!=0) { ksym = XKeycodeToKeysym(dpy, ev.xkey.keycode, 0); if (!IsModifierKey(ksym)) { key=XKeysymToString(ksym); panel->capturing = 0; break; } } WMHandleEvent(&ev); } if (!key) return NULL; buffer[0] = 0; if (ev.xkey.state & ControlMask) { strcat(buffer, "Control+"); } if (ev.xkey.state & ShiftMask) { strcat(buffer, "Shift+"); } if (ev.xkey.state & Mod1Mask) { strcat(buffer, "Mod1+"); } if (ev.xkey.state & Mod2Mask) { strcat(buffer, "Mod2+"); } if (ev.xkey.state & Mod3Mask) { strcat(buffer, "Mod3+"); } if (ev.xkey.state & Mod4Mask) { strcat(buffer, "Mod4+"); } if (ev.xkey.state & Mod5Mask) { strcat(buffer, "Mod5+"); } strcat(buffer, key); return wstrdup(buffer); }
void W_DispatchMessage(W_View * target, XEvent * event) { if (target->window == None) return; event->xclient.window = target->window; event->xclient.display = target->screen->display; WMHandleEvent(event); /* XSendEvent(target->screen->display, target->window, False, SubstructureNotifyMask, event); */ }
void W_RedisplayView(W_View * view) { XEvent ev; if (!view->flags.mapped) return; ev.xexpose.type = Expose; ev.xexpose.display = view->screen->display; ev.xexpose.window = view->window; ev.xexpose.count = 0; ev.xexpose.serial = 0; WMHandleEvent(&ev); }
void ResetGame(void) { int i, x, y, ox, oy; MoveCount = 0; for (i = 0; i < Size*Size-1; i++) { Map[i] = i; } Map[i] = -1; ox = x = Size-1; oy = y = Size-1; for (i = 0; i < 5; i++) { int ok; ok = 1; switch (rand()%4) { case 0: if (x > 0) x--; else ok = 0; break; case 2: if (x < Size-1) x++; else ok = 0; break; case 1: if (y > 0) y--; else ok = 0; break; case 3: if (y < Size-1) y++; else ok = 0; break; } if (ok) { MoveButton(MAP(x,y), ox, oy); SWAP(MAP(ox, oy), MAP(x, y)); while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) { XEvent ev; WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev); WMHandleEvent(&ev); } ox = x; oy = y; } } }
void WMRunModalLoop(WMScreen * scr, WMView * view) { /* why is scr passed if is determined from the view? */ /*WMScreen *scr = view->screen; */ int oldModalLoop = scr->modalLoop; WMView *oldModalView = scr->modalView; scr->modalView = view; scr->modalLoop = 1; while (scr->modalLoop) { XEvent event; WMNextEvent(scr->display, &event); WMHandleEvent(&event); } scr->modalView = oldModalView; scr->modalLoop = oldModalLoop; }
void appIconMouseDown(WObjDescriptor *desc, XEvent *event) { WAppIcon *aicon = desc->parent; WIcon *icon = aicon->icon; XEvent ev; int x=aicon->x_pos, y=aicon->y_pos; int dx=event->xbutton.x, dy=event->xbutton.y; int grabbed=0; int done=0; int superfluous = wPreferences.superfluous; /* we catch it to avoid problems */ WScreen *scr = icon->core->screen_ptr; WWorkspace *workspace = scr->workspaces[scr->current_workspace]; int shad_x = 0, shad_y = 0, docking=0, dockable, collapsed = 0; int ix, iy; int clickButton = event->xbutton.button; Pixmap ghost = None; Window wins[2]; Bool movingSingle = False; int oldX = x; int oldY = y; Bool hasMoved = False; if (aicon->editing || WCHECK_STATE(WSTATE_MODAL)) return; if (IsDoubleClick(scr, event)) { iconDblClick(desc, event); return; } if (event->xbutton.button == Button3) { WObjDescriptor *desc; WApplication *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; } openApplicationMenu(wapp, event->xbutton.x_root, event->xbutton.y_root); /* allow drag select of menu */ desc = &scr->icon_menu->menu->descriptor; event->xbutton.send_event = True; (*desc->handle_mousedown)(desc, event); return; } #ifdef DEBUG puts("Moving icon"); #endif if (event->xbutton.state & MOD_MASK) wLowerFrame(icon->core); else wRaiseFrame(icon->core); if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask |ButtonReleaseMask|ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) !=GrabSuccess) { wwarning("pointer grab failed for appicon move"); } if (wPreferences.flags.nodock && wPreferences.flags.noclip) dockable = 0; else dockable = canBeDocked(icon->owner); wins[0] = icon->core->window; wins[1] = scr->dock_shadow; XRestackWindows(dpy, wins, 2); if (superfluous) { if (icon->pixmap!=None) ghost = MakeGhostIcon(scr, icon->pixmap); else ghost = MakeGhostIcon(scr, icon->core->window); XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, ghost); XClearWindow(dpy, scr->dock_shadow); } while (!done) { WMMaskEvent(dpy, PointerMotionMask|ButtonReleaseMask|ButtonPressMask |ButtonMotionMask|ExposureMask, &ev); switch (ev.type) { case Expose: WMHandleEvent(&ev); break; case MotionNotify: hasMoved = True; if (!grabbed) { if (abs(dx-ev.xmotion.x)>=MOVE_THRESHOLD || abs(dy-ev.xmotion.y)>=MOVE_THRESHOLD) { XChangeActivePointerGrab(dpy, ButtonMotionMask |ButtonReleaseMask|ButtonPressMask, wCursor[WCUR_MOVE], CurrentTime); grabbed=1; } else { break; } } x = ev.xmotion.x_root - dx; y = ev.xmotion.y_root - dy; if (movingSingle) { XMoveWindow(dpy, icon->core->window, x, y); } else { wAppIconMove(aicon, x, y); } if (dockable) { if (scr->dock && wDockSnapIcon(scr->dock, aicon, x, y, &ix, &iy, False)) { shad_x = scr->dock->x_pos + ix*wPreferences.icon_size; shad_y = scr->dock->y_pos + iy*wPreferences.icon_size; if (scr->last_dock != scr->dock && collapsed) { scr->last_dock->collapsed = 1; wDockHideIcons(scr->last_dock); collapsed = 0; } if (!collapsed && (collapsed = scr->dock->collapsed)) { scr->dock->collapsed = 0; wDockShowIcons(scr->dock); } if (scr->dock->auto_raise_lower) wDockRaise(scr->dock); scr->last_dock = scr->dock; XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); if (!docking) { XMapWindow(dpy, scr->dock_shadow); } docking = 1; } else if (workspace->clip && wDockSnapIcon(workspace->clip, aicon, x, y, &ix, &iy, False)) { shad_x = workspace->clip->x_pos + ix*wPreferences.icon_size; shad_y = workspace->clip->y_pos + iy*wPreferences.icon_size; if (scr->last_dock != workspace->clip && collapsed) { scr->last_dock->collapsed = 1; wDockHideIcons(scr->last_dock); collapsed = 0; } if (!collapsed && (collapsed = workspace->clip->collapsed)) { workspace->clip->collapsed = 0; wDockShowIcons(workspace->clip); } if (workspace->clip->auto_raise_lower) wDockRaise(workspace->clip); scr->last_dock = workspace->clip; XMoveWindow(dpy, scr->dock_shadow, shad_x, shad_y); if (!docking) { XMapWindow(dpy, scr->dock_shadow); } docking = 1; } else if (docking) { XUnmapWindow(dpy, scr->dock_shadow); docking = 0; } } break; case ButtonPress: break; case ButtonRelease: if (ev.xbutton.button != clickButton) break; XUngrabPointer(dpy, CurrentTime); if (docking) { Bool docked; /* icon is trying to be docked */ SlideWindow(icon->core->window, x, y, shad_x, shad_y); XUnmapWindow(dpy, scr->dock_shadow); docked = wDockAttachIcon(scr->last_dock, aicon, ix, iy); if (scr->last_dock->auto_collapse) { collapsed = 0; } if (workspace->clip && workspace->clip != scr->last_dock && workspace->clip->auto_raise_lower) wDockLower(workspace->clip); if (!docked) { /* If icon could not be docked, slide it back to the old * position */ SlideWindow(icon->core->window, x, y, oldX, oldY); } wSoundPlay(WSOUND_DOCK); } else { if (movingSingle) { /* move back to its place */ SlideWindow(icon->core->window, x, y, oldX, oldY); wAppIconMove(aicon, oldX, oldY); } else { XMoveWindow(dpy, icon->core->window, x, y); aicon->x_pos = x; aicon->y_pos = y; } if (workspace->clip && workspace->clip->auto_raise_lower) wDockLower(workspace->clip); } if (collapsed) { scr->last_dock->collapsed = 1; wDockHideIcons(scr->last_dock); collapsed = 0; } if (superfluous) { if (ghost!=None) XFreePixmap(dpy, ghost); XSetWindowBackground(dpy, scr->dock_shadow, scr->white_pixel); } if (wPreferences.auto_arrange_icons) wArrangeIcons(scr, True); if (wPreferences.single_click && !hasMoved) iconDblClick(desc, event); done = 1; break; } } #ifdef DEBUG puts("End icon move"); #endif }
int main(int argc, char **argv) { Display *dpy; WMScreen *scr; char *path; int i; char *display_name = ""; wsetabort(wAbort); memset(DeadHandlers, 0, sizeof(DeadHandlers)); WMInitializeApplication("WPrefs", &argc, argv); WMSetResourcePath(RESOURCE_PATH); path = WMPathForResourceOfType("WPrefs.tiff", NULL); if (!path) { /* maybe it is run directly from the source directory */ WMSetResourcePath("."); path = WMPathForResourceOfType("WPrefs.tiff", NULL); if (!path) { WMSetResourcePath(".."); } } if (path) { wfree(path); } if (argc > 1) { for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) { printf("WPrefs (Window Maker) %s\n", VERSION); exit(0); } else if (strcmp(argv[i], "-display") == 0) { i++; if (i >= argc) { wwarning(_("too few arguments for %s"), argv[i - 1]); exit(0); } display_name = argv[i]; } else { print_help(argv[0]); exit(0); } } } setlocale(LC_ALL, ""); #ifdef I18N if (getenv("NLSPATH")) bindtextdomain("WPrefs", getenv("NLSPATH")); else bindtextdomain("WPrefs", LOCALEDIR); bind_textdomain_codeset("WPrefs", "UTF-8"); textdomain("WPrefs"); if (!XSupportsLocale()) { wwarning(_("X server does not support locale")); } if (XSetLocaleModifiers("") == NULL) { wwarning(_("cannot set locale modifiers")); } #endif dpy = XOpenDisplay(display_name); if (!dpy) { wfatal(_("could not open display %s"), XDisplayName(display_name)); exit(0); } #if 0 XSynchronize(dpy, 1); #endif scr = WMCreateScreen(dpy, DefaultScreen(dpy)); if (!scr) { wfatal(_("could not initialize application")); exit(0); } xext_xkb_supported = XkbQueryExtension(dpy, NULL, NULL, NULL, NULL, NULL); WMPLSetCaseSensitive(False); Initialize(scr); while (1) { XEvent event; WMNextEvent(dpy, &event); while (DeadChildrenCount-- > 0) { int i; for (i = 0; i < MAX_DEATHS; i++) { if (DeadChildren[i] == DeadHandlers[i].pid) { (*DeadHandlers[i].handler) (DeadHandlers[i].data); DeadHandlers[i].pid = 0; } } } WMHandleEvent(&event); } }
void StartWindozeCycle(WWindow *wwin, XEvent *event, Bool next, Bool class_only) { WShortKey binding; WSwitchPanel *swpanel = NULL; WScreen *scr = wScreenForRootWindow(event->xkey.root); KeyCode leftKey = XKeysymToKeycode(dpy, XK_Left); KeyCode rightKey = XKeysymToKeycode(dpy, XK_Right); KeyCode homeKey = XKeysymToKeycode(dpy, XK_Home); KeyCode endKey = XKeysymToKeycode(dpy, XK_End); KeyCode shiftLKey = XKeysymToKeycode(dpy, XK_Shift_L); KeyCode shiftRKey = XKeysymToKeycode(dpy, XK_Shift_R); KeyCode escapeKey = XKeysymToKeycode(dpy, XK_Escape); KeyCode returnKey = XKeysymToKeycode(dpy, XK_Return); Bool esc_cancel = False; Bool somethingElse = False; Bool done = False; Bool hasModifier; int modifiers; WWindow *newFocused; WWindow *oldFocused; XEvent ev; if (!wwin) return; if (next) { if (class_only) binding = wKeyBindings[WKBD_GROUPNEXT]; else binding = wKeyBindings[WKBD_FOCUSNEXT]; } else { if (class_only) binding = wKeyBindings[WKBD_GROUPPREV]; else binding = wKeyBindings[WKBD_FOCUSPREV]; } hasModifier = (binding.modifier != 0); if (hasModifier) XGrabKeyboard(dpy, scr->root_win, False, GrabModeAsync, GrabModeAsync, CurrentTime); scr->flags.doing_alt_tab = 1; swpanel = wInitSwitchPanel(scr, wwin, class_only); oldFocused = wwin; if (swpanel) { if (wwin->flags.mapped && !wPreferences.panel_only_open) newFocused = wSwitchPanelSelectNext(swpanel, !next, True, False); else newFocused = wSwitchPanelSelectFirst(swpanel, False); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else { if (wwin->frame->workspace == w_global.workspace.current) newFocused = wwin; else newFocused = NULL; } while (hasModifier && !done) { WMMaskEvent(dpy, KeyPressMask | KeyReleaseMask | ExposureMask | PointerMotionMask | ButtonReleaseMask | EnterWindowMask, &ev); /* ignore CapsLock */ modifiers = ev.xkey.state & w_global.shortcut.modifiers_mask; if (!swpanel) break; switch (ev.type) { case KeyPress: if ((wKeyBindings[WKBD_FOCUSNEXT].keycode == ev.xkey.keycode && wKeyBindings[WKBD_FOCUSNEXT].modifier == modifiers) || (wKeyBindings[WKBD_GROUPNEXT].keycode == ev.xkey.keycode && wKeyBindings[WKBD_GROUPNEXT].modifier == modifiers) || ev.xkey.keycode == rightKey) { newFocused = wSwitchPanelSelectNext(swpanel, False, ev.xkey.keycode != rightKey, (!class_only && wKeyBindings[WKBD_GROUPNEXT].keycode == ev.xkey.keycode && wKeyBindings[WKBD_GROUPNEXT].modifier == modifiers)); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if ((wKeyBindings[WKBD_FOCUSPREV].keycode == ev.xkey.keycode && wKeyBindings[WKBD_FOCUSPREV].modifier == modifiers) || (wKeyBindings[WKBD_GROUPPREV].keycode == ev.xkey.keycode && wKeyBindings[WKBD_GROUPPREV].modifier == modifiers) || ev.xkey.keycode == leftKey) { newFocused = wSwitchPanelSelectNext(swpanel, True, ev.xkey.keycode != leftKey, (!class_only && wKeyBindings[WKBD_GROUPPREV].keycode == ev.xkey.keycode && wKeyBindings[WKBD_GROUPPREV].modifier == modifiers)); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if (ev.xkey.keycode == homeKey || ev.xkey.keycode == endKey) { newFocused = wSwitchPanelSelectFirst(swpanel, ev.xkey.keycode != homeKey); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); } else if (ev.xkey.keycode == escapeKey) { /* Focus the first window of the swpanel, despite the 'False' */ newFocused = wSwitchPanelSelectFirst(swpanel, False); oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, True); esc_cancel = True; done = True; } else if (ev.xkey.keycode == returnKey) { /* Close the switchpanel without eating the keypress */ done = True; } else if (ev.xkey.keycode != shiftLKey && ev.xkey.keycode != shiftRKey) { somethingElse = True; done = True; } break; case KeyRelease: if (ev.xkey.keycode == shiftLKey || ev.xkey.keycode == shiftRKey) if (wPreferences.strict_windoze_cycle) break; if (ev.xkey.keycode == leftKey || ev.xkey.keycode == rightKey) break; if (ev.xkey.keycode == XK_Return) break; if (ev.xkey.keycode != binding.keycode) done = True; break; case EnterNotify: /* ignore unwanted EnterNotify's */ break; case LeaveNotify: case MotionNotify: case ButtonRelease: { WWindow *tmp; tmp = wSwitchPanelHandleEvent(swpanel, &ev); if (tmp) { newFocused = tmp; oldFocused = change_focus_and_raise(newFocused, oldFocused, swpanel, scr, False); if (ev.type == ButtonRelease) done = True; } } break; default: WMHandleEvent(&ev); break; } } if (hasModifier) XUngrabKeyboard(dpy, CurrentTime); if (swpanel) wSwitchPanelDestroy(swpanel); if (newFocused && !esc_cancel) { wRaiseFrame(newFocused->frame->core); CommitStacking(scr); if (!newFocused->flags.mapped) wMakeWindowVisible(newFocused); wSetFocusTo(scr, newFocused); } scr->flags.doing_alt_tab = 0; if (somethingElse) WMHandleEvent(&ev); }
static void dragDivider(WMSplitView * sPtr, int clickX, int clickY) { int divider, pos, ofs, done, dragging; int i, count; XEvent ev; WMScreen *scr; int minCoord, maxCoord, coord; if (sPtr->constrainProc) { updateConstraints(sPtr); checkSizes(sPtr); distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr)); checkPositions(sPtr); updateSubviewsGeom(sPtr); } scr = sPtr->view->screen; divider = ofs = pos = done = 0; coord = (sPtr->flags.vertical) ? clickX : clickY; count = _GetSubviewsCount(); if (count < 2) return; for (i = 0; i < count - 1; i++) { pos += _GetSizeAt(i) + DIVIDER_THICKNESS; if (coord < pos) { ofs = coord - pos + DIVIDER_THICKNESS; done = 1; break; } divider++; } if (!done) return; getMinMaxDividerCoord(sPtr, divider, &minCoord, &maxCoord); done = 0; dragging = 0; while (!done) { WMMaskEvent(scr->display, ButtonMotionMask | ButtonReleaseMask | ExposureMask, &ev); coord = (sPtr->flags.vertical) ? ev.xmotion.x : ev.xmotion.y; switch (ev.type) { case ButtonRelease: done = 1; if (dragging) drawDragingRectangle(sPtr, pos); break; case MotionNotify: if (dragging) drawDragingRectangle(sPtr, pos); if (coord - ofs < minCoord) pos = minCoord; else if (coord - ofs > maxCoord) pos = maxCoord; else pos = coord - ofs; drawDragingRectangle(sPtr, pos); dragging = 1; break; default: WMHandleEvent(&ev); break; } } if (dragging) { W_SplitViewSubview *p1, *p2; int totSize; p1 = _GetPSubviewStructAt(divider); p2 = _GetPSubviewStructAt(divider + 1); totSize = p1->size + DIVIDER_THICKNESS + p2->size; p1->size = pos - p1->pos; p2->size = totSize - p1->size - DIVIDER_THICKNESS; p2->pos = p1->pos + p1->size + DIVIDER_THICKNESS; resizeView(sPtr, p1->view, p1->size); moveView(sPtr, p2->view, p2->pos); resizeView(sPtr, p2->view, p2->size); sPtr->flags.subviewsWereManuallyMoved = 1; } }
Bool wHandleAppIconMove(WAppIcon *aicon, XEvent *event) { WIcon *icon = aicon->icon; virtual_screen *vscr = aicon->icon->vscr; WScreen *scr = vscr->screen_ptr; WDock *originalDock = aicon->dock; /* can be NULL */ WDock *lastDock = originalDock; WDock *allDocks[vscr->drawer.drawer_count + 2]; /* clip, dock and drawers (order determined at runtime) */ WDrawerChain *dc; Bool dockable = True; Bool ondock = True; Bool grabbed = False; Bool collapsed = False; /* Stores the collapsed state of lastDock, before the moving appicon entered it */ int superfluous = wPreferences.superfluous; /* we cache it to avoid problems */ int omnipresent = aicon->omnipresent; /* this must be cached */ Bool showed_all_clips = False; int clickButton = event->xbutton.button; Pixmap ghost = None; Window wins[2]; /* Managing shadow window */ XEvent ev; int x = aicon->x_pos, y = aicon->y_pos; int ofs_x = event->xbutton.x, ofs_y = event->xbutton.y; int shad_x = x, shad_y = y; int ix = aicon->xindex, iy = aicon->yindex; int i; int oldX = x; int oldY = y; Bool hasMoved = False; if (wPreferences.flags.noupdates && originalDock != NULL) return False; if (event->xbutton.state & MOD_MASK) { /* * If Mod is pressed for an docked appicon, * assume it is to undock it,so don't lower it */ if (originalDock == NULL) wLowerFrame(icon->vscr, icon->core); } else { wRaiseFrame(icon->vscr, icon->core); } if (XGrabPointer(dpy, icon->core->window, True, ButtonMotionMask | ButtonReleaseMask | ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) wwarning("Pointer grab failed in wHandleAppIconMove"); if (originalDock == NULL) { ondock = False; if (wPreferences.flags.nodock && wPreferences.flags.noclip && wPreferences.flags.nodrawer) dockable = False; else dockable = canBeDocked(icon->owner); } /* * We try the various docks in that order: * - First, the dock the appicon comes from, if any * - Then, the drawers * - Then, the "dock" (WM_DOCK) * - Finally, the clip */ i = 0; if (originalDock != NULL) allDocks[i++] = originalDock; /* Testing vscr->drawers is enough, no need to test wPreferences.flags.nodrawer */ for (dc = vscr->drawer.drawers; dc != NULL; dc = dc->next) if (dc->adrawer != originalDock) allDocks[i++] = dc->adrawer; if (!wPreferences.flags.nodock && vscr->dock.dock != originalDock) allDocks[i++] = vscr->dock.dock; if (!wPreferences.flags.noclip && originalDock != vscr->workspace.array[vscr->workspace.current]->clip) allDocks[i++] = vscr->workspace.array[vscr->workspace.current]->clip; /* In case the clip, the dock, or both, are disabled */ for ( ; i < vscr->drawer.drawer_count + 2; i++) allDocks[i] = NULL; wins[0] = icon->core->window; wins[1] = scr->dock_shadow; XRestackWindows(dpy, wins, 2); XMoveResizeWindow(dpy, scr->dock_shadow, aicon->x_pos, aicon->y_pos, ICON_SIZE, ICON_SIZE); if (superfluous) { if (icon->pixmap != None) ghost = MakeGhostIcon(vscr, icon->pixmap); else ghost = MakeGhostIcon(vscr, icon->core->window); XSetWindowBackgroundPixmap(dpy, scr->dock_shadow, ghost); XClearWindow(dpy, scr->dock_shadow); } if (ondock) XMapWindow(dpy, scr->dock_shadow); while (1) { WMMaskEvent(dpy, PointerMotionMask | ButtonReleaseMask | ButtonPressMask | ButtonMotionMask | ExposureMask | EnterWindowMask, &ev); switch (ev.type) { case Expose: WMHandleEvent(&ev); break; case EnterNotify: /* * It means the cursor moved so fast that it entered * something else (if moving slowly, it would have * stayed in the appIcon that is being moved. Ignore * such "spurious" EnterNotifiy's */ break; case MotionNotify: hasMoved = True; appicon_move_motion(vscr, scr, ev, &lastDock, &originalDock, aicon, allDocks, &collapsed, &dockable, &ondock, &x, &y, &ix, &iy, &shad_x, &shad_y, &ofs_x, &ofs_y, &grabbed, omnipresent, &showed_all_clips); break; case ButtonPress: break; case ButtonRelease: if (ev.xbutton.button != clickButton) break; appicon_move_button_release(originalDock, lastDock, aicon, icon, x, y, oldX, oldY, shad_x, shad_y, ix, iy, &collapsed, ondock, ghost, showed_all_clips); return hasMoved; } } }
/* *----------------------------------------------------------------------- * manageAllWindows-- * Manages all windows in the screen. * * Notes: * Called when the wm is being started. * No events can be processed while the windows are being * reparented/managed. *----------------------------------------------------------------------- */ static void manageAllWindows(WScreen * scr, int crashRecovery) { Window root, parent; Window *children; unsigned int nchildren; unsigned int i, j; WWindow *wwin; XGrabServer(dpy); XQueryTree(dpy, scr->root_win, &root, &parent, &children, &nchildren); scr->flags.startup = 1; /* first remove all icon windows */ for (i = 0; i < nchildren; i++) { XWMHints *wmhints; if (children[i] == None) continue; wmhints = XGetWMHints(dpy, children[i]); if (wmhints && (wmhints->flags & IconWindowHint)) { for (j = 0; j < nchildren; j++) { if (children[j] == wmhints->icon_window) { XFree(wmhints); wmhints = NULL; children[j] = None; break; } } } if (wmhints) { XFree(wmhints); } } for (i = 0; i < nchildren; i++) { if (children[i] == None) continue; wwin = wManageWindow(scr, children[i]); if (wwin) { /* apply states got from WSavedState */ /* shaded + minimized is not restored correctly */ if (wwin->flags.shaded) { wwin->flags.shaded = 0; wShadeWindow(wwin); } if (wwin->flags.miniaturized && (wwin->transient_for == None || wwin->transient_for == scr->root_win || !windowInList(wwin->transient_for, children, nchildren))) { wwin->flags.skip_next_animation = 1; wwin->flags.miniaturized = 0; wIconifyWindow(wwin); } else { wClientSetState(wwin, NormalState, None); } if (crashRecovery) { int border; border = (!HAS_BORDER(wwin) ? 0 : scr->frame_border_width); wWindowMove(wwin, wwin->frame_x - border, wwin->frame_y - border - (wwin->frame->titlebar ? wwin->frame->titlebar->height : 0)); } } } XUngrabServer(dpy); /* hide apps */ wwin = scr->focused_window; while (wwin) { if (wwin->flags.hidden) { WApplication *wapp = wApplicationOf(wwin->main_window); if (wapp) { wwin->flags.hidden = 0; wHideApplication(wapp); } else { wwin->flags.hidden = 0; } } wwin = wwin->prev; } XFree(children); scr->flags.startup = 0; scr->flags.startup2 = 1; while (XPending(dpy)) { XEvent ev; WMNextEvent(dpy, &ev); WMHandleEvent(&ev); } w_global.workspace.last_used = 0; wWorkspaceForceChange(scr, 0); if (!wPreferences.flags.noclip) wDockShowIcons(w_global.workspace.array[w_global.workspace.current]->clip); scr->flags.startup2 = 0; }