Ejemplo n.º 1
0
static void x11_window_update_foreign_event_mask(CoglOnscreen *onscreen,
                                                 guint32 event_mask,
                                                 void *user_data)
{
    GdkWindow *window = GDK_WINDOW(user_data);

    /* we assume that a GDK event mask is bitwise compatible with X11
       event masks */
    gdk_window_set_events(window, (GdkEventMask) (event_mask | EVENT_MASK));
}
Ejemplo n.º 2
0
static void
clutter_stage_gdk_update_foreign_event_mask (CoglOnscreen *onscreen,
					     guint32 event_mask,
					     void *user_data)
{
  ClutterStageGdk *stage_gdk = user_data;

  /* we assume that a GDK event mask is bitwise compatible with X11
     event masks */
  gdk_window_set_events (stage_gdk->window, event_mask | CLUTTER_STAGE_GDK_EVENT_MASK);
}
Ejemplo n.º 3
0
static void
add_workarea_filter (NemoDesktopManager *manager)
{
    GdkWindow *root_window = gdk_screen_get_root_window (manager->screen);

    manager->root_window = root_window;

    gdk_window_set_events (root_window, GDK_PROPERTY_CHANGE_MASK);
    gdk_window_add_filter (root_window,
                           gdk_filter_func,
                           manager);
}
void install_check_click_on_desktop (void)
{
	Window desktop_window;
	GdkWindow *window;
	Atom user_time_window;
	Atom user_time;

	if (!get_desktop_window (&desktop_window)) {
		return;
	}

	/* Access the desktop window. desktop_window is the root window for the
         * default screen, so we know using gdk_display_get_default() is correct. */
	window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (),
	                                                 desktop_window);

	/* It may contain an atom to tell us which other window to monitor */
	user_time_window = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME_WINDOW");
	user_time = gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME");
	if (user_time != None  &&  user_time_window != None)
	{
		/* Looks like the atoms are there */
		Atom actual_type;
		int actual_format;
		gulong nitems;
		gulong bytes;
		Window *data;

		/* We only use this extra property if the actual user-time property's missing */
		int  status = XGetWindowProperty( GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window)), desktop_window, user_time,
					0, 4, False, AnyPropertyType, &actual_type, &actual_format,
					&nitems, &bytes, (unsigned char **)&data );
		if (actual_type == None)
		{
			/* No user-time property, so look for the user-time-window */
                        status = XGetWindowProperty( GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window)), desktop_window, user_time_window,
					0, 4, False, AnyPropertyType, &actual_type, &actual_format,
					&nitems, &bytes, (unsigned char **)&data );
			if (actual_type != None)
			{
				/* We have another window to monitor */
				desktop_window = *data;
				window = gdk_x11_window_foreign_new_for_display (gdk_window_get_display (window),
				                                                 desktop_window);
			}
		}
	}

	gdk_window_set_events (window, GDK_PROPERTY_CHANGE_MASK);
	gdk_window_add_filter (window, desktop_window_event_filter, NULL);
}
Ejemplo n.º 5
0
static void matenu_settings_real_attach_to_window (MatenuSettings* self, GdkWindow* window) {
	GdkEventMask events;
	g_return_if_fail (self != NULL);
	if (self->priv->_window != NULL) {
		gdk_window_remove_filter (window, _matenu_settings_event_filter_gdk_filter_func, self);
	}
	if (window == NULL) {
		return;
	}
	matenu_settings_set_window (self, window);
	gdk_window_add_filter (self->priv->_window, _matenu_settings_event_filter_gdk_filter_func, self);
	events = gdk_window_get_events (self->priv->_window);
	gdk_window_set_events (self->priv->_window, events | GDK_PROPERTY_CHANGE_MASK);
	matenu_settings_pull (self);
}
Ejemplo n.º 6
0
static void
tbo_drawing_realize (GtkWidget *widget)
{
    GdkWindow *bin_window;

    if (GTK_WIDGET_CLASS (tbo_drawing_parent_class)->realize)
            (* GTK_WIDGET_CLASS (tbo_drawing_parent_class)->realize) (widget);

    bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget));
    gdk_window_set_events (bin_window,
                           (gdk_window_get_events (bin_window) |
                            GDK_BUTTON_PRESS_MASK |
                            GDK_BUTTON_RELEASE_MASK |
                            GDK_POINTER_MOTION_MASK));
}
Ejemplo n.º 7
0
static void
initialize_root_window (HDDesktop *desktop)
{
  HDDesktopPrivate *priv = desktop->priv;

  priv->root_window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (),
                                                              gdk_x11_get_default_root_xwindow ());

  gdk_window_set_events (priv->root_window,
                         gdk_window_get_events (priv->root_window) | GDK_PROPERTY_CHANGE_MASK);

  gdk_window_add_filter (priv->root_window,
                         filter_property_changed,
                         desktop);
}
Ejemplo n.º 8
0
static void activate(GtkApplication *app, gpointer user_data)
{
	GUI* gptr = (GUI*) user_data;
	Window* w = gptr->get_window();

	w->builder = gtk_builder_new_from_file ("builder.ui");
	w->save_button = GTK_WIDGET(gtk_builder_get_object(w->builder, "button_save"));
	w->window = GTK_WIDGET(gtk_builder_get_object(w->builder, "window"));
	w->drawing_area_fract = GTK_WIDGET(gtk_builder_get_object(w->builder, "drawingarea_fract"));
	w->left_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry1"));
	w->right_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry2"));
	w->up_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry3"));
	w->down_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry4"));
	w->width_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry5"));
	w->height_entry = GTK_WIDGET(gtk_builder_get_object(w->builder, "entry6"));
	w->render_button = GTK_WIDGET(gtk_builder_get_object(w->builder, "button_render"));
	w->combobox = GTK_WIDGET(gtk_builder_get_object(w->builder, "combobox"));

	gtk_entry_set_text((GtkEntry*)w->left_entry, "-1.0");
	gtk_entry_set_text((GtkEntry*)w->right_entry, "1.0");
	gtk_entry_set_text((GtkEntry*)w->up_entry, "1.0");
	gtk_entry_set_text((GtkEntry*)w->down_entry, "-1.0");
	gtk_entry_set_text((GtkEntry*)w->width_entry, "800");
	gtk_entry_set_text((GtkEntry*)w->height_entry, "600");


	for(int i = 0; i < gptr->get_rs_count(); ++i) {
		gtk_combo_box_text_append_text (
				(GtkComboBoxText*)w->combobox,
			   	gptr->get_rs()[i].get_id().c_str());
	}
	gtk_combo_box_set_active((GtkComboBox*)w->combobox, 0);

	gdk_window_set_events(
			gtk_widget_get_window(w->drawing_area_fract),
			GDK_ALL_EVENTS_MASK);

	g_signal_connect (w->drawing_area_fract, "draw", G_CALLBACK(draw_callback), gptr);
	g_signal_connect (w->drawing_area_fract, "size-allocate", G_CALLBACK(da_allocate_callback), gptr);
	g_signal_connect (w->render_button, "clicked", G_CALLBACK(parse_args_callback), gptr);
	g_signal_connect (w->drawing_area_fract, "button-press-event", G_CALLBACK(button_press_callback), gptr);
	g_signal_connect (w->drawing_area_fract, "button-release-event", G_CALLBACK(button_release_callback), gptr);
	g_signal_connect (w->save_button, "clicked", G_CALLBACK (save_file), gptr);

	gptr->render();
	gtk_application_add_window(app, GTK_WINDOW(w->window));
}
Ejemplo n.º 9
0
static void
mate_rr_labeler_init (MateRRLabeler *labeler)
{
	GdkWindow *gdkwindow;

	labeler->priv = G_TYPE_INSTANCE_GET_PRIVATE (labeler, MATE_TYPE_RR_LABELER, MateRRLabelerPrivate);

	labeler->priv->workarea_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
						    "_NET_WORKAREA",
						    True);

	labeler->priv->screen = gdk_screen_get_default ();
	/* code is not really designed to handle multiple screens so *shrug* */
	gdkwindow = gdk_screen_get_root_window (labeler->priv->screen);
	gdk_window_add_filter (gdkwindow, (GdkFilterFunc) screen_xevent_filter, labeler);
	gdk_window_set_events (gdkwindow, gdk_window_get_events (gdkwindow) | GDK_PROPERTY_CHANGE_MASK);
}
Ejemplo n.º 10
0
void setup_background(GtkWidget* container, GtkWidget* webview,
                      const char* xatom_name)
{
    _BG_ATOM = gdk_x11_get_xatom_by_name(xatom_name);

    BackgroundInfo* info = create_background_info(container, webview);
    background_info_set_background_by_drawable(info, get_blurred_background());

    //TODO:
    //we shoul use xatom_name window to set events instead of root window
    //because the monitors changed signal will came before root window rect changed
    //so the Xroot window rect maybe keep old rect in update_bg function
    gdk_window_set_events(gdk_get_default_root_window(),
                          GDK_PROPERTY_CHANGE_MASK);
    gdk_window_add_filter(gdk_get_default_root_window(),
                          (GdkFilterFunc)update_bg, info);
}
Ejemplo n.º 11
0
/**
 * Set the events that the underlying GdkWindow will receive.
 */
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkWidgetOverride_gtk_1widget_1set_1events
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jint _mask
)
{
	GtkWidget* self;
	GdkWindow* window;
	GdkEventMask mask;

	// convert parameter self
	self = (GtkWidget*) _self;

	mask = (GdkEventMask) _mask;

	window = gtk_widget_get_window(self);
	gdk_window_set_events(window, mask);
}
Ejemplo n.º 12
0
/*
 * Standard Gtk+ function
 */
