Esempio n. 1
0
static void
panel_start_gui(panel *p)
{
    ENTER;

    // main toplevel window
    p->topgwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(p->topgwin), 0);
    g_signal_connect(G_OBJECT(p->topgwin), "destroy-event",
        (GCallback) panel_destroy_event, p);
    g_signal_connect(G_OBJECT(p->topgwin), "size-request",
        (GCallback) panel_size_req, p);
    g_signal_connect(G_OBJECT(p->topgwin), "map-event",
        (GCallback) panel_mapped, p);
    g_signal_connect(G_OBJECT(p->topgwin), "configure-event",
        (GCallback) panel_configure_event, p);
    g_signal_connect(G_OBJECT(p->topgwin), "button-press-event",
        (GCallback) panel_button_press_event, p);
    g_signal_connect(G_OBJECT(p->topgwin), "scroll-event",
        (GCallback) panel_scroll_event, p);

    gtk_window_set_resizable(GTK_WINDOW(p->topgwin), FALSE);
    gtk_window_set_wmclass(GTK_WINDOW(p->topgwin), "panel", "fbpanel2");
    gtk_window_set_title(GTK_WINDOW(p->topgwin), "panel");
    gtk_window_set_position(GTK_WINDOW(p->topgwin), GTK_WIN_POS_NONE);
    gtk_window_set_decorated(GTK_WINDOW(p->topgwin), FALSE);
    gtk_window_set_accept_focus(GTK_WINDOW(p->topgwin), FALSE);
    if (p->setdocktype)
        gtk_window_set_type_hint(GTK_WINDOW(p->topgwin),
            GDK_WINDOW_TYPE_HINT_DOCK);

    if (p->layer == LAYER_ABOVE)
        gtk_window_set_keep_above(GTK_WINDOW(p->topgwin), TRUE);
    else if (p->layer == LAYER_BELOW)
        gtk_window_set_keep_below(GTK_WINDOW(p->topgwin), TRUE);
    gtk_window_stick(GTK_WINDOW(p->topgwin));

    gtk_widget_realize(p->topgwin);
    p->topxwin = GDK_WINDOW_XWINDOW(p->topgwin->window);
    DBG("topxwin = %lx\n", p->topxwin);
    /* ensure configure event */
    XMoveWindow(GDK_DISPLAY(), p->topxwin, 20, 20);
    XSync(GDK_DISPLAY(), False);
    
    gtk_widget_set_app_paintable(p->topgwin, TRUE);
    calculate_position(p);
    gtk_window_move(GTK_WINDOW(p->topgwin), p->ax, p->ay);
    gtk_window_resize(GTK_WINDOW(p->topgwin), p->aw, p->ah);
    DBG("move-resize x %d y %d w %d h %d\n", p->ax, p->ay, p->aw, p->ah);
    //XSync(GDK_DISPLAY(), False);
    //gdk_flush();

    // background box all over toplevel
    p->bbox = gtk_bgbox_new();
    gtk_container_add(GTK_CONTAINER(p->topgwin), p->bbox);
    gtk_container_set_border_width(GTK_CONTAINER(p->bbox), 0);
    if (p->transparent) {
        p->bg = fb_bg_get_for_display();
        gtk_bgbox_set_background(p->bbox, BG_ROOT, p->tintcolor, p->alpha);
    }

    // main layout manager as a single child of background widget box
    p->lbox = p->my_box_new(FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(p->lbox), 0);
    gtk_container_add(GTK_CONTAINER(p->bbox), p->lbox);

    p->box = p->my_box_new(FALSE, p->spacing);
    gtk_container_set_border_width(GTK_CONTAINER(p->box), 0);
    gtk_box_pack_start(GTK_BOX(p->lbox), p->box, TRUE, TRUE,
        (p->round_corners) ? p->round_corners_radius : 0);
    if (p->round_corners) {
        make_round_corners(p);
        DBG("make_round_corners\n");
    }
    /* start window creation process */
    gtk_widget_show_all(p->topgwin);
    /* .. and hide it from user until everything is done */
    gtk_widget_hide(p->topgwin);

    p->menu = panel_make_menu(p);

    if (p->setstrut)
        panel_set_wm_strut(p);
    
    XSelectInput(GDK_DISPLAY(), GDK_ROOT_WINDOW(), PropertyChangeMask);
    gdk_window_add_filter(gdk_get_default_root_window(),
          (GdkFilterFunc)panel_event_filter, p);
    //XSync(GDK_DISPLAY(), False);
    gdk_flush();
    RET();
}
Esempio n. 2
0
/**
 * Grab a frame from x11 (public device demuxer API).
 *
 * @param s1 Context from avformat core
 * @param pkt Packet holding the brabbed frame
 * @return frame size in bytes
 */
static int
x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
{
    struct x11grab *s = s1->priv_data;
    Display *dpy = s->dpy;
    XImage *image = s->image;
    int x_off = s->x_off;
    int y_off = s->y_off;

    int screen;
    Window root;
    int follow_mouse = s->follow_mouse;

    int64_t curtime, delay;
    struct timespec ts;

    /* Calculate the time of the next frame */
    s->time_frame += INT64_C(1000000);

    /* wait based on the frame rate */
    for(;;) {
        curtime = av_gettime();
        delay = s->time_frame * av_q2d(s->time_base) - curtime;
        if (delay <= 0) {
            if (delay < INT64_C(-1000000) * av_q2d(s->time_base)) {
                s->time_frame += INT64_C(1000000);
            }
            break;
        }
        ts.tv_sec = delay / 1000000;
        ts.tv_nsec = (delay % 1000000) * 1000;
        nanosleep(&ts, NULL);
    }

    av_init_packet(pkt);
    pkt->data = image->data;
    pkt->size = s->frame_size;
    pkt->pts = curtime;

    screen = DefaultScreen(dpy);
    root = RootWindow(dpy, screen);
    if (follow_mouse) {
        int screen_w, screen_h;
        int pointer_x, pointer_y, _;
        Window w;

        screen_w = DisplayWidth(dpy, screen);
        screen_h = DisplayHeight(dpy, screen);
        XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_);
        if (follow_mouse == -1) {
            // follow the mouse, put it at center of grabbing region
            x_off += pointer_x - s->width  / 2 - x_off;
            y_off += pointer_y - s->height / 2 - y_off;
        } else {
            // follow the mouse, but only move the grabbing region when mouse
            // reaches within certain pixels to the edge.
            if (pointer_x > x_off + s->width - follow_mouse) {
                x_off += pointer_x - (x_off + s->width - follow_mouse);
            } else if (pointer_x < x_off + follow_mouse)
                x_off -= (x_off + follow_mouse) - pointer_x;
            if (pointer_y > y_off + s->height - follow_mouse) {
                y_off += pointer_y - (y_off + s->height - follow_mouse);
            } else if (pointer_y < y_off + follow_mouse)
                y_off -= (y_off + follow_mouse) - pointer_y;
        }
        // adjust grabbing region position if it goes out of screen.
        s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
        s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);

        if (s->show_region && s->region_win)
            XMoveWindow(dpy, s->region_win,
                        s->x_off - REGION_WIN_BORDER,
                        s->y_off - REGION_WIN_BORDER);
    }

    if (s->show_region) {
        if (s->region_win) {
            XEvent evt;
            // clean up the events, and do the initinal draw or redraw.
            for (evt.type = NoEventMask; XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask, &evt); );
            if (evt.type)
                x11grab_draw_region_win(s);
        } else {
            x11grab_region_win_init(s);
        }
    }

    if(s->use_shm) {
        if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes)) {
            av_log (s1, AV_LOG_INFO, "XShmGetImage() failed\n");
        }
    } else {
        if (!xget_zpixmap(dpy, root, image, x_off, y_off)) {
            av_log (s1, AV_LOG_INFO, "XGetZPixmap() failed\n");
        }
    }

    if (s->draw_mouse) {
        paint_mouse_pointer(image, s);
    }

    return s->frame_size;
}
Esempio n. 3
0
void
button_press(XEvent ev)
{
  Client *c;
  int mouse_x, mouse_y;
  DEBUG_PRINT("got ButtonPress\n");
  get_mouse_x_y(&mouse_x, &mouse_y);
  if(ev.xbutton.window == root) {
    switch(ev.xbutton.button) {
      case Button2:
        system("gtk-switch &");
        break;
      default:
        system("gtk-panel &");
        break;
    }
  }
  c = find_client_by_frame(ev.xbutton.window);
  if (c) {
    Decal *decal;
    XEvent peek;

    decal = decal_at(c, ev.xbutton.x, ev.xbutton.y);
    XPeekEvent(disp, &peek);

    if (decal) {
      Decal *tmp_decal;
      XEvent tmp_ev;
      XMaskEvent(disp, ButtonReleaseMask, &tmp_ev);
      tmp_decal = decal_at(c, tmp_ev.xbutton.x, tmp_ev.xbutton.y);
      if(tmp_decal == decal)
        do_decal_fn(c, decal, ev.xbutton.button);
      return;
    }

    if (ev.xbutton.button == Button2) {
      shade_client(c);
      XSync(disp, False);
      icccm_send_configure_event(c);
      return;
    }

    if (ev.xbutton.button == Button3) {
      return;
    }

    /* the user let go immediately, so treat as click not drag */
    if (peek.type == ButtonRelease) {
      Window top;
      Client *tmp;
      char *name;

      top = x_get_top_window();
      XFetchName(disp, top, &name);
      DEBUG_VAR("top window: %s\n", name);
      XFree(name);

      tmp = find_client_by_frame(top);
      if (!tmp)
        DEBUG_PRINT("top window not found as frame\n");

      if (c->frame == top) {
        DEBUG_PRINT("client is on top\n");
        XLowerWindow(disp, c->frame);
      } else {
        DEBUG_PRINT("client is NOT on top\n");
        XRaiseWindow(disp, c->frame);
      }
    }

    /* motion before release detected, so drag and move */
    if (peek.type == MotionNotify) {
      drag_client(c, mouse_x, mouse_y);
      if (MOVE_AFTER_DRAG) {
        XMoveWindow(disp, c->frame, c->x, c->y);
      }
      XSync(disp,False);
      if (SEND_CONFIGURE_AFTER_DRAG) {
        icccm_send_configure_event(c);
      }
    }
  }
}
Esempio n. 4
0
void ColorButton::move(int x, int y)
{
    XMoveWindow(x11->dpy, win, x, y);
}
//==============================================================================
VstPluginExternalEditor::VstPluginExternalEditor (BasePlugin* plugin_,
                                                  VstPluginWindow* window_)
  : PluginEditorComponent (plugin_),
#if defined(LINUX)
    eventProc (0),
#endif
    handle (0),
    window (window_),
    editorWidth (0),
    editorHeight (0),
    offsetX (0),
    offsetY (0)
#ifdef JUCE_MAC && 0
	, vstGuiWindow(0)
