Пример #1
0
/************************************************************************
 *
 *  ClassInitialize
 *
 ************************************************************************/
static void 
ClassInitialize( void )
{
    if (PrintContextToWidget == 0)
	PrintContextToWidget = XUniqueContext();
    if (_XmPrintScreenToShellContext == 0)
	_XmPrintScreenToShellContext = XUniqueContext();
}    
Пример #2
0
Файл: DragBS.c Проект: att/uwin
/*
 * fetch the cached atoms table
 */
static XmDndTargetsTable
get_targets_table(Display *display)
{
    XmDndTargetsTable targets = NULL;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_targets_table(%d)\n",
		      __FILE__, __LINE__));

    if (displayToTargets == (XContext)0)
    {
	displayToTargets = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToTargets, (XPointer *)&targets) != XCSUCCESS)
    {
	DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_targets_table(%d) - NULL\n",
		      __FILE__, __LINE__));

	return NULL;
    }

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_targets_table(%d) - %p\n",
		      __FILE__, __LINE__, targets));

    return targets;
}
Пример #3
0
Файл: DragBS.c Проект: att/uwin
/*
 * lookup (program local) the value of the drag window
 */
static Window
get_drag_window(Display *display)
{
    Window win;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_drag_window(%d)\n",
		      __FILE__, __LINE__));

    if (displayToDW == None)
    {
	displayToDW = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToDW, (XPointer *)&win) == XCSUCCESS)
    {
	DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_drag_window(%d) - %p\n",
		      __FILE__, __LINE__, win));

	return win;
    }

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_drag_window(%d) - None\n",
		      __FILE__, __LINE__));

    return None;
}
Пример #4
0
int show_x_dialog (Display *dpy, Window parent, int x, int y) {
	if (_dlg_mwin) return -1;
	if (!_dlg_ctx) {
		_dlg_ctx = XUniqueContext();
	}
	_parent = parent;

	XColor dummy;
	Colormap colormap = DefaultColormap (dpy, DefaultScreen (dpy));
	if (!XAllocNamedColor (dpy, colormap, "LightGray", &_c_gray1, &dummy)) return -1;
	if (!XAllocNamedColor (dpy, colormap, "DarkGray", &_c_gray2, &dummy)) return -1;

	update_menus();

	int items; for (items = 0; mainmenu[items].text; ++items);
	if (open_x_dialog_win(dpy, &_dlg_mwin, x, y, 0, mainmenu, items)) {
		return -1;
	}
#if 1
	XGrabPointer (dpy, _dlg_mwin, True,
			ButtonReleaseMask | ButtonPressMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | StructureNotifyMask,
			GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
	XGrabKeyboard (dpy, _dlg_mwin, True, GrabModeAsync, GrabModeAsync, CurrentTime);
	//XSetInputFocus (dpy, parent, RevertToNone, CurrentTime);
#endif
	return 0;
}
Пример #5
0
Файл: DragBS.c Проект: att/uwin
/*
 * cache the atoms table
 */
static void
set_atoms_table(Display *display, XmDndAtomsTable table)
{
    XmDndAtomsTable atoms;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:set_atoms_table(%d)\n",
		      __FILE__, __LINE__));

    if (displayToAtoms == (XContext)0)
	displayToAtoms = XUniqueContext();

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToAtoms, (XPointer *)&atoms) == XCSUCCESS)
    {
	if (atoms == table)
	{
	    return;
	}

	XDeleteContext(display, DefaultRootWindow(display),
		       displayToAtoms);
    }

    XSaveContext(display, DefaultRootWindow(display),
		 displayToAtoms, (XPointer)table);
}
Пример #6
0
/***********************************************************************
 *		set_window_cursor
 */