static void Dw_gtk_viewport_realize (GtkWidget *widget)
{
   GtkDwViewport *viewport;

   GTK_WIDGET_CLASS(parent_class)->realize (widget);

   gdk_window_set_events (widget->window,
                          gdk_window_get_events (widget->window)
                          | GDK_BUTTON_PRESS_MASK
                          | GDK_BUTTON_RELEASE_MASK
                          | GDK_POINTER_MOTION_MASK
                          | GDK_ENTER_NOTIFY_MASK
                          | GDK_LEAVE_NOTIFY_MASK);

   viewport = GTK_DW_VIEWPORT (widget);
   gdk_window_get_geometry (widget->window, NULL, NULL, NULL, NULL,
                            &viewport->depth);

   Dw_gtk_viewport_update_background (viewport);
   if (viewport->child)
      Dw_widget_update_cursor (viewport->child);
}
Ejemplo n.º 13
0
/**
 * hildon_program_add_window:
 * @self: The @HildonProgram to which the window should be registered
 * @window: A @HildonWindow to be added
 *
 * Registers a @HildonWindow as belonging to a given @HildonProgram. This
 * allows to apply program-wide settings as all the registered windows,
 * such as hildon_program_set_common_menu() and
 * hildon_pogram_set_common_toolbar()
 **/
void
hildon_program_add_window                       (HildonProgram *self, 
                                                 HildonWindow *window)
{
    HildonProgramPrivate *priv;
    
    g_return_if_fail (HILDON_IS_PROGRAM (self));
    
    priv = HILDON_PROGRAM_GET_PRIVATE (self);
    g_assert (priv);

    if (g_slist_find_custom (priv->windows, window,
           hildon_program_window_list_compare) )
    {
        /* We already have that window */
        return;
    }

    if (!priv->window_count)
    {
        hildon_program_update_top_most (self);
        
        /* Now that we have a window we should start keeping track of
         * the root window */
        gdk_window_set_events (gdk_get_default_root_window (),
                gdk_window_get_events (gdk_get_default_root_window ()) | GDK_PROPERTY_CHANGE_MASK);

        gdk_window_add_filter (gdk_get_default_root_window (),
                hildon_program_root_window_event_filter, self );
    }
    
    hildon_window_set_can_hibernate_property (window, &priv->killable);

    hildon_window_set_program (window, G_OBJECT (self));

    priv->windows = g_slist_append (priv->windows, window);
    priv->window_count ++;
}
Ejemplo n.º 14
0
// this function will make sure that everything has been initialized.
nsresult
nsScreenManagerGtk :: EnsureInit()
{
  if (mCachedScreenArray.Count() > 0)
    return NS_OK;

  mRootWindow = gdk_get_default_root_window();
  g_object_ref(mRootWindow);

  // GDK_STRUCTURE_MASK ==> StructureNotifyMask, for ConfigureNotify
  // GDK_PROPERTY_CHANGE_MASK ==> PropertyChangeMask, for PropertyNotify
  gdk_window_set_events(mRootWindow,
                        GdkEventMask(gdk_window_get_events(mRootWindow) |
                                     GDK_STRUCTURE_MASK |
                                     GDK_PROPERTY_CHANGE_MASK));
  gdk_window_add_filter(mRootWindow, root_window_event_filter, this);
#ifdef MOZ_X11
  mNetWorkareaAtom =
    XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False);
#endif

  return Init();
}
static void
panel_background_monitor_connect_to_screen (PanelBackgroundMonitor *monitor,
					    GdkScreen              *screen)
{
	if (monitor->screen != NULL && monitor->gdkwindow != NULL) {
		gdk_window_remove_filter (monitor->gdkwindow,
					  panel_background_monitor_xevent_filter,
					  monitor);
	}

	monitor->screen = screen;
	g_signal_connect_swapped (screen, "size-changed", 
	    G_CALLBACK (panel_background_monitor_changed), monitor);

	monitor->gdkwindow = gdk_screen_get_root_window (screen);
	monitor->xwindow   = gdk_x11_drawable_get_xid (monitor->gdkwindow);

	gdk_window_add_filter (
		monitor->gdkwindow, panel_background_monitor_xevent_filter, monitor);

	gdk_window_set_events (
		monitor->gdkwindow, 
		gdk_window_get_events (monitor->gdkwindow) | GDK_PROPERTY_CHANGE_MASK);
}
Ejemplo n.º 16
0
void container_size_workaround(GtkWidget* container, GdkRectangle* allocation)
{
    static GRWLock lock;
    g_rw_lock_writer_lock(&lock);
    update_primary_info(&dock);
    g_rw_lock_writer_unlock(&lock);
    if (gtk_widget_get_realized(container) && (dock.width != allocation->width || dock.height != allocation->height)) {
        GdkWindow* w = gtk_widget_get_window(container);
        GdkGeometry geo = {0};
        geo.min_width = 0;
        geo.min_height = 0;

        gdk_window_set_geometry_hints(w, &geo, GDK_HINT_MIN_SIZE);
        XSelectInput(gdk_x11_get_default_xdisplay(), GDK_WINDOW_XID(w), NoEventMask);
        gdk_window_move_resize(w, dock.x, dock.y, dock.width, dock.height);
        gdk_flush();
        gdk_window_set_events(w, gdk_window_get_events(w));

        g_warning("[%s] size workaround run fix (%d,%d) to (%d,%d)\n",
                  __func__,
                  allocation->width, allocation->height,
                  dock.width, dock.height);
    }
}
Ejemplo n.º 17
0
int main(int argc, char *argv[], char *env[])
{
    int i;
    const char* desktop_name;
    char *file;

    setlocale(LC_CTYPE, "");

#if !GLIB_CHECK_VERSION(2, 32, 0)
    g_thread_init(NULL);
#endif
/*    gdk_threads_init();
    gdk_threads_enter(); */

    gtk_init(&argc, &argv);

#ifdef ENABLE_NLS
    bindtextdomain ( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR );
    bind_textdomain_codeset ( GETTEXT_PACKAGE, "UTF-8" );
    textdomain ( GETTEXT_PACKAGE );
#endif

    XSetLocaleModifiers("");
    XSetErrorHandler((XErrorHandler) panel_handle_x_error);

    resolve_atoms();

    desktop_name = g_getenv("XDG_CURRENT_DESKTOP");
    is_in_lxde = desktop_name && (0 == strcmp(desktop_name, "LXDE"));

    for (i = 1; i < argc; i++) {
        if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
            usage();
            exit(0);
        } else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
            printf("lxpanel %s\n", version);
            exit(0);
        } else if (!strcmp(argv[i], "--log")) {
            i++;
            if (i == argc) {
                g_critical( "lxpanel: missing log level");
                usage();
                exit(1);
            } else {
                /* deprecated */
            }
        } else if (!strcmp(argv[i], "--configure") || !strcmp(argv[i], "-C")) {
            config = 1;
        } else if (!strcmp(argv[i], "--profile") || !strcmp(argv[i], "-p")) {
            i++;
            if (i == argc) {
                g_critical( "lxpanel: missing profile name");
                usage();
                exit(1);
            } else {
                cprofile = g_strdup(argv[i]);
            }
        } else {
            printf("lxpanel: unknown option - %s\n", argv[i]);
            usage();
            exit(1);
        }
    }

    /* Add a gtkrc file to be parsed too. */
    file = _user_config_file_name("gtkrc", NULL);
    gtk_rc_parse(file);
    g_free(file);

    /* Check for duplicated lxpanel instances */
    if (!check_main_lock() && !config) {
        printf("There is already an instance of LXPanel.  Now to exit\n");
        exit(1);
    }

    _ensure_user_config_dirs();

    /* Add our own icons to the search path of icon theme */
    gtk_icon_theme_append_search_path( gtk_icon_theme_get_default(), PACKAGE_DATA_DIR "/images" );

    fbev = fb_ev_new();

    is_restarting = FALSE;

    /* init LibFM */
    fm_gtk_init(NULL);

    /* prepare modules data */
    lxpanel_prepare_modules();
    init_static_plugins();

    load_global_config();

    /* NOTE: StructureNotifyMask is required by XRandR
     * See init_randr_support() in gdkscreen-x11.c of gtk+ for detail.
     */
    gdk_window_set_events(gdk_get_default_root_window(), GDK_STRUCTURE_MASK |
            GDK_SUBSTRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK);
    gdk_window_add_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL);

    if( G_UNLIKELY( ! start_all_panels() ) )
        g_warning( "Config files are not found.\n" );