#endif
{
    DBG ("VstPluginExternalEditor::VstPluginExternalEditor");
    
    setWantsKeyboardFocus (true);
    setVisible (true);

#if defined(LINUX)
    plugin->openEditor (window->getWindowHandle (), display);

    handle = getChildWindow ((Window) window->getWindowHandle ());
    if (handle)
        eventProc = (EventProcPtr) obtainPropertyFromXWindow (handle,
                                                              XInternAtom (display, "_XEventProc", false));

#elif defined(_WIN32)
    plugin->openEditor (window->getWindowHandle (), (void*) 0);

	handle = GetWindow ((HWND) window->getWindowHandle(), GW_CHILD);
#endif

    if (editorWidth <= 0 || editorHeight <= 0)
        plugin->getEditorSize (editorWidth, editorHeight);

    jassert (editorWidth > 0 && editorHeight > 0);
    setSize (editorWidth, editorHeight);

    offsetX = window->getBorderThickness().getLeft ();
    offsetY = window->getTitleBarHeight()
              + window->getMenuBarHeight()
              + window->getBorderThickness().getTop ();
    
    if (handle)
    {
#if defined(LINUX)
        XResizeWindow (display, handle, editorWidth, editorHeight);
        XMoveWindow (display, handle, offsetX, offsetY);
#elif defined (_WIN32)
		MoveWindow (handle, offsetX, offsetY, editorWidth, editorHeight, true); 
#endif
    }
    
//#ifdef JUCE_MAC
#if 0
    setGuiWindow(new MacVSTGUIPositionHelperWindow(plugin, window->getX() + offsetX, window->getY() + offsetY));
    showGUI(true);
#endif

	repaint ();

	startTimer (1000 / 10);
}
int hxc_scrollbar::WinProc(hxc_scrollbar *This,Window Win,XEvent *Ev)
{
	int mpos;
	This->common_winproc(Ev);
  switch(Ev->type){
  case MotionNotify:
  	if(This->horizontal){
	  	mpos=Ev->xmotion.x;
	  }else{
	  	mpos=Ev->xmotion.y;
	  }
  	
    if((Ev->xmotion.state) & Button1Mask){
      if(This->dragstage==1){
        (This->do_drag)(mpos-(This->arrowheight)-(This->drag_y),true);
      }
    }else if((Ev->xmotion.state) & Button2Mask){
      (This->do_drag)(mpos-(This->arrowheight),false); //set middle where clicked, if possible
    }
    break;
  case ButtonRelease:
    if (Ev->xbutton.button==Button4 || Ev->xbutton.button==Button5) break; // No wheel
    if(This->dragstage){
      This->dragstage=0;
      This->draw();
    }
    break;
  case ButtonPress:
    if (Ev->xbutton.button==Button1){
      XWindowAttributes wa;
      XGetWindowAttributes(This->XD,This->handle,&wa);
      int h;
      int mx,my;
      if (This->horizontal){
        mx=Ev->xbutton.y;
        my=Ev->xbutton.x;
        h=wa.width;
      }else{
        mx=Ev->xbutton.x;
        my=Ev->xbutton.y;
        h=wa.height;
      }

      if (my<This->arrowheight){  //scrolled one up
        if (This->notifyproc) (This->notifyproc)(This,SBN_SCROLLBYONE,-1);
      }else if (my>h-(This->arrowheight)){  //scroll one down
        if (This->notifyproc) (This->notifyproc)(This,SBN_SCROLLBYONE,1);
      }else if (my<(This->arrowheight)+(This->ty)){  //page up
        if (This->notifyproc) (This->notify_reposition)((This->pos)-(This->viewrange));
      }else if (my>(This->arrowheight)+(This->ty)+(This->th)){ //page down
        if (This->notifyproc) (This->notify_reposition)((This->pos)+(This->viewrange));
      }else{   //start drag
        This->dragstage=1;
        This->drag_y=my-((This->arrowheight)+(This->ty));
        This->draw();
      }
      break;
    }else if (Ev->xbutton.button==Button2){ //MMB
    	if(This->horizontal){
  	  	mpos=Ev->xmotion.x;
  	  }else{
  	  	mpos=Ev->xmotion.y;
  	  }
      (This->do_drag)(mpos-(This->arrowheight),false); //set middle where clicked, if possible
    }else if (Ev->xbutton.button==Button4){  //wheel up
      if (This->notifyproc) (This->notify_reposition)((This->pos)-(This->viewrange));
    }else if (Ev->xbutton.button==Button5){ //wheel down
      if (This->notifyproc) (This->notify_reposition)((This->pos)+(This->viewrange));
    }

    break;
  case Expose:
    if (Ev->xexpose.count>0) break;
    This->draw();
    XSync(This->XD,0);
    break;
  case ConfigureNotify:
    XWindowAttributes wa,but_wa;
    XGetWindowAttributes(This->XD,Win,&wa);
    XGetWindowAttributes(This->XD,This->DownBut.handle,&but_wa);
    if(This->horizontal){
    	XMoveWindow(This->XD,This->DownBut.handle,wa.width-but_wa.height,0);
    }else{
    	XMoveWindow(This->XD,This->DownBut.handle,0,wa.height-but_wa.height);
    }
    XSync(This->XD,0);
    break;
  }
  return 0;
}
Esempio n. 7
0
JNIEXPORT void JNICALL  Java_sun_awt_X11_XlibWrapper_XMoveWindow
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint width, jint height) 
{
    AWT_CHECK_HAVE_LOCK();   
    XMoveWindow( (Display *) display,(Window) window,width,height);
}
Esempio n. 8
0
static void showApercu(WScreen *scr, int x, int y, int height, int width, char *title, Pixmap apercu)
{
	Pixmap pixmap;
	WMFont *font = scr->info_text_font;
	int titleHeight = 0;
	char *shortenTitle = title;

	if (scr->balloon->contents)
		XFreePixmap(dpy, scr->balloon->contents);

	if (wPreferences.miniwin_title_balloon) {
		shortenTitle = ShrinkString(font, title, width - APERCU_BORDER);
		titleHeight = countLines(shortenTitle) * WMFontHeight(font) + 4;
		height += titleHeight;
	}

	if (x < 0)
		x = 0;
	else if (x + width > scr->scr_width - 1)
		x = scr->scr_width - width - APERCU_BORDER;

	if (y - height - 2 < 0) {
		y += wPreferences.icon_size;
		if (y < 0)
			y = 0;
	} else {
		y -= height + 2;
	}

	if (scr->window_title_texture[0])
		XSetForeground(dpy, scr->draw_gc, scr->window_title_texture[0]->any.color.pixel);
	else
		XSetForeground(dpy, scr->draw_gc, scr->light_pixel);

	pixmap = XCreatePixmap(dpy, scr->root_win, width, height, scr->w_depth);
	XFillRectangle(dpy, pixmap, scr->draw_gc, 0, 0, width, height);

	if (shortenTitle && wPreferences.miniwin_title_balloon) {
		drawMultiLineString(scr->wmscreen, pixmap, scr->window_title_color[0], font,
						APERCU_BORDER, APERCU_BORDER, shortenTitle, strlen(shortenTitle));
		wfree(shortenTitle);
	}

	XCopyArea(dpy, apercu, pixmap, scr->draw_gc,
				0, 0, (wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size,
				(wPreferences.icon_size - 1 - APERCU_BORDER) * wPreferences.apercu_size,
				APERCU_BORDER, APERCU_BORDER + titleHeight);

#ifdef SHAPED_BALLOON
	XShapeCombineMask(dpy, scr->balloon->window, ShapeBounding, 0, 0, None, ShapeSet);
#endif
	XResizeWindow(dpy, scr->balloon->window, width, height);
	XMoveWindow(dpy, scr->balloon->window, x, y);

	XSetWindowBackgroundPixmap(dpy, scr->balloon->window, pixmap);

	XClearWindow(dpy, scr->balloon->window);
	XMapRaised(dpy, scr->balloon->window);


	scr->balloon->contents = pixmap;

	scr->balloon->mapped = 1;
}
Esempio n. 9
0
int
spadAction(void)
{
  int code,viewCommand;
  float f1,f2;
  int i1,i2,i3,viewGoAhead;
  static int ack = 1;

  if (viewAloned==yes) {
      close(0);
      return(-1);
      }
  readViewman(&viewCommand,intSize);

  switch (viewCommand) {

  case hideControl2D:
    readViewman(&i1,intSize);
    if (i1) {                         /* show control panel */
      if (viewport->haveControl) XUnmapWindow(dsply,control->controlWindow);
      putControlPanelSomewhere(someInt);
    } else {    /* turn off control panel */
      if (viewport->haveControl) {
        viewport->haveControl = no;
        XUnmapWindow(dsply,control->controlWindow);
      }
    }
    break;

  case changeTitle:
    readViewman(&i1,intSize);
    readViewman(viewport->title,i1);
    viewport->title[i1] = '\0';
    writeTitle();
    writeControlTitle();
    XFlush(dsply);
    spadDraw=no;
    break;

  case writeView:
    readViewman(&i1,intSize);
    readViewman(filename,i1);
    filename[i1] = '\0';
    sprintf(errorStr,"writing of viewport data");
    i3 = 0;
    readViewman(&i2,intSize);
    while (i2) {
      i3 = i3 | (1<<i2);
      readViewman(&i2,intSize);
    }
    if (writeViewport(i3) < 0)
      fprintf(stderr,"          Nothing was written\n");
    break;

  case closeAll2D:
    code = check(write(Socket,&ack,intSize));
    goodbye(-1);

  case ps2D:
    readViewman(&i1,intSize);
    buttonAction(viewCommand);
    break;

  case axesOnOff2D:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].axesOn = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case axesColor2D:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].axesColor = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case unitsOnOff2D:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].unitsOn = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case unitsColor2D:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].unitsColor = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case connectOnOff:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].connectOn = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case pointsOnOff:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].pointsOn = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case spline2D:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    graphStateArray[i1].splineOn = i2;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;

  case showing2D:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&i2,intSize);
    /* simulate a button press to turn display number on/off */
    graphStateArray[i1].showing = !i2;
    clickedOnGraph(i1,i1+graphStart);
    break;

  case scale2D:
    readViewman(&i1,intSize);
    i1--;   /* passed index is [1..9] but internal representation is [0..8] */
    readViewman(&f1,floatSize);
    readViewman(&f2,floatSize);
    graphStateArray[i1].scaleX = f1;
    graphStateArray[i1].scaleY = f2;
    if (graphStateArray[i1].scaleX > maxScale)
      graphStateArray[i1].scaleX = maxScale;
    else
      if (graphStateArray[i1].scaleX < minScale)
        graphStateArray[i1].scaleX = minScale;
    if (graphStateArray[i1].scaleY > maxScale)
      graphStateArray[i1].scaleY = maxScale;
    else
      if (graphStateArray[i1].scaleY < minScale)
        graphStateArray[i1].scaleY = minScale;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;   /* scale2D */


  case translate2D:
    readViewman(&i1,intSize);
    i1--;   /* passed index is [1..9] but internal representation is [0..8] */
    readViewman(&f1,floatSize);
    readViewman(&f2,floatSize);
    graphStateArray[i1].centerX = f1;
    graphStateArray[i1].centerY = f2;
    if (graphStateArray[i1].centerX > maxDelta)
      graphStateArray[i1].centerX = maxDelta;
    else if (graphStateArray[i1].centerX < -maxDelta)
           graphStateArray[i1].centerX = maxDelta;
    if (graphStateArray[i1].centerY > maxDelta)
      graphStateArray[i1].centerY = maxDelta;
    else if (graphStateArray[i1].centerY < -maxDelta)
           graphStateArray[i1].centerY = maxDelta;
    if (graphStateArray[i1].showing) spadDraw=yes;
    break;   /* translate2D */

  case moveViewport:
    readViewman(&i1,intSize);
    readViewman(&i2,intSize);
    XMoveWindow(dsply,viewport->titleWindow,i1,i2);
    XSync(dsply,False);
    break;

 case resizeViewport:
    readViewman(&i1,intSize);
    readViewman(&i2,intSize);
    XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight);
    XResizeWindow(dsply,viewport->viewWindow,i1,i2);
    spadDraw=yes;
    break;

  case putGraph:
    readViewman(&i1,intSize);           /* key of graph to get */
    readViewman(&i2,intSize);           /* slot to drop graph onto 0..8*/
    readViewman(&viewGoAhead,intSize);
    if (viewGoAhead < 0) {
      sprintf(control->message,"%s%d","Couldn't put into graph ",i2+1);
      writeControlMessage();
    } else {
      sprintf(control->message,"%s%d","Dropped onto graph ",i2+1);
      writeControlMessage();
      freeGraph(i2);
      graphArray[i2].key = i1;
      getGraphFromViewman(i2);
      /* simulate a button press to turn display number on and select on */
      /* need !yes since it will be inverted */
      graphStateArray[i2].selected = no;
      graphStateArray[i2].connectOn = yes;
      graphStateArray[i2].showing = !(graphStateArray[i2].showing);
      clickedOnGraph(i2,i2+graphStart);
      clickedOnGraphSelect(i2,i2+graphSelectStart);
    }
    break;

  case spadPressedAButton:
    readViewman(&i1,intSize);
    buttonAction(i1);
    break;

  default:
    return(-1);
  } /* switch */


  ack++;
  code = check(write(Socket,&ack,intSize));
  return(0);

}
Esempio n. 10
0
void PackRootIcons (void)
{
    int iOld, iNew;
    ClientData *pCD;
    ClientData *pCD_active;
    int hasActiveText = 1;
#ifdef WSM
    WsClientData *pWsc;
#endif /* WSM */

    /* 
     * find context of the activeIconTextWin to get pCD and then 
     * if it is the same as this client, hide it.
     */

    if (XFindContext (DISPLAY, ACTIVE_PSD->activeIconTextWin,
			wmGD.windowContextType, (caddr_t *)&pCD_active))
    {
	hasActiveText = 0;
    }

    /* 
     *  Traverse the list and pack them together
     */

    if (wmGD.iconAutoPlace)
    {
	for (iOld = iNew = 0; iOld < ACTIVE_WS->IPData.totalPlaces; 
	    iOld++, iNew++)
	{
	    if (ACTIVE_WS->IPData.placeList[iOld].pCD == NULL)
	    {
		/* advance to next non-null entry */
		while (++iOld < ACTIVE_WS->IPData.totalPlaces && 
		       !ACTIVE_WS->IPData.placeList[iOld].pCD)
		    ;
	    }

	    if (iOld < ACTIVE_WS->IPData.totalPlaces && iOld != iNew)
	    {
		/* move the icon from its old place to the new place */

		MoveIconInfo (&ACTIVE_WS->IPData, iOld, iNew);

		pCD = ACTIVE_WS->IPData.placeList[iNew].pCD;
#ifdef WSM
		pWsc = GetWsClientData (ACTIVE_WS, pCD);
		pWsc->iconPlace = iNew;
		CvtIconPlaceToPosition (&ACTIVE_WS->IPData, 
		    pWsc->iconPlace, &pWsc->iconX, &pWsc->iconY);
#else /* WSM */
		pCD->iconPlace = iNew;
		CvtIconPlaceToPosition (&ACTIVE_WS->IPData, 
		    pCD->iconPlace, &pCD->iconX, &pCD->iconY);
#endif /* WSM */

		if (hasActiveText && (pCD == pCD_active))
		{
		    /* hide activeIconTextWin first */
		    HideActiveIconText ((WmScreenData *)NULL);
#ifdef WSM
		    XMoveWindow (DISPLAY, pWsc->iconFrameWin, pWsc->iconX, 
			     pWsc->iconY);
#else /* WSM */
		    XMoveWindow (DISPLAY, ICON_FRAME_WIN(pCD), pCD->iconX, 
			     pCD->iconY);
#endif /* WSM */
		    ShowActiveIconText (pCD);
		}
		else
		{
#ifdef WSM
		    XMoveWindow (DISPLAY, pWsc->iconFrameWin, pWsc->iconX, 
			     pWsc->iconY);
#else /* WSM */
		    XMoveWindow (DISPLAY, ICON_FRAME_WIN(pCD), pCD->iconX, 
			     pCD->iconY);
#endif /* WSM */
		}
	    }
	}
    }
} /* END OF FUNCTION PackRootIcons */
/*
 * Enters the game mode
 */
