static void
update_wm_window (void)
{
  Window *xwindow;
  Atom type;
  gint format;
  gulong nitems;
  gulong bytes_after;

  XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
		      XInternAtom (GDK_DISPLAY (), "_NET_SUPPORTING_WM_CHECK", False),
		      0, G_MAXLONG, False, XA_WINDOW, &type, &format,
		      &nitems, &bytes_after, (guchar **) &xwindow);

  if (type != XA_WINDOW)
    {
      wm_window = None;
     return;
    }

  gdk_error_trap_push ();
  XSelectInput (GDK_DISPLAY (), *xwindow, StructureNotifyMask | PropertyChangeMask);
  XSync (GDK_DISPLAY (), False);

  if (gdk_error_trap_pop ())
    {
       XFree (xwindow);
       wm_window = None;
       return;
    }

    wm_window = *xwindow;
    XFree (xwindow);
}
Example #2
0
File: main.c Project: iwaim/ibus
static void
_xim_forward_gdk_event (GdkEventKey *event, X11IC *x11ic)
{
    g_return_if_fail (x11ic != NULL);

    IMForwardEventStruct fe = {0};
    XEvent xkp = {0};

    xkp.xkey.type = (event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease;
    xkp.xkey.serial = 0L;
    xkp.xkey.send_event = False;
    xkp.xkey.same_screen = True;
    xkp.xkey.display = GDK_DISPLAY();
    xkp.xkey.window =
        x11ic->focus_window ? x11ic->focus_window : x11ic->client_window;
    xkp.xkey.subwindow = None;
    xkp.xkey.root = DefaultRootWindow (GDK_DISPLAY());

    xkp.xkey.time = 0;
    xkp.xkey.state = event->state;
    xkp.xkey.keycode = event->hardware_keycode;

    fe.major_code = XIM_FORWARD_EVENT;
    fe.icid = x11ic->icid;
    fe.connect_id = x11ic->connect_id;
    fe.sync_bit = 0;
    fe.serial_number = 0L;
    fe.event = xkp;

    IMForwardEvent (_xims, (XPointer) & fe);
}
Example #3
0
/*
 * detect_get_clipboard - try and get the CLIPBOARD_NAME clipboard
 *
 * Returns TRUE if successfully retrieved and FALSE otherwise.
 */
gboolean detect_get_clipboard()
{
    static const GtkTargetEntry targets[] = { {CLIPBOARD_NAME, 0, 0} };
    gboolean retval = FALSE;
    GtkClipboard *clipboard;
    Atom atom;

    atom = gdk_x11_get_xatom_by_name(CLIPBOARD_NAME);

    XGrabServer(GDK_DISPLAY());

    if (XGetSelectionOwner(GDK_DISPLAY(), atom) != None)
        goto out;

    clipboard = gtk_clipboard_get(gdk_atom_intern(CLIPBOARD_NAME, FALSE));

    if (gtk_clipboard_set_with_data(
                clipboard, targets,
                G_N_ELEMENTS (targets),
                clipboard_get_func,
                clipboard_clear_func, NULL))
        retval = TRUE;

out:
    XUngrabServer (GDK_DISPLAY ());
    gdk_flush ();

    return retval;
}
Example #4
0
void
R_gtk_setEventHandler()
{
#ifndef WIN32
  static InputHandler *h = NULL;
  if(!h)
    {
      if (!GDK_DISPLAY())
        error("GDK display not found - please make sure X11 is running");
      h = addInputHandler(R_InputHandlers, ConnectionNumber(GDK_DISPLAY()),
                          R_gtk_eventHandler, -1);
    }
#else
  /* Create a dummy window for receiving messages */
  LPCTSTR class = "cairoDevice";
  HINSTANCE instance = GetModuleHandle(NULL);
  WNDCLASS wndclass = { 0, DefWindowProc, 0, 0, instance, NULL, 0, 0, NULL,
                        class };
  RegisterClass(&wndclass);
  HWND win = CreateWindow(class, NULL, 0, 1, 1, 1, 1, HWND_MESSAGE,
                          NULL, instance, NULL);

  SetTimer(win, CD_TIMER_ID, CD_TIMER_DELAY, (TIMERPROC)R_gtk_timer_proc);
#endif
}
Example #5
0
wxGLContext::wxGLContext(wxWindow* win, const wxGLContext* other)
{
    wxGLCanvas *gc = (wxGLCanvas*) win;

    if (wxGLCanvas::GetGLXVersion() >= 13)
    {
        // GLX >= 1.3
        GLXFBConfig *fbc = gc->m_fbc;
        wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGl") );
        m_glContext = glXCreateNewContext( GDK_DISPLAY(), fbc[0], GLX_RGBA_TYPE,
                                           other ? other->m_glContext : None,
                                           GL_TRUE );
    }
    else
    {
        // GLX <= 1.2
        XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
        wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
        m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
                                        other ? other->m_glContext : None,
                                        GL_TRUE );
    }

    if ( !m_glContext )
    {
        wxFAIL_MSG( _T("Couldn't create OpenGl context") );
    }
}
Example #6
0
File: main.c Project: hychen/ibus
static void
_xim_forward_key_event (X11IC   *x11ic,
                        guint    keyval,
                        guint    keycode,
                        guint    state)
{
    g_return_if_fail (x11ic != NULL);

    IMForwardEventStruct fe = {0};
    XEvent xkp = {0};

    xkp.xkey.type = (state & IBUS_RELEASE_MASK) ? KeyRelease : KeyPress;
    xkp.xkey.serial = 0L;
    xkp.xkey.send_event = False;
    xkp.xkey.same_screen = True;
    xkp.xkey.display = GDK_DISPLAY();
    xkp.xkey.window =
        x11ic->focus_window ? x11ic->focus_window : x11ic->client_window;
    xkp.xkey.subwindow = None;
    xkp.xkey.root = DefaultRootWindow (GDK_DISPLAY());

    xkp.xkey.time = 0;
    xkp.xkey.state = state;
    xkp.xkey.keycode = (keycode == 0) ? 0 : keycode + 8;

    fe.major_code = XIM_FORWARD_EVENT;
    fe.icid = x11ic->icid;
    fe.connect_id = x11ic->connect_id;
    fe.sync_bit = 0;
    fe.serial_number = 0L;
    fe.event = xkp;

    IMForwardEvent (_xims, (XPointer) & fe);
}
static KeyCode grab_key(char *keystring)
{
	KeySym sym;
	KeyCode code;
	gint i;

	if ((sym = XStringToKeysym(keystring)) == NoSymbol)
		return 0;
	if ((code = XKeysymToKeycode(GDK_DISPLAY(), sym)) == 0)
		return 0;

	gdk_error_trap_push();
	for (i = 0; i < ScreenCount(GDK_DISPLAY()); i++) {
		XGrabKey(GDK_DISPLAY(), code,
				AnyModifier, RootWindow(GDK_DISPLAY(),i),
				1, GrabModeAsync, GrabModeAsync);
	}

	gdk_flush();
	if (gdk_error_trap_pop()) {
		g_warning("Couldn't grab %s: another client may already have done so",
				keystring);
		return 0;
	}
	return code;
}
Example #8
0
File: fbxkb.c Project: kba/fbxkb
static void
init()
{
    int dummy;

    ENTER;
    if (!XkbQueryExtension(GDK_DISPLAY(), &dummy, &xkb_event_type, &dummy,
            &dummy, &dummy)) {
        ERR("no XKB extension\n");
        exit(1);
    }
    XSetLocaleModifiers("");
    XSetErrorHandler((XErrorHandler) Xerror_handler);
    dpy = GDK_DISPLAY();
    if (chdir(IMGPREFIX)) {
        ERR("can't chdir to %s\n", IMGPREFIX);
        exit(1);
    }
    if (!(default_flag = get_flag("zz"))) {
        ERR("can't load default flag image\n");
        exit(1);
    }
    XkbSelectEventDetails(dpy, XkbUseCoreKbd, XkbStateNotify,
          XkbAllStateComponentsMask, XkbGroupStateMask);
    gdk_window_add_filter(NULL, (GdkFilterFunc)filter, NULL);
    RET();
}
Example #9
0
static GdkFilterReturn
filter_mmkeys (GdkXEvent *xevent, GdkEvent *event, gpointer data)
{
	XEvent *xev;
	XKeyEvent *key;

	xev = (XEvent *) xevent;
	if (xev->type != KeyPress) {
		return GDK_FILTER_CONTINUE;
	}

	key = (XKeyEvent *) xevent;

	if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPlay) == key->keycode) {
		g_signal_emit (data, signals[MM_PLAYPAUSE], 0, 0);
		return GDK_FILTER_REMOVE;
	} else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPause) == key->keycode) {
		g_signal_emit (data, signals[MM_PLAYPAUSE], 0, 0);
		return GDK_FILTER_REMOVE;
	} else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPrev) == key->keycode) {
		g_signal_emit (data, signals[MM_PREV], 0, 0);
		return GDK_FILTER_REMOVE;
	} else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioNext) == key->keycode) {
		g_signal_emit (data, signals[MM_NEXT], 0, 0);
		return GDK_FILTER_REMOVE;
	} else if (XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioStop) == key->keycode) {
		g_signal_emit (data, signals[MM_STOP], 0, 0);
		return GDK_FILTER_REMOVE;
	} else {
		return GDK_FILTER_CONTINUE;
	}
}
Example #10
0
File: trayicon.c Project: aufau/xqf
/* from gdk-pixbuf-xlib-drawabel.c */
static gboolean xlib_window_is_viewable (Window w) {
	XWindowAttributes wa;

	while (w != 0) {
		Window parent, root, *children;
		guint nchildren;

		XGetWindowAttributes (GDK_DISPLAY(), w, &wa);

		if (wa.map_state != IsViewable) {
			return FALSE;
		}

		if (!XQueryTree (GDK_DISPLAY(), w, &root, &parent, &children, &nchildren))
			return FALSE;

		if (nchildren > 0)
			XFree (children);

		if ((parent == root) || (w == root))
			return TRUE;

		w = parent;
	}
	return FALSE;
}
Example #11
0
static void
mmkeys_init (MmKeys *object)
{
	int keycodes[N_KEYCODES];
	GdkDisplay *display;
	GdkScreen *screen;
	GdkWindow *root;
	guint i, j;

	display = gdk_display_get_default ();

	keycodes[0] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPrev);
	keycodes[1] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioNext);
	keycodes[2] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPlay);
	keycodes[3] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPause);
	keycodes[4] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioStop);

	for (i = 0; i < gdk_display_get_n_screens (display); i++) {
		screen = gdk_display_get_screen (display, i);

		if (screen != NULL) {
			root = gdk_screen_get_root_window (screen);

			for (j = 0; j < N_KEYCODES; j++) {
				if (keycodes[j] > 0)
					grab_mmkey (keycodes[j], root);
			}

			gdk_window_add_filter (root, filter_mmkeys, object);
		}
	}
}
Example #12
0
File: pager.c Project: g7/fbpanel
static void
task_get_sizepos(task *t)
{
    Window root, junkwin;
    int rx, ry;
    guint dummy;
    XWindowAttributes win_attributes;

    ENTER;
    if (!XGetWindowAttributes(GDK_DISPLAY(), t->win, &win_attributes)) {
        if (!XGetGeometry (GDK_DISPLAY(), t->win, &root, &t->x, &t->y, &t->w, &t->h,
                  &dummy, &dummy)) {
            t->x = t->y = t->w = t->h = 2;
        }

    } else {
        XTranslateCoordinates (GDK_DISPLAY(), t->win, win_attributes.root,
              -win_attributes.border_width,
              -win_attributes.border_width,
              &rx, &ry, &junkwin);
        t->x = rx;
        t->y = ry;
        t->w = win_attributes.width;
        t->h = win_attributes.height;
        DBG("win=0x%lx WxH=%dx%d\n", t->win,t->w, t->h);
    }
    RET();
}
Example #13
0
File: key.c Project: morenko/sven
void ungrab_key (int key_code)
{
	GdkWindow *root=gdk_get_default_root_window();
	
	gdk_error_trap_push ();
	XUngrabKey (GDK_DISPLAY (), key_code, AnyModifier,
			(GDK_WINDOW_XID (root) ? GDK_WINDOW_XID (root) : DefaultRootWindow (GDK_DISPLAY())));
	XUngrabKey (GDK_DISPLAY (), AnyKey, AnyModifier, (GDK_WINDOW_XID (root) ? GDK_WINDOW_XID (root) : DefaultRootWindow (GDK_DISPLAY())));


	gdk_flush ();
	if (gdk_error_trap_pop ()) 
	{
		gchar *error;
		gchar *key;

		key=g_strdup_printf ("%s",(XKeysymToString (XKeycodeToKeysym (GDK_DISPLAY (), key_code, 0)) != NULL)? 
		XKeysymToString (XKeycodeToKeysym (GDK_DISPLAY (),key_code, 0)):
		g_strdup_printf ("%d",key_code));
		
		error = g_strdup_printf
			(_("It seems that another application already has"
			   " access to the multimedia keys.\n"
			   "Key %s couldn't be bound.\n"
			   "Is another daemon already running ?\n"),
			 key);
		show_error(error);
		printf("[Sven][ERROR]:%s",error);
		g_free (key);
		g_free (error);
	}
}
Example #14
0
static Pixmap
get_pixmap_prop (Window the_window, char *prop_id)
{
  Atom prop, type;
  int format;
  unsigned long length, after;
  unsigned char *data;


  Window desktop_window = get_desktop_window(the_window);

  if(desktop_window == None)
    desktop_window = GDK_ROOT_WINDOW();

  prop = XInternAtom(GDK_DISPLAY(), prop_id, True);

  if (prop == None)
    return None;

  XGetWindowProperty(GDK_DISPLAY(), desktop_window, prop, 0L, 1L, False,
         AnyPropertyType, &type, &format, &length, &after,
         &data);

  if (type == XA_PIXMAP)
    return *((Pixmap *)data);

  return None;
}
Example #15
0
wxGLContext::wxGLContext(
               bool WXUNUSED(isRGB), wxWindow *win,
               const wxPalette& WXUNUSED(palette),
               const wxGLContext *other        /* for sharing display lists */
)
{
    m_window = win;
    m_widget = win->m_wxwindow;

    wxGLCanvas *gc = (wxGLCanvas*) win;

    if (wxGLCanvas::GetGLXVersion() >= 13)
      {
	// GLX >= 1.3
	GLXFBConfig *fbc = gc->m_fbc;
	wxCHECK_RET( fbc, _T("invalid GLXFBConfig for OpenGl") );
	m_glContext = glXCreateNewContext( GDK_DISPLAY(), fbc[0], GLX_RGBA_TYPE,
					   other ? other->m_glContext : None,
					   GL_TRUE );
      }
    else
      {
	// GLX <= 1.2
	XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
    wxCHECK_RET( vi, _T("invalid visual for OpenGl") );
    m_glContext = glXCreateContext( GDK_DISPLAY(), vi,
                                    other ? other->m_glContext : None,
                                    GL_TRUE );
      }

    if ( !m_glContext )
    {
        wxFAIL_MSG( _T("Couldn't create OpenGl context") );
    }
}
Example #16
0
File: trayicon.c Project: aufau/xqf
void tray_init(GtkWidget * main_window) {
	gdk_pixbuf_xlib_init (GDK_DISPLAY(), DefaultScreen (GDK_DISPLAY()));

	/* local copy */
	window = main_window;

	gtk_window_get_position(GTK_WINDOW(window), &x_pos, &y_pos);

	tray_create_menu();

	busy_ani = tray_icon_load_animation ("busy.ani", TRUE);
	ready_ani = tray_icon_load_animation("ready.ani", FALSE);

	frame_basic = load_pixmap_as_pixbuf("trayicon/frame_basic.png");

	if (frame_basic)
		tray_icon = egg_tray_icon_new ("xqf", frame_basic);

	if (tray_icon && tray_icon->ready) {
		g_signal_connect(tray_icon, "button_press_event", G_CALLBACK(tray_icon_pressed),tray_icon);

		gtk_widget_hide(window);
	}
	else
		gtk_widget_show(window);
}
Example #17
0
int main(int argc, char **argv)
{
  gdk_init(NULL, NULL);

  /* Force to output original string, usually are Traditional Chinese */
  if (strstr(argv[0],"hime-trad"))
    send_hime_message(GDK_DISPLAY(), TRAD_OUTPUT_TOGGLE);

  /* Force to output Simplified Chinese */
  if (strstr(argv[0],"hime-sim"))
    send_hime_message(GDK_DISPLAY(), SIM_OUTPUT_TOGGLE);

  /* Toggle between Original string and Simplified Chinese */
  if (strstr(argv[0],"hime-gb-toggle"))
    send_hime_message(GDK_DISPLAY(), GB_OUTPUT_TOGGLE);

  /* Toggle virtual keyboard */
  if (strstr(argv[0],"hime-kbm-toggle"))
    send_hime_message(GDK_DISPLAY(), KBM_TOGGLE);

  if (strstr(argv[0],"hime-exit")) {
    Display *dpy = GDK_DISPLAY();
    if (find_hime_window(dpy)==None)
      return 0;
    send_hime_message(dpy, HIME_EXIT_MESSAGE);
  }

  return 0;
}
// the following function is stolen from xfdesktop
static void
set_num_screens (gpointer num)
{
    static Atom xa_NET_NUMBER_OF_DESKTOPS = 0;
    XClientMessageEvent sev;
    int n;

    if (!xa_NET_NUMBER_OF_DESKTOPS)
    {
	xa_NET_NUMBER_OF_DESKTOPS =
	    XInternAtom (GDK_DISPLAY (), "_NET_NUMBER_OF_DESKTOPS", False);
    }

    n = GPOINTER_TO_INT (num);

    sev.type = ClientMessage;
    sev.display = GDK_DISPLAY ();
    sev.format = 32;
    sev.window = GDK_ROOT_WINDOW ();
    sev.message_type = xa_NET_NUMBER_OF_DESKTOPS;
    sev.data.l[0] = n;

    gdk_error_trap_push ();

    XSendEvent (GDK_DISPLAY (), GDK_ROOT_WINDOW (), False,
		SubstructureNotifyMask | SubstructureRedirectMask,
		(XEvent *) & sev);

    gdk_flush ();
    gdk_error_trap_pop ();
}
Example #19
0
/* Get the geometry of a task window in screen coordinates. */
static void task_get_geometry(PagerTask * tk)
{
    /* Install an error handler that ignores BadWindow and BadDrawable.
     * We frequently get a ConfigureNotify event on deleted windows. */
    XErrorHandler previous_error_handler = XSetErrorHandler(panel_handle_x_error_swallow_BadWindow_BadDrawable);

    XWindowAttributes win_attributes;
    if (XGetWindowAttributes(GDK_DISPLAY(), tk->win, &win_attributes))
    {
        Window unused_win;
        int rx, ry;
        XTranslateCoordinates(GDK_DISPLAY(), tk->win, win_attributes.root,
              - win_attributes.border_width,
              - win_attributes.border_width,
              &rx, &ry, &unused_win);
        tk->x = rx;
        tk->y = ry;
        tk->w = win_attributes.width;
        tk->h = win_attributes.height;
    }
    else
    {
        Window unused_win;
        guint unused;
        if ( ! XGetGeometry(GDK_DISPLAY(), tk->win,
            &unused_win, &tk->x, &tk->y, &tk->w, &tk->h, &unused, &unused))
        {
            tk->x = tk->y = tk->w = tk->h = 2;
        }
    }

    XSetErrorHandler(previous_error_handler);
}
Example #20
0
/**
 * gpm_dpms_x11_set_mode:
 **/
