Example #1
0
void WindowManager::handleMapRequest( XMapRequestEvent* event )
{
	Window window = event->window;

	// if we have this window in our collection then we just show it and exit
	if( true == _theKnowlegeBase.contains(window) )
	{
		XWindow* xWindow = _theKnowlegeBase[window];
		xWindow->show();

		return;
	}

	if( true == XLibWrapper::isWindowSupposedTohaveDecorations(window) )
	{
		// once we got here it means we have to do some magic on this window to make it usable for h**o-erectus descendants

		// so here we start: abracadabra, jmih, jmah jjjahh...
		XWindow* xWindow = new XWindow( window );
		if( 0 != xWindow )
		{
			_theKnowlegeBase.insert( window, xWindow );
			xWindow->show();
			_taskBar->add( xWindow );
			XSync( QX11Info::display(), FALSE );
		}
		// hmm...  seems that was it
	}
	else
		// in all other cases it must be a shaped or popup window - we don't care about that, we just show it naked, let people see how ugly it is
		XLibWrapper::showWindow( window );
}
Example #2
0
static bool
create_xwindow(bool xv, struct xdata *data)
{
	if (data->xwin)
		return false;

	if (xv)
		data->xwin = new XVWindow();
	else
		data->xwin = new XWindow();

	data->xdisp = XOpenDisplay(0);
	g_printerr("opened display %p\n", data->xdisp);

	XWindow *win = data->xwin;

	return win->Init(data->xdisp,
			 data->window,
			 data->gc,
			 data->x,
			 data->y,
			 data->ww,
			 data->wh,
			 data->iw,
			 data->ih);
}
Example #3
0
extern "C" int XSelectInput(Display *display, Window window, long mask) {
  XWindow* xwindow = Windows::get_xwindow(window);
  if(xwindow == 0)
    return 1;
  xwindow->event_mask(xwindow->event_mask() ^ mask);
  return 0;
}
bool EnterNotifyRequestHandler::processEvent(XEvent* event) {
    Window windowID = event->xcrossing.window;
    qDebug() << "[+] EnterNotify vent 0x" << hex << windowID;

    // Si la ventana es un cliente
    if(this->wl->existClient(windowID))
    {
        qDebug() << "\t EnterNotify: Entramos a la ventana";
        XWindow* xwindow = this->wl->getXWindowByClientID(windowID);

        // Si el cliente bypassea el WM
        if(xwindow->bypassWM())
        {
            qDebug() << "\tEl cliente bypassea el WM";
            return false;

        // Si no lo bypassea
        }
        else
        {
            return true;
        }

    // Si no es un cliente
    } else {
        qDebug() << "\tLa ventana no es un cliente";
        return false;
    }
}
 void SchemeComponent::PaintComponent(Graphics* g) {
   XWindow* win = this->GetParentWindow();
   if (win == NULL) {
     return;
   }
   for (vector<string>::iterator i = instructions.begin(); i != instructions.end(); i++) {
     scheme_interpreter_execute_graphics_instruction(win->GetWindowNum(), i->c_str());
   }
 }
