Example #1
0
void
awt_changeAttributes(Display *dpy, Widget w, unsigned long mask,
                     XSetWindowAttributes *xattr)
{
    WidgetList          wlist;
    Cardinal            wlen = 0;
    Cardinal            i;

    if (XtWindow(w) && XtIsRealized(w)) {
        XChangeWindowAttributes(dpy,
                                XtWindow(w),
                                mask,
                                xattr);
    } else {
        return;
    }
    XtVaGetValues(w,
                  XmNchildren, &wlist,
                  XmNnumChildren, &wlen,
                  NULL);
    for (i = 0; i < wlen; i++) {
        if (XtWindow(wlist[i]) && XtIsRealized(wlist[i])) {
            XChangeWindowAttributes(dpy,
                                    XtWindow(wlist[i]),
                                    mask,
                                    xattr);
        }
    }
}
Example #2
0
int
init_form_window(char *name, int cols)
{
    XSetWindowAttributes wa;    /* The X attributes structure */

    /* First allocate memory for the new window structure   */

    gWindow = alloc_hd_window();
    open_form_window();
    gWindow->width = window_width(cols);

    if (name == NULL) {
        /** Then allocate an empty page, and assign it to gWindow->page */
        gWindow->page = alloc_page((char *) NULL);
    }
    else {
        /* Try to find the page in the page hash table */
        gWindow->page = (HyperDocPage *) hash_find(gWindow->fPageHashTable, name);
        if (gWindow->page == NULL) {
            fprintf(stderr, "Couldn't find page %s\n", name);
            return (-1);
        }
    }

    get_GCs(gWindow);
    hash_insert(&gSessionHashTable, (char *)gWindow,(char *) &gWindow->fMainWindow);

    wa.background_pixel = gBackgroundColor;
    XChangeWindowAttributes(gXDisplay, gWindow->fMainWindow, CWBackPixel, &wa);
    XChangeWindowAttributes(gXDisplay, gWindow->fScrollWindow, CWBackPixel,&wa);
    return 1;
}
Example #3
0
static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y)
{
	xfContext* xfc = (xfContext*) context;
	XWindowAttributes current;
	XSetWindowAttributes tmp;
	BOOL ret = FALSE;

	if (!xfc->focused || !xfc->window)
		return TRUE;

	xf_lock_x11(xfc, FALSE);

	if (XGetWindowAttributes(xfc->display, xfc->window->handle, &current) == 0)
		goto out;

	tmp.event_mask = (current.your_event_mask & ~(PointerMotionMask));

	if (XChangeWindowAttributes(xfc->display, xfc->window->handle, CWEventMask,
	                            &tmp) == 0)
		goto out;

	XWarpPointer(xfc->display, None, xfc->window->handle, 0, 0, 0, 0, x, y);
	tmp.event_mask = current.your_event_mask;
	XChangeWindowAttributes(xfc->display, xfc->window->handle, CWEventMask, &tmp);
	ret = TRUE;
out:
	xf_unlock_x11(xfc, FALSE);
	return ret;
}
Example #4
0
void Menu2ws(Menu *menu,short ws)
{
  XSetWindowAttributes wattr;
  XGCValues xgcv;
  Node *mi;

  xgcv.foreground=TheScreen.Colors[ws][UDE_Light].pixel;
  XChangeGC(disp,TheScreen.MenuLightGC,GCForeground,&xgcv);
  xgcv.foreground=TheScreen.Colors[ws][UDE_Shadow].pixel;
  XChangeGC(disp,TheScreen.MenuShadowGC,GCForeground,&xgcv);
  xgcv.foreground=TheScreen.Colors[ws][UDE_Back].pixel;
  XChangeGC(disp,TheScreen.MenuBackGC,GCForeground,&xgcv);
  xgcv.foreground=TheScreen.Colors[ws][UDE_StandardText].pixel;
  XChangeGC(disp,TheScreen.MenuTextGC,GCForeground,&xgcv);

  wattr.background_pixel=TheScreen.Colors[ws][UDE_Back].pixel;
  XChangeWindowAttributes(disp,menu->win,CWBackPixel,&wattr);
  mi=NULL;
  while((mi=NodeNext(menu->Items,mi))){
    MenuItem *item;
    item=mi->data;
    if(item->type!=I_LINE) {
      XChangeWindowAttributes(disp,item->win,CWBackPixel,&wattr);
      if(item->type==I_SUBMENU) Menu2ws(item->data,ws);
    }
  }
}
Example #5
0
void status_bar() {
    unsigned int i, y;
    XSetWindowAttributes setattr;
    setattr.override_redirect = True;
    unsigned long vmask = CWOverrideRedirect;

    y = (topbar == 0) ? 0+ug_bar : desktops[barmon].h+bdw-ug_bar;
    sb_width = ug_bar;
    for(i=0;i<DESKTOPS;++i) {
        sb_bar[i].sb_win = XCreateSimpleWindow(dis, root, desktops[barmon].x+sb_width, y,
                                            sb_bar[i].width-2,sb_height,2,theme[3].barcolor,theme[0].barcolor);

        XSelectInput(dis, sb_bar[i].sb_win, ButtonPressMask|EnterWindowMask|LeaveWindowMask);
        XChangeWindowAttributes(dis, sb_bar[i].sb_win, vmask, &setattr);
        XMapWindow(dis, sb_bar[i].sb_win);
        sb_width += sb_bar[i].width;
    }
    sb_area = XCreateSimpleWindow(dis, root, desktops[barmon].x+sb_desks+ug_bar, y,
             desktops[barmon].w-lessbar-(sb_desks+2)-2*ug_bar,sb_height,2,theme[3].barcolor,theme[1].barcolor);

    XSelectInput(dis, sb_area, ButtonPressMask|ExposureMask|EnterWindowMask|LeaveWindowMask);
    XChangeWindowAttributes(dis, sb_area, vmask, &setattr);
    XMapWindow(dis, sb_area);
    XWindowAttributes attr;
    XGetWindowAttributes(dis, sb_area, &attr);
    total_w = attr.width;
    area_sb = XCreatePixmap(dis, root, total_w, sb_height, DefaultDepth(dis, screen));
    XFillRectangle(dis, area_sb, theme[0].gc, 0, 0, total_w, sb_height+4);
    status_text("");
    update_bar();
}
Example #6
0
int main() 
{
	printf("opening display\n");
	Display *d = XOpenDisplay(NULL);
	
	printf("grabbing default screen\n");
	int screen = DefaultScreen(d);
	printf("default screen = %d\n", screen);
	
	printf("grabbing root window\n");
	Window root = DefaultRootWindow(d);
	
	// tell root window you'll be capturing it's events
	XSetWindowAttributes a;
	a.event_mask = StructureNotifyMask|SubstructureNotifyMask|EnterWindowMask|LeaveWindowMask; // root + child (sub) windows created, window-in, window-out
	XSelectInput(d, root, a.event_mask);
	
	// handle errors
	XSetErrorHandler(handle_xerror);

	// capture those events
	XEvent e;
	
	// main event loop
	for (;;) {
		XNextEvent(d, &e);
		
		if (e.type == CreateNotify) {
			printf("Event: create\n");
			XSelectInput(e.xcreatewindow.display, e.xcreatewindow.window, a.event_mask);
			XSetWindowBorderWidth(e.xcreatewindow.display, e.xcreatewindow.window, 1); // always set border to 1px
		}
		
		else if (e.type == ConfigureNotify) {
			printf("EVENT: configure\n");
		}
			
		else if (e.type == EnterNotify) {
			printf("EVENT: focus-in\n");
			focused_win = e.xcrossing.window;
			a.border_pixel = WhitePixel(e.xcrossing.display, screen);
			XChangeWindowAttributes(e.xcrossing.display, focused_win, CWBorderPixel, &a);
		}
		
		else if (e.type == LeaveNotify) {
			printf("EVENT: focus-out\n");
			a.border_pixel = BlackPixel(e.xcrossing.display, screen);
			XChangeWindowAttributes(e.xcrossing.display, e.xcrossing.window, CWBorderPixel, &a);
		}
	}
	
	return 0;
}
Example #7
0
int UIInquireVector(Widget widget, XEvent *event, int x0, int y0, int *x1, int *y1) {
    XSetWindowAttributes xswa;
    XGCValues xgcv;
    static GC gc = (GC) NULL;
    static Cursor cursor[2] = {(Cursor) NULL, (Cursor) NULL};
    static int inLoop, cont, ret;

    if (cursor[0] == (Cursor) NULL) cursor[0] = XCreateFontCursor(XtDisplay(widget), XC_hand2);
    if (cursor[1] == (Cursor) NULL) cursor[1] = XCreateFontCursor(XtDisplay(widget), XC_top_left_arrow);
    if (gc == (GC) NULL) {
        xgcv.function = GXinvert;
        gc = XtGetGC(widget, GCFunction, &xgcv);
    }
    if (inLoop == false) {
        if (event->type != ButtonPress) return (false);
        inLoop = cont = true;
        ret = false;
        xswa.cursor = cursor[0];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        *x1 = event->xbutton.x;
        *y1 = event->xbutton.y;
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        do {
            XtAppNextEvent(UIApplicationContext(), event);
            XtDispatchEvent(event);
        } while (cont);
        XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
        xswa.cursor = cursor[1];
        XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
        inLoop = false;
        return (ret);
    }
    else
        switch (event->type) {
            case ButtonRelease:
                xswa.cursor = cursor[1];
                XChangeWindowAttributes(XtDisplay(widget), XtWindow(widget), CWCursor, &xswa);
                ret = true;
                cont = false;
                break;
            case MotionNotify:
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                *x1 = event->xmotion.x;
                *y1 = event->xmotion.y;
                XDrawLine(XtDisplay(widget), XtWindow(widget), gc, x0, y0, *x1, *y1);
                break;
            case LeaveNotify:
                ret = false;
                cont = false;
                break;
        }
    return (false);
}
Example #8
0
void
snoop_legacy(Window win)
{
	Window parent, root, *kids = NULL;
	XSetWindowAttributes sattrs;
	unsigned int nkids = 0, i;

	/*
	 * Firefox stops responding to keys when KeyPressMask is used, so
	 * settle for KeyReleaseMask
	 */
	int type = PointerMotionMask | KeyReleaseMask | Button1MotionMask |
		Button2MotionMask | Button3MotionMask | Button4MotionMask |
		Button5MotionMask | ButtonMotionMask;

	if (XQueryTree(dpy, win, &root, &parent, &kids, &nkids) == FALSE) {
		warn("can't query window tree\n");
		goto done;
	}

	XSelectInput(dpy, root, type);

	/* listen for newly mapped windows */
	sattrs.event_mask = SubstructureNotifyMask;
	XChangeWindowAttributes(dpy, root, CWEventMask, &sattrs);

	for (i = 0; i < nkids; i++) {
		XSelectInput(dpy, kids[i], type);
		snoop_legacy(kids[i]);
	}

done:
	if (kids != NULL)
		XFree(kids); /* hide yo kids */
}
Example #9
0
/*
 * This handles just some initial setup directly related to the 
 * Window manager object which is passed as a pointer
 */