/*
 * FIXME: configure??
    if (config)
        configure();
*/
    gtk_main();

    XSelectInput (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_ROOT_WINDOW(), NoEventMask);
    gdk_window_remove_filter(gdk_get_default_root_window (), (GdkFilterFunc)panel_event_filter, NULL);

    /* destroy all panels */
    g_slist_foreach( all_panels, (GFunc) gtk_widget_destroy, NULL );
    g_slist_free( all_panels );
    all_panels = NULL;
    g_free( cfgfile );

    free_global_config();

    lxpanel_unload_modules();
    fm_gtk_finalize();

    /* gdk_threads_leave(); */

    g_object_unref(fbev);

    if (!is_restarting)
        return 0;
    if (strchr(argv[0], G_DIR_SEPARATOR))
        execve(argv[0], argv, env);
    else
        execve(g_find_program_in_path(argv[0]), argv, env);
    return 1;
}
Ejemplo n.º 18
0
static VALUE
gdkwin_set_events(VALUE self, VALUE mask)
{
    gdk_window_set_events(_SELF(self), RVAL2GFLAGS(mask, GDK_TYPE_EVENT_MASK));
    return self;
}
Ejemplo n.º 19
0
GdkFilterReturn
event_filter_func (GdkXEvent *gdkxevent,
		   GdkEvent  *event,
		   gpointer  data)
{
    GdkDisplay *gdkdisplay;
    XEvent     *xevent = gdkxevent;
    gulong     xid = 0;
    Window     select = 0;

    gdkdisplay = gdk_display_get_default ();

    switch (xevent->type) {
    case CreateNotify:
	{
	    if (!wnck_window_get (xevent->xcreatewindow.window))
	    {
		GdkWindow *toplevel = create_foreign_window (xevent->xcreatewindow.window);

		if (toplevel)
		{
		    gdk_window_set_events (toplevel,
					   gdk_window_get_events (toplevel) |
					   GDK_PROPERTY_CHANGE_MASK);

		    /* check if the window is a switcher and update accordingly */

		    if (get_window_prop (xevent->xcreatewindow.window, select_window_atom, &select))
			update_switcher_window (xevent->xcreatewindow.window, select);
		}
	    }
	}
	break;
    case ButtonPress:
    case ButtonRelease:
	xid = (gulong)
	    g_hash_table_lookup (frame_table,
				 GINT_TO_POINTER (xevent->xbutton.window));
	break;
    case EnterNotify:
    case LeaveNotify:
	xid = (gulong)
	    g_hash_table_lookup (frame_table,
				 GINT_TO_POINTER (xevent->xcrossing.window));
	break;
    case MotionNotify:
	xid = (gulong)
	    g_hash_table_lookup (frame_table,
				 GINT_TO_POINTER (xevent->xmotion.window));
	break;
    case PropertyNotify:
	if (xevent->xproperty.atom == frame_input_window_atom)
	{
	    WnckWindow *win;

	    xid = xevent->xproperty.window;

	    win = wnck_window_get (xid);
	    if (win)
	    {
		Window frame;

		if (!get_window_prop (xid, select_window_atom, &select))
		{
		    if (get_window_prop (xid, frame_input_window_atom, &frame))
			add_frame_window (win, frame, FALSE);
		    else
			remove_frame_window (win);
		}
	    }
	}
	if (xevent->xproperty.atom == frame_output_window_atom)
	{
	    WnckWindow *win;

	    xid = xevent->xproperty.window;

	    win = wnck_window_get (xid);
	    if (win)
	    {
		Window frame;

		if (!get_window_prop (xid, select_window_atom, &select))
		{
		    if (get_window_prop (xid, frame_output_window_atom, &frame))
			add_frame_window (win, frame, TRUE);
		    else
			remove_frame_window (win);
		}
	    }
	}
	else if (xevent->xproperty.atom == compiz_shadow_info_atom ||
		 xevent->xproperty.atom == compiz_shadow_color_atom)
	{
	    GdkScreen  *g_screen = gdk_display_get_default_screen (gdkdisplay);
	    Window     root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (g_screen));
	    WnckScreen *screen;

	    screen = wnck_screen_get_for_root (root);

	    if (screen)
	    {
		if (gwd_process_decor_shadow_property_update ())
		    decorations_changed (screen);
	    }
	}
	else if (xevent->xproperty.atom == mwm_hints_atom)
	{
	    WnckWindow *win;

	    xid = xevent->xproperty.window;

	    win = wnck_window_get (xid);
	    if (win)
	    {
		decor_t  *d = g_object_get_data (G_OBJECT (win), "decor");
		gboolean decorated = FALSE;

		/* Only decorations that are actually bound to windows can be decorated
		 * ignore cases where a broken application which shouldn't be decorated
		 * sets the decoration hint */
		if (get_mwm_prop (xid) & (MWM_DECOR_ALL | MWM_DECOR_TITLE) && d->win)
		    decorated = TRUE;

		if (decorated != d->decorated)
		{
		    d->decorated = decorated;
		    if (decorated)
		    {
			d->context = NULL;
			d->width = d->height = 0;

			d->frame = gwd_get_decor_frame (get_frame_type (win));

			update_window_decoration_state (win);
			update_window_decoration_actions (win);
			update_window_decoration_icon (win);
			request_update_window_decoration_size (win);
			update_event_windows (win);
		    }
		    else
		    {
			remove_frame_window (win);
		    }
		}
	    }
	}
	else if (xevent->xproperty.atom == select_window_atom)
	{
	    Window select;

	    if (get_window_prop (xevent->xproperty.window, select_window_atom, &select))
		update_switcher_window (xevent->xproperty.window, select);
	}
	break;
    case DestroyNotify:
	g_hash_table_remove (frame_table,
			     GINT_TO_POINTER (xevent->xproperty.window));
	break;
    case ClientMessage:
	if (xevent->xclient.message_type == toolkit_action_atom)
	{
	    long action;

	    action = xevent->xclient.data.l[0];
	    if (action == toolkit_action_window_menu_atom)
	    {
		WnckWindow *win;

		win = wnck_window_get (xevent->xclient.window);
		if (win)
		{
		    action_menu_map (win,
				     xevent->xclient.data.l[2],
				     xevent->xclient.data.l[1]);
		}
	    }
	    else if (action == toolkit_action_force_quit_dialog_atom)
	    {
		WnckWindow *win;

		win = wnck_window_get (xevent->xclient.window);
		if (win)
		{
		    if (xevent->xclient.data.l[2])
			show_force_quit_dialog (win,
						xevent->xclient.data.l[1]);
		    else
			hide_force_quit_dialog (win);
		}
	    }
	}
	else if (xevent->xclient.message_type == decor_request_atom)
	{
	    WnckWindow *win = wnck_window_get (xevent->xclient.window);

	    if (win)
		update_window_decoration_size (win);
	}
    default:
	break;
    }

    if (xid)
    {
	WnckWindow *win;

	win = wnck_window_get (xid);
	if (win)
	{
	    decor_t *d = g_object_get_data (G_OBJECT (win), "decor");

	    if (d->decorated)
	    {
		gint             i, j;
		event_callback   cb = NULL;
		Window           w = xevent->xany.window;

		for (i = 0; i < 3; ++i)
		    for (j = 0; j < 3; ++j)
			if (d->event_windows[i][j].window == w)
			    cb = d->event_windows[i][j].callback;

		if (!cb)
		{
		    for (i = 0; i < BUTTON_NUM; ++i)
			if (d->button_windows[i].window == w)
			    cb = d->button_windows[i].callback;
		}

		if (cb)
		{
		    decor_event      gtkwd_event;
		    decor_event_type gtkwd_type;

		    gtkwd_event.window = w;

		    switch (xevent->type)
		    {
			case ButtonPress:
			case ButtonRelease:
			    if (xevent->type == ButtonPress)
				gtkwd_type = GButtonPress;
			    else
				gtkwd_type = GButtonRelease;
			    gtkwd_event.button = xevent->xbutton.button;
			    gtkwd_event.x = xevent->xbutton.x;
			    gtkwd_event.y = xevent->xbutton.y;
			    gtkwd_event.x_root = xevent->xbutton.x_root;
			    gtkwd_event.y_root = xevent->xbutton.y_root;
			    gtkwd_event.time = xevent->xbutton.time;
			    break;
			case EnterNotify:
			case LeaveNotify:
			    if (xevent->type == EnterNotify)
				gtkwd_type = GEnterNotify;
			    else
				gtkwd_type = GLeaveNotify;
			    gtkwd_event.x = xevent->xcrossing.x;
			    gtkwd_event.y = xevent->xcrossing.y;
			    gtkwd_event.x_root = xevent->xcrossing.x_root;
			    gtkwd_event.y_root = xevent->xcrossing.y_root;
			    gtkwd_event.time = xevent->xcrossing.time;
			    break;
			default:
			    cb = NULL;
			    break;
		    }
		    if (cb)
			(*cb) (win, &gtkwd_event, gtkwd_type);
		}
	    }
	}
    }

    return GDK_FILTER_CONTINUE;
}
Ejemplo n.º 20
0
Client *
newclient(void) {
	int i;
	Client *c;
	WebKitWebSettings *settings;
	GdkGeometry hints = { 1, 1 };
	char *uri, *ua;

	if(!(c = calloc(1, sizeof(Client))))
		die("Cannot malloc!\n");
	/* Window */
	if(embed) {
		c->win = gtk_plug_new(embed);
	}
	else {
		c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		/* TA:  20091214:  Despite what the GNOME docs say, the ICCCM
		 * is always correct, so we should still call this function.
		 * But when doing so, we *must* differentiate between a
		 * WM_CLASS and a resource on the window.  By convention, the
		 * window class (WM_CLASS) is capped, while the resource is in
		 * lowercase.   Both these values come as a pair.
		 */
		gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf");

		/* TA:  20091214:  And set the role here as well -- so that
		 * sessions can pick this up.
		 */
		gtk_window_set_role(GTK_WINDOW(c->win), "Surf");
	}
	gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
	g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
	g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c);
	g_signal_connect(G_OBJECT(c->win), "size-allocate", G_CALLBACK(resize), c);

	if(!(c->items = calloc(1, sizeof(GtkWidget *) * LENGTH(items))))
		die("Cannot malloc!\n");

	/* contextmenu */
	for(i = 0; i < LENGTH(items); i++) {
		c->items[i] = gtk_menu_item_new_with_label(items[i].label);
		g_signal_connect(G_OBJECT(c->items[i]), "activate",
				G_CALLBACK(itemclick), c);
	}

	/* VBox */
	c->vbox = gtk_vbox_new(FALSE, 0);

	/* Scrolled Window */
	c->scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
			GTK_POLICY_NEVER, GTK_POLICY_NEVER);

	/* Webview */
	c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
	g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
	g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c);
	g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c);
	g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c);
	g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
	g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(createwindow), c);
	g_signal_connect(G_OBJECT(c->view), "new-window-policy-decision-requested", G_CALLBACK(decidewindow), c);
	g_signal_connect(G_OBJECT(c->view), "mime-type-policy-decision-requested", G_CALLBACK(decidedownload), c);
	g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
	g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c);
	g_signal_connect(G_OBJECT(c->view), "populate-popup", G_CALLBACK(context), c);

	/* Indicator */
	c->indicator = gtk_drawing_area_new();
	gtk_widget_set_size_request(c->indicator, 0, 2);
	g_signal_connect (G_OBJECT (c->indicator), "expose_event",
			G_CALLBACK (exposeindicator), c);

	/* Arranging */
	gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
	gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
	gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
	gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);

	/* Setup */
	gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START);
	gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START);
	gtk_widget_grab_focus(GTK_WIDGET(c->view));
	gtk_widget_show(c->vbox);
	gtk_widget_show(c->indicator);
	gtk_widget_show(c->scroll);
	gtk_widget_show(GTK_WIDGET(c->view));
	gtk_widget_show(c->win);
	gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, GDK_HINT_MIN_SIZE);
	gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
	gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
	webkit_web_view_set_full_content_zoom(c->view, TRUE);
	settings = webkit_web_view_get_settings(c->view);
	if(!(ua = getenv("SURF_USERAGENT")))
		ua = useragent;
	g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
	uri = g_strconcat("file://", stylefile, NULL);
	g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
	g_free(uri);
	setatom(c, findprop, "");

	c->download = NULL;
	c->title = NULL;
	c->next = clients;
	clients = c;
	if(showxid) {
		gdk_display_sync(gtk_widget_get_display(c->win));
		printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
		fflush(NULL);
	}
	return c;
}
Ejemplo n.º 21
0
Panel * panel_new(PanelPrefs const * prefs)
{
	Panel * panel;
	GdkRectangle rect;
	GtkIconSize iconsize;
	char const * p;
	gboolean focus;
	gboolean above;

	if((panel = object_new(sizeof(*panel))) == NULL)
		return NULL;
	panel->screen = gdk_screen_get_default();
	if(_new_config(panel) == 0)
		_new_prefs(panel->config, panel->screen, &panel->prefs, prefs);
	panel->top_helper.panel = panel;
	panel->top_helper.type = PANEL_APPLET_TYPE_NORMAL;
	panel->top_helper.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
	panel->top_helper.config_get = _panel_helper_config_get;
	panel->top_helper.config_set = _panel_helper_config_set;
	panel->top_helper.error = _panel_helper_error;
	panel->top_helper.about_dialog = _panel_helper_about_dialog;
	panel->top_helper.lock = _panel_helper_lock;
#ifndef EMBEDDED
	panel->top_helper.logout_dialog = _panel_helper_logout_dialog;
#else
	panel->top_helper.logout_dialog = NULL;
#endif
	panel->top_helper.position_menu = _panel_helper_position_menu_top;
	panel->top_helper.preferences_dialog = _panel_helper_preferences_dialog;
	panel->top_helper.rotate_screen = _panel_helper_rotate_screen;
	panel->top_helper.shutdown_dialog = _panel_helper_shutdown_dialog;
	panel->top_helper.suspend = (_panel_can_suspend())
		? _panel_helper_suspend : NULL;
	panel->top = NULL;
	panel->bottom_helper = panel->top_helper;
	panel->bottom_helper.position_menu = _panel_helper_position_menu_bottom;
	panel->bottom = NULL;
	iconsize = GTK_ICON_SIZE_INVALID;
	if(panel->prefs.iconsize != NULL)
		iconsize = gtk_icon_size_from_name(panel->prefs.iconsize);
	if(iconsize == GTK_ICON_SIZE_INVALID)
	{
		panel->top_helper.icon_size = _new_size(panel,
				PANEL_POSITION_TOP);
		panel->bottom_helper.icon_size = _new_size(panel,
				PANEL_POSITION_BOTTOM);
	}
	else
	{
		panel->top_helper.icon_size = iconsize;
		panel->bottom_helper.icon_size = iconsize;
	}
	panel->pr_window = NULL;
	panel->ab_window = NULL;
#ifndef EMBEDDED
	panel->lo_window = NULL;
#endif
	panel->sh_window = NULL;
	if(panel->config == NULL)
	{
		panel_error(NULL, error_get(), 0); /* XXX put up a dialog box */
		panel_delete(panel);
		return NULL;
	}
	/* root window */
	panel->root = gdk_screen_get_root_window(panel->screen);
	_panel_reset(panel, &rect);
	focus = ((p = config_get(panel->config, NULL, "accept_focus")) == NULL
			|| strcmp(p, "1") == 0) ? TRUE : FALSE;
	above = ((p = config_get(panel->config, NULL, "keep_above")) == NULL
			|| strcmp(p, "1") == 0) ? TRUE : FALSE;
	panel->source = 0;
	/* top panel */
	if(config_get(panel->config, NULL, "top") != NULL)
	{
		panel->top = panel_window_new(PANEL_POSITION_TOP,
				&panel->top_helper, &rect);
		panel_window_set_accept_focus(panel->top, focus);
		panel_window_set_keep_above(panel->top, above);
	}
	/* bottom panel */
	if(config_get(panel->config, NULL, "bottom") != NULL
			|| config_get(panel->config, NULL, "top") == NULL)
	{
		panel->bottom = panel_window_new(PANEL_POSITION_BOTTOM,
				&panel->bottom_helper, &rect);
		panel_window_set_accept_focus(panel->bottom, focus);
		panel_window_set_keep_above(panel->bottom, above);
	}
	/* messages */
	desktop_message_register(PANEL_CLIENT_MESSAGE, _new_on_message, panel);
	/* manage root window events */
	gdk_window_set_events(panel->root, gdk_window_get_events(
				panel->root) | GDK_PROPERTY_CHANGE_MASK);
	gdk_window_add_filter(panel->root, _on_root_event, panel);
	/* load plug-ins when idle */
	panel->source = g_idle_add(_on_idle, panel);
	return panel;
}
Ejemplo n.º 22
0
void safe_window_move(GdkWindow* wrapper, int x, int y)
{
    XSelectInput(gdk_x11_get_default_xdisplay(), GDK_WINDOW_XID(wrapper), ExposureMask | VisibilityChangeMask | EnterWindowMask | LeaveWindowMask);
    gdk_window_move(wrapper, x, y);
    gdk_window_set_events(wrapper, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK);
}
Ejemplo n.º 23
0
int
main(int argc, char *argv[]) {
	Arg arg;
	Client *c;
	GdkGeometry hints = { 1, 1 };

	memset(&arg, 0, sizeof(arg));

	/* command line args */
	ARGBEGIN {
	case 'e':
		embed = strtol(EARGF(usage()), NULL, 0);
		break;
	case 'v':
		die("turf-"VERSION", ©2014 turf engineers, "
				"see LICENSE for details\n");
	case 'x':
		showxid = TRUE;
		break;
	default:
		usage();
	} ARGEND;
	if(argc > 0)
		arg.v = argv[0];

	sigchld(0);

	gtk_init(NULL, NULL);
	gtk_gl_init(NULL, NULL);

	dpy = GDK_DISPLAY();

	/* atoms */
	atoms[AtomFind] = XInternAtom(dpy, "_TURF_FIND", False);
	atoms[AtomGo] = XInternAtom(dpy, "_TURF_GO", False);
	atoms[AtomUri] = XInternAtom(dpy, "_TURF_URI", False);

	if(!(c = calloc(1, sizeof(Client))))
		die("Cannot malloc!\n");

	/* WIndow */
	if(embed) {
		c->win = gtk_plug_new(embed);
	} else {
		c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		gtk_window_set_wmclass(GTK_WINDOW(c->win), "turf", "Turf");
		gtk_window_set_role(GTK_WINDOW(c->win), "Turf");
	}
	gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
	g_signal_connect(G_OBJECT(c->win),
			"destroy",
			G_CALLBACK(destroywin), c);

	c->vbox = gtk_vbox_new(FALSE, 0);

	/* cef init */
	cef_settings_t *settings;
	if(!(settings = malloc(sizeof(cef_settings_t))))
		die("Cannot malloc\n");

	cef_initialize(NULL, settings, NULL);

	/* cef set as child (vbox) */

	gtk_container_add(GTK_CONTAINER(c->win), c->vbox);


	gtk_widget_show_all(GTK_WIDGET(c->win));
	gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints,
			GDK_HINT_MIN_SIZE);
	gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
	/* process X events for window - aka AtomFind/AtomGo
	 * gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
	 * setatom(c, AtomFind, "");
	 * setatom(c, AtomUri, "about:blank");
	 */

	c->title = NULL;
	c->next = clients;
	clients = c;

	if(showxid) {
		gdk_display_sync(gtk_widget_get_display(c->win));
		printf("%u\n",
			(guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
		fflush(NULL);
		if (fclose(stdout) != 0) {
			die("Error closing stdout");
		}
	}

	if(arg.v)
		loaduri(clients, &arg);

	gtk_main();
	cleanup();

	return EXIT_SUCCESS;
}
Ejemplo n.º 24
0
int main(int argc, char **argv)
{
#if WIN32
    WORD wVersionRequested;
    WSADATA wsaData;
    int err;
    wVersionRequested = MAKEWORD(2, 2);
    err = WSAStartup(wVersionRequested, &wsaData);
#endif

    dbg("%s\n", argv[0]);
    b_contrib = strstr(argv[0], "ts-contribute")!=NULL;

    if (b_contrib)
        dbg("b_contrib\n");

    set_is_chs();
    load_setttings();

    init_TableDir();
    b_pinyin = is_pinyin_kbm();

    gtk_init (&argc, &argv);
    load_gtab_list(TRUE);

    char gcin_dir[512];
    get_gcin_dir(gcin_dir);

    if (argc < 2) {
#if UNIX
        chdir(gcin_dir);
#else
        _chdir(gcin_dir);
#endif
    }

#if GCIN_i18n_message
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);
#endif

    get_gcin_user_fname(DOWNLOADED_PHRASES, downloaded_file_src);
    strcat(downloaded_file_src, ".src");

    pinmd = &inmd[default_input_method];

    if (pinmd->method_type == method_type_TSIN) {
        dbg("is tsin\n");
        pho_load();
        if (b_contrib) {
            load_tsin_contrib();
        } else {
            if (argc > 1)
                load_tsin_db_ex(&tsin_hand, argv[1], FALSE, FALSE, FALSE);
            else
                load_tsin_db();
        }

        ph_key_sz = 2;
    } else if (pinmd->filename) {
        if (b_contrib)
            p_err("Currently %s only supports tsin", argv[0]);

        dbg("gtab filename %s\n", pinmd->filename);
        init_gtab(default_input_method);
        is_gtab = TRUE;
        init_tsin_table_fname(pinmd, gtab_tsin_fname);
        load_tsin_db0(gtab_tsin_fname, TRUE);
    } else
        p_err("Your default input method %s doesn't use phrase database",
              pinmd->cname);

    dbg("ph_key_sz: %d\n", ph_key_sz);

#if UNIX
    dpy = GDK_DISPLAY();
#endif

    load_ts_phrase();

    mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_position(GTK_WINDOW(mainwin), GTK_WIN_POS_CENTER);
    g_signal_connect (G_OBJECT (mainwin), "key-press-event",  G_CALLBACK (key_press_event), NULL);

    gtk_window_set_has_resize_grip(GTK_WINDOW(mainwin), FALSE);
//  gtk_window_set_default_size(GTK_WINDOW (mainwin), 640, 520);
    set_window_gcin_icon(mainwin);

    vbox_top = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER(mainwin), vbox_top);

    GtkWidget *hbox_page = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), hbox_page, TRUE, FALSE, 0);

    GtkWidget *align_page = gtk_alignment_new(0, 0, 1.0, 1.0);
    gtk_box_pack_start (GTK_BOX (hbox_page), align_page, TRUE, TRUE, 0);

    GtkWidget *vbox_page = gtk_vbox_new (TRUE, 0);
    gtk_container_add (GTK_CONTAINER(align_page), vbox_page);

    scroll_bar = gtk_vscrollbar_new(
                     GTK_ADJUSTMENT(gtk_adjustment_new(tsN - PAGE_LEN,0, tsN, 1,PAGE_LEN,PAGE_LEN)));
    gtk_box_pack_start (GTK_BOX (hbox_page), scroll_bar, FALSE, FALSE, 0);

    g_signal_connect(G_OBJECT(scroll_bar), "change-value", G_CALLBACK(cb_scroll_bar), NULL);

    int i;
    for(i=0; i<PAGE_LEN; i++) {
        GtkWidget *hbox;
        hbox = gtk_hbox_new (FALSE, 0);
        gtk_box_pack_start (GTK_BOX (vbox_page), hbox, TRUE, TRUE, 0);
        button_check[i] = gtk_check_button_new();
        gtk_box_pack_start (GTK_BOX (hbox), button_check[i], FALSE, FALSE, 0);

        labels[i]=gtk_label_new(NULL);

        GtkWidget *align = gtk_alignment_new (0, 0, 0, 0);
        gtk_container_add(GTK_CONTAINER(align), labels[i]);
        gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0);
    }


    hbox_buttons = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox_top), hbox_buttons, FALSE, FALSE, 0);

    GtkWidget *button_delete = b_contrib ? gtk_button_new_with_label(_(_L("私密詞不上載"))):gtk_button_new_from_stock (GTK_STOCK_DELETE);
    gtk_box_pack_start (GTK_BOX (hbox_buttons), button_delete, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (button_delete), "clicked",
                      G_CALLBACK (cb_button_delete), NULL);

    GtkWidget *button_find = gtk_button_new_from_stock (GTK_STOCK_FIND);
    gtk_box_pack_start (GTK_BOX (hbox_buttons), button_find, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (button_find), "clicked",
                      G_CALLBACK (cb_button_find), NULL);