bool ConfigureRequestHandler::processEvent(XEvent* event) {
    Window windowID = event->xconfigurerequest.window;
    qDebug() << "[+] ConfigureRequest event 0x" << hex << windowID;

    // Si la ventana es un cliente
    if(this->wl->existClient(windowID)) {
        qDebug() << "\tLa ventana es un cliente, configurándolo...";
        XWindow* xwindow = this->wl->getXWindowByClientID(windowID);

        // Si el cliente bypassea el WM
        if(xwindow->bypassWM()) {
            qDebug() << "\tEl cliente bypassea el WM";
            return false;

        // Si no lo bypassea
        } else {
            if(event->xconfigurerequest.value_mask & CWX)
                xwindow->setX(event->xconfigurerequest.x);

            if(event->xconfigurerequest.value_mask & CWY)
                xwindow->setY(event->xconfigurerequest.y);

            // Hay que comprobar si la ventana tiene o no marco porque si no
            // las ventanas que solo aceptan tamaños múltiplos de un cierto
            // número dan problemas

            Config* cfg = Config::getInstance();

            if(event->xconfigurerequest.value_mask & CWWidth) {
                if(xwindow->haveFrame())
                    xwindow->setWidth(event->xconfigurerequest.width
                            + cfg->getLeftBorderWidth()
                            + cfg->getRightBorderWidth());
                else
                    xwindow->setWidth(event->xconfigurerequest.width);
            }

            if(event->xconfigurerequest.value_mask & CWHeight) {
                if(xwindow->haveFrame())
                    xwindow->setHeight(event->xconfigurerequest.height
                            + cfg->getTitlebarWidth() + cfg->getTopBorderWidth()
                            + cfg->getBottomBorderWidth());
                else
                    xwindow->setHeight(event->xconfigurerequest.height);
            }

            return true;
        }

    // Si no es un cliente
    } else {
        qDebug() << "\tLa ventana no es un cliente";
        return false;
    }
}
Example #7
0
void WindowManager::handlePropertyChangedNotification( XPropertyEvent* event )
{
	Window window = event->window;

	Atom atom = event->atom;

	// we're interested in this only if this is a window that is under our responsability to make it nice looking
	if( false  == _theKnowlegeBase.contains(window) )
		return;

	XWindow* xWindow = _theKnowlegeBase[window];
	xWindow->propertyChanged( event );
}
Example #8
0
void WindowlistMenu::keyPressEvent (const XKeyEvent * const e) {

  unsigned int state = e->state;

  if (_debug)
    std::cout << BBTOOL << ": " << "WindowlistMenu: got keyPressEvent!" << std::endl;

  if (!_honor_modifiers) {
    state = e->state & ~(LockMask|scrollLockMask|numLockMask);
  }

  const Action *it = _keybindings->getAction(e, state, _screen);

  if (it) {
    switch (it->type()) {

    case Action::nextWindow:
    case Action::nextWindowOnAllWorkspaces:
    case Action::nextWindowOnAllScreens:
    case Action::nextWindowOfClass:
    case Action::nextWindowOfClassOnAllWorkspaces:
      selectNext();
      break;

    case Action::prevWindow:
    case Action::prevWindowOnAllWorkspaces:
    case Action::prevWindowOnAllScreens:
    case Action::prevWindowOfClass:
    case Action::prevWindowOfClassOnAllWorkspaces:
      selectPrevious();
      break;

    default:
      break;
    }
  }

  // if the user is cancelling the menu/cycle, then set focus back on the
  // window they started with.
  if (e->keycode == XKeysymToKeycode(_display, XK_Escape)) {
    XWindow * win = dynamic_cast<XWindow *>(*_windowList.begin());
    win->focus();
  } else if (e->keycode == XKeysymToKeycode(_display, XK_Up)) {
    selectPrevious(false);
  } else if (e->keycode == XKeysymToKeycode(_display, XK_Down)) {
    selectNext(false);
  }

  bt::Menu::keyPressEvent(e);

}
void XWindowBase::execSyncV(      FieldContainer    &oFrom,
                                        ConstFieldMaskArg  whichField,
                                        AspectOffsetStore &oOffsets,
                                        ConstFieldMaskArg  syncMode,
                                  const UInt32             uiSyncInfo)
{
    XWindow *pThis = static_cast<XWindow *>(this);

    pThis->execSync(static_cast<XWindow *>(&oFrom),
                    whichField,
                    oOffsets,
                    syncMode,
                    uiSyncInfo);
}
void MyWindow :: DoSize(XSize * size )
{
        XWindow * text = GetWindow(300);
        if(text) //is there a text object?
        {
                //calculate the new size/position of the text object
                XRect newSize;
                newSize.SetX( size->GetWidth() / 2 - 75 );
                newSize.SetY( size->GetHeight() / 2 - 10 );
                newSize.SetWidth( 150 );
                newSize.SetHeight( 20 );
                text->SetSize( &newSize );
        }
}
bool MapRequestHandler::processEvent(XEvent* event) {
    Window windowID = event->xmaprequest.window;
    qDebug() << "[+] MapRequest event 0x" << hex << windowID;

    // Si la ventana es un cliente
    if(this->wl->existClient(windowID)) {
        qDebug() << "\tLa ventana es un cliente";
        XWindow* xwindow = this->wl->getXWindowByClientID(windowID);

        // Si el cliente bypassea el WM
        if(xwindow->bypassWM()) {
            qDebug() << "\tEl cliente bypassea el WM";
            return false;

        // Si no lo bypassea
        } else {

            // Si la ventana se mapea por primera vez
            if(xwindow->getState() == WithdrawnState) {
                qDebug() << "\tEl cliente se mapea por primera vez";

                if(xwindow->needFrame()) {
                    qDebug() << "\tAñadiendo un marco al cliente";
                    xwindow->addFrame();

                    // No hace falta añadir el cliente a la lista por que ya se
                    // añadió en CreateNotifyHandler

                    qDebug() << "\tAñadiendo el marco (0x" << hex
                             << xwindow->getFrameID() << ") a la lista";
                    wl->addFrame(xwindow->getFrameID(), xwindow);
                } else
                    qDebug() << "\tEl cliente no necesita marco";

                qDebug() << "\tMapeando la ventana";
                xwindow->setState(NormalState);

                qDebug() << "\tAñadiendo la ventana de la lista del EWMH";
                this->wl->addToManagedWindows(xwindow);

                qDebug() << "\tActualizando la ventana activa";
                this->wl->setActiveWindow(this->wl->getTopWindow());
            }

            return true;
        }

    // Si la ventana es un marco
    } else if(this->wl->existFrame(windowID)) {
        qDebug() << "\tLa ventana es un marco";
        return false;

    // Si no se ni un marco ni un cliente
    } else {
        qDebug() << "\tLa ventana no es ni un cliente ni un marco";
        return false;
    }

}
Example #12
0
void WindowManager::handleConfigureRequest( XConfigureRequestEvent* event )
{
	Window window = event->window;

	// if we don't have a such a mafia-family-member, we just pretend that we didn't received any request - just as our justice do with us.
	// Or better be kinder and help it out as usually non RM governments do, probably this will make him stay and not leave the country in search for a better life
	if( false == _theKnowlegeBase.contains(window) )
	{
		XLibWrapper::configureWindow( event );
		return;
	}

	// damn, we have a such citizen (what the heck he wants - we're soooo busy), 
	// have to stop for not more than a second from my family business and do actually for what I've been elected
	XWindow* xWindow = _theKnowlegeBase[window];
	xWindow->configureWindow( event );
}
Example #13
0
File: gary.c Project: ombt/ombt
main(int argc, char **argv)
{
	/* create window display */
	XWindowDisplay *windisp = new XWindowDisplay((char *)0, 0);

	/* create a window */
	XWindow *win = new XWindow(argv[0], windisp, 50, 50, 800, 600,
	"-adobe-courier-bold-o-normal--18-180-75-75-m-110-iso8859-1");

	/* concatenate all strings together */
	char buf[BUFSIZ];
	*buf = 0;
	for (int arg = 1; arg < argc; arg++)
	{
		strcat(buf, " ");
		strcat(buf, argv[arg]);
	}

	/* create random number generators */
	Uniform xdist(1.0, 800.0);
	Uniform ydist(1.0, 600.0);

	/* set seed for random number generator */
	long seed = time((long *)0) | 1L;
	srand48(seed);

	/* write string on screen */
	win->display();
	while ( 1 )
	{
		int x = (int)xdist.randomSample();
		int y = (int)ydist.randomSample();
		win->putString(x, y, buf);
		win->display();
		sleep(1);
	}

	/* all done */
	delete win;
	delete windisp;

	/* all done */	
	return(0);
}
Example #14
0
void WindowlistMenu::keyReleaseEvent (const XKeyEvent * const e) {

  if (_debug)
    std::cout << BBTOOL << ": " << "WindowlistMenu: got keyReleaseEvent!" << std::endl;

  if (_screen->nothingIsPressed() ){
    // get what window is selected so we can focus it
    XWindow * win = getSelectedWindow();

    bt::Menu::hide();
    _screen->keyReleaseEvent(e);

    // if the user is ending his window-cycling adventure, then raise the window
    // for him.
    if (win)
      win->focus();
  }

  bt::Menu::keyReleaseEvent(e);

}
Example #15
0
void WindowManager::ProcessMessages() {
	processing = true;
#if defined(NEX_WINDOWS)
	static MSG msg;
	while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
		if (msg.message == WM_QUIT) {
			ApplicationContext::Instance().SetQuitting(true);
		}
		TranslateMessage(&msg);
		DispatchMessageW(&msg);
	}