int FGAPIENTRY glutEnterGameMode( void )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" );

    if( fgStructure.GameModeWindow )
        fgAddToWindowDestroyList( fgStructure.GameModeWindow );
    else
        fghRememberState( );

    if( ! fghChangeDisplayMode( GL_FALSE ) )
    {
        fgWarning( "failed to change screen settings" );
        return 0;
    }

    fgStructure.GameModeWindow = fgCreateWindow(
        NULL, "FREEGLUT", GL_TRUE, 0, 0,
        GL_TRUE, fgState.GameModeSize.X, fgState.GameModeSize.Y,
        GL_TRUE, GL_FALSE
    );

    fgStructure.GameModeWindow->State.Width  = fgState.GameModeSize.X;
    fgStructure.GameModeWindow->State.Height = fgState.GameModeSize.Y;
    fgStructure.GameModeWindow->State.NeedToResize = GL_TRUE;

#if TARGET_HOST_POSIX_X11

    /*
     * Sync needed to avoid a real race, the Xserver must have really created
     * the window before we can grab the pointer into it:
     */
    XSync( fgDisplay.Display, False );
    /*
     * Grab the pointer to confine it into the window after the calls to
     * XWrapPointer() which ensure that the pointer really enters the window.
     *
     * We also need to wait here until XGrabPointer() returns GrabSuccess,
     * otherwise the new window is not viewable yet and if the next function
     * (XSetInputFocus) is called with a not yet viewable window, it will exit
     * the application which we have to aviod, so wait until it's viewable:
     */
    while( GrabSuccess != XGrabPointer(
               fgDisplay.Display, fgStructure.GameModeWindow->Window.Handle,
               TRUE,
               ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
               | PointerMotionMask,
               GrabModeAsync, GrabModeAsync,
               fgStructure.GameModeWindow->Window.Handle, None, CurrentTime) )
        usleep( 100 );
    /*
     * Change input focus to the new window. This will exit the application
     * if the new window is not viewable yet, see the XGrabPointer loop above.
     */
    XSetInputFocus(
        fgDisplay.Display,
        fgStructure.GameModeWindow->Window.Handle,
        RevertToNone,
        CurrentTime
    );

    /* Move the Pointer to the middle of the fullscreen window */
    XWarpPointer(
        fgDisplay.Display,
        None,
        fgDisplay.RootWindow,
        0, 0, 0, 0,
        fgState.GameModeSize.X/2, fgState.GameModeSize.Y/2
    );

#   ifdef HAVE_X11_EXTENSIONS_XF86VMODE_H

    if( fgDisplay.DisplayModeValid )
    {
        int x, y;
        Window child;

        /* Change to viewport to the window topleft edge: */
        if( !XF86VidModeSetViewPort( fgDisplay.Display, fgDisplay.Screen, 0, 0 ) )
            fgWarning( "XF86VidModeSetViewPort failed" );

        /*
         * Final window repositioning: It could be avoided using an undecorated
         * window using override_redirect, but this * would possily require
         * more changes and investigation.
         */

        /* Get the current postion of the drawable area on screen */
        XTranslateCoordinates(
            fgDisplay.Display,
            fgStructure.CurrentWindow->Window.Handle,
            fgDisplay.RootWindow,
            0, 0, &x, &y,
            &child
        );

        /* Move the decorataions out of the topleft corner of the display */
        XMoveWindow( fgDisplay.Display, fgStructure.CurrentWindow->Window.Handle,
                     -x, -y);
    }

#endif

    /* Grab the keyboard, too */
    XGrabKeyboard(
        fgDisplay.Display,
        fgStructure.GameModeWindow->Window.Handle,
        FALSE,
        GrabModeAsync, GrabModeAsync,
        CurrentTime
    );

#endif

    return fgStructure.GameModeWindow->ID;
}
Esempio n. 12
0
static void appicon_move_motion(virtual_screen *vscr, WScreen *scr, XEvent ev,
                                WDock **lastDock, WDock **originalDock,
                                WAppIcon *aicon, WDock **allDocks,
                                Bool *collapsed, Bool *dockable, Bool *ondock,
                                int *x, int *y, int *ix, int *iy,
                                int *shad_x, int *shad_y, int *ofs_x, int *ofs_y,
				Bool *grabbed, int omnipresent, Bool *showed_all_clips)
{
	WDock *theNewDock = NULL;
	int i, j;

	if (!(*grabbed)) {
		if (abs(*ofs_x - ev.xmotion.x) < MOVE_THRESHOLD &&
		    abs(*ofs_y - ev.xmotion.y) < MOVE_THRESHOLD)
			return;

		XChangeActivePointerGrab(dpy,
					 ButtonMotionMask | ButtonReleaseMask | ButtonPressMask,
					 wPreferences.cursor[WCUR_MOVE], CurrentTime);
		*grabbed = True;
	}

	if (omnipresent && !(*showed_all_clips)) {
		for (j = 0; j < vscr->workspace.count; j++) {
			if (j == vscr->workspace.current)
				continue;

			wDockShowIcons(vscr->workspace.array[j]->clip);
			/*
			 * Note: if dock is collapsed (for instance, because it
			 * auto-collapses), its icons still won't show up
			 */
		}

		*showed_all_clips = True; /* To prevent flickering */
	}

	*x = ev.xmotion.x_root - *ofs_x;
	*y = ev.xmotion.y_root - *ofs_y;
	wAppIconMove(aicon, *x, *y);
	if (!(ev.xmotion.state & MOD_MASK) || aicon->launching || aicon->lock || *originalDock == NULL) {
		for (i = 0; *dockable && i < vscr->drawer.drawer_count + 2; i++) {
			WDock *theDock = allDocks[i];
			if (theDock == NULL)
				break;

			if (wDockSnapIcon(theDock, aicon, *x, *y, ix, iy, (theDock == *originalDock))) {
				theNewDock = theDock;
				break;
			}
		}

		/* Stay in lastDock if no dock really wants us */
		if (*originalDock != NULL && theNewDock == NULL &&
		    (aicon->launching || aicon->lock || aicon->running))
			theNewDock = *lastDock;
	}

	if (*lastDock != NULL && *lastDock != theNewDock) {
		/* Leave lastDock in the state we found it */
		if ((*lastDock)->type == WM_DRAWER)
			wDrawerFillTheGap(*lastDock, aicon, (*lastDock == *originalDock));

		if (*collapsed) {
			(*lastDock)->collapsed = 1;
			wDockHideIcons(*lastDock);
			*collapsed = False;
		}

		if ((*lastDock)->auto_raise_lower)
			wDockLower(*lastDock);
	}

	if (theNewDock != NULL) {
		if (*lastDock != theNewDock) {
			*collapsed = theNewDock->collapsed;
			if (*collapsed) {
				theNewDock->collapsed = 0;
				wDockShowIcons(theNewDock);
			}

			if (theNewDock->auto_raise_lower) {
				wDockRaise(theNewDock);
				/* And raise the moving tile above it */
				wRaiseFrame(aicon->icon->vscr, aicon->icon->core);
			}

			*lastDock = theNewDock;
		}

		*shad_x = (*lastDock)->x_pos + *ix * wPreferences.icon_size;
		*shad_y = (*lastDock)->y_pos + *iy * wPreferences.icon_size;

		XMoveWindow(dpy, scr->dock_shadow, *shad_x, *shad_y);

		if (!(*ondock))
			XMapWindow(dpy, scr->dock_shadow);

		*ondock = 1;
	} else {
		*lastDock = NULL;
		if (*ondock)
			XUnmapWindow(dpy, scr->dock_shadow);

		*ondock = 0;
	}
}
Esempio n. 13
0
void wAppIconMove(WAppIcon *aicon, int x, int y)
{
	XMoveWindow(dpy, aicon->icon->core->window, x, y);
	aicon->x_pos = x;
	aicon->y_pos = y;
}
Esempio n. 14
0
void XfitMan::moveWindow(Window _win, int _x, int _y) const
{
    XMoveWindow(QX11Info::display(), _win, _x, _y);
}
Esempio n. 15
0
// Enter fullscreen mode
//
static void enterFullscreenMode(_GLFWwindow* window)
{
    if (!_glfw.x11.saver.changed)
    {
        // Remember old screen saver settings
        XGetScreenSaver(_glfw.x11.display,
                        &_glfw.x11.saver.timeout,
                        &_glfw.x11.saver.interval,
                        &_glfw.x11.saver.blanking,
                        &_glfw.x11.saver.exposure);

        // Disable screen saver
        XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
                        DefaultExposures);

        _glfw.x11.saver.changed = GL_TRUE;
    }

    _glfwSetVideoMode(window->monitor, &window->videoMode);

    if (_glfw.x11.hasEWMH &&
        _glfw.x11.NET_WM_STATE != None &&
        _glfw.x11.NET_WM_STATE_FULLSCREEN != None)
    {
        if (_glfw.x11.NET_ACTIVE_WINDOW != None)
        {
            // Ask the window manager to raise and focus the GLFW window
            // Only focused windows with the _NET_WM_STATE_FULLSCREEN state end
            // up on top of all other windows ("Stacking order" in EWMH spec)

            XEvent event;
            memset(&event, 0, sizeof(event));

            event.type = ClientMessage;
            event.xclient.window = window->x11.handle;
            event.xclient.format = 32; // Data is 32-bit longs
            event.xclient.message_type = _glfw.x11.NET_ACTIVE_WINDOW;
            event.xclient.data.l[0] = 1; // Sender is a normal application
            event.xclient.data.l[1] = 0; // We don't really know the timestamp

            XSendEvent(_glfw.x11.display,
                       _glfw.x11.root,
                       False,
                       SubstructureNotifyMask | SubstructureRedirectMask,
                       &event);
        }

        // Ask the window manager to make the GLFW window a fullscreen window
        // Fullscreen windows are undecorated and, when focused, are kept
        // on top of all other windows

        XEvent event;
        memset(&event, 0, sizeof(event));

        event.type = ClientMessage;
        event.xclient.window = window->x11.handle;
        event.xclient.format = 32; // Data is 32-bit longs
        event.xclient.message_type = _glfw.x11.NET_WM_STATE;
        event.xclient.data.l[0] = _NET_WM_STATE_ADD;
        event.xclient.data.l[1] = _glfw.x11.NET_WM_STATE_FULLSCREEN;
        event.xclient.data.l[2] = 0; // No secondary property
        event.xclient.data.l[3] = 1; // Sender is a normal application

        XSendEvent(_glfw.x11.display,
                   _glfw.x11.root,
                   False,
                   SubstructureNotifyMask | SubstructureRedirectMask,
                   &event);
    }
    else if (window->x11.overrideRedirect)
    {
        // In override-redirect mode we have divorced ourselves from the
        // window manager, so we need to do everything manually

        GLFWvidmode mode;
        _glfwPlatformGetVideoMode(window->monitor, &mode);

        XRaiseWindow(_glfw.x11.display, window->x11.handle);
        XSetInputFocus(_glfw.x11.display, window->x11.handle,
                       RevertToParent, CurrentTime);
        XMoveWindow(_glfw.x11.display, window->x11.handle, 0, 0);
        XResizeWindow(_glfw.x11.display, window->x11.handle,
                      mode.width, mode.height);
    }
}
Esempio n. 16
0
Window
gui_create_taskbar (void)
{
	Window win;
	MWMHints mwm;
	XSizeHints size_hints;
	XWMHints wmhints;
	XSetWindowAttributes att;
	unsigned long strut[4];

	att.background_pixel = palette[5];
	att.event_mask = ButtonPressMask | ExposureMask;

	win = XCreateWindow (  /* display */ dd,
								  /* parent  */ root_win,
								  /* x       */ 0,
								  /* y       */ scr_height - WINHEIGHT,
								  /* width   */ WINWIDTH,
								  /* height  */ WINHEIGHT,
								  /* border  */ 0,
								  /* depth   */ CopyFromParent,
								  /* class   */ InputOutput,
								  /* visual  */ CopyFromParent,
								  /*value mask*/ CWBackPixel | CWEventMask,
								  /* attribs */ &att);

    /* reserve "WINHEIGHT" pixels at the bottom of the screen */
	strut[0] = 0;
	strut[1] = 0;
	strut[2] = 0;
	strut[3] = WINHEIGHT;
	XChangeProperty (dd, win, atom__NET_WM_STRUT, XA_CARDINAL, 32,
						  PropModeReplace, (unsigned char *) strut, 4);

	/* reside on ALL desktops */
	set_prop (win, atom__NET_WM_DESKTOP, XA_CARDINAL, 0xFFFFFFFF);
	set_prop (win, atom__NET_WM_WINDOW_TYPE, XA_ATOM,
				 atom__NET_WM_WINDOW_TYPE_DOCK);
	/* use old gnome hint since sawfish doesn't support _NET_WM_STRUT */
	set_prop (win, atom__WIN_HINTS, XA_CARDINAL,
				 WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_WINLIST |
				 WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_DO_NOT_COVER);

	/* borderless motif hint */
	bzero (&mwm, sizeof (mwm));
	mwm.flags = MWM_HINTS_DECORATIONS;
	XChangeProperty (dd, win, atom__MOTIF_WM_HINTS, atom__MOTIF_WM_HINTS, 32,
						  PropModeReplace, (unsigned char *) &mwm,
						  sizeof (MWMHints) / 4);

	/* make sure the WM obays our window position */
	size_hints.flags = PPosition;
	/*XSetWMNormalHints (dd, win, &size_hints);*/
	XChangeProperty (dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32,
						  PropModeReplace, (unsigned char *) &size_hints,
						  sizeof (XSizeHints) / 4);

	/* make our window unfocusable */
	wmhints.flags = InputHint;
	wmhints.input = False;
	/*XSetWMHints (dd, win, &wmhints);*/
	XChangeProperty (dd, win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace,
							(unsigned char *) &wmhints, sizeof (XWMHints) / 4);

	XMapWindow (dd, win);

#ifdef XFT
	xftdraw = XftDrawCreate (dd, win, DefaultVisual (dd, scr_screen), 
									 DefaultColormap (dd, scr_screen));
#endif


	XMoveWindow (dd, win, 0, scr_height - WINHEIGHT);

	return win;
}
Esempio n. 17
0
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{
    XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
}
Esempio n. 18
0
/*
 * Change the specified window's position
 */
