Esempio n. 1
0
Window
ExtInitWinCreate(void)
{
   Ecore_X_Window      win_ex;	/* Hmmm.. */
   Window              win;
   Atom                a;

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinCreate\n");

   a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
   ESync(0);

   if (fork())
     {
	/* Parent */
	EUngrabServer();

	for (;;)
	  {
	     if (EDebug(EDBUG_TYPE_SESSION))
		Eprintf("ExtInitWinCreate - parent\n");

	     /* Hack to give the child some space. Not foolproof. */
	     sleep(1);

	     if (ecore_x_window_prop_window_get
		 (WinGetXwin(VROOT), a, &win_ex, 1) > 0)
		break;
	  }

	win = win_ex;
	if (EDebug(EDBUG_TYPE_SESSION))
	   Eprintf("ExtInitWinCreate - parent - %#lx\n", win);

	return win;
     }

   /* Child - Create the init window */

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinCreate - child\n");

   /* Clean up inherited stuff */

   SignalsRestore();

   EImageExit(0);
   EDisplayDisconnect();

   ExtInitWinMain();

   /* We will never get here */
   return None;
}
Esempio n. 2
0
int
main(int argc, char **argv)
{
    int                 ch, i, loop;
    struct utsname      ubuf;
    const char         *str, *dstr;

    /* This function runs all the setup for startup, and then
     * proceeds into the primary event loop at the end.
     */

    /* Init state variable struct */
    memset(&Mode, 0, sizeof(EMode));

    Mode.wm.master = 1;
    Mode.wm.pid = getpid();
    Mode.wm.exec_name = argv[0];
    Mode.wm.startup = 1;

    Mode.mode = MODE_NONE;

    EXInit();
    Dpy.screen = -1;

    str = getenv("EDEBUG");
    if (str)
        EDebugInit(str);
    str = getenv("EDEBUG_COREDUMP");
    if (str)
        Mode.wm.coredump = 1;
    str = getenv("EDEBUG_EXIT");
    if (str)
        Mode.debug_exit = atoi(str);

    str = getenv("ECONFNAME");
    if (str)
        EConfNameSet(str);
    str = getenv("ECONFDIR");
    if (str)
        EDirUserSet(str);
    str = getenv("ECACHEDIR");
    if (str)
        EDirUserCacheSet(str);

    srand((unsigned int)time(NULL));

    if (!uname(&ubuf))
        Mode.wm.machine_name = Estrdup(ubuf.nodename);
    if (!Mode.wm.machine_name)
        Mode.wm.machine_name = Estrdup("localhost");

    /* Now we're going to interpret any of the commandline parameters
     * that are passed to it -- Well, at least the ones that we
     * understand.
     */

    Mode.theme.path = NULL;
    dstr = NULL;

    for (loop = 1; loop;)
    {
        ch = EoptGet(argc, argv);
        if (ch <= 0)
            break;
#if 0
        Eprintf("Opt: %c: %d - %s\n", ch, eoptind, eoptarg);
#endif
        switch (ch)
        {
        default:
        case '?':
            printf("e16: Ignoring: ");
            for (i = eoptind; i < argc; i++)
                printf("%s ", argv[i]);
            printf("\n");
            loop = 0;
            break;
        case 'h':
            EoptHelp();
            exit(0);
            break;
        case 'd':
            dstr = eoptarg;
            break;
        case 'f':
            Mode.wm.restart = 1;
            break;
        case 'p':
            EConfNameSet(eoptarg);
            break;
        case 'P':
            EDirUserSet(eoptarg);
            break;
        case 'Q':
            EDirUserCacheSet(eoptarg);
            break;
        case 's':
            Mode.wm.single = 1;
            Dpy.screen = strtoul(eoptarg, NULL, 10);
            break;
        case 'S':
            SetSMID(eoptarg);
            break;
        case 't':
            Mode.theme.path = Estrdup(eoptarg);
            break;
        case 'V':
            printf("%s %s\n", e_wm_name, e_wm_version);
            exit(0);
            break;
        case 'v':
            EDebugSet(EDBUG_TYPE_VERBOSE, 1);
            break;
        case 'w':
            sscanf(eoptarg, "%dx%d", &Mode.wm.win_w, &Mode.wm.win_h);
            Mode.wm.window = 1;
            Mode.wm.single = 1;
            Mode.wm.master = 0;
            break;
#ifdef USE_EXT_INIT_WIN
        case 'X':
            ExtInitWinSet(strtoul(eoptarg, NULL, 0));
            Mode.wm.restart = 1;
            break;
#endif
        case 'm':
            Mode.wm.master = 0;
            Mode.wm.master_screen = strtoul(eoptarg, NULL, 10);
            break;
        }
    }

    SignalsSetup();		/* Install signal handlers */

    EDirsSetup();
    ECheckEprog("epp");
    ECheckEprog("eesh");

    SetupX(dstr);		/* This is where the we fork per screen */
    /* X is now running, and we have forked per screen */

    ESavePrefixSetup();

    /* So far nothing should rely on a selected settings or theme. */
    ConfigurationLoad();		/* Load settings */

    /* Initialise internationalisation */
    LangInit();

    /* The theme path must now be available for config file loading. */
    ThemePathFind();

    /* Set the Environment variables */
    Esetenv("EVERSION", e_wm_version);
    Esetenv("EROOT", EDirRoot());
    Esetenv("EBIN", EDirBin());
    Esetenv("ECONFDIR", EDirUser());
    Esetenv("ECACHEDIR", EDirUserCache());
    Esetenv("ETHEME", Mode.theme.path);

    /* Move elsewhere? */
    EImageInit();
    HintsInit();
    CommsInit();
    SessionInit();
    SnapshotsLoad();

#if USE_DBUS
    DbusInit();
#endif

    if (Mode.wm.window)
        EMapWindow(VROOT);

    ModulesSignal(ESIGNAL_INIT, NULL);

    /* Load the theme */
    ThemeConfigLoad();

    if (Mode.debug_exit)
        return 0;

    /* Do initial configuration */
    ModulesSignal(ESIGNAL_CONFIGURE, NULL);

    /* Set root window cursor */
    ECsrApply(ECSR_ROOT, WinGetXwin(VROOT));

#ifdef USE_EXT_INIT_WIN
    /* Kill the E process owning the "init window" */
    ExtInitWinKill();
#endif

    /* let's make sure we set this up and go to our desk anyways */
    DeskGoto(DesksGetCurrent());
    ESync(ESYNC_MAIN);

#ifdef SIGCONT
    for (i = 0; i < Mode.wm.child_count; i++)
        kill(Mode.wm.children[i], SIGCONT);
#endif

    ModulesSignal(ESIGNAL_START, NULL);
#if ENABLE_DIALOGS
    DialogsInit();
#endif
    EwinsManage();

    RunInitPrograms();
    SnapshotsSpawn();

    if (!Mode.wm.restart)
        StartupWindowsOpen();

    Conf.startup.firsttime = 0;
    Mode.wm.save_ok = Conf.autosave;
    Mode.wm.startup = 0;
    autosave();

    /* The primary event loop */
    EventsMain();

    SessionExit(EEXIT_QUIT, NULL);

    return 0;
}
Esempio n. 3
0
/*
 * This function sets up all of our connections to X
 */