void set_window_cursor( struct x11drv_win_data *data, HCURSOR handle )
{
    Cursor cursor, prev;

    wine_tsx11_lock();
    if (!handle) cursor = get_empty_cursor();
    else if (!cursor_context || XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
    {
        /* try to create it */
        wine_tsx11_unlock();
        if (!(cursor = create_cursor( handle ))) return;

        wine_tsx11_lock();
        if (!cursor_context) cursor_context = XUniqueContext();
        if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&prev ))
        {
            /* someone else was here first */
            XFreeCursor( gdi_display, cursor );
            cursor = prev;
        }
        else
        {
            XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor );
            TRACE( "cursor %p created %lx\n", handle, cursor );
        }
    }

    XDefineCursor( gdi_display, data->whole_window, cursor );
    /* make the change take effect immediately */
    XFlush( gdi_display );
    data->cursor = handle;
    wine_tsx11_unlock();
}
Пример #7
0
static W_View *createView(W_Screen * screen, W_View * parent)
{
	W_View *view;

	if (ViewContext == 0)
		ViewContext = XUniqueContext();

	view = wmalloc(sizeof(W_View));
	view->screen = screen;

	if (parent != NULL) {
		/* attributes are not valid for root window */
		view->attribFlags = CWEventMask | CWBitGravity;
		view->attribs = defAtts;

		view->attribFlags |= CWBackPixel | CWColormap | CWBorderPixel;
		view->attribs.background_pixel = W_PIXEL(screen->gray);
		view->attribs.border_pixel = W_PIXEL(screen->black);
		view->attribs.colormap = screen->colormap;

		view->backColor = WMRetainColor(screen->gray);

		adoptChildView(parent, view);
	}

	view->xic = 0;

	view->refCount = 1;

	view->eventHandlers = WMCreateArrayWithDestructor(4, wfree);

	return view;
}
Пример #8
0
int _glfwPlatformInit(void)
{
    XInitThreads();

    _glfw.x11.display = XOpenDisplay(NULL);
    if (!_glfw.x11.display)
    {
        _glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display");
        return GL_FALSE;
    }

    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
    _glfw.x11.context = XUniqueContext();

    if (!initExtensions())
        return GL_FALSE;

    _glfw.x11.cursor = createNULLCursor();

    if (!_glfwInitContextAPI())
        return GL_FALSE;

    _glfwInitTimer();
    _glfwInitJoysticks();
    _glfwInitGammaRamp();

    return GL_TRUE;
}
Пример #9
0
void init_x_and_imlib(void)
{
	disp = XOpenDisplay(NULL);
	if (!disp)
		eprintf("Can't open X display. It *is* running, yeah?");
	vis = DefaultVisual(disp, DefaultScreen(disp));
	depth = DefaultDepth(disp, DefaultScreen(disp));
	cm = DefaultColormap(disp, DefaultScreen(disp));
	root = RootWindow(disp, DefaultScreen(disp));
	scr = ScreenOfDisplay(disp, DefaultScreen(disp));
	xid_context = XUniqueContext();

#ifdef HAVE_LIBXINERAMA
	init_xinerama();
#endif				/* HAVE_LIBXINERAMA */

	imlib_context_set_display(disp);
	imlib_context_set_visual(vis);
	imlib_context_set_colormap(cm);
	imlib_context_set_color_modifier(NULL);
	imlib_context_set_progress_function(NULL);
	imlib_context_set_operation(IMLIB_OP_COPY);
	wmDeleteWindow = XInternAtom(disp, "WM_DELETE_WINDOW", False);

	/* Initialise random numbers */
	srand(getpid() * time(NULL) % ((unsigned int) -1));

	return;
}
Пример #10
0
Файл: DragBS.c Проект: att/uwin
/*
 * cache the atoms table
 */