#if 0
    GtkWidget *button_edit = gtk_button_new_from_stock (GTK_STOCK_EDIT);
    gtk_box_pack_start (GTK_BOX (hbox_buttons), button_edit, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (button_edit), "clicked",
                      G_CALLBACK (cb_button_edit), NULL);
#endif

    GtkWidget *button_save =  b_contrib ? gtk_button_new_with_label(_(_L("上載詞")))
                              :gtk_button_new_from_stock (GTK_STOCK_SAVE);

    gtk_box_pack_start (GTK_BOX (hbox_buttons), button_save, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (button_save), "clicked",
                      G_CALLBACK (cb_button_save), NULL);


    GtkWidget *button_quit = gtk_button_new_from_stock (GTK_STOCK_QUIT);
    gtk_box_pack_start (GTK_BOX (hbox_buttons), button_quit, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (button_quit), "clicked",
                      G_CALLBACK (do_exit), NULL);

    if (!b_contrib && !is_gtab) {
        GtkWidget *button_download = gtk_button_new_with_label(_(_L("下載共享詞庫")));
        gtk_box_pack_start (GTK_BOX (hbox_buttons), button_download, FALSE, FALSE, 0);
        g_signal_connect (G_OBJECT (button_download), "clicked",
                          G_CALLBACK (cb_button_download), NULL);
    }

    g_signal_connect (G_OBJECT (mainwin), "delete_event", G_CALLBACK (do_exit), NULL);

    gtk_widget_realize (mainwin);
    gtk_widget_show_all(mainwin);