void fgPlatformPositionWindow( SFG_Window *window, int x, int y )
{
    XMoveWindow( fgDisplay.pDisplay.Display, window->Window.Handle,
                 x, y );
    XFlush( fgDisplay.pDisplay.Display ); /* XXX Shouldn't need this */
}
Esempio n. 19
0
void MarkPosCB (Widget parent, XtPointer clientData, XtPointer callData)
/* create dialog box for specifying positions to mark */
{
  Widget form, toplabel, equlab, label1, label2, label3;
  Widget data1, data2, data3, sep1, sep2, sep3;
  Widget FileButton, OKButton, CancelButton;
  XmString     RA=NULL, Dec=NULL,label=NULL, sizestr=NULL, equstr=NULL;
  char         valuestr[100], ctype[5];
  int          h, d, m, toHours;
  short        xpos, ypos;
  float        s;
  ImageDisplay *IDdata = (ImageDisplay*)clientData;
  Display *dpy = XtDisplay(parent);


/* validity checks */
  if (!IDdata) return;
  if (!image[CurImag].valid) return;

/* register IDdata */
  mark.IDdata = IDdata;

  /* don't make another one */
  if (PositionBoxActive) {
    if (XtIsRealized (mark.dialog))
	XMapRaised (XtDisplay(IDdata->shell), XtWindow(mark.dialog));
    return;
  }
  label = XmStringCreateSimple ("Position to mark on image");
  sizestr = XmStringCreateSimple ("size");
/* mark as active */
  PositionBoxActive = 1;

  mark.dialog = XtVaCreatePopupShell ("MarkPos", xmDialogShellWidgetClass, 
				 IDdata->shell, 
				 XmNautoUnmanage, False,
				 XmNwidth,     150,
				 XmNheight,    180,
				 XmNdeleteResponse, XmDESTROY,
				 NULL);

/* make Form widget to stick things on */
  form = XtVaCreateManagedWidget ("MarkForm", xmFormWidgetClass,
				  mark.dialog,
				  XmNautoUnmanage, False,
				  XmNwidth,     150,
				  XmNheight,    180,
				  XmNx,           0,
				  XmNy,           0,
				  NULL);

/* info label widgets */
  toplabel = XtVaCreateManagedWidget ("Label", xmLabelWidgetClass, 
				    form, 
				    XmNwidth,           150,
				    XmNlabelString,   label,
				    XmNtopAttachment, XmATTACH_FORM,
				    XmNleftAttachment,  XmATTACH_FORM,
				    NULL);

/* Equinox */
  if ((usr_equinox>0.0) && (image[CurImag].Image->descript->equinox>0.0))
    sprintf(valuestr,"Equinox %7.1f", usr_equinox);
  else if (image[CurImag].Image->descript->equinox>0.0)
    sprintf(valuestr,"Equinox %7.1f", image[CurImag].Image->descript->equinox);
  else
    sprintf(valuestr,"Equinox unknown");
  equstr = XmStringCreateSimple (valuestr);
  equlab = XtVaCreateManagedWidget ("EquLabel", xmLabelWidgetClass, 
				    form, 
				    XmNwidth,           150,
				    XmNlabelString,   equstr,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     toplabel,
				    XmNleftAttachment,  XmATTACH_FORM,
				    NULL);

/* set labels from FITS file info */
  strncpy (ctype, image[CurImag].cname[0]->sp, 4); ctype[4] = 0;
  if (ctype[2]=='-') ctype[2]=' '; if (ctype[3]=='-') ctype[3]=' ';
  RA = XmStringCreateSimple (ctype);
  strncpy (ctype, image[CurImag].cname[1]->sp, 4); ctype[4] = 0;
  if (ctype[2]=='-') ctype[2]=' '; if (ctype[3]=='-') ctype[3]=' ';
  Dec = XmStringCreateSimple (ctype);

/* RA */
  label1 = XtVaCreateManagedWidget ("RA", xmLabelWidgetClass,
				    form,
				    XmNheight,    30,
				    XmNlabelString,   RA,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     equlab,
				    XmNleftAttachment,  XmATTACH_FORM,
				    NULL);
/*  first axis in hours or degrees? */
    strncpy (ctype, image[CurImag].cname[0]->sp, 4);
    toHours = (!strncmp(ctype, "RA", 2)) || (!strncmp(ctype, "LL", 2));
/* default is reference position */
  mark.ra = image[CurImag].crval[0];
  mark.dec = image[CurImag].crval[1];
 
 /* precess if necessary */
  if ((usr_equinox > 0.0) && 
      (image[CurImag].Image->descript->usr_equinox !=
       image[CurImag].Image->descript->equinox))
      {if (image[CurImag].Image->descript->equinox==1950.0) 
	 BtoJ (&mark.ra, &mark.dec);
       if (image[CurImag].Image->descript->equinox==2000.0) 
	 JtoB (&mark.ra, &mark.dec);}

  if (toHours)
    {rahms (mark.ra, &h, &m, &s);
     sprintf (valuestr, "%2.2d %2.2d %5f", h, m, s);}
  else
    {decdms (mark.ra, &h, &m, &s);
     sprintf (valuestr, "%3.2d %2.2d %5f", h, m, s);
   }
  mark.data1 = XtVaCreateManagedWidget ("RA data", xmTextFieldWidgetClass, 
				    form, 
				    XmNvalue,        valuestr,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     equlab,
				    XmNleftAttachment, XmATTACH_WIDGET,
				    XmNleftWidget,     label1,
				    XmNrightAttachment,  XmATTACH_FORM,
				    NULL);
/* separator */
    sep1 = XtVaCreateManagedWidget ("sep1", xmSeparatorWidgetClass,
				   form, 
				   XmNwidth,           150,
				   XmNtopAttachment, XmATTACH_WIDGET,
				   XmNtopWidget,     mark.data1,
				   XmNleftAttachment,  XmATTACH_FORM,
				   NULL);
/* Dec */
  label2 = XtVaCreateManagedWidget ("Dec", xmLabelWidgetClass,
				    form,
				    XmNheight,    30,
				    XmNlabelString,   Dec,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     sep1,
				    XmNleftAttachment,  XmATTACH_FORM,
				    NULL);

  decdms (mark.dec, &d, &m, &s);
  if (d<0) d = -d;
  sprintf (valuestr, "%3.2d %2.2d %5f", d, m, s);
  if (mark.dec<0.0) valuestr[0]='-'; /* neg 0 dec. */
  mark.data2 = XtVaCreateManagedWidget ("Dec data", xmTextFieldWidgetClass, 
				    form, 
				    XmNvalue,        valuestr,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     sep1,
				    XmNleftAttachment, XmATTACH_WIDGET,
				    XmNleftWidget,     label2,
				    XmNrightAttachment,  XmATTACH_FORM,
				    NULL);

/* separator */
    sep2 = XtVaCreateManagedWidget ("sep2", xmSeparatorWidgetClass,
				   form, 
				   XmNwidth,           150,
				   XmNtopAttachment, XmATTACH_WIDGET,
				   XmNtopWidget,     mark.data2,
				   XmNleftAttachment,  XmATTACH_FORM,
				   NULL);
/* size */
  label3 = XtVaCreateManagedWidget ("pos size", xmLabelWidgetClass,
				    form,
				    XmNheight,    30,
				    XmNlabelString,   sizestr,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     sep2,
				    XmNleftAttachment,  XmATTACH_FORM,
				    NULL);

  mark.iInner = 8;  mark.iOuter = 15;
  sprintf (valuestr, " %d %d", mark.iInner, mark.iOuter);
  mark.data3 = XtVaCreateManagedWidget ("size data", xmTextFieldWidgetClass, 
				    form, 
				    XmNvalue,        valuestr,
				    XmNtopAttachment, XmATTACH_WIDGET,
				    XmNtopWidget,     sep2,
				    XmNleftAttachment, XmATTACH_WIDGET,
				    XmNleftWidget,     label3,
				    XmNrightAttachment,  XmATTACH_FORM,
				    NULL);
/* separator */
    sep3 = XtVaCreateManagedWidget ("sep3", xmSeparatorWidgetClass,
				   form, 
				   XmNwidth,           150,
				   XmNtopAttachment, XmATTACH_WIDGET,
				   XmNtopWidget,     mark.data3,
				   XmNleftAttachment,  XmATTACH_FORM,
				   NULL);
/* File button */
  FileButton = XtVaCreateManagedWidget ("File", xmPushButtonWidgetClass, 
				    form, 
				    XmNbottomAttachment, XmATTACH_FORM,
				    XmNleftAttachment,  XmATTACH_FORM,
				    NULL);
  XtAddCallback (FileButton, XmNactivateCallback, PosFileButCB, 
		 (XtPointer)IDdata);

/* Cancel button */
  CancelButton = XtVaCreateManagedWidget ("Cancel", xmPushButtonWidgetClass, 
				    form, 
				    XmNbottomAttachment, XmATTACH_FORM,
				    XmNleftAttachment, XmATTACH_WIDGET,
				    XmNleftWidget,     FileButton,
				    NULL);
  XtAddCallback (CancelButton, XmNactivateCallback, PosCancelButCB, 
		 (XtPointer)IDdata);

/* OK button */
  OKButton = XtVaCreateManagedWidget ("Mark", xmPushButtonWidgetClass, 
				    form, 
				    XmNbottomAttachment, XmATTACH_FORM,
				    XmNleftAttachment, XmATTACH_WIDGET,
				    XmNleftWidget,     CancelButton,
				    XmNrightAttachment, XmATTACH_FORM,
				    NULL);
  XtAddCallback (OKButton, XmNactivateCallback, PosOKButCB, (XtPointer)IDdata);

  if (label) XmStringFree(label);
  if (equstr) XmStringFree(equstr);
  if (RA) XmStringFree(RA);
  if (Dec) XmStringFree(Dec);
  if (sizestr) XmStringFree(sizestr);

/* set it up */
  XtManageChild (mark.dialog);

/* put it some place reasonable */
/*  where is parent? */
     XtVaGetValues (IDdata->shell,
		    XmNx, &xpos,
		    XmNy, &ypos,
		    NULL);
  ypos += 180;
  if (xpos<0) xpos = 0;
  XMoveWindow (XtDisplay(IDdata->shell), XtWindow(mark.dialog), 
	       xpos, ypos);
} /* end MarkPosCB */
Esempio n. 20
0
/**
@brief    Reparents the specified framed_window to a newly created frame.
@return   returns 1 if successful or 0 if no window was created.
@todo     A the moment each pointer is totally valid, in the future it will merely be an alias from another datastructure.
**/
int
create_frame(Display *display, struct Frame* frame
, Window framed_window, struct Popup_menu *window_menu, struct Separators *seps, const struct Workarea *workarea, struct Themes *themes
, struct Cursors *cursors, struct Atoms *atoms) {
  XWindowAttributes get_attributes;

  //printf("Creating frames->list[%d] with window %lu, connection %lu\n"
  //, frames->used, (unsigned long)framed_window, (unsigned long)display);
  //add this window to the save set as soon as possible so that if an error occurs it is still available

  XAddToSaveSet(display, framed_window);
  XSync(display, False);
  XGetWindowAttributes(display, framed_window, &get_attributes);

  /*** Set up defaults ***/
  frame->focussed = False;
  frame->sticky = False;
  frame->window_name = NULL;
  frame->framed_window = framed_window;
  frame->type = unknown;
  frame->theme_type = unknown;
  frame->mode = unset;
  frame->state = none;
  frame->wants_attention = False;
  frame->transient = 0;
  frame->width_inc = 1;
  frame->height_inc = 1;
  frame->menu.item = 0;

  frame->w_inc_offset = 0;
  frame->h_inc_offset = 0;

  frame->w = get_attributes.width;
  frame->h = get_attributes.height;

  get_frame_type_and_mode (display, frame, atoms, themes);

  frame->x = get_attributes.x - themes->window_type[frame->theme_type][window].x;
  frame->y = get_attributes.y - themes->window_type[frame->theme_type][window].y;
  frame->hspace = 0 - themes->window_type[frame->theme_type][window].w;
  frame->vspace = 0 - themes->window_type[frame->theme_type][window].h;


  // This is not set to the something sensive, like the size of the workarea
  // as it may change and we can't tell if it's a default value or a real
  // one set by the client.
  // Instead, always use the MIN of the workarea dimension and these values
  frame->max_width  = INT_MAX;
  frame->max_height = INT_MAX;

  //prevent overly small windows with these sensible defaults
  frame->min_width  = MINWIDTH + frame->hspace;
  frame->min_height = MINHEIGHT + frame->vspace;

  #ifdef ALLOW_OVERSIZE_WINDOWS_WITHOUT_MINIMUM_HINTS
  Screen* screen = DefaultScreenOfDisplay(display);
  /* Ugh Horrible.  */
  /* Many apps that are resizeable ask to be the size of the screen and since windows
     often don't specifiy their minimum size, we have no other way of knowing if they
     really need to be that size or not.  In case they do, this specifies that their
     current width is their minimum size, in the hope that it is overridden by the
     size hints. This kind of behaviour causes problems on small screens like the
     eee pc. */
  if(frame->w > XWidthOfScreen(screen))  frame->min_width = frame->w;
  if(frame->h > XHeightOfScreen(screen)) frame->min_height = frame->h;
  #endif

  /* This requires hspace and vspace to be set as well as the incremental hints */
  get_frame_hints(display, frame);

  frame_type_settings(display, frame, workarea);

  //Don't manage splash screens, they just cause the workspace to be created and instantly destroyed
  if(frame->type == splash) {
    XMapWindow(display, framed_window);
    XFlush(display);
    return 0;
  }


  get_frame_state(display, frame, atoms);
  create_frame_subwindows(display, frame, workarea, themes, cursors);
  create_frame_name(display, window_menu, frame, themes, atoms);

  get_frame_wm_hints(display, frame);  //this might need to change the focus, it's mode (to hidden) and so on
  get_frame_strut_hints_as_normal_hints(display, frame, atoms);

  //_NET_FRAME_EXTENTS, left, right, top, bottom, CARDINAL[4]/32
  int32_t ewmh_frame_extents[4] = { themes->window_type[frame->theme_type][window].x
  , themes->window_type[frame->theme_type][window].y
  , - themes->window_type[frame->theme_type][window].x - themes->window_type[frame->theme_type][window].w
  , - themes->window_type[frame->theme_type][window].y - themes->window_type[frame->theme_type][window].h
  };

  XChangeProperty(display, framed_window, atoms->frame_extents, XA_CARDINAL
  , 32, PropModeReplace, (unsigned char *)ewmh_frame_extents, 4);

  XSetWindowBorderWidth(display, framed_window, 0);

  change_frame_mode(display, frame, unset, workarea, themes);

  #ifdef CRASH_ON_BUG
  XGrabServer(display);
  XSetErrorHandler(supress_xerror);
  #endif

  XSelectInput(display, framed_window,  0);

  //reparent the framed_window to frame->widgets[window].widget
  XReparentWindow(display, framed_window, frame->widgets[window].widget, 0, 0);
  //for some odd reason the reparent only reports an extra unmap event if the window was already unmapped
  XRaiseWindow(display, framed_window);
  XMapWindow(display, frame->widgets[window].widget);

  #ifdef CRASH_ON_BUG
  XSetErrorHandler(NULL);
  XUngrabServer(display);
  #endif

  XSelectInput(display, framed_window,  PropertyChangeMask); //Property notify is used to update titles
  XSelectInput(display, frame->widgets[window].widget
  , SubstructureRedirectMask | SubstructureNotifyMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask);

  //Some windows only send the destroy event (e.g., gimp splash screen)
  XSync(display, False);

  //Intercept clicks so we can set the focus and possibly raise floating windows
  XGrabButton(display, Button1, 0, frame->widgets[window].widget
  , False, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);

  //do it for numlock as well
  XGrabButton(display, Button1, Mod2Mask, frame->widgets[window].widget
  , False, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);

  frame->w += frame->hspace;
  frame->h += frame->vspace;

  check_frame_limits(frame, workarea, themes);

  resize_frame(display, frame, workarea, themes);
  stack_frame(display, frame, seps);
  change_frame_state(display, frame, frame->state, seps, workarea, themes, atoms);
  XMoveResizeWindow(display, framed_window, 0, 0, frame->w - frame->hspace, frame->h - frame->vspace);
  XMoveWindow(display, framed_window, 0, 0);
  XMapWindow(display, framed_window);

  XFlush(display);
  save_frame_initial_state(frame);
  return 1;
}
Esempio n. 21
0
File: winwidget.c Progetto: derf/feh
void winwidget_create_window(winwidget ret, int w, int h)
{
	XSetWindowAttributes attr;
	XEvent ev;
	XClassHint *xch;
	MWMHints mwmhints;
	Atom prop = None;
	pid_t pid;
	int x = 0;
	int y = 0;
	char *tmpname;
#ifdef HOST_NAME_MAX
	char hostname[HOST_NAME_MAX];
#else /* ! HOST_NAME_MAX */
	long host_name_max;
	char *hostname;
#endif /* HOST_NAME_MAX */

	D(("winwidget_create_window %dx%d\n", w, h));

	if (ret->full_screen) {
		w = scr->width;
		h = scr->height;

#ifdef HAVE_LIBXINERAMA
		if (opt.xinerama && xinerama_screens) {
			w = xinerama_screens[xinerama_screen].width;
			h = xinerama_screens[xinerama_screen].height;
			x = xinerama_screens[xinerama_screen].x_org;
			y = xinerama_screens[xinerama_screen].y_org;
		}
#endif				/* HAVE_LIBXINERAMA */
	} else if (opt.geom_flags) {
		if (opt.geom_flags & WidthValue) {
			w = opt.geom_w;
		}
		if (opt.geom_flags & HeightValue) {
			h = opt.geom_h;
		}
		if (opt.geom_flags & XValue) {
			if (opt.geom_flags & XNegative) {
				x = scr->width - opt.geom_x;
			} else {
				x = opt.geom_x;
			}
		}
		if (opt.geom_flags & YValue) {
			if (opt.geom_flags & YNegative) {
				y = scr->height - opt.geom_y;
			} else {
				y = opt.geom_y;
			}
		}
	} else if (opt.screen_clip) {
		if (w > scr->width)
			w = scr->width;
		if (h > scr->height)
			h = scr->height;

#ifdef HAVE_LIBXINERAMA
		if (opt.xinerama && xinerama_screens) {
			if (w > xinerama_screens[xinerama_screen].width)
				w = xinerama_screens[xinerama_screen].width;
			if (h > xinerama_screens[xinerama_screen].height)
				h = xinerama_screens[xinerama_screen].height;
		}
#endif				/* HAVE_LIBXINERAMA */
	}

	if (opt.paused) {
		tmpname = estrjoin(" ", ret->name, "[Paused]", NULL);
		free(ret->name);
		ret->name = tmpname;
	}

	ret->x = x;
	ret->y = y;
	ret->w = w;
	ret->h = h;
	ret->visible = False;

	attr.backing_store = NotUseful;
	attr.override_redirect = False;
	attr.colormap = cm;
	attr.border_pixel = 0;
	attr.background_pixel = 0;
	attr.save_under = False;
	attr.event_mask =
	    StructureNotifyMask | ButtonPressMask | ButtonReleaseMask |
	    PointerMotionMask | EnterWindowMask | LeaveWindowMask |
	    KeyPressMask | KeyReleaseMask | ButtonMotionMask | ExposureMask
	    | FocusChangeMask | PropertyChangeMask | VisibilityChangeMask;

	memset(&mwmhints, 0, sizeof(mwmhints));
	if (opt.borderless || ret->full_screen) {
		prop = XInternAtom(disp, "_MOTIF_WM_HINTS", True);
		if (prop == None) {
			weprintf
			    ("Window Manager does not support MWM hints. "
			     "To get a borderless window I have to bypass your wm.");
			attr.override_redirect = True;
			mwmhints.flags = 0;
		} else {
			mwmhints.flags = MWM_HINTS_DECORATIONS;
			mwmhints.decorations = 0;
		}
	}

	ret->win =
	    XCreateWindow(disp, DefaultRootWindow(disp), x, y, w, h, 0,
			  depth, InputOutput, vis,
			  CWOverrideRedirect | CWSaveUnder | CWBackingStore
			  | CWColormap | CWBackPixel | CWBorderPixel | CWEventMask, &attr);

	if (mwmhints.flags) {
		XChangeProperty(disp, ret->win, prop, prop, 32,
				PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS);
	}
	if (ret->full_screen) {
		Atom prop_fs = XInternAtom(disp, "_NET_WM_STATE_FULLSCREEN", False);
		Atom prop_state = XInternAtom(disp, "_NET_WM_STATE", False);

		memset(&ev, 0, sizeof(ev));
		ev.xclient.type = ClientMessage;
		ev.xclient.message_type = prop_state;
		ev.xclient.display = disp;
		ev.xclient.window = ret->win;
		ev.xclient.format = 32;
		ev.xclient.data.l[0] = 1;
		ev.xclient.data.l[1] = prop_fs;

		XChangeProperty(disp, ret->win, prop_state, XA_ATOM, 32,
				PropModeReplace, (unsigned char *) &prop_fs, 1);
	}

	pid = getpid();
	prop = XInternAtom(disp, "_NET_WM_PID", False);
	XChangeProperty(disp, ret->win, prop, XA_CARDINAL, sizeof(pid_t) * 8,
			PropModeReplace, (const unsigned char *)&pid, 1);

#ifdef HOST_NAME_MAX
	if (gethostname(hostname, HOST_NAME_MAX) == 0) {
		hostname[HOST_NAME_MAX-1] = '\0';
		prop = XInternAtom(disp, "WM_CLIENT_MACHINE", False);
		XChangeProperty(disp, ret->win, prop, XA_STRING, sizeof(char) * 8,
				PropModeReplace, (unsigned char *)hostname, strlen(hostname));
	}
#else /* ! HOST_NAME_MAX */
	if ((host_name_max = sysconf(_SC_HOST_NAME_MAX)) != -1 ) {
		if ((hostname = calloc(1, host_name_max + 1)) != NULL ) {
			if (gethostname(hostname, host_name_max) == 0) {
				prop = XInternAtom(disp, "WM_CLIENT_MACHINE", False);
				XChangeProperty(disp, ret->win, prop, XA_STRING, sizeof(char) * 8,
						PropModeReplace, (unsigned char *)hostname, strlen(hostname));
			}
			free(hostname);
		}
	}
#endif /* HOST_NAME_MAX */

	XSetWMProtocols(disp, ret->win, &wmDeleteWindow, 1);
	winwidget_update_title(ret);
	xch = XAllocClassHint();
	xch->res_name = "feh";
	xch->res_class = "feh";
	XSetClassHint(disp, ret->win, xch);
	XFree(xch);

	/* Size hints */
	if (ret->full_screen || opt.geom_flags) {
		XSizeHints xsz;

		xsz.flags = USPosition;
		xsz.x = x;
		xsz.y = y;
		XSetWMNormalHints(disp, ret->win, &xsz);
		XMoveWindow(disp, ret->win, x, y);
	}
	if (opt.hide_pointer)
		winwidget_set_pointer(ret, 0);

	/* set the icon name property */
	XSetIconName(disp, ret->win, "feh");
	/* set the command hint */
	XSetCommand(disp, ret->win, cmdargv, cmdargc);

	winwidget_register(ret);

	/* do not scale down a thumbnail list window, only those created from it */
	if (opt.geom_enabled && (ret->type != WIN_TYPE_THUMBNAIL)) {
		opt.geom_w = w;
		opt.geom_h = h;
		opt.geom_flags |= WidthValue | HeightValue;
	}

	return;
}
Esempio n. 22
0
void
main(int argc, char* argv[])
{
  Display* display;		/* pointer to X Display structure.           */
  int screen_num;		/* number of screen to place the window on.  */
  Window win;			/* pointer to the newly created window.      */
  unsigned int display_width,
               display_height;	/* height and width of the X display.        */
  unsigned int win_width,
	       win_height;	/* height and width for the new window.      */
  char *display_name = getenv("DISPLAY");  /* address of the X display.      */
  GC gc;			/* GC (graphics context) used for drawing    */
				/*  in our window.			     */

  /* open connection with the X server. */
  display = XOpenDisplay(display_name);
  if (display == NULL) {
    fprintf(stderr, "%s: cannot connect to X server '%s'\n",
            argv[0], display_name);
    exit(1);
  }

  /* get the geometry of the default screen for our display. */
  screen_num = DefaultScreen(display);
  display_width = DisplayWidth(display, screen_num);
  display_height = DisplayHeight(display, screen_num);

  /* make the new window occupy 1/9 of the screen's size. */
  win_width = (display_width / 3);
  win_height = (display_height / 3);
  printf("window width - '%d'; height - '%d'\n", win_width, win_height);

  /* create a simple window, as a direct child of the screen's   */
  /* root window. Use the screen's white color as the background */
  /* color of the window. Place the new window's top-left corner */
  /* at the given 'x,y' coordinates.                             */
  win = create_simple_window(display, win_width, win_height, 0, 0);

  /* allocate a new GC (graphics context) for drawing in the window. */
  gc = create_gc(display, win, 0);
  XFlush(display);

  sleep(3);

  /* example of resizing a window. */
  {
    int i;

    /* start shrinking our window in a loop. */
    for (i=0; i<40; i++) {
      win_width -= 3;
      win_height -= 3;
      XResizeWindow(display, win, win_width, win_height);
      XFlush(display);
      usleep(20000);
    }

    /* start shrinking our window in a loop. */
    for (i=0; i<40; i++) {
      win_width += 3;
      win_height += 3;
      XResizeWindow(display, win, win_width, win_height);
      XFlush(display);
      usleep(20000);
    }
  }

  sleep(1);

  /* example of moving a window. */
  {
    int i;
    XWindowAttributes win_attr;
    int x, y;
    int scr_x, scr_y;
    Window child_win;
    /* this variable will store the ID of the parent window of our window. */
    Window parent_win;

    /* first, get the current attributes of our window. */
    XGetWindowAttributes(display, win, &win_attr);

    x = win_attr.x;
    y = win_attr.y;

    /* next, find the parent window of our window.      */
    {
      /* this variable will store the ID of the root window of the screen    */
      /* our window is mapped on.                                            */
      Window root_win;
      /* this variable will store an array of IDs of the child windows of    */
      /* our window.                                                         */
      Window* child_windows;
      /* and this one will store the number of child windows our window has. */
      int num_child_windows;

      /* finally, make the query for the above values. */
      XQueryTree(display, win,
                 &root_win,
                 &parent_win,
                 &child_windows, &num_child_windows);

      /* we need to free the list of child IDs, as it was dynamically */
      /* allocated by the XQueryTree function.                        */
      XFree(child_windows);
    }

    /* next, translate the location coordinates to screen coordinates. */
    /* this is done using the root window as the destination window.   */
    /* this works since the root window always spans the entire screen */
    /* area, and thus has its top-left corner always at the top-left   */
    /* corner of the screen.                                           */
    XTranslateCoordinates(display,
			  parent_win, win_attr.root,
			  x, y,
			  &scr_x, &scr_y,
			  &child_win);

    /* start moving the window to the left. */
    for (i=0; i<40; i++) {
      scr_x -= 3;
      XMoveWindow(display, win, scr_x, scr_y);
      XFlush(display);
      usleep(20000);
    }

    /* start moving the window to down. */
    for (i=0; i<40; i++) {
      scr_y += 3;
      XMoveWindow(display, win, scr_x, scr_y);
      XFlush(display);
      usleep(20000);
    }

    /* start moving the window to the right. */
    for (i=0; i<40; i++) {
      scr_x += 3;
      XMoveWindow(display, win, scr_x, scr_y);
      XFlush(display);
      usleep(20000);
    }

    /* start moving the window up. */
    for (i=0; i<40; i++) {
      scr_y -= 3;
      XMoveWindow(display, win, scr_x, scr_y);
      XFlush(display);
      usleep(20000);
    }
  }

  sleep(1);

  /* example of iconifying and de-iconifying a window. */
  {
    /* iconify our window. */
    XIconifyWindow(display, win, DefaultScreen(display));
    XFlush(display);
    sleep(2);
    /* de-iconify our window. */
    XMapWindow(display, win);
    XFlush(display);
    sleep(2);
  }

  /* flush all pending requests to the X server. */
  XFlush(display);

  /* make a delay for a short period. */
  sleep(2);

  /* close the connection to the X server. */
  XCloseDisplay(display);
}
Esempio n. 23
0
void MpVerticalScrollbar::SetSlider (int y) 
{ 
  MpForceRange(y,0,yspan); // enshure range
  yact = y;  
  XMoveWindow(Mp.theDisplay,bar->Win(),sx, y+sy); 
}
Esempio n. 24
0
/*
** GLW_SetMode
*/
int GLW_SetMode( const char *drivername, int mode, qboolean fullscreen )
{
	int attrib[] = {
		GLX_RGBA,					// 0
		GLX_RED_SIZE, 4,			// 1, 2
		GLX_GREEN_SIZE, 4,			// 3, 4
		GLX_BLUE_SIZE, 4,			// 5, 6
		GLX_DOUBLEBUFFER,			// 7
		GLX_DEPTH_SIZE, 1,			// 8, 9
		GLX_STENCIL_SIZE, 1,		// 10, 11
		None
	};
	// these match in the array
#define ATTR_RED_IDX 2
#define ATTR_GREEN_IDX 4
#define ATTR_BLUE_IDX 6
#define ATTR_DEPTH_IDX 9
#define ATTR_STENCIL_IDX 11
	Window root;
	XVisualInfo *visinfo;
	XSetWindowAttributes attr;
	unsigned long mask;
	int colorbits, depthbits, stencilbits;
	int tcolorbits, tdepthbits, tstencilbits;
	int MajorVersion, MinorVersion;
	int actualWidth, actualHeight;
	int i;
	const char*   glstring; // bk001130 - from cvs1.17 (mkv)

	ri.Printf( PRINT_ALL, "Initializing OpenGL display\n");

	ri.Printf (PRINT_ALL, "...setting mode %d:", mode );

	if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) )
	{
		ri.Printf( PRINT_ALL, " invalid mode\n" );
		return RSERR_INVALID_MODE;
	}
	ri.Printf( PRINT_ALL, " %d %d\n", glConfig.vidWidth, glConfig.vidHeight);

	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "Error couldn't open the X display\n");
		return RSERR_INVALID_MODE;
	}

	scrnum = DefaultScreen(dpy);
	root = RootWindow(dpy, scrnum);

	actualWidth = glConfig.vidWidth;
	actualHeight = glConfig.vidHeight;

	// Get video mode list
	MajorVersion = MinorVersion = 0;
	if (!XF86VidModeQueryVersion(dpy, &MajorVersion, &MinorVersion)) { 
		vidmode_ext = qfalse;
	} else {
		ri.Printf(PRINT_ALL, "Using XFree86-VidModeExtension Version %d.%d\n",
			MajorVersion, MinorVersion);
		vidmode_ext = qtrue;
	}

	// Check for DGA
	if (in_dgamouse->value) {
		if (!XF86DGAQueryVersion(dpy, &MajorVersion, &MinorVersion)) { 
			// unable to query, probalby not supported
			ri.Printf( PRINT_ALL, "Failed to detect XF86DGA Mouse\n" );
			ri.Cvar_Set( "in_dgamouse", "0" );
		} else {
			ri.Printf( PRINT_ALL, "XF86DGA Mouse (Version %d.%d) initialized\n",
				MajorVersion, MinorVersion);
		}
	}

	if (vidmode_ext) {
		int best_fit, best_dist, dist, x, y;
		
		XF86VidModeGetAllModeLines(dpy, scrnum, &num_vidmodes, &vidmodes);

		// Are we going fullscreen?  If so, let's change video mode
		if (fullscreen) {
			best_dist = 9999999;
			best_fit = -1;

			for (i = 0; i < num_vidmodes; i++) {
				if (glConfig.vidWidth > vidmodes[i]->hdisplay ||
					glConfig.vidHeight > vidmodes[i]->vdisplay)
					continue;

				x = glConfig.vidWidth - vidmodes[i]->hdisplay;
				y = glConfig.vidHeight - vidmodes[i]->vdisplay;
				dist = (x * x) + (y * y);
				if (dist < best_dist) {
					best_dist = dist;
					best_fit = i;
				}
			}

			if (best_fit != -1) {
				actualWidth = vidmodes[best_fit]->hdisplay;
				actualHeight = vidmodes[best_fit]->vdisplay;

				// change to the mode
				XF86VidModeSwitchToMode(dpy, scrnum, vidmodes[best_fit]);
				vidmode_active = qtrue;

				// Move the viewport to top left
				XF86VidModeSetViewPort(dpy, scrnum, 0, 0);

				ri.Printf(PRINT_ALL, "XFree86-VidModeExtension Activated at %dx%d\n",
					actualWidth, actualHeight);

			} else {
				fullscreen = qfalse;
				ri.Printf(PRINT_ALL, "XFree86-VidModeExtension: No acceptable modes found\n");
			}
		} else {
			ri.Printf(PRINT_ALL, "XFree86-VidModeExtension:  Ignored on non-fullscreen/Voodoo\n");
		}
	}


	if (!r_colorbits->value)
		colorbits = 24;
	else
		colorbits = r_colorbits->value;

	if (!r_depthbits->value)
		depthbits = 24;
	else
		depthbits = r_depthbits->value;
	stencilbits = r_stencilbits->value;

	for (i = 0; i < 16; i++) {
		// 0 - default
		// 1 - minus colorbits
		// 2 - minus depthbits
		// 3 - minus stencil
		if ((i % 4) == 0 && i) {
			// one pass, reduce
			switch (i / 4) {
			case 2 :
				if (colorbits == 24)
					colorbits = 16;
				break;
			case 1 :
				if (depthbits == 24)
					depthbits = 16;
				else if (depthbits == 16)
					depthbits = 8;
			case 3 :
				if (stencilbits == 24)
					stencilbits = 16;
				else if (stencilbits == 16)
					stencilbits = 8;
			}
		}

		tcolorbits = colorbits;
		tdepthbits = depthbits;
		tstencilbits = stencilbits;

		if ((i % 4) == 3) { // reduce colorbits
			if (tcolorbits == 24)
				tcolorbits = 16;
		}	

		if ((i % 4) == 2) { // reduce depthbits
			if (tdepthbits == 24)
				tdepthbits = 16;
			else if (tdepthbits == 16)
				tdepthbits = 8;
		}

		if ((i % 4) == 1) { // reduce stencilbits
			if (tstencilbits == 24)
				tstencilbits = 16;
			else if (tstencilbits == 16)
				tstencilbits = 8;
			else
				tstencilbits = 0;
		}

		if (tcolorbits == 24) {
			attrib[ATTR_RED_IDX] = 8;
			attrib[ATTR_GREEN_IDX] = 8;
			attrib[ATTR_BLUE_IDX] = 8;
		} else  {
			// must be 16 bit
			attrib[ATTR_RED_IDX] = 4;
			attrib[ATTR_GREEN_IDX] = 4;
			attrib[ATTR_BLUE_IDX] = 4;
		}

		attrib[ATTR_DEPTH_IDX] = tdepthbits; // default to 24 depth
		attrib[ATTR_STENCIL_IDX] = tstencilbits;

		visinfo = qglXChooseVisual(dpy, scrnum, attrib);
		if (!visinfo) {
			continue;
		}

		ri.Printf( PRINT_ALL, "Using %d/%d/%d Color bits, %d depth, %d stencil display.\n", 
			attrib[ATTR_RED_IDX], attrib[ATTR_GREEN_IDX], attrib[ATTR_BLUE_IDX],
			attrib[ATTR_DEPTH_IDX], attrib[ATTR_STENCIL_IDX]);

		glConfig.colorBits = tcolorbits;
		glConfig.depthBits = tdepthbits;
		glConfig.stencilBits = tstencilbits;
		break;
	}

	if (!visinfo) {
		ri.Printf( PRINT_ALL, "Couldn't get a visual\n" );
		return RSERR_INVALID_MODE;
	}

	/* window attributes */
	attr.background_pixel = BlackPixel(dpy, scrnum);
	attr.border_pixel = 0;
	attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
	attr.event_mask = X_MASK;
	if (vidmode_active) {
		mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore | 
			CWEventMask | CWOverrideRedirect;
		attr.override_redirect = True;
		attr.backing_store = NotUseful;
		attr.save_under = False;
	} else
		mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

	win = XCreateWindow(dpy, root, 0, 0, 
			actualWidth, actualHeight, 
			0, visinfo->depth, InputOutput,
			visinfo->visual, mask, &attr);

	XStoreName( dpy, win, WINDOW_CLASS_NAME );

	XMapWindow( dpy, win );

	if (vidmode_active)
		XMoveWindow(dpy, win, 0, 0);

	XFlush(dpy);
	XSync(dpy,False); // bk001130 - from cvs1.17 (mkv)
	ctx = qglXCreateContext(dpy, visinfo, NULL, True);
	XSync(dpy,False); // bk001130 - from cvs1.17 (mkv)

	qglXMakeCurrent(dpy, win, ctx);

	// bk001130 - from cvs1.17 (mkv)
	glstring = (const char *) qglGetString (GL_RENDERER);
        ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glstring );

	// bk010122 - new software token (Indirect)
	if ( !Q_stricmp( glstring, "Mesa X11")
	     || !Q_stricmp( glstring, "Mesa GLX Indirect") ) 
	{
	        if ( !r_allowSoftwareGL->integer ) {
		  ri.Printf( PRINT_ALL, "\n\n***********************************************************\n" );
		  ri.Printf( PRINT_ALL, " You are using software Mesa (no hardware acceleration)!   \n" );
		  ri.Printf( PRINT_ALL, " Driver DLL used: %s\n", drivername ); 
		  ri.Printf( PRINT_ALL, " If this is intentional, add\n" );
		  ri.Printf( PRINT_ALL, "       \"+set r_allowSoftwareGL 1\"\n" );
		  ri.Printf( PRINT_ALL, " to the command line when starting the game.\n" );
		  ri.Printf( PRINT_ALL, "***********************************************************\n");
		  GLimp_Shutdown( );
		  return RSERR_INVALID_MODE;
		} else {
		  ri.Printf( PRINT_ALL, "...using software Mesa (r_allowSoftwareGL==1).\n" );
		}
	}

	return RSERR_OK;
}
Esempio n. 25
0
/* test for CR 5217 */
void
main (int argc, char **argv)
{
   Display    *mydisplay;
   int        erster_aufruf=1; 
   Window     win_fix_pos, win_toggle;
   XEvent     event;
   XSizeHints hint;

   CommonTestInit (argc,argv);


   
   win_fix_pos = XCreateSimpleWindow (display, DefaultRootWindow(display),
                           50, 50, 200, 200, 0, 0, 1);

   win_toggle = XCreateSimpleWindow (display, DefaultRootWindow(display),
                           500, 500, 200, 200, 0, 0, 0);
 
   hint.flags = (USPosition | USSize | PMinSize | PMaxSize |
                 PResizeInc | PBaseSize | PAspect);

   hint.x = 50;
   hint.y = 50;
   hint.width  = 200; 
   hint.height = 200;
   hint.max_width  = 200;
   hint.max_height = 200;
   hint.min_width  = 200;
   hint.min_height = 200;
   hint.width_inc  = 1;
   hint.height_inc = 1;
   hint.base_width = hint.min_width;
   hint.base_height = hint.min_height;

   hint.min_aspect.x = hint.max_width;
   hint.min_aspect.y = hint.max_height;
   hint.max_aspect.x = hint.min_width;
   hint.max_aspect.y = hint.min_height;

   XSetStandardProperties (display, win_fix_pos, "win_fix_pos", "win_fix_pos",   None, None, None, &hint);

   hint.max_width  = 400;
   hint.max_height = 400;
   hint.x = 500;
   hint.y = 500;

   XSetStandardProperties( display, win_toggle, "win_toggle", "win_toggle",
                           None, None, None, &hint);

   XSelectInput (display, win_toggle, StructureNotifyMask);
   XMapWindow (display, win_toggle);
   XMapWindow (display, win_fix_pos);

   CommonPause();


   if (erster_aufruf == 1)
     {
       XMoveWindow (display, win_toggle, 50, 50);
       printf ("\nMove after Maximize was executed\n");
       erster_aufruf=0;
     }
    


CommonPause();

XtAppMainLoop(app_context);
}
Esempio n. 26
0
Bool MySetFocusHandler (IMChangeFocusStruct * call_data)
{
    CurrentIC = (IC *) FindIC (call_data->icid);
    connect_id = call_data->connect_id;

    if (ConnectIDGetState (connect_id) != IS_CLOSED) {
        if (icidGetIMState(call_data->icid) == IS_CLOSED)
            IMPreeditStart (ims, (XPointer) call_data);

        EnterChineseMode (lastConnectID == connect_id);

        if (!bUseDBus)
            DrawMainWindow ();

        if (ConnectIDGetState (connect_id) == IS_CHN) {
            if (bVK)
                DisplayVKWindow ();
        }
        else {
            XUnmapWindow (dpy, inputWindow);
            if (!bUseDBus)
                XUnmapWindow (dpy, VKWindow);
        }
    }
    else {
        if (icidGetIMState(call_data->icid) != IS_CLOSED)
            IMPreeditEnd (ims, (XPointer) call_data);

        CloseInputWindow();
        if (!bUseDBus) {
            XUnmapWindow (dpy, VKWindow);

#ifdef _ENABLE_TRAY
            DrawTrayWindow (INACTIVE_ICON, 0, 0, TRAY_ICON_HEIGHT, TRAY_ICON_WIDTH );
#endif
            if (hideMainWindow == HM_SHOW) {
                DisplayMainWindow ();
                DrawMainWindow ();
            }
            else
                XUnmapWindow (dpy, mainWindow);
        }
#ifdef _ENABLE_DBUS
        else
            updatePropertyByConnectID(connect_id);
#endif

        icidSetIMState(call_data->icid, ConnectIDGetState (connect_id));
        lastConnectID = connect_id;
        //When application gets the focus, re-record the time.
        bStartRecordType = False;
        iHZInputed = 0;

        if (ConnectIDGetTrackCursor (connect_id) && bTrackCursor) {
            position * pos = ConnectIDGetPos(connect_id);

            if (pos) {
                iClientCursorX = pos->x;
                iClientCursorY = pos->y;
                if (!bUseDBus)
                    XMoveWindow (dpy, inputWindow, iClientCursorX, iClientCursorY);
#ifdef _ENABLE_DBUS
                else
                    KIMUpdateSpotLocation(iClientCursorX, iClientCursorY);
#endif
            }
        }

#ifdef _ENABLE_DBUS
        if (bUseDBus)
            registerProperties();
#endif
    }

    return True;
}
Esempio n. 27
0
void gl_position (int x, int y) {
	XMoveWindow(_gl_display, _gl_win, x, y);
}
Esempio n. 28
0
rserr_t GLimp_SetMode( int mode, int colorbits, bool fullscreen ) {
	if ( !XInitThreads() ) {
		common->Printf( "...XInitThreads() failed, disabling r_smp\n" );
		Cvar_Set( "r_smp", "0" );
	}

	// set up our custom error handler for X failures
	XSetErrorHandler( &qXErrorHandler );

	if ( fullscreen && in_nograb->value ) {
		common->Printf( "Fullscreen not allowed with in_nograb 1\n" );
		Cvar_Set( "r_fullscreen", "0" );
		r_fullscreen->modified = false;
		fullscreen = false;
	}

	common->Printf( "...setting mode %d:", mode );

	if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, &glConfig.windowAspect, mode ) ) {
		common->Printf( " invalid mode\n" );
		return RSERR_INVALID_MODE;
	}
	common->Printf( " %d %d\n", glConfig.vidWidth, glConfig.vidHeight );

	// open the display
	if ( !( dpy = XOpenDisplay( NULL ) ) ) {
		fprintf( stderr, "Error couldn't open the X display\n" );
		return RSERR_INVALID_MODE;
	}

	scrnum = DefaultScreen( dpy );
	Window root = RootWindow( dpy, scrnum );

	// Get video mode list
	if ( !XF86VidModeQueryVersion( dpy, &vidmode_MajorVersion, &vidmode_MinorVersion ) ) {
		vidmode_ext = false;
	} else {
		common->Printf( "Using XFree86-VidModeExtension Version %d.%d\n", vidmode_MajorVersion, vidmode_MinorVersion );
		vidmode_ext = true;
	}

	// Check for DGA
	int dga_MajorVersion = 0;
	int dga_MinorVersion = 0;
	if ( in_dgamouse->value ) {
		if ( !XF86DGAQueryVersion( dpy, &dga_MajorVersion, &dga_MinorVersion ) ) {
			// unable to query, probalby not supported
			common->Printf( "Failed to detect XF86DGA Mouse\n" );
			Cvar_Set( "in_dgamouse", "0" );
		} else {
			common->Printf( "XF86DGA Mouse (Version %d.%d) initialized\n", dga_MajorVersion, dga_MinorVersion );
		}
	}

	int actualWidth = glConfig.vidWidth;
	int actualHeight = glConfig.vidHeight;

	if ( vidmode_ext ) {
		int best_fit, best_dist, dist, x, y;

		XF86VidModeGetAllModeLines( dpy, scrnum, &num_vidmodes, &vidmodes );

		// Are we going fullscreen?  If so, let's change video mode
		if ( fullscreen ) {
			best_dist = 9999999;
			best_fit = -1;

			for ( int i = 0; i < num_vidmodes; i++ ) {
				if ( glConfig.vidWidth > vidmodes[ i ]->hdisplay ||
					 glConfig.vidHeight > vidmodes[ i ]->vdisplay ) {
					continue;
				}

				x = glConfig.vidWidth - vidmodes[ i ]->hdisplay;
				y = glConfig.vidHeight - vidmodes[ i ]->vdisplay;
				dist = ( x * x ) + ( y * y );
				if ( dist < best_dist ) {
					best_dist = dist;
					best_fit = i;
				}
			}

			if ( best_fit != -1 ) {
				actualWidth = vidmodes[ best_fit ]->hdisplay;
				actualHeight = vidmodes[ best_fit ]->vdisplay;

				// change to the mode
				XF86VidModeSwitchToMode( dpy, scrnum, vidmodes[ best_fit ] );
				vidmode_active = true;

				// Move the viewport to top left
				XF86VidModeSetViewPort( dpy, scrnum, 0, 0 );

				common->Printf( "XFree86-VidModeExtension Activated at %dx%d\n",
					actualWidth, actualHeight );
			} else {
				fullscreen = 0;
				common->Printf( "XFree86-VidModeExtension: No acceptable modes found\n" );
			}
		} else {
			common->Printf( "XFree86-VidModeExtension:  Ignored on non-fullscreen\n" );
		}
	}

	if ( !colorbits ) {
		colorbits = !r_colorbits->value ? 24 : r_colorbits->value;
	}
	int depthbits = !r_depthbits->value ? 24 : r_depthbits->value;
	int stencilbits = r_stencilbits->value;

	XVisualInfo* visinfo = NULL;
	for ( int i = 0; i < 16; i++ ) {
		// 0 - default
		// 1 - minus colorbits
		// 2 - minus depthbits
		// 3 - minus stencil
		if ( ( i % 4 ) == 0 && i ) {
			// one pass, reduce
			switch ( i / 4 ) {
			case 2:
				if ( colorbits == 24 ) {
					colorbits = 16;
				}
				break;
			case 1:
				if ( depthbits == 24 ) {
					depthbits = 16;
				} else if ( depthbits == 16 ) {
					depthbits = 8;
				}
				break;
			case 3:
				if ( stencilbits == 24 ) {
					stencilbits = 16;
				} else if ( stencilbits == 16 ) {
					stencilbits = 8;
				}
				break;
			}
		}

		int tcolorbits = colorbits;
		int tdepthbits = depthbits;
		int tstencilbits = stencilbits;

		if ( ( i % 4 ) == 3 ) {
			// reduce colorbits
			if ( tcolorbits == 24 ) {
				tcolorbits = 16;
			}
		}

		if ( ( i % 4 ) == 2 ) {
			// reduce depthbits
			if ( tdepthbits == 24 ) {
				tdepthbits = 16;
			} else if ( tdepthbits == 16 ) {
				tdepthbits = 8;
			}
		}

		if ( ( i % 4 ) == 1 ) {
			// reduce stencilbits
			if ( tstencilbits == 24 ) {
				tstencilbits = 16;
			} else if ( tstencilbits == 16 ) {
				tstencilbits = 8;
			} else {
				tstencilbits = 0;
			}
		}

		int attrib[] =
		{
			GLX_RGBA,			// 0
			GLX_RED_SIZE, 4,		// 1, 2
			GLX_GREEN_SIZE, 4,		// 3, 4
			GLX_BLUE_SIZE, 4,		// 5, 6
			GLX_DOUBLEBUFFER,		// 7
			GLX_DEPTH_SIZE, 1,		// 8, 9
			GLX_STENCIL_SIZE, 1,	// 10, 11
			//GLX_SAMPLES_SGIS, 4, /* for better AA */
			None
		};
		// these match in the array
		enum
		{
			ATTR_RED_IDX = 2,
			ATTR_GREEN_IDX = 4,
			ATTR_BLUE_IDX = 6,
			ATTR_DEPTH_IDX = 9,
			ATTR_STENCIL_IDX = 11
		};

		if ( tcolorbits == 24 ) {
			attrib[ ATTR_RED_IDX ] = 8;
			attrib[ ATTR_GREEN_IDX ] = 8;
			attrib[ ATTR_BLUE_IDX ] = 8;
		} else {
			// must be 16 bit
			attrib[ ATTR_RED_IDX ] = 4;
			attrib[ ATTR_GREEN_IDX ] = 4;
			attrib[ ATTR_BLUE_IDX ] = 4;
		}

		attrib[ ATTR_DEPTH_IDX ] = tdepthbits;	// default to 24 depth
		attrib[ ATTR_STENCIL_IDX ] = tstencilbits;

		visinfo = glXChooseVisual( dpy, scrnum, attrib );
		if ( !visinfo ) {
			continue;
		}

		common->Printf( "Using %d/%d/%d Color bits, %d depth, %d stencil display.\n",
			attrib[ ATTR_RED_IDX ], attrib[ ATTR_GREEN_IDX ], attrib[ ATTR_BLUE_IDX ],
			attrib[ ATTR_DEPTH_IDX ], attrib[ ATTR_STENCIL_IDX ] );

		glConfig.colorBits = tcolorbits;
		glConfig.depthBits = tdepthbits;
		glConfig.stencilBits = tstencilbits;
		break;
	}

	if ( !visinfo ) {
		common->Printf( "Couldn't get a visual\n" );
		return RSERR_INVALID_MODE;
	}

	//	Window attributes
	XSetWindowAttributes attr;
	unsigned long mask;
	attr.background_pixel = BlackPixel( dpy, scrnum );
	attr.border_pixel = 0;
	attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone );
	attr.event_mask = X_MASK;
	if ( vidmode_active ) {
		mask = CWBackPixel | CWColormap | CWSaveUnder | CWBackingStore |
			   CWEventMask | CWOverrideRedirect;
		attr.override_redirect = True;
		attr.backing_store = NotUseful;
		attr.save_under = False;
	} else {
		mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
	}

	win = XCreateWindow( dpy, root, 0, 0,
		actualWidth, actualHeight,
		0, visinfo->depth, InputOutput,
		visinfo->visual, mask, &attr );

	XStoreName( dpy, win, R_GetTitleForWindow() );

	/* GH: Don't let the window be resized */
	XSizeHints sizehints;
	sizehints.flags = PMinSize | PMaxSize;
	sizehints.min_width = sizehints.max_width = actualWidth;
	sizehints.min_height = sizehints.max_height = actualHeight;

	XSetWMNormalHints( dpy, win, &sizehints );

	XMapWindow( dpy, win );

	if ( vidmode_active ) {
		XMoveWindow( dpy, win, 0, 0 );
		//XRaiseWindow(dpy, win);
		//XWarpPointer(dpy, None, win, 0, 0, 0, 0, 0, 0);
		//XFlush(dpy);
		// Move the viewport to top left
		//XF86VidModeSetViewPort(dpy, scrnum, 0, 0);
	}

	//	hook to window close
	wm_protocols = XInternAtom( dpy, "WM_PROTOCOLS", False );
	wm_delete_window = XInternAtom( dpy, "WM_DELETE_WINDOW", False );
	XSetWMProtocols( dpy, win, &wm_delete_window, 1 );

	XFlush( dpy );

	XSync( dpy, False );	// bk001130 - from cvs1.17 (mkv)
	ctx = glXCreateContext( dpy, visinfo, NULL, True );
	XSync( dpy, False );	// bk001130 - from cvs1.17 (mkv)

	/* GH: Free the visinfo after we're done with it */
	XFree( visinfo );

	glXMakeCurrent( dpy, win, ctx );

	glConfig.deviceSupportsGamma = false;
	if ( vidmode_ext ) {
		if ( vidmode_MajorVersion < GAMMA_MINMAJOR ||
			 ( vidmode_MajorVersion == GAMMA_MINMAJOR && vidmode_MinorVersion < GAMMA_MINMINOR ) ) {
			common->Printf( "XF86 Gamma extension not supported in this version\n" );
		} else {
			XF86VidModeGetGamma( dpy, scrnum, &vidmode_InitialGamma );
			common->Printf( "XF86 Gamma extension initialized\n" );
			glConfig.deviceSupportsGamma = true;
		}
	}

	//	Check for software GL implementation.
	const char* glstring = ( char* )glGetString( GL_RENDERER );
	if ( !String::ICmp( glstring, "Mesa X11" ) ||
		 !String::ICmp( glstring, "Mesa GLX Indirect" ) ) {
		if ( !r_allowSoftwareGL->integer ) {
			common->Printf( "\n\n***********************************************************\n" );
			common->Printf( " You are using software Mesa (no hardware acceleration)!\n" );
			common->Printf( " If this is intentional, add\n" );
			common->Printf( "       \"+set r_allowSoftwareGL 1\"\n" );
			common->Printf( " to the command line when starting the game.\n" );
			common->Printf( "***********************************************************\n" );
			GLimp_Shutdown();
			return RSERR_INVALID_MODE;
		} else {
			common->Printf( "...using software Mesa (r_allowSoftwareGL==1).\n" );
		}
	}

	GLW_GenDefaultLists();

	return RSERR_OK;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nReshape(JNIEnv *env, jclass clazz, jlong display, jlong window_ptr, jint x, jint y, jint width, jint height) {
	Display *disp = (Display *)(intptr_t)display;
	Window window = (Window)window_ptr;
	XMoveWindow(disp, window, x, y);
	XResizeWindow(disp, window, width, height);
}
Esempio n. 30
0
xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width,
                                 int height)
{
	XEvent xevent;
	int input_mask;
	xfWindow* window;
	Window parentWindow;
	XClassHint* classHints;
	rdpSettings* settings;
	window = (xfWindow*) calloc(1, sizeof(xfWindow));

	if (!window)
		return NULL;

	settings = xfc->context.settings;
	parentWindow = (Window) xfc->context.settings->ParentWindowId;
	window->width = width;
	window->height = height;
	window->decorations = xfc->decorations;
	window->is_mapped = FALSE;
	window->is_transient = FALSE;
	window->handle = XCreateWindow(xfc->display, RootWindowOfScreen(xfc->screen),
	                               xfc->workArea.x, xfc->workArea.y, xfc->workArea.width, xfc->workArea.height,
	                               0, xfc->depth, InputOutput, xfc->visual,
	                               CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
	                               CWBorderPixel | CWWinGravity | CWBitGravity, &xfc->attribs);
	window->shmid = shm_open(get_shm_id(), (O_CREAT | O_RDWR),
	                         (S_IREAD | S_IWRITE));

	if (window->shmid < 0)
	{
		DEBUG_X11("xf_CreateDesktopWindow: failed to get access to shared memory - shmget()\n");
	}
	else
	{
		void* mem;
		ftruncate(window->shmid, sizeof(window->handle));
		mem = mmap(0, sizeof(window->handle), PROT_READ | PROT_WRITE, MAP_SHARED,
		           window->shmid, 0);

		if (mem == MAP_FAILED)
		{
			DEBUG_X11("xf_CreateDesktopWindow: failed to assign pointer to the memory address - shmat()\n");
		}
		else
		{
			window->xfwin = mem;
			*window->xfwin = window->handle;
		}
	}

	classHints = XAllocClassHint();

	if (classHints)
	{
		classHints->res_name = "xfreerdp";

		if (xfc->context.settings->WmClass)
			classHints->res_class = xfc->context.settings->WmClass;
		else
			classHints->res_class = "xfreerdp";

		XSetClassHint(xfc->display, window->handle, classHints);
		XFree(classHints);
	}

	xf_ResizeDesktopWindow(xfc, window, width, height);
	xf_SetWindowDecorations(xfc, window->handle, window->decorations);
	xf_SetWindowPID(xfc, window->handle, 0);
	input_mask =
	    KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
	    VisibilityChangeMask | FocusChangeMask | StructureNotifyMask |
	    PointerMotionMask | ExposureMask | PropertyChangeMask;

	if (xfc->grab_keyboard)
		input_mask |= EnterWindowMask | LeaveWindowMask;

	XChangeProperty(xfc->display, window->handle, xfc->_NET_WM_ICON, XA_CARDINAL,
	                32,
	                PropModeReplace, (BYTE*) xf_icon_prop, ARRAYSIZE(xf_icon_prop));

	if (parentWindow)
		XReparentWindow(xfc->display, window->handle, parentWindow, 0, 0);

	XSelectInput(xfc->display, window->handle, input_mask);
	XClearWindow(xfc->display, window->handle);
	xf_SetWindowTitleText(xfc, window->handle, name);
	XMapWindow(xfc->display, window->handle);
	xf_input_init(xfc, window->handle);

	/*
	 * NOTE: This must be done here to handle reparenting the window,
	 * so that we don't miss the event and hang waiting for the next one
	 */
	do
	{
		XMaskEvent(xfc->display, VisibilityChangeMask, &xevent);
	}
	while (xevent.type != VisibilityNotify);

	/*
	 * The XCreateWindow call will start the window in the upper-left corner of our current
	 * monitor instead of the upper-left monitor for remote app mode (which uses all monitors).
	 * This extra call after the window is mapped will position the login window correctly
	 */
	if (xfc->context.settings->RemoteApplicationMode)
	{
		XMoveWindow(xfc->display, window->handle, 0, 0);
	}
	else if (settings->DesktopPosX != UINT32_MAX && settings->DesktopPosY != UINT32_MAX)
	{
		XMoveWindow(xfc->display, window->handle, settings->DesktopPosX,
		            settings->DesktopPosY);
	}

	window->floatbar = xf_floatbar_new(xfc, window->handle, name, settings->Floatbar);
	return window;
}