#elif defined(NEX_LINUX)
	// for all registered windows
	XEvent event;
	WindowList::iterator it = registeredWindows.begin();
	WindowList::iterator end = registeredWindows.end();
	while (it != end) {
		XWindow* wind = static_cast<XWindow*>((*it));
		Display* disp = wind->GetDisplay();
		Window w = wind->GetWindow();
		while (XCheckWindowEvent(disp, w,
				wind->GetEventMask(), &event)) {
			XWindow::ProcessEvent(wind, event);
		}

		// The ClientMessage event does not appear under any Event Mask
		while (XCheckTypedWindowEvent(disp, w, ClientMessage, &event)) {
			XWindow::ProcessEvent(wind, event);
		}
		++it;
	}
#else
#error Not supported
#endif
	processing = false;
	_ProcessRemovedItems();
}
Example #16
0
XWindow * WindowlistMenu::getSelectedWindow() {

  WindowList::const_iterator it = _windowList.begin();
  const WindowList::const_iterator end = _windowList.end();

  XWindow * win = 0;

  unsigned int x = 0;
  for (; it != end; it++) {
    if ( static_cast<unsigned int>(_current_index) == x++ ) {
      win = dynamic_cast<XWindow *>(*it);
    }
  }

  if (0 == win)
    std::cerr << BBTOOL << ": " << "WindowlistMenu: getSelectedWindow--couldn't get window.  this won't turn out well.\n";

  if (_debug && win)
    std::cout << BBTOOL << ": " << "WindowlistMenu: getSelectedWindow: currently-selected window: ["
              << bt::toLocale(win->title()) << "]\n";
  return win;

}
Example #17
0
static gboolean
test(gpointer data)
{
	struct xdata *xdata = static_cast<struct xdata*>(data);
	XWindow *win = xdata->xwin;
	static guint c = 0;

	win->ProcessEvents();

	if (frame) {
		g_printerr(".");
		win->PutFrame(frame, 320, 240);
	}

	if (c++ <= 150)
		return TRUE;
	else {
		g_printerr("\n");
		c = 0;
		test_handler = 0;
		destroy_xwindow(xdata);
		return FALSE;
	}
}
Example #18
0
void CSubtitleFix::ReplacementFunc(XWindow& XWinThis, CSubtitleFix& /*Context*/, FFrame& Stack, RESULT_DECL)
{
    P_GET_OBJECT(UClass, pNewClass);
    P_GET_UBOOL_OPTX(bShow, 1);
    P_FINISH;

    //Note: we don't replace CinematicWindow, which has the same quirk. Advantage: cutscenes with no subtitles won't be cropped. Disadvantage: as soon as subtitles do show up, black bar spawns/grows.
    //Constructor function comparison is for early-out for most windows
    if (pNewClass->ClassConstructor == &XModalWindow::InternalConstructor && wcscmp(pNewClass->GetFullName(), L"Class DeusEx.ConWindowActive") == 0)
    {
        UClass* const pReplacementClass = LoadClass<UObject>(nullptr, L"DeusExe.ConWindowActive2", L"DeusExe", 0, nullptr);
        if (pReplacementClass)
        {
            pNewClass = pReplacementClass;
        }
    }

    XWindow* const pNewWin = XWinThis.CreateNewWindow(pNewClass, &XWinThis, bShow);

    *(static_cast<XWindow** const>(Result)) = pNewWin;
}
Example #19
0
void WindowlistMenu::showCycleMenu( WindowList theList ) {

  bt::Menu::clear();
  bt::Menu::setTitle(bt::toUnicode(_menu_title));
  if (_menu_title.length() > 0)
    bt::Menu::showTitle();

  _windowList = theList;

  WindowList::const_iterator it;
  const WindowList::const_iterator end = theList.end();

  // first, find out if we have any windows in our list for anything other
  // than the current desktop
  _desktop_nbr = _screen->getDesktopNumber();
  bool onlyThisDesktop = true;
  for (it = theList.begin(); it != end; it++) {
    unsigned int dNbr = (*it)->desktop();
    if ( (dNbr != _desktop_nbr) && (! (*it)->isSticky()) ) {
      onlyThisDesktop = false;
      break;
    }
  }

  // now add the windows to our list
  unsigned int i = 0;

  for (it = theList.begin(); it != end; it++) {
	  XWindow *win = (*it);
	  bt::ustring title = win->title();
	  unsigned int dNbr = win->desktop();
	  bt::ustring newTitle = bt::ellideText(title, 100, bt::toUnicode(" ... "));
	  if (! onlyThisDesktop) {
		  bt::ustring suffix = _screen->getDesktopName(dNbr);
		  if (suffix.size() > 0) {
			  newTitle.append(bt::toUnicode(" ("));
			  newTitle.append(suffix);
			  newTitle.append(bt::toUnicode(")"));
		  }
	  }
	  if (win->iconic()) {
		  newTitle.insert(0, bt::toUnicode("("));
		  newTitle.append(bt::toUnicode(")"));
	  }

	  bt::Menu::insertItem( newTitle, i++ );
  }

  // this is our current window, before cycling.  set it checked as a
  // visual indicator
  bt::Menu::setItemChecked(0, true);

  int x = _config->getNumberValue("cyclemenux", 20);
  int y = _config->getNumberValue("cyclemenuy", 20);

  // now show the menu
  bt::Menu::popup(x, y, false);
  bt::Menu::move(x,y);

  // reset our marker as we will increment it in selectNext...
  _current_index = -1;

  // we don't have anything selected initially, so we need to set the
  // selection to the second one (the first one is the
  // currently-selected window
  selectNext();
  selectNext();

}
bool ClientMessageHandler::processEvent(XEvent* event) {
    Window windowID = event->xclient.window;
    qDebug() << "[+] ClientMessage event 0x" << hex << windowID;
    AtomList* al = AtomList::getInstance();

    qDebug() << "\tPropiedad a cambiar: " << XGetAtomName(
            QX11Info::display(), event->xclient.message_type);

    // Si la ventana es un cliente
    if(this->wl->existClient(windowID)) {
        qDebug() << "\tLa ventana es un cliente";
        XWindow* xwindow = this->wl->getXWindowByClientID(windowID);

        //----------------------------------------------------------------------

        // ICCCM

        if(event->xclient.message_type == al->getAtom("WM_CHANGE_STATE")
                        && event->xclient.format == 32
                        && event->xclient.data.l[0] == IconicState) {
                    qDebug() << "\tSe solicita minimizar el cliente";
                    xwindow->setState(IconicState);
                    return true;


        //----------------------------------------------------------------------

        // EWMH

        } else if(event->xclient.message_type
                == al->getAtom("_NET_ACTIVE_WINDOW")) {
            EWMHRoot ewmh;
            ewmh.receivedActiveWindow(this->wl, xwindow);

        } else if(event->xclient.message_type
                == al->getAtom("_NET_CLOSE_WINDOW")) {
            EWMHRoot ewmh;
            ewmh.receivedCloseWindow(xwindow);
        }


        // TODO Se debería recibir _NET_WM_USER_TIME para poder hacer activas
        //      las ventanas al clickar en cualquier parte, no solo en el marco,
        //      pero no se recibe :(

        return false;

    // Si la ventana es un marco
    } else if(wl->existFrame(windowID)) {
        qDebug() << "\tLa ventana es un marco";

        // XdndLeave
        // XdndEnter
        // XdndPosition

        return false;

    // Si no es ni un marco ni un cliente
    } else {
        qDebug() << "\tLa ventana no es ni un cliente ni un marco";

        // _NET_SHOWING_DESKTOP

        return false;
    }
}