//  load_ts_phrase();

    disp_page();

#if 0
    GdkWindow *gdkwin=gtk_widget_get_window(mainwin);
    gdk_window_set_events(gdkwin, GDK_BUTTON_PRESS_MASK|GDK_SCROLL_MASK| gdk_window_get_events(gdkwin));
#endif

    gtk_main();
    return 0;
}
Ejemplo n.º 25
0
static gboolean
clutter_stage_gdk_realize (ClutterStageWindow *stage_window)
{
  ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window);
  ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
  ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
  ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (backend);
  GdkWindowAttr attributes;
  gboolean cursor_visible;
  gboolean use_alpha;
  gfloat   width, height;

  if (stage_gdk->foreign_window)
    {
      width = gdk_window_get_width (stage_gdk->window);
      height = gdk_window_get_height (stage_gdk->window);
    }
  else
    {
      if (stage_gdk->window != NULL)
        {
          /* complete realizing the stage */
          cairo_rectangle_int_t geometry;

          clutter_stage_gdk_get_geometry (stage_window, &geometry);
          clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper),
                                  geometry.width,
                                  geometry.height);

          gdk_window_ensure_native (stage_gdk->window);
          gdk_window_set_events (stage_gdk->window, CLUTTER_STAGE_GDK_EVENT_MASK);

          return TRUE;
        }
      else
        {
          attributes.title = NULL;
          g_object_get (stage_cogl->wrapper,
                        "cursor-visible", &cursor_visible,
                        "title", &attributes.title,
                        "width", &width,
                        "height", &height,
                        "use-alpha", &use_alpha,
                        NULL);

          attributes.width = width;
          attributes.height = height;
          attributes.wclass = GDK_INPUT_OUTPUT;
          attributes.window_type = GDK_WINDOW_TOPLEVEL;
          attributes.event_mask = CLUTTER_STAGE_GDK_EVENT_MASK;

          attributes.cursor = NULL;
          if (!cursor_visible)
            {
              if (stage_gdk->blank_cursor == NULL)
                stage_gdk->blank_cursor = gdk_cursor_new_for_display (backend_gdk->display, GDK_BLANK_CURSOR);

              attributes.cursor = stage_gdk->blank_cursor;
            }

          attributes.visual = NULL;
          if (use_alpha)
            {
              attributes.visual = gdk_screen_get_rgba_visual (backend_gdk->screen);

              if (attributes.visual == NULL)
                clutter_stage_set_use_alpha (stage_cogl->wrapper, FALSE);
            }

          if (attributes.visual == NULL)
            {
             /* This could still be an RGBA visual, although normally it's not */
             attributes.visual = gdk_screen_get_system_visual (backend_gdk->screen);
            }

          stage_gdk->foreign_window = FALSE;
          stage_gdk->window = gdk_window_new (NULL, &attributes,
                                              GDK_WA_TITLE | GDK_WA_CURSOR | GDK_WA_VISUAL);

          g_free (attributes.title);
        }

      clutter_stage_gdk_set_gdk_geometry (stage_gdk);
    }

  gdk_window_ensure_native (stage_gdk->window);

  g_object_set_data (G_OBJECT (stage_gdk->window),
                     "clutter-stage-window", stage_gdk);

  stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
					    width, height);