void
SetupX(const char *dstr)
{
   int                 err;
   char                buf[128];
   unsigned int        mask;

   if (!dstr)
      dstr = getenv("DISPLAY");
   if (!dstr)
      dstr = ":0.0";

   /* Open a connection to the diplay nominated by the DISPLAY variable */
   err = EDisplayOpen(dstr, Dpy.screen);
   if (err)
     {
	Alert(_("Enlightenment cannot connect to the display nominated by\n"
		"your shell's DISPLAY environment variable. You may set this\n"
		"variable to indicate which display name Enlightenment is to\n"
		"connect to. It may be that you do not have an Xserver already\n"
		"running to serve that Display connection, or that you do not\n"
		"have permission to connect to that display. Please make sure\n"
		"all is correct before trying again. Run an Xserver by running\n"
		"xdm or startx first, or contact your local system\n"
		"administrator, or Xserver vendor, or read the X, xdm and\n"
		"startx manual pages before proceeding.\n"));
	EExit(1);
     }

   if (getenv("ESYNCHRONIZE"))
      XSynchronize(disp, True);

   Dpy.screens = ScreenCount(disp);
   Dpy.screen = DefaultScreen(disp);

   if (Mode.wm.master ||
       Mode.wm.master_screen < 0 || Mode.wm.master_screen >= Dpy.screens)
      Mode.wm.master_screen = Dpy.screen;

   /* Start up on multiple heads, if appropriate */
   if (Dpy.screens > 1 && !Mode.wm.single && !Mode.wm.restart)
     {
	int                 i;

	for (i = 0; i < Dpy.screens; i++)
	  {
	     pid_t               pid;

	     if (i == Dpy.screen)
		continue;

	     pid = fork();
	     if (pid)
	       {
		  /* We are the master */
		  Mode.wm.child_count++;
		  Mode.wm.children =
		     EREALLOC(pid_t, Mode.wm.children, Mode.wm.child_count);
		  Mode.wm.children[Mode.wm.child_count - 1] = pid;
	       }
	     else
	       {
		  /* We are a slave */
		  EDisplayDisconnect();
		  Mode.wm.master = 0;
		  Mode.wm.pid = getpid();
		  Dpy.screen = i;
		  ExtInitWinSet(NoXID);
#ifdef SIGSTOP
		  kill(getpid(), SIGSTOP);
#endif
		  EDisplayOpen(dstr, i);
		  /* Terminate the loop as I am the child process... */
		  break;
	       }
	  }
     }

   Dpy.name = Estrdup(DisplayString(disp));
   Esetenv("DISPLAY", Dpy.name);

   Dpy.pixel_black = BlackPixel(disp, Dpy.screen);
   Dpy.pixel_white = WhitePixel(disp, Dpy.screen);

   EDisplaySetErrorHandlers(EventShowError, HandleXIOError);

   /* Root defaults */
   RROOT = ERegisterWindow(DefaultRootWindow(disp), NULL);

   if (Mode.wm.window)
     {
	VROOT = ECreateWindow(RROOT, 0, 0, Mode.wm.win_w, Mode.wm.win_h, 0);

	/* Enable eesh and edox to pick up the virtual root */
	Esnprintf(buf, sizeof(buf), "%#x", WinGetXwin(VROOT));
	Esetenv("ENL_WM_ROOT", buf);
     }
   else
     {
	/* Running E normally on the root window */
	VROOT = RROOT;
     }

   Dpy.root_gc = EXCreateGC(WinGetXwin(VROOT), 0, NULL);

   /* Initialise event handling */
   EventsInit();

   /* select all the root window events to start managing */
   Dpy.last_error_code = 0;
   mask =
      StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Another Window Manager is already running"),
	       _("OK"), NULL, NULL,
	       _("Another Window Manager is already running.\n" "\n"
		 "You will have to quit your current Window Manager first before\n"
		 "you can successfully run Enlightenment.\n"));
	EExit(1);
     }

   mask |= ButtonPressMask | ButtonReleaseMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Cannot select root window button press events"),
	       _("OK"), NULL, NULL,
	       _("Root window button actions will not work.\n"));
     }

   /* warn, if necessary about X version problems */
   if (ProtocolVersion(disp) != 11)
     {
	AlertX(_("X server version error"), _("Ignore this error"), "",
	       _("Quit Enlightenment"),
	       _("WARNING:\n"
		 "This is not an X11 Xserver. It in fact talks the X%i protocol.\n"
		 "This may mean Enlightenment will either not function, or\n"
		 "function incorrectly. If it is later than X11, then your\n"
		 "server is one the author of Enlightenment neither have\n"
		 "access to, nor have heard of.\n"), ProtocolVersion(disp));
     }

   /* damn that bloody numlock stuff - ok I'd rather XFree got fixed to not */
   /* have it as a modifier and everyone have to write specific code to mask */
   /* it out - but well.... */
   /* ok under Xfree Numlock and Scollock are lock modifiers and we need */
   /* to hunt them down to mask them out - EVIL EVIL EVIL hack but needed */
   {
      XModifierKeymap    *mod;
      EX_KeyCode          nl, sl;
      unsigned int        numlock, scrollock;
      int                 i;

      int                 masks[8] = {
	 ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
	 Mod4Mask, Mod5Mask
      };

      numlock = scrollock = 0;
      mod = XGetModifierMapping(disp);
      nl = EKeysymToKeycode(XK_Num_Lock);
      sl = EKeysymToKeycode(XK_Scroll_Lock);
      if ((mod) && (mod->max_keypermod > 0))
	{
	   for (i = 0; i < (8 * mod->max_keypermod); i++)
	     {
		if ((nl) && (mod->modifiermap[i] == nl))
		   numlock = masks[i / mod->max_keypermod];
		else if ((sl) && (mod->modifiermap[i] == sl))
		   scrollock = masks[i / mod->max_keypermod];
	     }
	}
      Mode.masks.mod_combos[0] = 0;
      Mode.masks.mod_combos[1] = LockMask;
      if (numlock)
	{
	   Mode.masks.mod_combos[2] = numlock;
	   Mode.masks.mod_combos[5] = LockMask | numlock;
	}
      if (scrollock)
	{
	   Mode.masks.mod_combos[3] = scrollock;
	   Mode.masks.mod_combos[6] = LockMask | scrollock;
	}
      if (numlock && scrollock)
	{
	   Mode.masks.mod_combos[4] = numlock | scrollock;
	   Mode.masks.mod_combos[7] = LockMask | numlock | scrollock;
	}

      Mode.masks.mod_key_mask =
	 (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask |
	  Mod5Mask) & (~(numlock | scrollock | LockMask));

      if (mod)
	 XFreeModifiermap(mod);
   }

   ScreenInit();
}
Esempio n. 4
0
static              Window
ExtInitWinMain(void)
{
   int                 i, loop, err;
   Ecore_X_Window      win;
   XGCValues           gcv;
   GC                  gc;
   Pixmap              pmap;
   Atom                a;
   EiwData             eiwd;
   EiwLoopFunc        *eiwc_loop_func;

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinMain enter\n");

   err = EDisplayOpen(NULL, -1);
   if (err)
      return None;

   EGrabServer();

   EImageInit();

   eiwd.attr.backing_store = NotUseful;
   eiwd.attr.override_redirect = True;
   eiwd.attr.colormap = WinGetCmap(VROOT);
   eiwd.attr.border_pixel = 0;
   eiwd.attr.background_pixel = 0;
   eiwd.attr.save_under = True;
   win = XCreateWindow(disp, WinGetXwin(VROOT),
		       0, 0, WinGetW(VROOT), WinGetH(VROOT),
		       0, CopyFromParent, InputOutput, CopyFromParent,
		       CWOverrideRedirect | CWSaveUnder | CWBackingStore |
		       CWColormap | CWBackPixel | CWBorderPixel, &eiwd.attr);

   pmap = XCreatePixmap(disp, win,
			WinGetW(VROOT), WinGetH(VROOT), WinGetDepth(VROOT));
   gcv.subwindow_mode = IncludeInferiors;
   gc = XCreateGC(disp, win, GCSubwindowMode, &gcv);
   XCopyArea(disp, WinGetXwin(VROOT), pmap, gc,
	     0, 0, WinGetW(VROOT), WinGetH(VROOT), 0, 0);
   XSetWindowBackgroundPixmap(disp, win, pmap);
   XMapRaised(disp, win);
   XFreePixmap(disp, pmap);
   XFreeGC(disp, gc);

   a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
   ecore_x_window_prop_window_set(WinGetXwin(VROOT), a, &win, 1);

   XSelectInput(disp, win, StructureNotifyMask);

   EUngrabServer();
   ESync(0);

#if USE_EIWC_WINDOW && USE_EIWC_RENDER
   eiwc_loop_func = _eiw_render_init(win, &eiwd);
   if (!eiwc_loop_func)
      eiwc_loop_func = _eiw_window_init(win, &eiwd);
#elif USE_EIWC_RENDER
   eiwc_loop_func = _eiw_render_init(win, &eiwd);
#elif USE_EIWC_WINDOW
   eiwc_loop_func = _eiw_window_init(win, &eiwd);
#endif
   if (!eiwc_loop_func)
      return None;

   {
      XWindowAttributes   xwa;
      char                s[1024];
      EImage             *im;

      for (i = loop = 1;; i++, loop++)
	{
	   if (i > 12)
	      i = 1;

	   /* If we get unmapped we are done */
	   XGetWindowAttributes(disp, win, &xwa);
	   if (xwa.map_state == IsUnmapped)
	      break;

	   Esnprintf(s, sizeof(s), "pix/wait%i.png", i);
	   if (EDebug(EDBUG_TYPE_SESSION) > 1)
	      Eprintf("ExtInitWinCreate - child %s\n", s);

	   im = ThemeImageLoad(s);
	   if (im)
	     {
		eiwc_loop_func(win, im, &eiwd);
		EImageFree(im);
	     }
	   ESync(0);
	   usleep(50000);

	   /* If we still are here after 5 sec something is wrong. */
	   if (loop > 100)
	      break;
	}
   }

   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("ExtInitWinMain exit\n");

   EDisplayClose();

   exit(0);
}
Esempio n. 5
0
File: events.c Progetto: Limsik/e17
static void
HandleEvent(XEvent * ev)
{
   Win                 win;

#if ENABLE_DEBUG_EVENTS
   if (EDebug(ev->type))
      EventShow(ev);
#endif

   win = ELookupXwin(ev->xany.window);

   switch (ev->type)
     {
     case KeyPress:
	Mode.events.last_keycode = ev->xkey.keycode;
	Mode.events.last_keystate = ev->xkey.state;
	/* FALLTHROUGH */
     case KeyRelease:
	Mode.events.time = ev->xkey.time;
	ModeGetXY(ev->xkey.x_root, ev->xkey.y_root);
#if 0				/* FIXME - Why? */
	if (ev->xkey.root != WinGetXwin(VROOT))
	  {
	     XSetInputFocus(disp, ev->xkey.root, RevertToPointerRoot,
			    CurrentTime);
	     ESync();
	     ev->xkey.time = CurrentTime;
	     EXSendEvent(ev->xkey.root, 0, ev);
	     return;
	  }
#endif
	Mode.events.on_screen = ev->xkey.same_screen;
	goto do_stuff;

     case ButtonPress:
     case ButtonRelease:
	Mode.events.time = ev->xbutton.time;
	ModeGetXY(ev->xbutton.x_root, ev->xbutton.y_root);
	Mode.events.on_screen = ev->xbutton.same_screen;
	TooltipsHide();
	goto do_stuff;

     case MotionNotify:
	Mode.events.time = ev->xmotion.time;
	Mode.events.px = Mode.events.mx;
	Mode.events.py = Mode.events.my;
	ModeGetXY(ev->xmotion.x_root, ev->xmotion.y_root);
	Mode.events.mx = Mode.events.cx;
	Mode.events.my = Mode.events.cy;
	Mode.events.on_screen = ev->xmotion.same_screen;
	break;

     case EnterNotify:
	Mode.context_win = win;
	Mode.events.time = ev->xcrossing.time;
	Mode.events.on_screen = ev->xcrossing.same_screen;
	if (ev->xcrossing.mode == NotifyGrab &&
	    ev->xcrossing.detail == NotifyInferior)
	  {
	     Mode.grabs.pointer_grab_window = ev->xany.window;
	     if (!Mode.grabs.pointer_grab_active)
		Mode.grabs.pointer_grab_active = 2;
	  }
	ModeGetXY(ev->xcrossing.x_root, ev->xcrossing.y_root);
	TooltipsHide();
	goto do_stuff;

     case LeaveNotify:
	Mode.events.time = ev->xcrossing.time;
	Mode.events.on_screen = ev->xcrossing.same_screen;
	if (ev->xcrossing.mode == NotifyGrab &&
	    ev->xcrossing.detail == NotifyInferior)
	  {
	     Mode.grabs.pointer_grab_window = None;
	     Mode.grabs.pointer_grab_active = 0;
	  }
	ModeGetXY(ev->xcrossing.x_root, ev->xcrossing.y_root);
	TooltipsHide();
	goto do_stuff;

     case PropertyNotify:
	Mode.events.time = ev->xproperty.time;
	break;

      do_stuff:
	if (ev->xany.window == WinGetXwin(VROOT))
	   ActionclassesGlobalEvent(ev);
	break;
     }

   switch (ev->type)
     {
     case KeyPress:		/*  2 */
     case KeyRelease:		/*  3 */
	/* Unfreeze keyboard in case we got here by keygrab */
	XAllowEvents(disp, AsyncKeyboard, CurrentTime);
	break;

     case ButtonPress:		/*  4 */
	SoundPlay(SOUND_BUTTON_CLICK);

	Mode.events.double_click =
	   ((ev->xbutton.time - Mode.events.last_btime < DOUBLE_CLICK_TIME) &&
	    ev->xbutton.button == Mode.events.last_button &&
	    ev->xbutton.window == Mode.events.last_bpress2);

	Mode.events.last_bpress = ev->xbutton.window;
	Mode.events.last_bpress2 = ev->xbutton.window;
	Mode.events.last_btime = ev->xbutton.time;
	Mode.events.last_button = ev->xbutton.button;
	break;
     case ButtonRelease:	/*  5 */
	SoundPlay(SOUND_BUTTON_RAISE);
	break;
     }

   /* The new event dispatcher */
   EventCallbacksProcess(win, ev);

   /* Post-event stuff TBD */
   switch (ev->type)
     {
     case ButtonRelease:	/*  5 */
	Mode.events.last_bpress = 0;
	break;

#if 1				/* Do this here? */
     case DestroyNotify:
	EUnregisterXwin(ev->xdestroywindow.window);
	break;
#endif

     case MappingNotify:
	XRefreshKeyboardMapping(&ev->xmapping);
	if (Conf.testing.bindings_reload)
	   ActionclassesReload();
	break;
     }
}
Esempio n. 6
0
static void
MenuShow(Menu * m, char noshow)
{
   EWin               *ewin;
   int                 x, y, w, h;
   int                 wx, wy, mw, mh;
   int                 head_num = 0;

   if (m->shown)
      return;

   if (MenuLoad(m) || m->redraw)
      MenuRealize(m);

   if (m->num <= 0)
      return;

   if (!m->win || !m->items[0]->win)
      MenuRealize(m);

   if (!m->style)
      return;

   ewin = m->ewin;
   if (ewin)
     {
#if 0				/* ??? */
	EwinRaise(ewin);
	EwinShow(ewin);
	return;
#else
	MenuHide(m);
#endif
     }

   EGetGeometry(m->items[0]->win, NULL, &x, &y, &w, &h, NULL, NULL);
   mw = m->w;
   mh = m->h;

   EQueryPointer(NULL, &wx, &wy, NULL, NULL);
   wx -= EoGetX(DesksGetCurrent()) + x + (w / 2);
   wy -= EoGetY(DesksGetCurrent()) + y + (h / 2);
   if (Conf.menus.onscreen)
     {
	Border             *b;

	b = BorderFind(m->style->border_name);
	if (b)
	  {
	     int                 sx, sy, sw, sh;

	     head_num = ScreenGetGeometryByPointer(&sx, &sy, &sw, &sh);

	     if (wx > sx + sw - mw - b->border.right)
		wx = sx + sw - mw - b->border.right;
	     if (wx < sx + b->border.left)
		wx = sx + b->border.left;

	     if (wy > sy + sh - mh - b->border.bottom)
		wy = sy + sh - mh - b->border.bottom;
	     if (wy < sy + b->border.top)
		wy = sy + b->border.top;
	  }
     }

   EMoveWindow(m->win, wx, wy);

   ewin = AddInternalToFamily(m->win, m->style->border_name, EWIN_TYPE_MENU,
			      &_MenuEwinOps, m);
   if (ewin)
     {
	ewin->client.event_mask |= KeyPressMask;
	ESelectInput(m->win, ewin->client.event_mask);

	ewin->head = head_num;

	EwinResize(ewin, ewin->client.w, ewin->client.h, 0);

	if (Conf.menus.animate)
	   EwinInstantShade(ewin, 0);

	if (!noshow)
	  {
	     ICCCM_Cmap(NULL);
	     EwinOpFloatAt(ewin, OPSRC_NA, EoGetX(ewin), EoGetY(ewin));
	     EwinShow(ewin);
	     if (Conf.menus.animate)
		EwinUnShade(ewin);
	  }
     }

   m->shown = 1;
   m->last_access = time(0);
   Mode_menus.just_shown = 1;

   if (!Mode_menus.first)
     {
	Mode_menus.context_ewin = GetContextEwin();
#if 0
	Eprintf("Mode_menus.context_ewin set %s\n",
		EwinGetTitle(Mode_menus.context_ewin));
#endif
	ESync(ESYNC_MENUS);
	Mode_menus.first = m;
	MenuShowMasker(m);
	TooltipsEnable(0);
	GrabKeyboardSet(m->win);
     }
   m->ref_count++;
}
Esempio n. 7
0
/* outstanding BUG: zooming on shaped windows leaves stuff exposed beneath them..... */
void
Zoom(EWin * ewin, int on)
{
   if (Mode.wm.window)
      return;

   if (!ewin)
      ewin = zoom_last_ewin;
   if (!ewin)
      return;

   if (zoom_can == 0)
      ZoomInit();

   if (zoom_can <= 0)
      return;

   Dprintf("%s: on=%d\n", __func__, on);
   if (!on)
     {
	/* Unzoom */

	if (ewin != zoom_last_ewin)
	   return;

	_ZoomEwinRestore(ewin);
	SwitchRes(0, 0, 0, 0, 0, NULL, NULL);
	zw = zh = 0;
	zoom_last_ewin = NULL;
     }
   else if (ewin == zoom_last_ewin)
     {
	/* Already zoomed */
	return;
     }
   else
     {
	/* Zoom */

	if (ewin->state.fullscreen)
	   return;

	if (!zoom_last_ewin)	/* first zoom */
	  {
	     on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h, &zw, &zh);
	  }
	else			/* we are zoomed in on another window already.... */
	  {
	     _ZoomEwinRestore(zoom_last_ewin);
	     if ((ewin->client.w <= zw) && (ewin->client.h <= zh) &&
		 ((ewin->client.w >= zw / 2) || (ewin->client.h >= zh / 2)))
	       {
		  /* YAY no need to change resolution :-D */
	       }
	     else
	       {
		  /* SwitchRes only tracks the LAST mode, so we have to switch back to
		   * the original mode before switching to new target mode
		   * so that we can restore the original vid mode when we zoom
		   * out of the last window ;( */
		  SwitchRes(0, 0, 0, 0, 0, NULL, NULL);
		  on = SwitchRes(1, 0, 0, ewin->client.w, ewin->client.h,
				 &zw, &zh);
	       }
	  }

	Dprintf("%s: SwitchRes=%d - client size %dx%d -> screen %dx%d\n",
		__func__, on, ewin->client.w, ewin->client.h, zw, zh);
	if (!on)
	   return;

	ewin->save_fs.x = EoGetX(ewin);
	ewin->save_fs.y = EoGetY(ewin);
	EwinRaise(ewin);
	EwinBorderSetTo(ewin, BorderCreateFiller(ewin->client.w,
						 ewin->client.h, zw, zh));
	EwinMoveResize(ewin, 0, 0, ewin->client.w, ewin->client.h, 0);
	ewin->state.zoomed = 1;
	FocusToEWin(ewin, FOCUS_SET);
	zoom_last_ewin = ewin;
     }

   EwinWarpTo(ewin, 1);
   ESync(0);
   EwinStateUpdate(ewin);
   HintsSetWindowState(ewin);
}
Esempio n. 8
0
File: iconify.c Progetto: Limsik/e17
static void
IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
{
   EWin               *fr, *to;
   unsigned int        t0;
   double              a, aa, spd;
   int                 x, y, x1, y1, x2, y2, x3, y3, x4, y4, w, h;
   int                 fx, fy, fw, fh, tx, ty, tw, th;
   Window              root = WinGetXwin(VROOT);
   GC                  gc;
   XGCValues           gcv;

   /* Window: Extents, Iconbox: Center */
   if (iconify)
     {
	fr = ewin;
	to = ibox;
	fw = EoGetW(fr) + 4;
	fh = EoGetH(fr) + 4;
	fx = EoGetX(fr) - 2;
	fy = EoGetY(fr) - 2;
	tw = 4;
	th = 4;
	tx = EoGetX(to) + EoGetW(to) / 2 - 2;
	ty = EoGetY(to) + EoGetH(to) / 2 - 2;
     }
   else
     {
	fr = ibox;
	to = ewin;
	fw = 4;
	fh = 4;
	fx = EoGetX(fr) + EoGetW(fr) / 2 - 2;
	fy = EoGetY(fr) + EoGetH(fr) / 2 - 2;
	tw = EoGetW(to) + 4;
	th = EoGetH(to) + 4;
	tx = EoGetX(to) + 2;
	ty = EoGetY(to) + 2;
     }
   fx += EoGetX(EoGetDesk(fr));
   fy += EoGetY(EoGetDesk(fr));
   tx += EoGetX(EoGetDesk(to));
   ty += EoGetY(EoGetDesk(to));

   gcv.subwindow_mode = IncludeInferiors;
   gcv.function = GXxor;
   gcv.line_width = 2;
   gcv.foreground = Dpy.pixel_white;
   if (gcv.foreground == 0)
      gcv.foreground = Dpy.pixel_black;
   gc = EXCreateGC(root,
		   GCFunction | GCForeground | GCSubwindowMode | GCLineWidth,
		   &gcv);

   spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;

   t0 = GetTimeMs();
   for (a = 0.0; a < 1.0; a += spd)
     {
	aa = 1.0 - a;

	x = (int)((fx * aa) + (tx * a));
	y = (int)((fy * aa) + (ty * a));
	w = (int)((fw * aa) + (tw * a));
	h = (int)((fh * aa) + (th * a));

	x = (2 * x + w) / 2;	/* x middle */
	y = (2 * y + h) / 2;	/* y middle */
	w /= 2;			/* width/2 */
	h /= 2;			/* height/2 */

	x1 = (int)(x + w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
	y1 = (int)(y + h * cos(a * 6.2831853072));
	x2 = (int)(x + w * (1 - .5 * sin(a * 6.2831853072)));
	y2 = (int)(y - h * cos(a * 6.2831853072));
	x3 = (int)(x - w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
	y3 = (int)(y - h * cos(a * 6.2831853072));
	x4 = (int)(x - w * (1 - .5 * sin(a * 6.2831853072)));
	y4 = (int)(y + h * cos(a * 6.2831853072));

	XDrawLine(disp, root, gc, x1, y1, x2, y2);
	XDrawLine(disp, root, gc, x2, y2, x3, y3);
	XDrawLine(disp, root, gc, x3, y3, x4, y4);
	XDrawLine(disp, root, gc, x4, y4, x1, y1);

	ESync(0);
	IB_Animate_Sleep(t0, a);

	XDrawLine(disp, root, gc, x1, y1, x2, y2);
	XDrawLine(disp, root, gc, x2, y2, x3, y3);
	XDrawLine(disp, root, gc, x3, y3, x4, y4);
	XDrawLine(disp, root, gc, x4, y4, x1, y1);
     }

   EXFreeGC(gc);
}
Esempio n. 9
0
File: iconify.c Progetto: Limsik/e17
static void
IB_Animate_B(char iconify, EWin * ewin, EWin * ibox)
{
   EWin               *fr, *to;
   unsigned int        t0;
   double              a, spd;
   int                 x, y, w, h;
   int                 fx, fy, fw, fh, tx, ty, tw, th;
   Window              root = WinGetXwin(VROOT);
   GC                  gc;
   XGCValues           gcv;

   if (iconify)
     {
	fr = ewin;
	to = ibox;
     }
   else
     {
	fr = ibox;
	to = ewin;
     }

   fx = EoGetX(fr) - 2;
   fy = EoGetY(fr) - 2;
   fw = EoGetW(fr) + 3;
   fh = EoGetH(fr) + 3;

   tx = EoGetX(to) - 2;
   ty = EoGetY(to) - 2;
   tw = EoGetW(to) + 3;
   th = EoGetH(to) + 3;

   fx += EoGetX(EoGetDesk(fr));
   fy += EoGetY(EoGetDesk(fr));
   tx += EoGetX(EoGetDesk(to));
   ty += EoGetY(EoGetDesk(to));

   gcv.subwindow_mode = IncludeInferiors;
   gcv.function = GXxor;
   gcv.fill_style = FillOpaqueStippled;
   gcv.foreground = Dpy.pixel_white;
   if (gcv.foreground == 0)
      gcv.foreground = Dpy.pixel_black;
   gc = EXCreateGC(root,
		   GCFunction | GCForeground | GCSubwindowMode | GCFillStyle,
		   &gcv);

   XDrawLine(disp, root, gc, fx, fy, tx, ty);
   XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
   XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
   XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
   XDrawRectangle(disp, root, gc, tx, ty, tw, th);
   XDrawRectangle(disp, root, gc, fx, fy, fw, fh);

   spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;

   t0 = GetTimeMs();
   for (a = 0.0; a < 1.0; a += spd)
     {
	x = (int)(fx + a * (tx - fx));
	w = (int)(fw + a * (tw - fw));
	y = (int)(fy + a * (ty - fy));
	h = (int)(fh + a * (th - fh));
	XDrawRectangle(disp, root, gc, x, y, w, h);

	ESync(0);
	IB_Animate_Sleep(t0, a);

	XDrawRectangle(disp, root, gc, x, y, w, h);
     }

   XDrawLine(disp, root, gc, fx, fy, tx, ty);
   XDrawLine(disp, root, gc, fx + fw, fy, tx + tw, ty);
   XDrawLine(disp, root, gc, fx, fy + fh, tx, ty + th);
   XDrawLine(disp, root, gc, fx + fw, fy + fh, tx + tw, ty + th);
   XDrawRectangle(disp, root, gc, tx, ty, tw, th);
   XDrawRectangle(disp, root, gc, fx, fy, fw, fh);

   EXFreeGC(gc);
}