static gboolean
gpm_dpms_x11_set_mode (GpmDpms *dpms, GpmDpmsMode mode, GError **error)
{
	GpmDpmsMode current_mode;
	CARD16 state;
	CARD16 current_state;
	BOOL current_enabled;

	if (!dpms->priv->dpms_capable) {
		egg_debug ("not DPMS capable");
		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
			     "Display is not DPMS capable");
		return FALSE;
	}

	if (!DPMSInfo (GDK_DISPLAY (), &current_state, &current_enabled)) {
		egg_debug ("couldn't get DPMS info");
		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
			     "Unable to get DPMS state");
		return FALSE;
	}

	if (!current_enabled) {
		egg_debug ("DPMS not enabled");
		g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
			     "DPMS is not enabled");
		return FALSE;
	}

	switch (mode) {
	case GPM_DPMS_MODE_ON:
		state = DPMSModeOn;
		break;
	case GPM_DPMS_MODE_STANDBY:
		state = DPMSModeStandby;
		break;
	case GPM_DPMS_MODE_SUSPEND:
		state = DPMSModeSuspend;
		break;
	case GPM_DPMS_MODE_OFF:
		state = DPMSModeOff;
		break;
	default:
		state = DPMSModeOn;
		break;
	}

	gpm_dpms_x11_get_mode (dpms, &current_mode, NULL);
	if (current_mode != mode) {
		if (! DPMSForceLevel (GDK_DISPLAY (), state)) {
			g_set_error (error, GPM_DPMS_ERROR, GPM_DPMS_ERROR_GENERAL,
				     "Could not change DPMS mode");
			return FALSE;
		}
		XSync (GDK_DISPLAY (), FALSE);
	}

	return TRUE;
}
Example #21
0
void grab_keys(int mk, int uk, int dk,
	       int mm, int um, int dm,
	       int step) {
  Display* disp = GDK_DISPLAY();

  // ungrab any previous keys
  XUngrabKey(disp, AnyKey, AnyModifier, GDK_ROOT_WINDOW());

  volMuteKey = mk;
  volUpKey = uk;
  volDownKey = dk;
  volMuteMods = mm;
  volUpMods = um;
  volDownMods = dm;
  volStep = step;

  if (mk < 0 &&
      uk < 0 &&
      dk < 0)
    return;
  
  xErr = 0;
  errBuf = g_malloc(errBufSize*sizeof(gchar));
  printBuf = errBuf + snprintf(errBuf,errBufSize,_("Could not bind the following hotkeys:\n"));
  errBufSize -= (printBuf - errBuf);

  if (muteSymStr) g_free(muteSymStr);
  if (upSymStr)   g_free(upSymStr);
  if (downSymStr) g_free(downSymStr);
  muteSymStr = gtk_accelerator_name(XkbKeycodeToKeysym(GDK_DISPLAY(), volMuteKey, 0, 0),volMuteMods);
  upSymStr = gtk_accelerator_name(XkbKeycodeToKeysym(GDK_DISPLAY(),volUpKey,0, 0),volUpMods);
  downSymStr = gtk_accelerator_name(XkbKeycodeToKeysym(GDK_DISPLAY(), volDownKey, 0, 0),volDownMods);

  XErrorHandler old_hdlr = XSetErrorHandler(errhdl);
  if (volMuteKey > 0) {
    muteSerial = NextRequest(disp);
    XGrabKey(disp,volMuteKey,volMuteMods,GDK_ROOT_WINDOW(),1,GrabModeAsync,GrabModeAsync);
  }

  if (volUpKey > 0) {
    upSerial = NextRequest(disp);
    XGrabKey(disp,volUpKey,volUpMods,GDK_ROOT_WINDOW(),1,GrabModeAsync,GrabModeAsync);
  }

  if (volDownKey > 0) {
    downSerial = NextRequest(disp);
    XGrabKey(disp,volDownKey,volDownMods,GDK_ROOT_WINDOW(),1,GrabModeAsync,GrabModeAsync);
  }

  XFlush(disp);
  XSync(disp, False);
  (void) XSetErrorHandler(old_hdlr);
  
  if (xErr) 
    g_idle_add(idle_report_error, NULL);
  else
    g_free(errBuf);
}
Example #22
0
void
panel_set_wm_strut(panel *p)
{
    gulong data[12] = { 0 };
    int i = 4;

    ENTER;
    if (!GTK_WIDGET_MAPPED(p->topgwin))
        return;
    /* most wm's tend to ignore struts of unmapped windows, and that's how
     * fbpanel hides itself. so no reason to set it. */
    if (p->autohide)
        return;
    switch (p->edge) {
    case EDGE_LEFT:
        i = 0;
        data[i] = p->aw;
        data[4 + i*2] = p->ay;
        data[5 + i*2] = p->ay + p->ah;
        if (p->autohide) data[i] = p->height_when_hidden;
        break;
    case EDGE_RIGHT:
        i = 1;
        data[i] = p->aw;
        data[4 + i*2] = p->ay;
        data[5 + i*2] = p->ay + p->ah;
        if (p->autohide) data[i] = p->height_when_hidden;
        break;
    case EDGE_TOP:
        i = 2;
        data[i] = p->ah;
        data[4 + i*2] = p->ax;
        data[5 + i*2] = p->ax + p->aw;
        if (p->autohide) data[i] = p->height_when_hidden;
        break;
    case EDGE_BOTTOM:
        i = 3;
        data[i] = p->ah;
        data[4 + i*2] = p->ax;
        data[5 + i*2] = p->ax + p->aw;
        if (p->autohide) data[i] = p->height_when_hidden;
        break;
    default:
        ERR("wrong edge %d. strut won't be set\n", p->edge);
        RET();
    }
    DBG("type %d. width %ld. from %ld to %ld\n", i, data[i], data[4 + i*2],
        data[5 + i*2]);

    /* if wm supports STRUT_PARTIAL it will ignore STRUT */
    XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_STRUT_PARTIAL,
                    XA_CARDINAL, 32, PropModeReplace,  (unsigned char *) data, 12);
    /* old spec, for wms that do not support STRUT_PARTIAL */
    XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_STRUT,
                    XA_CARDINAL, 32, PropModeReplace,  (unsigned char *) data, 4);

    RET();
}
char *
egg_tray_manager_get_child_title (EggTrayManager *manager,
				  EggTrayManagerChild *child)
{
  Window *child_window;
  Atom utf8_string, atom, type;
  int result;
  gchar *val, *retval;
  int format;
  gulong nitems;
  gulong bytes_after;
  guchar *tmp;

  g_return_val_if_fail (EGG_IS_TRAY_MANAGER (manager), NULL);
  g_return_val_if_fail (GTK_IS_SOCKET (child), NULL);
  
  child_window = g_object_get_data (G_OBJECT (child),
				    "egg-tray-child-window");

  utf8_string = XInternAtom (GDK_DISPLAY (), "UTF8_STRING", False);
  atom = XInternAtom (GDK_DISPLAY (), "_NET_WM_NAME", False);

  gdk_error_trap_push ();

  result = XGetWindowProperty (GDK_DISPLAY (),
			       *child_window,
			       atom,
			       0, G_MAXLONG,
			       False, utf8_string,
			       &type, &format, &nitems,
			       &bytes_after, &tmp);
  val = (gchar *) tmp;
  if (gdk_error_trap_pop () || result != Success)
    return NULL;

  if (type != utf8_string ||
      format != 8 ||
      nitems == 0)
    {
      if (val)
	XFree (val);
      return NULL;
    }

  if (!g_utf8_validate (val, nitems, NULL))
    {
      XFree (val);
      return NULL;
    }

  retval = g_strndup (val, nitems);

  XFree (val);

  return retval;

}
Example #24
0
static void
grab_key_real (Key *key, GdkWindow *root, gboolean grab, int result)
{
        if (grab)
                XGrabKey (GDK_DISPLAY(), key->keycode, (result | key->state),
                                GDK_WINDOW_XID (root), True, GrabModeAsync, GrabModeAsync);
        else
                XUngrabKey(GDK_DISPLAY(), key->keycode, (result | key->state),
                                GDK_WINDOW_XID (root));
}
Example #25
0
void* wxGLCanvas::ChooseGLFBC(int *attribList)
{
    int data[512];
    GetGLAttribListFromWX( attribList, data );
    attribList = (int*) data;

    int returned;
    return glXChooseFBConfig( GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
                              attribList, &returned );
}
static void
hn_others_button_get_workarea (GtkAllocation *allocation)
{
  unsigned long n;
  unsigned long extra;
  int format;
  int status;
  Atom property = XInternAtom (GDK_DISPLAY (), WORKAREA_ATOM, FALSE);
  Atom realType;
  
  /* This is needed to get rid of the punned type-pointer 
     breaks strict aliasing warning*/
  union
  {
    unsigned char *char_value;
    int *int_value;
  } value;
    
  status = XGetWindowProperty (GDK_DISPLAY (), 
			       GDK_ROOT_WINDOW (), 
			       property, 
			       0L, 
			       4L,
			       0, 
			       XA_CARDINAL, 
			       &realType, 
			       &format,
			       &n, 
			       &extra, 
			       (unsigned char **) &value.char_value);
    
  if (status == Success &&
      realType == XA_CARDINAL &&
      format == 32 && 
      n == 4  &&
      value.char_value != NULL)
  {
    allocation->x = value.int_value[0];
    allocation->y = value.int_value[1];
    allocation->width = value.int_value[2];
    allocation->height = value.int_value[3];
  }
  else
  {
    allocation->x = 0;
    allocation->y = 0;
    allocation->width = 0;
    allocation->height = 0;
  }
    
  if (value.char_value) 
  {
    XFree(value.char_value);  
  }
}
Example #27
0
static void ungrab_key(KeyCode code)
{
	int i;

	gdk_error_trap_push();
	for (i = 0; i < ScreenCount(GDK_DISPLAY()); i++)
		XUngrabKey(GDK_DISPLAY(), code,
				AnyModifier, RootWindow(GDK_DISPLAY(),i));
	gdk_flush();
	if (gdk_error_trap_pop())
		g_warning("Couldn't ungrab keycode %d", code);
}
Example #28
0
File: trayicon.c Project: aufau/xqf
guint egg_tray_icon_send_message (EggTrayIcon *icon,
		gint timeout,
		const gchar *message,
		gint len) {
	guint stamp;

	g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
	g_return_val_if_fail (timeout >= 0, 0);
	g_return_val_if_fail (message != NULL, 0);

	if (icon->manager_window == None)
		return 0;

	if (len < 0)
		len = strlen (message);

	stamp = icon->stamp++;

	/* Get ready to send the message */
	egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE, (Window)gtk_plug_get_id (GTK_PLUG (icon)), timeout, len, stamp);

	/* Now to send the actual message */
	gdk_error_trap_push ();
	while (len > 0) {
		XClientMessageEvent ev;
		Display *xdisplay;

		xdisplay = GDK_DISPLAY();

		ev.type = ClientMessage;
		ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
		ev.format = 8;
		ev.message_type = XInternAtom (xdisplay,
				"_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
		if (len > 20) {
			memcpy (&ev.data, message, 20);
			len -= 20;
			message += 20;
		}
		else {
			memcpy (&ev.data, message, len);
			len = 0;
		}

		XSendEvent (GDK_DISPLAY(), icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
		XSync (GDK_DISPLAY(), False);
	}
	gdk_error_trap_pop ();

	return stamp;
}
Example #29
0
void wxGLContext::SetCurrent()
{
    if (m_glContext)
    {
        GdkWindow *window = GTK_PIZZA(m_widget)->bin_window;
      
      if (wxGLCanvas::GetGLXVersion() >= 13)
	// GLX >= 1.3
	glXMakeContextCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), GDK_WINDOW_XWINDOW(window), m_glContext );
      else
	// GLX <= 1.2
        glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext );
    }
}
Example #30
0
static void
panel_set_wm_strut(panel *p)
{
    gulong data[12] = { 0 };
    int i = 4;

    ENTER;
    if (!GTK_WIDGET_MAPPED (p->topgwin))
        return;
    switch (p->edge) {
    case EDGE_LEFT:
        i = 0;
        data[i] = p->aw;
        data[4 + i*2] = p->ay;
        data[5 + i*2] = p->ay + p->ah;
        break;
    case EDGE_RIGHT:
        i = 1;
        data[i] = p->aw;
        data[4 + i*2] = p->ay;
        data[5 + i*2] = p->ay + p->ah;
        break;
    case EDGE_TOP:
        i = 2;
        data[i] = p->ah;
        data[4 + i*2] = p->ax;
        data[5 + i*2] = p->ax + p->aw;
        break;
    case EDGE_BOTTOM:
        i = 3;
        data[i] = p->ah;
        data[4 + i*2] = p->ax;
        data[5 + i*2] = p->ax + p->aw;
        break;
    default:
        ERR("wrong edge %d. strut won't be set\n", p->edge);
        RET();
    }		
    DBG("type %d. width %d. from %d to %d\n", i, data[i], data[4 + i*2], data[5 + i*2]);
                
    /* if wm supports STRUT_PARTIAL it will ignore STRUT */
    XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_STRUT_PARTIAL, 
          XA_CARDINAL, 32, PropModeReplace,  (unsigned char *) data, 12);
    /* old spec, for wms that do not support STRUT_PARTIAL */
    XChangeProperty(GDK_DISPLAY(), p->topxwin, a_NET_WM_STRUT, 
          XA_CARDINAL, 32, PropModeReplace,  (unsigned char *) data, 4); 

    RET();
}