static void
set_targets_table(Display *display, XmDndTargetsTable table)
{
    XmDndTargetsTable targets;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:set_targets_table(%d) - %p\n",
		      __FILE__, __LINE__, table));

    if (displayToTargets == (XContext)0)
    {
	displayToTargets = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToTargets, (XPointer *)&targets) == XCSUCCESS)
    {

	if (targets == table)
	{
	    return;
	}

	XDeleteContext(display, DefaultRootWindow(display),
		       displayToTargets);
    }

    XSaveContext(display, DefaultRootWindow(display),
		 displayToTargets, (XPointer)table);
}
Пример #11
0
extern void GeometryInitialize()
{
    if (initialized)
    	return;
    initialized = TRUE;

    geometryContext = XUniqueContext();
}
Пример #12
0
 virtual XContext create_detached(XDisplay& display) const {
     XContext detached = None;
     if (None != (detached = XUniqueContext())) {
         return detached;
     } else {
         LAMNA_LOG_ERROR("failed None == XUniqueContext()");
     }
     return None;
 }
Пример #13
0
int main(int argc, char **argv) {
  wm_t *wm = NULL;
  int i;
  wm = wm_create(NULL);
  wm_set_log_level(wm, LOG_INFO);

  container_context = XUniqueContext();
  client_container_context = XUniqueContext();

  wm_log(wm, LOG_INFO, "== num screens: %d", wm->num_screens);
  for (i = 0; i < wm->num_screens; i++) {
    XWindowAttributes attr;
    Window root = wm->screens[i]->root;;
    container_t *root_container;
    XGetWindowAttributes(wm->dpy, root, &attr);
    root_container = container_new(wm, root, attr.x, attr.y, attr.width, attr.height);
    container_show(root_container);
    wm_log(wm, LOG_INFO, "Setting current container to %tx", root_container);
    current_container = root_container;

    /* Grab keys */
    XGrabKey(wm->dpy, XKeysymToKeycode(wm->dpy, XK_j), Mod1Mask, root, False, GrabModeAsync, GrabModeAsync);
    XGrabKey(wm->dpy, XKeysymToKeycode(wm->dpy, XK_h), Mod1Mask, root, False, GrabModeAsync, GrabModeAsync);
  }

  container_focus(current_container);
  wm_listener_add(wm, WM_EVENT_MAPREQUEST, addwin);
  wm_listener_add(wm, WM_EVENT_MAPNOTIFY, addwin);
  wm_listener_add(wm, WM_EVENT_UNMAPNOTIFY, unmap);
  wm_listener_add(wm, WM_EVENT_ENTERNOTIFY, focus_container);
  wm_listener_add(wm, WM_EVENT_EXPOSE, expose_container);
  wm_listener_add(wm, WM_EVENT_KEYDOWN, keydown);
  wm_listener_add(wm, WM_EVENT_KEYUP, keyup);

  /* Start main loop. At this point, our code will only execute when events
   * happen */
  XSync(wm->dpy, False);
  wm_main(wm);

  return 0;
}
Пример #14
0
//==============================================================================
void MessageManager::doPlatformSpecificInitialisation()
{
    if (JUCEApplication::isStandaloneApp())
    {
        // Initialise xlib for multiple thread support
        static bool initThreadCalled = false;

        if (! initThreadCalled)
        {
            if (! XInitThreads())
            {
                // This is fatal!  Print error and closedown
                Logger::outputDebugString ("Failed to initialise xlib thread support.");
                Process::terminate();
                return;
            }

            initThreadCalled = true;
        }

        LinuxErrorHandling::installXErrorHandlers();
        LinuxErrorHandling::installKeyboardBreakHandler();
    }

    // Create the internal message queue
    InternalMessageQueue::getInstance();

    // Try to connect to a display
    String displayName (getenv ("DISPLAY"));
    if (displayName.isEmpty())
        displayName = ":0.0";

    display = XOpenDisplay (displayName.toUTF8());

    if (display != 0)  // This is not fatal! we can run headless.
    {
        // Create a context to store user data associated with Windows we create in WindowDriver
        windowHandleXContext = XUniqueContext();

        // We're only interested in client messages for this window, which are always sent
        XSetWindowAttributes swa;
        swa.event_mask = NoEventMask;

        // Create our message window (this will never be mapped)
        const int screen = DefaultScreen (display);
        juce_messageWindowHandle = XCreateWindow (display, RootWindow (display, screen),
                                                  0, 0, 1, 1, 0, 0, InputOnly,
                                                  DefaultVisual (display, screen),
                                                  CWEventMask, &swa);
    }
}
Пример #15
0
static int setup_display() {
	int depth, i, formatCount, convDepth = -1;
	XPixmapFormatValues* formats;

	if (s_setup_done) {
		return 1;
	}

	s_display = XOpenDisplay(0);

	if (!s_display) {
		printf("Unable to open X11 display\n");
		return 0;
	}

	s_context = XUniqueContext();
	s_screen = DefaultScreen(s_display);
	s_visual = DefaultVisual(s_display, s_screen);
	formats = XListPixmapFormats(s_display, &formatCount);
	depth = DefaultDepth(s_display, s_screen);

	for (i = 0; i < formatCount; ++i) {
		if (depth == formats[i].depth) {
			convDepth = formats[i].bits_per_pixel;
			break;
		}
	}
  
	XFree(formats);

	// We only support 32-bit right now
	if (convDepth != 32) {
		printf("Unable to find 32-bit format for X11 display\n");
		XCloseDisplay(s_display);
		return 0;
	}

	s_depth = depth;

	s_gc = DefaultGC(s_display, s_screen);

	s_screen_width = DisplayWidth(s_display, s_screen);
	s_screen_height = DisplayHeight(s_display, s_screen);

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

	s_setup_done = 1;

	return 1;
}
Пример #16
0
void
ExternalClientInitialize (Display *display, Window win)
{
  extw_initialize_atoms(display);
  extw_which_side = extw_client_send;
  if (!context_inited)
    {
      focus_context = XUniqueContext();
      context_inited = 1;
    }
  XSaveContext(display, win, focus_context, 0);
  XSelectInput(display, win, EnterWindowMask | LeaveWindowMask |
	       FocusChangeMask);
}
Пример #17
0
int _glfwPlatformInit(void)
{
    // HACK: If the current locale is C, apply the environment's locale
    //       This is done because the C locale breaks character input
    if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
        setlocale(LC_CTYPE, "");

    XInitThreads();

    _glfw.x11.display = XOpenDisplay(NULL);
    if (!_glfw.x11.display)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to open X display");
        return GL_FALSE;
    }

    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
    _glfw.x11.context = XUniqueContext();

    if (!initExtensions())
        return GL_FALSE;

    _glfw.x11.cursor = createNULLCursor();

    if (XSupportsLocale())
    {
        XSetLocaleModifiers("");

        _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, 0, 0);
        if (_glfw.x11.im)
        {
            if (!hasUsableInputMethodStyle())
            {
                XCloseIM(_glfw.x11.im);
                _glfw.x11.im = NULL;
            }
        }
    }

    if (!_glfwInitContextAPI())
        return GL_FALSE;

    if (!_glfwInitJoysticks())
        return GL_FALSE;

    _glfwInitTimer();

    return GL_TRUE;
}
Пример #18
0
int glwtInit(
    const GLWTConfig *config,
    void (*error_callback)(const char *msg, void *userdata),
    void *userdata)
{
    glwt.error_callback = error_callback;
    glwt.userdata = userdata;

    XInitThreads();

    XSetIOErrorHandler(xlib_io_error);
    XSetErrorHandler(xlib_error);

    glwt.x11.xcontext = XUniqueContext();

    if((glwt.x11.display = XOpenDisplay(NULL)) == NULL)
    {
        glwtErrorPrintf("XOpenDisplay failed");
        return -1;
    }

    glwt.x11.screen_num = DefaultScreen(glwt.x11.display);

    int xkb_major = XkbMajorVersion, xkb_minor = XkbMinorVersion;
    int xkb_opcode = -1, xkb_event = -1, xkb_error = -1;
    if(!XkbQueryExtension(glwt.x11.display, &xkb_opcode, &xkb_event, &xkb_error, &xkb_major, &xkb_minor))
    {
        glwtErrorPrintf("Xkb extension missing");
        goto error;
    }

    if((glwt.x11.xim = XOpenIM(glwt.x11.display, NULL, NULL, NULL)) == NULL)
    {
        glwtErrorPrintf("XOpenIM failed");
        goto error;
    }

    if(init_x11_atoms() != 0)
        goto error;

#ifdef GLWT_USE_EGL
    glwt.egl.display = eglGetDisplay(glwt.x11.display);
    if(glwtInitEGL(config) != 0)
#else
    if(glwtInitGLX(config) != 0)
#endif
        goto error;

    XVisualInfo template;
Пример #19
0
static XawVendorShellExtPart *
SetExtPart(VendorShellWidget w, XawVendorShellExtWidget vew)
{
    contextDataRec *contextData;

    if (extContext == (XContext)0) extContext = XUniqueContext();

    contextData = XtNew(contextDataRec);
    contextData->parent = (Widget)w;
    contextData->ve = (Widget)vew;
    if (XSaveContext(XtDisplay(w), (Window)(((intptr_t)w)&0xffffffff), extContext, (char *)contextData)) {
	return(NULL);
    }
    return(&(vew->vendor_ext));
}
Пример #20
0
static Widget SetErrCnxt(Widget w, XIM xim)
{
    contextErrDataRec *contextErrData;

    if (errContext == (XContext)0) errContext = XUniqueContext();

    contextErrData = XtNew(contextErrDataRec);
    contextErrData->widget = w;
    contextErrData->xim = xim;
    if (XSaveContext(XtDisplay(w), (Window)(uintptr_t)xim, errContext,
	(char *)contextErrData)) {
	return(NULL);
    }
    return(contextErrData->widget);
}
Пример #21
0
container_t *container_new(wm_t *wm, Window parent, int x, int y,
                           int width, int height) {
  XWindowAttributes attr;
  container_t *container;
  container = xmalloc(sizeof(container_t));
  container->context = XUniqueContext();
  container->frame = mkframe(wm, parent, x, y, width, height);
  //container->title = mktitle(wm, parent, x, y, width, height);
  container->wm = wm;
  container->focused = False;

  XGetWindowAttributes(wm->dpy, parent, &attr);
  container->screen = attr.screen;

  container_create_gc(container);
  XSaveContext(wm->dpy, container->frame, container_context, (XPointer)container);
  return container;
}
Пример #22
0
void BrowserControl::init()
{
    char* loc = setlocale(LC_ALL, "");
    if (!loc)
        fprintf(stderr, "Could not use the the default environment locale\n");

    if (!XSupportsLocale())
        fprintf(stderr, "Default locale \"%s\" is no supported\n", loc ? loc : "");

    // When changing the locale being used we must call XSetLocaleModifiers (refer to manpage).
    if (!XSetLocaleModifiers(""))
        fprintf(stderr, "Could not set locale modifiers for locale \"%s\"\n", loc ? loc : "");

    m_display = XOpenDisplay(0);
    if (!m_display)
        fatalError("couldn't connect to X server\n");

    m_context = XUniqueContext();
}
Пример #23
0
Файл: DragBS.c Проект: att/uwin
/*
 * fetch the cached atoms table
 */
static XmDndAtomsTable
get_atoms_table(Display *display)
{
    XmDndAtomsTable tbl = NULL;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_atoms_table(%d)\n",
		      __FILE__, __LINE__));

    if (displayToAtoms == (XContext)0)
    {
	displayToAtoms = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToAtoms, (XPointer *)&tbl) != XCSUCCESS)
    {
	return NULL;
    }

    return tbl;
}
Пример #24
0
Файл: DragBS.c Проект: att/uwin
/*
 * cache (program local) the value of the drag window
 */