#if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT)
  if (GDK_IS_X11_WINDOW (stage_gdk->window))
    {
      cogl_x11_onscreen_set_foreign_window_xid (stage_cogl->onscreen,
                                                GDK_WINDOW_XID (stage_gdk->window),
                                                clutter_stage_gdk_update_foreign_event_mask,
                                                stage_gdk);
    }
  else
#endif
#if defined(GDK_WINDOWING_WAYLAND) && defined(COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
  if (GDK_IS_WAYLAND_WINDOW (stage_gdk->window))
    {
      cogl_wayland_onscreen_set_foreign_surface (stage_cogl->onscreen,
                                                 gdk_wayland_window_get_wl_surface (stage_gdk->window));
    }
  else
#endif
#if defined(GDK_WINDOWING_WIN32) && defined(COGL_HAS_WIN32_SUPPORT)
  if (GDK_IS_WIN32_WINDOW (stage_gdk->window))
    {
      cogl_win32_onscreen_set_foreign_window (stage_cogl->onscreen,
					      gdk_win32_window_get_handle (stage_gdk->window));
    }
  else
#endif
    {
      g_warning ("Cannot find an appropriate CoglWinsys for a "
		 "GdkWindow of type %s", G_OBJECT_TYPE_NAME (stage_gdk->window));

      cogl_object_unref (stage_cogl->onscreen);
      stage_cogl->onscreen = NULL;

      if (!stage_gdk->foreign_window)
        gdk_window_destroy (stage_gdk->window);

      stage_gdk->window = NULL;

      return FALSE;
    }

  return clutter_stage_window_parent_iface->realize (stage_window);
}
Ejemplo n.º 26
0
int main (int argc, char **argv)
{
    GdkWindow *rootwindow;		 /* RootWindow of X11*/
    GMainLoop *loop;                       /* the event loop */
    char *pw_dir;
    char *xml_file;
    uid_t uid;
    struct passwd *pass;

    /* inits some gdk stuff */
    gdk_init(&argc, &argv);

#ifdef ENABLE_LIBWNCK
    screen = wnck_screen_get_default ();
    wnck_screen_force_update (screen);  
#endif
  
    parse_options(&argc, &argv);
  
    uid = getuid();
    pass = getpwuid (uid);
    pw_dir = pass->pw_dir;
  
    xml_file = (char*) malloc (sizeof (char) * (strlen (XML_FILE) + strlen (pw_dir) + 1));
    sprintf (xml_file, "%s%s", pw_dir, XML_FILE);
    
    eventlist = parseDoc (xml_file);
    if (eventlist == NULL)
    {
	g_print ("xml error or no elements in list\n");
	exit (1);
    }
    free (xml_file);

    rootwindow = gdk_window_foreign_new (gdk_x11_get_default_root_xwindow());
    /*rootwindow = gdk_window_foreign_new (0x1200002); */

    if (rootwindow == NULL)
    {
	g_print ("rootwindow == NULL\n");
	exit (1);
    }
  
    /* check if GDK_BUTTON_PRESS_MASK is available */
    gdk_error_trap_push ();

    /* ... Call the X function which may cause an error here ... */
    gdk_window_set_events (rootwindow, GDK_BUTTON_PRESS_MASK);
    gdk_window_set_events (rootwindow, GDK_SCROLL_MASK);
  
    /* Flush the X queue to catch errors now. */
    gdk_flush ();

    if (gdk_error_trap_pop ())
    {
	char error[] = "grootevent: an error occured while querying the X server.\n"
	    "A window manager or an application is already grapping\n"
	    "the buttons from the root window.\n\n"
	    "Please read the documentation to get more help about this.\n";
	g_print (error);
	exit (1);
    }
    
    gdk_event_handler_set (event_func, NULL, NULL);

    loop = g_main_loop_new (NULL, FALSE);
    g_main_loop_run (loop);
   
    return 0;
}
Ejemplo n.º 27
0
int main(int argc, char **argv)
{
	pa_glib_mainloop *mainloop;
	pa_mainloop_api *mainloop_api;
	pa_context *context;
	GdkWindow *root;
	int status = EXIT_SUCCESS;
	int i;

	gtk_init(&argc, &argv);

	mainloop = pa_glib_mainloop_new(NULL);
	if (!mainloop) {
		fprintf(stderr, "pa_glib_mainloop_new() failed\n");
		status = EXIT_FAILURE;
		goto out;
	}

	mainloop_api = pa_glib_mainloop_get_api(mainloop);

	if (pa_signal_init(mainloop_api) < 0) {
		fprintf(stderr, "pa_signal_init() failed\n");
		status = EXIT_FAILURE;
		goto mainloop_free;
	}
	pa_signal_new(SIGINT, exit_signal_callback, NULL);
	pa_signal_new(SIGTERM, exit_signal_callback, NULL);

	context = pa_context_new(mainloop_api, NULL);
	if (!context) {
		fprintf(stderr, "pa_context_new() failed\n");
		status = EXIT_FAILURE;
		goto mainloop_free;
	}

	pa_context_set_state_callback(context, context_state_callback, NULL);
	if (pa_context_connect(context, NULL, 0, NULL) < 0) {
		fprintf(stderr, "pa_context_connect() failed: %s\n",
			pa_strerror(pa_context_errno(context)));
		status = EXIT_FAILURE;
		goto context_unref;
	}

	if (!notify_init(APP_NAME)) {
		fprintf(stderr, "Could not initialize libnotify\n");
		status = EXIT_FAILURE;
		goto context_unref;
	}

	notification = notify_notification_new(APP_NAME, NULL, NULL);
	if (!notification) {
		fprintf(stderr, "notify_notification_new() failed\n");
		status = EXIT_FAILURE;
		goto notify_uninit;
	}

	notify_notification_set_timeout(notification, NOTIFY_EXPIRES_DEFAULT);
	notify_notification_set_hint_string(notification, "synchronous", "volume");

	root = gdk_get_default_root_window();

	gdk_window_set_events(root, GDK_KEY_PRESS_MASK);
	gdk_window_add_filter(root, filter, context);

	for (i = 0; i < sizeof(keysyms) / sizeof(keysyms[0]); i++) {
		keycodes[i] = XKeysymToKeycode(GDK_WINDOW_XDISPLAY(root), keysyms[i]);
		if (!keycodes[i]) {
			fprintf(stderr, "%s is not mapped on this keyboard\n",
				XKeysymToString(keysyms[i]));
			continue;
		}
		XGrabKey(GDK_WINDOW_XDISPLAY(root), keycodes[i], AnyModifier,
			 GDK_WINDOW_XID(root), False, GrabModeAsync,
			 GrabModeAsync);
	}

	gtk_main();

	g_object_unref(G_OBJECT(notification));
notify_uninit:
	notify_uninit();
context_unref:
	pa_context_unref(context);
mainloop_free:
	pa_glib_mainloop_free(mainloop);
out:
	return status;
}
Ejemplo n.º 28
0
int
main (int argc, char *argv[])
{
    GdkDisplay    *gdkdisplay;
    Display       *xdisplay;
    GdkScreen     *gdkscreen;
    WnckScreen    *screen;
    gint          i, j, status;
    gboolean      replace = FALSE;
    unsigned int  nchildren;
    Window        root_ret, parent_ret;
    Window        *children = NULL;
    GList	  *windows, *win;
    decor_frame_t *bare_p, *switcher_p;

    const char *option_meta_theme = NULL;
    gint       option_blur_type = 0;

    program_name = argv[0];

    gtk_init (&argc, &argv);

    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    for (i = 0; i < argc; i++)
    {
	if (strcmp (argv[i], "--minimal") == 0)
	{
	    minimal = TRUE;
	}
	else if (strcmp (argv[i], "--replace") == 0)
	{
	    replace = TRUE;
	}
	else if (strcmp (argv[i], "--blur") == 0)
	{
	    if (argc > ++i)
	    {
		if (strcmp (argv[i], "titlebar") == 0)
		    option_blur_type = BLUR_TYPE_TITLEBAR;
		else if (strcmp (argv[i], "all") == 0)
		    option_blur_type = BLUR_TYPE_ALL;
	    }
	}

#ifdef USE_METACITY
	else if (strcmp (argv[i], "--metacity-theme") == 0)
	{
	    if (argc > ++i)
		option_meta_theme = argv[i];
	}
#endif

	else if (strcmp (argv[i], "--help") == 0)
	{
	    fprintf (stderr, "%s "
		     "[--minimal] "
		     "[--replace] "
		     "[--blur none|titlebar|all] "

#ifdef USE_METACITY
		     "[--metacity-theme THEME] "
#endif

		     "[--help]"

		     "\n", program_name);
	    return 0;
	}
    }

    gdkdisplay = gdk_display_get_default ();
    xdisplay   = gdk_x11_display_get_xdisplay (gdkdisplay);
    gdkscreen  = gdk_display_get_default_screen (gdkdisplay);

    frame_input_window_atom  = XInternAtom (xdisplay,
					    DECOR_INPUT_FRAME_ATOM_NAME, FALSE);
    frame_output_window_atom = XInternAtom (xdisplay,
					    DECOR_OUTPUT_FRAME_ATOM_NAME, FALSE);

    win_decor_atom	= XInternAtom (xdisplay, DECOR_WINDOW_ATOM_NAME, FALSE);
    win_blur_decor_atom	= XInternAtom (xdisplay, DECOR_BLUR_ATOM_NAME, FALSE);
    wm_move_resize_atom = XInternAtom (xdisplay, "_NET_WM_MOVERESIZE", FALSE);
    restack_window_atom = XInternAtom (xdisplay, "_NET_RESTACK_WINDOW", FALSE);
    select_window_atom	= XInternAtom (xdisplay, DECOR_SWITCH_WINDOW_ATOM_NAME,
				       FALSE);
    mwm_hints_atom	= XInternAtom (xdisplay, "_MOTIF_WM_HINTS", FALSE);
    switcher_fg_atom    = XInternAtom (xdisplay,
				       DECOR_SWITCH_FOREGROUND_COLOR_ATOM_NAME,
				       FALSE);
    
    compiz_shadow_info_atom  = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_PROPERTIES", FALSE);
    compiz_shadow_color_atom = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_COLOR", FALSE);

    toolkit_action_atom			  =
	XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION", FALSE);
    toolkit_action_window_menu_atom	  =
	XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", FALSE);
    toolkit_action_force_quit_dialog_atom =
	XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG",
		     FALSE);

    net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0);
    net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0);

    decor_request_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_REQUEST", 0);
    decor_pending_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_PENDING", 0);
    decor_delete_pixmap_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_DELETE_PIXMAP", 0);

    status = decor_acquire_dm_session (xdisplay,
				       gdk_screen_get_number (gdkscreen),
				       "gwd", replace, &dm_sn_timestamp);
    if (status != DECOR_ACQUIRE_STATUS_SUCCESS)
    {
	if (status == DECOR_ACQUIRE_STATUS_FAILED)
	{
	    fprintf (stderr,
		     "%s: Could not acquire decoration manager "
		     "selection on screen %d display \"%s\"\n",
		     program_name, gdk_screen_get_number (gdkscreen),
		     DisplayString (xdisplay));
	}
	else if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING)
	{
	    fprintf (stderr,
		     "%s: Screen %d on display \"%s\" already "
		     "has a decoration manager; try using the "
		     "--replace option to replace the current "
		     "decoration manager.\n",
		     program_name, gdk_screen_get_number (gdkscreen),
		     DisplayString (xdisplay));
	}

	return 1;
    }

    screen = wnck_screen_get_default ();

    initialize_decorations ();

    notified = gwd_settings_notified_impl_new (screen);

    if (!notified)
	return 1;

    writable = GWD_SETTINGS_WRITABLE_INTERFACE (gwd_settings_impl_new (option_blur_type != BLUR_TYPE_NONE ? &option_blur_type : NULL,
								       option_meta_theme ? &option_meta_theme : NULL,
								       notified));

    if (!writable)
    {
	g_object_unref (notified);
	return 1;
    }

    settings = GWD_SETTINGS_INTERFACE (writable);

    gwd_settings_writable_freeze_updates (writable);

    if (!init_settings (writable,
			screen))
    {
	g_object_unref (writable);
	fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]);
	return 1;
    }

    for (i = 0; i < 3; i++)
    {
	for (j = 0; j < 3; j++)
	{
	    if (cursor[i][j].shape != XC_left_ptr)
		cursor[i][j].cursor =
		    XCreateFontCursor (xdisplay, cursor[i][j].shape);
	}
    }

    xformat_rgba = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
    xformat_rgb  = XRenderFindStandardFormat (xdisplay, PictStandardRGB24);

    frame_table = g_hash_table_new (NULL, NULL);
    destroyed_pixmaps_table = g_hash_table_new (NULL, NULL);

    if (!create_tooltip_window ())
    {
	g_object_unref (writable);

	free (settings);
	fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
	return 1;
    }

    wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);

    gdk_window_add_filter (NULL,
			   selection_event_filter_func,
			   NULL);

    if (!minimal)
    {
	GdkWindow *root = create_foreign_window (gdk_x11_get_default_root_xwindow ());

 	gdk_window_add_filter (NULL,
 			       event_filter_func,
 			       NULL);
			       
	XQueryTree (xdisplay, gdk_x11_get_default_root_xwindow (),
		    &root_ret, &parent_ret, &children, &nchildren);

	for (i = 0; i < nchildren; i++)
	{
	    GdkWindow *toplevel = create_foreign_window  (children[i]);

	    /* Need property notify on all windows */

	    gdk_window_set_events (toplevel,
				   gdk_window_get_events (toplevel) |
				   GDK_PROPERTY_CHANGE_MASK);
	}

	/* Need MapNotify on new windows */
	gdk_window_set_events (root, gdk_window_get_events (root) |
			       GDK_STRUCTURE_MASK |
			       GDK_PROPERTY_CHANGE_MASK |
			       GDK_VISIBILITY_NOTIFY_MASK |
			       GDK_SUBSTRUCTURE_MASK);
 
 	connect_screen (screen);
    }

    decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen),
			     WINDOW_DECORATION_TYPE_PIXMAP |
			     WINDOW_DECORATION_TYPE_WINDOW);

    /* Update the decorations based on the settings */
    gwd_settings_writable_thaw_updates (writable);

    /* Keep the default, bare and switcher decorations around
     * since otherwise they will be spuriously recreated */

    bare_p = gwd_get_decor_frame ("bare");
    switcher_p = gwd_get_decor_frame ("switcher");

    update_default_decorations (gdkscreen);

    gtk_main ();

    win = windows = wnck_screen_get_windows (screen);

    while (win != NULL)
    {
	WnckWindow *w = (WnckWindow *) win->data;

	window_closed (screen, w);

	win = g_list_next (win);
    }

    g_list_free (windows);

    if (tip_label)
	gtk_widget_destroy (GTK_WIDGET (tip_label));

    if (tip_window)
	gtk_widget_destroy (GTK_WIDGET (tip_window));

    gwd_decor_frame_unref (bare_p);
    gwd_decor_frame_unref (switcher_p);

    fini_settings ();

    return 0;
}
Ejemplo n.º 29
0
static void
gs_theme_window_real_realize (GtkWidget *widget)
{
	GdkWindow     *window;
	Window         remote_xwindow;
	GtkRequisition requisition;
	GtkAllocation  allocation;
	const char    *preview_xid;
	int            x;
	int            y;
	int            width;
	int            height;
	int            event_mask;

	event_mask = 0;
	window = NULL;
	preview_xid = g_getenv ("XSCREENSAVER_WINDOW");

	if (preview_xid != NULL)
	{
		char *end;

		remote_xwindow = (Window) strtoul (preview_xid, &end, 0);

		if ((remote_xwindow != 0) && (end != NULL) &&
		        ((*end == ' ') || (*end == '\0')) &&
		        ((remote_xwindow < G_MAXULONG) || (errno != ERANGE)))
		{
			window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), remote_xwindow);
			if (window != NULL)
			{
				/* This is a kludge; we need to set the same
				 * flags gs-window-x11.c does, to ensure they
				 * don't get unset by gtk_window_map() later.
				 */
				gtk_window_set_decorated (GTK_WINDOW (widget), FALSE);

				gtk_window_set_skip_taskbar_hint (GTK_WINDOW (widget), TRUE);
				gtk_window_set_skip_pager_hint (GTK_WINDOW (widget), TRUE);

				gtk_window_set_keep_above (GTK_WINDOW (widget), TRUE);

				gtk_window_fullscreen (GTK_WINDOW (widget));

				event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK;
				gtk_widget_set_events (widget, gtk_widget_get_events (widget) | event_mask);
			}
		}
	}

	if (window == NULL)
	{
		GtkWidgetClass *parent_class;

		parent_class = GTK_WIDGET_CLASS (gs_theme_window_parent_class);

		if (parent_class->realize != NULL)
			parent_class->realize (widget);

		return;
	}

	gtk_style_context_set_background (gtk_widget_get_style_context (widget),
	                                  window);
	gdk_window_set_decorations (window, (GdkWMDecoration) 0);
	gdk_window_set_events (window, gdk_window_get_events (window) | event_mask);

	gtk_widget_set_window (widget, window);
	gdk_window_set_user_data (window, widget);
	gtk_widget_set_realized (widget, TRUE);

	gdk_window_get_geometry (window, &x, &y, &width, &height);

	if (width < MIN_SIZE || height < MIN_SIZE)
	{
		g_critical ("This window is way too small to use");
		exit (1);
	}

	gtk_widget_get_preferred_size (widget, &requisition, NULL);
	allocation.x = x;
	allocation.y = y;
	allocation.width = width;
	allocation.height = height;
	gtk_widget_size_allocate (widget, &allocation);
	gtk_window_resize (GTK_WINDOW (widget), width, height);
}
Ejemplo n.º 30
0
Client *
newclient(void) {
	Client *c;
	WebKitWebSettings *settings;
	gchar *uri;

	if(!(c = calloc(1, sizeof(Client))))
		die("Cannot malloc!\n");
	/* Window */
	if(embed) {
		c->win = gtk_plug_new(embed);
	}
	else {
		c->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
		gtk_window_set_wmclass(GTK_WINDOW(c->win), "surf", "surf");
	}
	gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600);
	g_signal_connect(G_OBJECT(c->win), "destroy", G_CALLBACK(destroywin), c);
	g_signal_connect(G_OBJECT(c->win), "key-press-event", G_CALLBACK(keypress), c);

	/* VBox */
	c->vbox = gtk_vbox_new(FALSE, 0);

	/* scrolled window */
	c->scroll = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(c->scroll),
			GTK_POLICY_NEVER, GTK_POLICY_NEVER);

	/* webview */
	c->view = WEBKIT_WEB_VIEW(webkit_web_view_new());
	g_signal_connect(G_OBJECT(c->view), "title-changed", G_CALLBACK(titlechange), c);
	g_signal_connect(G_OBJECT(c->view), "load-progress-changed", G_CALLBACK(progresschange), c);
	g_signal_connect(G_OBJECT(c->view), "load-finished", G_CALLBACK(loadfinished), c);
	g_signal_connect(G_OBJECT(c->view), "load-committed", G_CALLBACK(loadcommit), c);
	g_signal_connect(G_OBJECT(c->view), "load-started", G_CALLBACK(loadstart), c);
	g_signal_connect(G_OBJECT(c->view), "hovering-over-link", G_CALLBACK(linkhover), c);
	g_signal_connect(G_OBJECT(c->view), "create-web-view", G_CALLBACK(newwindow), c);
	g_signal_connect(G_OBJECT(c->view), "download-requested", G_CALLBACK(initdownload), c);
	g_signal_connect(G_OBJECT(c->view), "window-object-cleared", G_CALLBACK(windowobjectcleared), c);
	g_signal_connect_after(session, "request-started", G_CALLBACK(request), c);

	/* urlbar */
	c->urlbar = gtk_entry_new();
	gtk_entry_set_has_frame(GTK_ENTRY(c->urlbar), FALSE);
	g_signal_connect(G_OBJECT(c->urlbar), "focus-out-event", G_CALLBACK(unfocusbar), c);

	/* searchbar */
	c->searchbar = gtk_entry_new();
	gtk_entry_set_has_frame(GTK_ENTRY(c->searchbar), FALSE);
	g_signal_connect(G_OBJECT(c->searchbar), "focus-out-event", G_CALLBACK(unfocusbar), c);

	/* indicator */
	c->indicator = gtk_drawing_area_new();
	gtk_widget_set_size_request(c->indicator, 0, 2);
	g_signal_connect (G_OBJECT (c->indicator), "expose_event",
			G_CALLBACK (exposeindicator), c);

	/* Arranging */
	gtk_container_add(GTK_CONTAINER(c->scroll), GTK_WIDGET(c->view));
	gtk_container_add(GTK_CONTAINER(c->win), c->vbox);
	gtk_container_add(GTK_CONTAINER(c->vbox), c->scroll);
	gtk_container_add(GTK_CONTAINER(c->vbox), c->searchbar);
	gtk_container_add(GTK_CONTAINER(c->vbox), c->urlbar);
	gtk_container_add(GTK_CONTAINER(c->vbox), c->indicator);

	/* Setup */
	gtk_box_set_child_packing(GTK_BOX(c->vbox), c->urlbar, FALSE, FALSE, 0, GTK_PACK_START);
	gtk_box_set_child_packing(GTK_BOX(c->vbox), c->searchbar, FALSE, FALSE, 0, GTK_PACK_START);
	gtk_box_set_child_packing(GTK_BOX(c->vbox), c->indicator, FALSE, FALSE, 0, GTK_PACK_START);
	gtk_box_set_child_packing(GTK_BOX(c->vbox), c->scroll, TRUE, TRUE, 0, GTK_PACK_START);
	gtk_widget_grab_focus(GTK_WIDGET(c->view));
	gtk_widget_hide_all(c->searchbar);
	gtk_widget_hide_all(c->urlbar);
	gtk_widget_show(c->vbox);
	gtk_widget_show(c->indicator);
	gtk_widget_show(c->scroll);
	gtk_widget_show(GTK_WIDGET(c->view));
	gtk_widget_show(c->win);
	gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
	gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
	webkit_web_view_set_full_content_zoom(c->view, TRUE);
	settings = webkit_web_view_get_settings(c->view);
	g_object_set(G_OBJECT(settings), "user-agent", "surf", NULL);
	uri = g_strconcat("file://", stylefile, NULL);
	g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
	g_free(uri);

	c->download = NULL;
	c->title = NULL;
	c->next = clients;
	clients = c;
	if(showxid) {
		gdk_display_sync(gtk_widget_get_display(c->win));
		printf("%u\n", (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window));
		fflush(NULL);
	}
	return c;
}