void setup(WM* wm) {
  XSetWindowAttributes swa;
  
	/* init atoms */
	wm->wmatom[WMProtocols] =   XInternAtom(wm->dpy, "WM_PROTOCOLS", False);
	wm->wmatom[WMDelete] =      XInternAtom(wm->dpy, "WM_DELETE_WINDOW", False);
	wm->wmatom[WMName] =        XInternAtom(wm->dpy, "WM_NAME", False);
	wm->wmatom[WMState] =       XInternAtom(wm->dpy, "WM_STATE", False);
	wm->netatom[NetSupported] = XInternAtom(wm->dpy, "_NET_SUPPORTED", False);
	wm->netatom[NetWMName] =    XInternAtom(wm->dpy, "_NET_WM_NAME", False);
  
  // init geometry
  wm->sx = wm->sy = 0;
  wm->sw = DisplayWidth(wm->dpy, wm->screen);
  wm->sh = DisplayHeight(wm->dpy, wm->screen);

  // init window area
  wm->wax = wm->way = 0;
  wm->waw = wm->sw;
  wm->wah = wm->sh;

	swa.event_mask = SubstructureRedirectMask |
                   SubstructureNotifyMask |
                   EnterWindowMask |
                   LeaveWindowMask |
                   StructureNotifyMask;
	XChangeWindowAttributes(wm->dpy, wm->root, CWEventMask, &swa);
	XSelectInput(wm->dpy, wm->root, swa.event_mask);

  // TODO: Grabkeys, Multihead-Support, Xinerama, Compiz, Multitouch :D
}
void CL_DisplayWindow_OpenGL::set_windowed()
{
	if(!fullscreen)
		return;

	if (0)
	{ // FIXME: See FIXME in set_fullscreen
		// Hide window
		XUnmapWindow(disp, window);
		XSync(disp, True);

		// Turn on WM control 
		attributes.override_redirect = False;
		XChangeWindowAttributes(disp, window, CWBorderPixel | CWColormap | CWOverrideRedirect, &attributes);

		XMoveResizeWindow(disp, window, 0, 0, fullscreen_width, fullscreen_height);

		XMapRaised(disp, window);
		XSync(disp, True);
	}

	fullscreen = false;

	// Only restore mode if we ever switched mode.
	if (old_x != -1 || old_y != -1)
	{
		XF86VidModeSwitchToMode(disp, 0, &old_mode);
		XF86VidModeSetViewPort(disp, 0, old_x, old_y);
	}

	XUngrabPointer(disp, CurrentTime);

	XSync(disp, True);
}
Example #11
0
void
wm_set_fullscreen(Display *dpy, Window window, int x, int y, unsigned int width, unsigned int height)
{
	if(WM_PERSONALITY == WM_PERSONALITY_NETWM && NETWM_HAS_FULLSCREEN)
	{
		Atom props[6];
		CARD32 desktop = (CARD32)-1;
		
		props[0] = _NET_WM_STATE_FULLSCREEN;
		props[1] = _NET_WM_STATE_SKIP_TASKBAR;
		props[2] = _NET_WM_STATE_SKIP_PAGER;
		props[3] = _NET_WM_STATE_ABOVE;
		props[4] = _NET_WM_STATE_STICKY;
		props[5] = 0;
		XChangeProperty(dpy, window, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char*)props, 5);
		XChangeProperty(dpy, window, _NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&desktop, 1);
	}
	else
	{
		XSetWindowAttributes wattr;
		wattr.override_redirect = True;
		XChangeWindowAttributes(dpy, window, CWOverrideRedirect, &wattr);
		XMoveResizeWindow(dpy, window, x, y, width, height);
	}
}
Example #12
0
MSSash::MSSash(MSPane *owner_) : MSWidgetCommon(owner_)
{
  _highlightThickness=0;
  _shadowThickness=0;
  _row=0,_column=0,_min=0,_max=0;
  acceptFocus(MSFalse);

  unsigned long whitePixel=server()->pixel("white");
  unsigned long blackPixel=server()->pixel("black");

  _crossCursor=new MSDisplayCursor(server(),XC_tcross,blackPixel,whitePixel);

  XSetWindowAttributes attrib;
  attrib.cursor=_crossCursor->cursor();
  XChangeWindowAttributes(display(),window(),CWCursor,&attrib);

  XGCValues values;
  values.foreground=whitePixel^background();
  values.background=blackPixel;
  values.line_width=2;
  values.function=GXxor;
  values.subwindow_mode=IncludeInferiors;
  _drawGC.setGCValues(server(),MSTrue,&values,
                      GCForeground|GCBackground|GCLineWidth|GCFunction|GCSubwindowMode);
  selectInput(MSSashEventMask);
}
static int motCanvasSetBgColorAttrib(Ihandle* ih, const char* value)
{
  Pixel color;

  /* ignore given value, must use only from parent for the scrollbars */
  char* parent_value = iupBaseNativeParentGetBgColor(ih);

  color = iupmotColorGetPixelStr(parent_value);
  if (color != (Pixel)-1)
  {
    Widget sb;
    Widget sb_win = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");

    iupmotSetBgColor(sb_win, color);

    sb = (Widget)iupAttribGet(ih, "_IUPMOT_SBVERT");
    if (sb) iupmotSetBgColor(sb, color);

    sb = (Widget)iupAttribGet(ih, "_IUPMOT_SBHORIZ");
    if (sb) iupmotSetBgColor(sb, color);
  }

  if (!IupGetCallback(ih, "ACTION")) 
    iupdrvBaseSetBgColorAttrib(ih, value);  /* Use the given value only here */
  else
  {
    XSetWindowAttributes attrs;
    attrs.background_pixmap = None;
    XChangeWindowAttributes(iupmot_display, XtWindow(ih->handle), CWBackPixmap, &attrs);
    iupAttribSet(ih, "_IUPMOT_NO_BGCOLOR", "1");
  }

  return 1;
}
Example #14
0
void iupmotCBcreatecanvas(Widget w, XtPointer data, XEvent *ev, Boolean *cont)
{
  Ihandle *n = (Ihandle*)data;

  if (ev->type != CreateNotify) return;

  if (ev->xcreatewindow.window == XtWindow((Widget) handle(n)))
  {
    Icallback cb = IupGetCallback(n, IUP_MAP_CB);
    XSetWindowAttributes attr;

    /* Seta o bit de gravidade para ForgetGravity e
     * habilita backing store */

    attr.bit_gravity = ForgetGravity;
    if (iupCheck(n, "BACKINGSTORE"))
      attr.backing_store = WhenMapped;
    else
      attr.backing_store = NotUseful;
    attr.background_pixel = None;
    XChangeWindowAttributes( iupmot_display, ev->xcreatewindow.window,
        CWBackingStore | CWBitGravity, &attr );

    iupdrvSetAttribute(n, IUP_CURSOR, IupGetAttribute(n, IUP_CURSOR));

    if (cb)
    {
      iupmot_incallback = 1;
      if (cb (n)==IUP_CLOSE) iupmot_exitmainloop = 1;
      iupmot_incallback = 0;
    }
  }
}
Example #15
0
/*----------------------------------------------------------------------*/
static void
Realize(Widget w,XtValueMask * mask,XSetWindowAttributes* wa)
{
    XSetWindowAttributes attr;

    /* Make sure only subclasses of XfePrimitive get instanciated */
    if ((XtClass(w) == xfePrimitiveWidgetClass))
    {
		_XfeWarning(w,MESSAGE0);

		return;
    }

    /* Let XmPrimitive create the window */
    (*xmPrimitiveWidgetClass->core_class.realize)(w,mask,wa);
    
    /* Set the Bit Gravity */
    attr.bit_gravity = _XfePrimitiveAccessBitGravity(w);
    
    XChangeWindowAttributes(XtDisplay(w),_XfeWindow(w),CWBitGravity,&attr);

    /* Define the cursor if needed */
    if (_XfeCursorGood(_XfeCursor(w)) && _XfePointerInside(w))
	{
		XfeCursorDefine(w,_XfeCursor(w));
    }
}
Example #16
0
ShortcutDialog::ShortcutDialog(const QKeySequence& cut)
    : _shortcut(cut)
{
    QWidget *vBoxContainer = new QWidget(this);
    vBoxContainer->setLayout(new QVBoxLayout(vBoxContainer));
    vBoxContainer->layout()->addWidget(widget = new KKeySequenceWidget(vBoxContainer));
    vBoxContainer->layout()->addWidget(warning = new QLabel(vBoxContainer));
    warning->hide();
    widget->setKeySequence(cut);

    // To not check for conflicting shortcuts. The widget would use a message
    // box which brings down kwin.
    widget->setCheckForConflictsAgainst(KKeySequenceWidget::None);
    // It's a global shortcut so don't allow multikey shortcuts
    widget->setMultiKeyShortcutsAllowed(false);

    // Listen to changed shortcuts
    connect(
        widget, SIGNAL(keySequenceChanged(QKeySequence)),
        SLOT(keySequenceChanged(QKeySequence)));

    setMainWidget(vBoxContainer);
    widget->setFocus();

    // make it a popup, so that it has the grab
    XSetWindowAttributes attrs;
    attrs.override_redirect = True;
    XChangeWindowAttributes(display(), winId(), CWOverrideRedirect, &attrs);
    setWindowFlags(Qt::Popup);
}
Example #17
0
File: popup.c Project: Fnux/tint3
popup_window *create_window(Display *dsp, GC *gc, int x, int y, int w, int h) {
    popup_window *result = malloc(sizeof(popup_window));
    if (!result) {
        perror("could not allocate space for a popupwindow");
        return NULL;
    }

    int s = DefaultScreen(dsp);
    unsigned long wht = WhitePixel(dsp, s);
    unsigned long blk = BlackPixel(dsp, s);
    Window root = RootWindow(dsp, s);
    Window win = XCreateSimpleWindow(dsp, root, x, y, w, h, 1, blk, wht);
    XSelectInput(dsp, win, ExposureMask | KeyPressMask);
    XSetWindowAttributes set_attr;
    set_attr.override_redirect = True;
    XChangeWindowAttributes(dsp, win, CWOverrideRedirect, &set_attr);
    XMapWindow(dsp, win);

    result->x = x;
    result->y = y;
    result->w = w;
    result->h = h;
    result->win = win;
    result->ctx = *gc;
    result->dsp = dsp;
    result->canvas = XCreatePixmap(dsp, root, w, h, 32);

    pthread_create(&(result->thread), NULL, &window_action_listener, result);
    pthread_detach(result->thread);
    return result;
}
RazorTaskButton::RazorTaskButton(const Window window, QWidget *parent) :
    QToolButton(parent),
    mWindow(window)
{
    setCheckable(true);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    setMinimumWidth(1);
    setMinimumHeight(1);
    setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    setAcceptDrops(true);

    updateText();
    updateIcon();

    connect(this, SIGNAL(clicked(bool)), this, SLOT(btnClicked(bool)));
    connect(this, SIGNAL(toggled(bool)), this, SLOT(checkedChanged(bool)));


    XWindowAttributes oldAttr;
    XGetWindowAttributes(QX11Info::display(), mWindow, &oldAttr);

    XSetWindowAttributes newAttr;
    newAttr.event_mask = oldAttr.your_event_mask | PropertyChangeMask;
    XChangeWindowAttributes(QX11Info::display(), mWindow, CWEventMask, &newAttr);

    setStyle(&mStyle);
}
Example #19
0
RazorTaskButton::RazorTaskButton(const Window window, QWidget *parent) :
    QToolButton(parent),
    mWindow(window)
{
    setCheckable(true);
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    setMinimumWidth(1);
    setMinimumHeight(1);
    setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    setAcceptDrops(true);

    updateText();
    updateIcon();

    connect(this, SIGNAL(clicked(bool)), this, SLOT(btnClicked(bool)));
    connect(this, SIGNAL(toggled(bool)), this, SLOT(checkedChanged(bool)));

    XSelectInput(QX11Info::display(), mWindow, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);

    XSetWindowAttributes attr;
    attr.event_mask = PropertyChangeMask;
    XChangeWindowAttributes(QX11Info::display(), QX11Info::appRootWindow(), CWEventMask, &attr);

    setStyle(&mStyle);
}
Example #20
0
/**
@pre      display is valid, themes is valid, cursors is valid.
@pre      all widgets are zero'd.
@pre      themes is valid and has loaded at least a background for the popup_menu_parent. 
@post     Menu with borders and background but no items is created but not mapped.
@brief    This function is used to create a blank and generic menu.  Items must be added by caller.
@return   void
**/
void 
create_popup_menu(Display *display, struct Popup_menu *menu, struct Themes *themes, struct Cursors *cursors) {

  XSetWindowAttributes set_attributes;
  Window root = DefaultRootWindow(display);
  Screen* screen = DefaultScreenOfDisplay(display);
  int black = BlackPixelOfScreen(screen);
  
  const int width = menu->inner_width + themes->popup_menu[popup_l_edge].w + themes->popup_menu[popup_r_edge].w;
  const int height = menu->inner_height + themes->popup_menu[popup_t_edge].h + themes->popup_menu[popup_b_edge].h;
  
  menu->widgets[popup_menu_parent].widget = XCreateSimpleWindow(display, root
  , 0, 0
  , width, height, 0, black, black);

  XDefineCursor(display, menu->widgets[popup_menu_parent].widget, cursors->normal);
  XSetWindowBackgroundPixmap(display, menu->widgets[popup_menu_parent].widget
  , themes->popup_menu[popup_menu_parent].state_p[normal]);
   
  //Currently, this is the "base" of the popup menu.
  //A similar loop will be needed for the actual menu items but not in this function
  for(int i = popup_t_edge; i < popup_menu_parent; i++) { //popup_menu_parent already done

    int x = themes->popup_menu[i].x;
    int y = themes->popup_menu[i].y;
    int w = themes->popup_menu[i].w;
    int h = themes->popup_menu[i].h;
    
    if(x < 0)  x += width;
    if(y < 0)  y += height; 
    if(w <= 0) w += width;
    if(h <= 0) h += height;
  
    menu->widgets[i].widget = XCreateSimpleWindow(display
    , menu->widgets[popup_menu_parent].widget
    , x, y, w, h, 0, black, black);
    
    if(themes->popup_menu[i].w <= 0) w = XWidthOfScreen(screen);
    if(themes->popup_menu[i].h <= 0) h = XWidthOfScreen(screen);    
    for(int j = 0; j <= inactive; j++) {
      if(themes->popup_menu[i].state_p[j]) {
        menu->widgets[i].state[j] = XCreateSimpleWindow(display, menu->widgets[i].widget
        , 0, 0, w, h, 0, black, black);
        XSetWindowBackgroundPixmap(display, menu->widgets[i].state[j]
        , themes->popup_menu[i].state_p[j]);
        if(j == normal) XMapWindow(display, menu->widgets[i].state[j]);
      }
    }

    XMapWindow(display, menu->widgets[i].widget);
  } 

  set_attributes.override_redirect = True; 
  XChangeWindowAttributes(display, menu->widgets[popup_menu_parent].widget, CWOverrideRedirect, &set_attributes);

//  XMapWindow(display, menu->widgets[popup_menu_parent].widget);
  XFlush(display);


}
Example #21
0
void
fl_set_canvas_attributes( FL_OBJECT            * ob,
                          unsigned int           mask,
                          XSetWindowAttributes * xswa )
{
    FLI_CANVAS_SPEC *sp = ob->spec;

    /* Must not allow adding/removing events. We take care of soliciting
       events via canvas handler registrations */

    if ( mask & CWEventMask )
    {
        M_err( "fl_set_canvas_attributes", "Changing Events not supported" );
        mask &= ~ CWEventMask;
    }

    sp->user_mask = mask;
    sp->user_xswa = *xswa;

    /* Check if canvas is already active */

    if ( sp->window )
    {
        XChangeWindowAttributes( flx->display, sp->window,
                                 sp->user_mask, &sp->user_xswa );

        if ( mask & CWColormap )
            BegWMColormap( sp );
    }
}
static void
create_host_window (void)
{
  unsigned long valuemask;
  XSetWindowAttributes attributes;

  display = XOpenDisplay (NULL);
  if (display) {
    window =
        XCreateSimpleWindow (display, DefaultRootWindow (display), 0, 0,
        x_width, x_height, 0, 0, 0);
    if (window) {
      valuemask = CWOverrideRedirect;
      attributes.override_redirect = True;
      XChangeWindowAttributes (display, window, valuemask, &attributes);
      XSetWindowBackgroundPixmap (display, window, None);
      XMapRaised (display, window);
      XSync (display, FALSE);
    } else {
      GST_DEBUG ("could not create X window!");
    }
  } else {
    GST_DEBUG ("could not open display!");
  }
}
Example #23
0
File: FTips.c Project: fvwmorg/fvwm
static
void __setup_cs(Display *dpy)
{
	XSetWindowAttributes xswa;
	unsigned long valuemask = 0;


	if (current_config->colorset > -1)
	{
		xswa.border_pixel = Colorset[current_config->colorset].fg;
		xswa.background_pixel = Colorset[current_config->colorset].bg;
		if (Colorset[current_config->colorset].pixmap)
		{
			/* set later */
			xswa.background_pixmap = None;
			valuemask = CWBackPixmap | CWBorderPixel;;
		}
		else
		{
			valuemask = CWBackPixel | CWBorderPixel;
		}
	}
	else
	{
		xswa.border_pixel = current_config->border_pixel;
		xswa.background_pixel = current_config->bg;
		valuemask = CWBackPixel | CWBorderPixel;
	}
	XChangeWindowAttributes(dpy, win, valuemask, &xswa);
}
Example #24
0
/*
===========
IN_GrabMouse
===========
*/
void IN_GrabMouse (void)
{
	if (mouse_available && !mouse_grab_active && x_win)
	{
		XWindowAttributes attribs_1;
		XSetWindowAttributes attribs_2;

		XGetWindowAttributes(x_disp, x_win, &attribs_1);
		attribs_2.event_mask = attribs_1.your_event_mask | KEY_MASK | MOUSE_MASK;
		XChangeWindowAttributes(x_disp, x_win, CWEventMask, &attribs_2);

		// hide cursor
		XDefineCursor(x_disp, x_win, CreateNullCursor());
		// grab pointer
		XGrabPointer(x_disp, x_win, True, 0, GrabModeAsync, GrabModeAsync, x_win, None, CurrentTime);

		if (dga_mouse_available)
		{
			if (!vidmode_fullscreen && (vid.width < 640 || vid.height < 480))
				Con_Warning ("Running low-res windowed mode, XFree86 DGA Mouse disabled\n");
			else
				IN_ActivateDGAMouse();

		}

		mouse_grab_active = true;
	}
}
Example #25
0
void LightBorder(Display *disp, Window win, unsigned long color)
{
    XSetWindowAttributes attributes;

    attributes.border_pixel = color;
    XChangeWindowAttributes(disp, win, CWBorderPixel, &attributes);
}
Example #26
0
static void
set_event_mask(Display *dpy, Window win)
{
   XSetWindowAttributes attr;
   attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
   XChangeWindowAttributes(dpy, win, CWEventMask, &attr);
}
Example #27
0
Window psb_xrandr_create_full_screen_window(unsigned int destx, unsigned int desty, unsigned int destw, unsigned int desth)
{
    int x, y, width, height;
    Window win;

    x = psb_xrandr_info->extend_crtc->x;
    y = psb_xrandr_info->extend_crtc->y;
    width = psb_xrandr_info->extend_crtc->width;
    height = psb_xrandr_info->extend_crtc->height;

    if (destw == 0 || desth == 0) {
        destw = width;
        desth = height;
    }
    win = XCreateSimpleWindow(psb_xrandr_info->dpy, DefaultRootWindow(psb_xrandr_info->dpy), destx, desty, destw, desth, 0, 0, 0);

    MWMHints mwmhints;
    Atom MOTIF_WM_HINTS;

    mwmhints.flags = MWM_HINTS_DECORATIONS;
    mwmhints.decorations = 0; /* MWM_DECOR_BORDER */
    MOTIF_WM_HINTS = XInternAtom(psb_xrandr_info->dpy, "_MOTIF_WM_HINTS", False);
    XChangeProperty(psb_xrandr_info->dpy, win, MOTIF_WM_HINTS, MOTIF_WM_HINTS, sizeof(long) * 8,
                    PropModeReplace, (unsigned char*) &mwmhints, sizeof(mwmhints) / sizeof(long));

    XSetWindowAttributes attributes;
    attributes.override_redirect = 1;
    unsigned long valuemask;
    valuemask = CWOverrideRedirect ;
    XChangeWindowAttributes(psb_xrandr_info->dpy, win, valuemask, &attributes);

    XMapWindow(psb_xrandr_info->dpy, win);
    XFlush(psb_xrandr_info->dpy);
    return win;
}
Example #28
0
int
init_top_window(char *name)
{
    HyperDocPage *page;
    XSetWindowAttributes wa;    /* The X attributes structure */
    HDWindow *old_win = gWindow;

    gWindow = alloc_hd_window();

    if (name == NULL) {
        /** Then allocate an empty page, and assign it to gWindow->page */
        page = alloc_page((char *) NULL);
    }
    else {
        /* Try to find the page in the page hash table */
        page = (HyperDocPage *) hash_find(gWindow->fPageHashTable, name);
        if (page == NULL) {
            fprintf(stderr, "(HyperDoc)  Couldn\'t find page %s in page hash table \n",
                    name);
            if (gParentWindow == NULL)
                /* Gaak, This is a start up error */
                exit(-1);
            else {
                gWindow = old_win;
                return -1;
            }
        }
    }

    /* First allocate memory for the new window structure   */
    gWindow->page = page;

    if (old_win == NULL)
        open_window(0);
    else
        open_window(old_win->fMainWindow);

    get_GCs(gWindow);
    XMapWindow(gXDisplay, gWindow->fMainWindow);
    hash_insert(&gSessionHashTable, (char *)gWindow,(char *) &gWindow->fMainWindow);

    change_text(gRmColor, gRmFont);
    wa.background_pixel = gBackgroundColor;
    XChangeWindowAttributes(gXDisplay, gWindow->fMainWindow, CWBackPixel, &wa);
    XChangeWindowAttributes(gXDisplay, gWindow->fScrollWindow, CWBackPixel,&wa);
    return 1;
}
Example #29
0
int main(int argc, const char** argv)
{
	XInitThreads();
	s_display = XOpenDisplay(0);

	int32_t screen = DefaultScreen(s_display);
	int32_t depth = DefaultDepth(s_display, screen);
	Visual* visual = DefaultVisual(s_display, screen);
	Window root = RootWindow(s_display, screen);

	XSetWindowAttributes windowAttrs = { 0 };
	windowAttrs.background_pixmap = 0;
	windowAttrs.border_pixel = 0;
	windowAttrs.event_mask = 0
			| ButtonPressMask
			| ButtonReleaseMask
			| ExposureMask
			| KeyPressMask
			| KeyReleaseMask
			| PointerMotionMask
			| ResizeRedirectMask
			| StructureNotifyMask
			;

	int width = 800;
	int height = 600;

	s_window = XCreateWindow(s_display
							, root
							, 0, 0
							, width, height, 0, depth
							, InputOutput
							, visual
							, CWBorderPixel|CWEventMask
							, &windowAttrs
							);

	// Clear window to black.
	XSetWindowAttributes attr = { 0 };
	XChangeWindowAttributes(s_display, s_window, CWBackPixel, &attr);

	const char* wmDeleteWindowName = "WM_DELETE_WINDOW";
	XInternAtoms(s_display, (char **)&wmDeleteWindowName, 1, False, &wmDeleteWindow);
	XSetWMProtocols(s_display, s_window, &wmDeleteWindow, 1);

	XMapWindow(s_display, s_window);
	XStoreName(s_display, s_window, "ProDBG");

	bgfx::x11SetDisplayWindow(s_display, s_window);
    
    ProDBG_create((void*)s_window, width, height);

	processEvents();

	XUnmapWindow(s_display, s_window);
	XDestroyWindow(s_display, s_window);

	return EXIT_SUCCESS;
}
// Set up a window.
int initWindow( long width, long height ) {
  int defScreen;
  XSetWindowAttributes wAttr;
  XGCValues gcValues;
  char buffer[64] = "Graphics";
  XTextProperty xtp = {(unsigned char *)buffer, 125, 8, strlen(buffer)};

  /*
   * connect to the X server.  uses the server specified in the
   * DISPLAY environment variable
   */
  curDisplay = XOpenDisplay((char *) NULL);
  if ((Display *) NULL == curDisplay) {
    fprintf(stderr, "Fish School Stats Display:  could not open display.\n");
      exit(-1);
  }
   
  /*
   * begin to create a window
   */
  defdepth = DefaultDepth(curDisplay,0);
  bytesPerPixel = defdepth/8;
  bytesPerPixel = bytesPerPixel == 3 ? 4 : bytesPerPixel;

  defScreen = DefaultScreen(curDisplay);

  curWindow = XCreateWindow(curDisplay, DefaultRootWindow(curDisplay),
                            10, 10, width, height, 0, 
                            defdepth, InputOutput, 
                            DefaultVisual(curDisplay, defScreen),
                            0, &wAttr);


  /*
   * request mouse button and keypress events
   */
  wAttr.event_mask = ButtonPressMask | KeyPressMask | ExposureMask;
  XChangeWindowAttributes(curDisplay, curWindow, CWEventMask, &wAttr);

  /*
   * force it to appear on the screen
   */
  XSetWMName(curDisplay, curWindow, &xtp);
  XMapWindow(curDisplay, curWindow);

  /*
   * create a graphics context.  this stores a drawing state; stuff like
   * current color and line width.  this gc is for drawing into our
   * window. 
   */
  curGC = XCreateGC(curDisplay, curWindow, 0, &gcValues);
  defaultFont = XQueryFont(curDisplay, XGContextFromGC(curGC));

  XSetWindowColormap( curDisplay,
                      curWindow,
                      DefaultColormapOfScreen(DefaultScreenOfDisplay(curDisplay)));

  return(bytesPerPixel);
}