static void
set_drag_window(Display *display, Window win)
{
    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:set_drag_window(%d)\n",
		      __FILE__, __LINE__));

    if (displayToDW == None)
    {
	displayToDW = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToDW, (XPointer *)&win) == XCSUCCESS)
    {
	XDeleteContext(display, DefaultRootWindow(display),
		       displayToDW);
    }

    XSaveContext(display, DefaultRootWindow(display),
		 displayToDW, (XPointer)win);
}
Пример #25
0
Файл: x.c Проект: Limsik/e17
static void
EXidAdd(Win win)
{
#if DEBUG_XWIN
   Eprintf("EXidAdd: %p %#lx\n", win, win->xwin);
#endif
   if (!xid_context)
      xid_context = XUniqueContext();

   XSaveContext(disp, win->xwin, xid_context, (XPointer) win);

   if (!win_first)
     {
	win_first = win_last = win;
     }
   else
     {
	win->prev = win_last;
	win_last->next = win;
	win_last = win;
     }
}
Пример #26
0
Файл: UxXt.c Проект: juddy/edcde
/******************************************************************************
NAME:           UxPutContext( wgt, context )

INPUT:          Widget  wgt             - Widget
                XtPointer context       - context pointer

RETURN:         int                     UX_ERROR / UX_NO_ERROR

DESCRIPTION:    Uses the X Context manager to store the given context pointer
                in a memory location that is indexed by the given widget id.
                Also adds a destroyCallback to delete that context when the
                widget is destroyed.

EXT REFERENCES: UxTopLevel, xcontext_id
EXT EFFECTS:    xcontext_id

CREATION:       Visual Edge Software            April 6 1991
-----------------------------------------------------------------------------*/
int     UxPutContext( Widget wgt, caddr_t context )
{
        int             status;

        if ( xcontext_id == 0 )
                xcontext_id = XUniqueContext();

        if ( wgt == NULL )
                return ( UX_ERROR );

        status = XSaveContext( XtDisplay( UxTopLevel ),
                               (Window) wgt,
                               xcontext_id,
                               (char *) context );
        if ( status != 0 )
                return ( UX_ERROR );

        XtAddCallback (wgt, XmNdestroyCallback,
                        UxDeleteContextCB, (XtPointer)(XtArgVal) xcontext_id);

        return ( UX_NO_ERROR );
}
Пример #27
0
int
UxPutClassCode(Widget wgt, int id)
#endif				/* _NO_PROTO */
{
    int status;

    if (xcontext_mid == 0)
	xcontext_mid = XUniqueContext();

    if (wgt == NULL)
	return (UX_ERROR);

    status = XSaveContext(XtDisplay(UxTopLevel),
			  (Window) wgt,
			  xcontext_mid,
			  (XtPointer) id);
    if (status != 0)
	return (UX_ERROR);

    XtAddCallback(wgt, XmNdestroyCallback,
		  UxDeleteContextCB, (XtPointer) xcontext_mid);

    return (UX_NO_ERROR);
}
Пример #28
0
void InitVariables(void)
{
  FvwmContext = XUniqueContext();
  MenuContext = XUniqueContext();

  /* initialize some lists */
  Scr.AllBindings = NULL;
  Scr.AllMenus = NULL;
  Scr.TheList = NULL;

  Scr.DefaultIcon = NULL;

  Scr.d_depth = DefaultDepth(dpy, Scr.screen);
  Scr.FvwmRoot.w = Scr.Root;
  Scr.FvwmRoot.next = 0;

  /*  RBW - 05/15/1998 - 2 new fields to init - stacking order chain.  */
  Scr.FvwmRoot.stack_next = &Scr.FvwmRoot;
  Scr.FvwmRoot.stack_prev = &Scr.FvwmRoot;

  XGetWindowAttributes(dpy, Scr.Root, &(Scr.FvwmRoot.attr));
  Scr.root_pushes = 0;
  Scr.pushed_window = &Scr.FvwmRoot;
  Scr.FvwmRoot.number_cmap_windows = 0;

  /* create graphics contexts */
  CreateGCs();

  SetupButtons();		/* setup win-95 title bar buttons */

  Scr.MyDisplayWidth = DisplayWidth(dpy, Scr.screen);
  Scr.MyDisplayHeight = DisplayHeight(dpy, Scr.screen);

  Scr.NoBoundaryWidth = 1;
  Scr.BoundaryWidth = BOUNDARY_WIDTH;
  Scr.CornerWidth = CORNER_WIDTH;
  Scr.Hilite = NULL;
  Scr.Focus = NULL;
  Scr.Ungrabbed = NULL;

  Scr.StdFont.font = NULL;

#ifndef NON_VIRTUAL
  Scr.VxMax = 2 * Scr.MyDisplayWidth;
  Scr.VyMax = 2 * Scr.MyDisplayHeight;
#else
  Scr.VxMax = 0;
  Scr.VyMax = 0;
#endif
  Scr.Vx = Scr.Vy = 0;

  Scr.SizeWindow = None;

  /* Sets the current desktop number to zero */
  /* Multiple desks are available even in non-virtual
   * compilations */
  {
    Atom atype;
    int aformat;
    unsigned long nitems, bytes_remain;
    unsigned char *prop;

    Scr.CurrentDesk = 0;
    if ((XGetWindowProperty(dpy, Scr.Root, _XA_WM_DESKTOP, 0L, 1L, True,
			    _XA_WM_DESKTOP, &atype, &aformat, &nitems,
			    &bytes_remain, &prop)) == Success) {
      if (prop != NULL) {
	Restarting = True;
	Scr.CurrentDesk = *(unsigned long *) prop;
      }
    }
  }

  Scr.EdgeScrollX = Scr.EdgeScrollY = 100;
  Scr.ScrollResistance = Scr.MoveResistance = 0;
  Scr.OpaqueSize = 5;
  Scr.ClickTime = 150;
  Scr.ColormapFocus = COLORMAP_FOLLOWS_MOUSE;

  /* set major operating modes */
  Scr.NumBoxes = 0;

  Scr.randomx = Scr.randomy = 0;
  Scr.buttons2grab = 7;

  return;
}
Пример #29
0
int _glfwPlatformInit(void)
{
#if !defined(X_HAVE_UTF8_STRING)
    // HACK: If the current locale is C, apply the environment's locale
    //       This is done because the C locale breaks wide character input
    if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
        setlocale(LC_CTYPE, "");
#endif

    XInitThreads();

    _glfw.x11.display = XOpenDisplay(NULL);
    if (!_glfw.x11.display)
    {
        const char* display = getenv("DISPLAY");
        if (display)
        {
            _glfwInputError(GLFW_PLATFORM_ERROR,
                            "X11: Failed to open display %s", display);
        }
        else
        {
            _glfwInputError(GLFW_PLATFORM_ERROR,
                            "X11: The DISPLAY environment variable is missing");
        }

        return GLFW_FALSE;
    }

    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
    _glfw.x11.context = XUniqueContext();

    if (!initExtensions())
        return GLFW_FALSE;

    _glfw.x11.cursor = createNULLCursor();

    if (XSupportsLocale())
    {
        XSetLocaleModifiers("");

        _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
        if (_glfw.x11.im)
        {
            if (!hasUsableInputMethodStyle())
            {
                XCloseIM(_glfw.x11.im);
                _glfw.x11.im = NULL;
            }
        }
    }

    if (!_glfwInitContextAPI())
        return GLFW_FALSE;

    if (!_glfwInitJoysticks())
        return GLFW_FALSE;

    _glfwInitTimer();

    return GLFW_TRUE;
}
Пример #30
0
/** Prepare the connection. */
void StartupConnection(void)
{

   XSetWindowAttributes attr;
#ifdef USE_SHAPE
   int shapeError;
#endif
#ifdef USE_XRENDER
   int renderEvent;
   int renderError;
#endif
   struct sigaction sa;
   char name[32];
   Window win;
   XEvent event;
   int revert;

   initializing = 1;
   OpenConnection();

#if 0
   XSynchronize(display, True);
#endif

   /* Create the supporting window used to verify JWM is running. */
   supportingWindow = JXCreateSimpleWindow(display, rootWindow,
                                           0, 0, 1, 1, 0, 0, 0);

   /* Get the atom used for the window manager selection. */
   snprintf(name, 32, "WM_S%d", rootScreen);
   managerSelection = JXInternAtom(display, name, False);

   /* Get the current window manager and take the selection. */
   GrabServer();
   win = JXGetSelectionOwner(display, managerSelection);
   if(win != None) {
      JXSelectInput(display, win, StructureNotifyMask);
   }
   JXSetSelectionOwner(display, managerSelection,
                       supportingWindow, CurrentTime);
   UngrabServer();

   /* Wait for the current selection owner to give up the selection. */
   if(win != None) {
      /* Note that we need to wait for the current selection owner
       * to exit before we can expect to select SubstructureRedirectMask. */
      XIfEvent(display, &event, SelectionReleased, (XPointer)&win);
      JXSync(display, False);
   }

   event.xclient.display = display;
   event.xclient.type = ClientMessage;
   event.xclient.window = rootWindow;
   event.xclient.message_type = JXInternAtom(display, managerProperty, False);
   event.xclient.format = 32;
   event.xclient.data.l[0] = CurrentTime;
   event.xclient.data.l[1] = managerSelection;
   event.xclient.data.l[2] = supportingWindow;
   event.xclient.data.l[3] = 2;
   event.xclient.data.l[4] = 0;
   JXSendEvent(display, rootWindow, False, StructureNotifyMask, &event);
   JXSync(display, False);

   JXSetErrorHandler(ErrorHandler);

   clientContext = XUniqueContext();
   frameContext = XUniqueContext();

   /* Set the events we want for the root window.
    * Note that asking for SubstructureRedirect will fail
    * if another window manager is already running.
    */
   attr.event_mask
      = SubstructureRedirectMask
      | SubstructureNotifyMask
      | StructureNotifyMask
      | PropertyChangeMask
      | ColormapChangeMask
      | ButtonPressMask
      | ButtonReleaseMask
      | PointerMotionMask | PointerMotionHintMask;
   JXChangeWindowAttributes(display, rootWindow, CWEventMask, &attr);

   memset(&sa, 0, sizeof(sa));
   sa.sa_flags = 0;
   sa.sa_handler = HandleExit;
   sigaction(SIGTERM, &sa, NULL);
   sigaction(SIGINT, &sa, NULL);
   sigaction(SIGHUP, &sa, NULL);

   sa.sa_flags = SA_NOCLDWAIT;
   sa.sa_handler = SIG_DFL;
   sigaction(SIGCHLD, &sa, NULL);

#ifdef USE_SHAPE
   haveShape = JXShapeQueryExtension(display, &shapeEvent, &shapeError);
   if (haveShape) {
      Debug("shape extension enabled");
   } else {
      Debug("shape extension disabled");
   }
#endif

#ifdef USE_XRENDER
   haveRender = JXRenderQueryExtension(display, &renderEvent, &renderError);
   if(haveRender) {
      Debug("render extension enabled");
   } else {
      Debug("render extension disabled");
   }
#endif

   /* Make sure we have input focus. */
   win = None;
   JXGetInputFocus(display, &win, &revert);
   if(win == None) {
      JXSetInputFocus(display, rootWindow, RevertToParent, CurrentTime);
   }

   initializing = 0;

}