static int open_TraceWin()
		/*success-> return 0;*/
{
	int		i;

	open_window(&win, kTraceWinID);
	position_window(&win);
	
	mac_ctl_reset_trc();
	for(i = 0; i < 16; i++)
	    init_bitset(channel_program_flags + i, 128);

	return 0;
}
示例#2
0
static int open_SpecWin()
		/*success-> return 0;*/
{
#ifdef SUPPORT_SOUNDSPEC
	open_window(&win, kSpecWinID);
	position_window(&win);
	
	//always 
	//if( win.show ){ //Preference on
		open_soundspec();
	   	soundspec_update_wave(NULL, 0);
	//}
#endif /* SUPPORT_SOUNDSPEC */
	return 0;
}
示例#3
0
static int open_LogWin()
		/*success-> return 0;*/
{
	open_window(&win, kLogWinID);
	position_window(&win);
	setsize_window(&win);
	
	SetPortWindowPort(win.ref);
	TextSize(10);
	gLogTE=TENew(&win.ref->portRect, &win.ref->portRect);
	if( gLogTE==0 ) mac_ErrorExit("\ppCannot open LogWindow!");
	
	TEFeatureFlag(teFAutoScroll, teBitSet, gLogTE);
	TEActivate(gLogTE);
	return 0;
}
示例#4
0
static int open_DocWin()
		/*success-> return 0;*/
{
	Rect	r;

	open_window(&win, kDocWinID);
	position_window(&win);
	setsize_window(&win);
	
	SetPortWindowPort(win.ref);
	TextSize(10);
	r=win.ref->portRect; r.right-=16;
	gDocTE=TENew(&r, &r);
	if( gDocTE==0 ) mac_ErrorExit("\pCannot open DocWindow!");
	
	TEFeatureFlag(teFAutoScroll, teBitSet, gDocTE);
	TEActivate(gDocTE);
	return 0;
}
示例#5
0
static int open_ListWin()
		/*success-> return 0;*/
{
	Rect		listRect, dataBounds;
	Point		cSize;

	open_window(&win, kListWinID);
	position_window(&win);
	setsize_window(&win);
	
	SetPortWindowPort(win.ref);
	TextSize(10);
	listRect=win.ref->portRect;	listRect.right-=14; listRect.bottom-=14;
	dataBounds.top=dataBounds.left=0; dataBounds.right=1; dataBounds.bottom=0;
	cSize.h=1024; cSize.v=14;
	gPlaylist = LNew(&listRect, &dataBounds, cSize, 0, win.ref, 
						1, 1, 0, 1);
	return 0;
}
示例#6
0
static int open_PlayerWin()
		/*success-> return 0;*/
{
	int	i;
	OSErr	err;
	RGBColor	back={0,0,0},
				fore={65535,65535,65535};
	
	open_window( &win, kPlayerWinID);
	position_window(&win);
	
	SetPortWindowPort(win.ref);
	RGBForeColor(&fore);
	RGBBackColor(&back);
	logo= GetPicture(128);
	logoDown= GetPicture(132);
	
	for(i=0; i<6; i++)
		button[i]= GetCIcon(i+200);
	iconPlay=GetCIcon(210);
	iconPause=GetCIcon(211);
	iconVol=GetCIcon(206);
	iconTab=GetCIcon(207);
	iconNotLoop=GetCIcon(208);
	iconLoop=GetCIcon(209);
	
	if(gHasDragMgr)
	{
		receiveRgn=NewRgn();
		if( receiveRgn )
		{
			GetWindowContentRgn(win.ref, receiveRgn);
			err=InstallTrackingHandler(NewDragTrackingHandlerProc(DragTrackingProc),
								(WindowPtr)win.ref, 0);
			if(err) ExitToShell();
			
			err=InstallReceiveHandler(NewDragReceiveHandlerProc(DragReceiveFunc),
							(WindowPtr)win.ref, 0);
			if(err) ExitToShell();
		}
	}
	return 0;
}
示例#7
0
/*
 * Popup a window with wrapped text in it.
 * For Motif, the text is explicitly wrapped inside this method.
 */
static Widget
internal_popup_window(Widget parent,
		      popupMessageSizeHintT size,
		      popupMessageT type,
		      int x_coord, int y_coord,
		      const char *helptext,
		      char *msg_buf,
#ifndef MOTIF
		      const char *xaw_ret_action_str,
#endif
		      pre_message_cbT pre_cb, XtPointer arg,
		      const char *yes_button, message_cbT yes_cb, XtPointer yes_arg,
		      const char *no_button, message_cbT no_cb, XtPointer no_arg,
		      const char *cancel_button, message_cbT cancel_cb, XtPointer cancel_arg)
{
    int my_popup_num = 0;
#ifdef MOTIF
    XmString str;
#endif
    Widget ret;

    ASSERT(type < (sizeof my_msg_map / sizeof my_msg_map[0]), "too few elements in my_msg_map");

#if DEBUG
    fprintf(stderr, "internal_popup_window called with prompt: \"%s\"\n", msg_buf);
#endif

    if (globals.widgets.top_level == 0) {
	/* If toplevel window hasn't been created yet, dump messages to STDERR
	   and return.
	*/
	fprintf(stderr, "\n%s:\n%s\n", my_msg_map[type].window_title, msg_buf);
	if (helptext) {
	    fputs("---------- helptext ----------\n", stderr);
	    fputs(helptext, stderr);
	    fputs("\n---------- end of helptext ----------\n", stderr);
	}
	return NULL;
    }
    /* search for first free position in g_popup_array */
    while (my_popup_num < MAX_POPUPS && (g_popup_array[my_popup_num] == 1)) {
	my_popup_num++;
    }
    if (my_popup_num == MAX_POPUPS) {
	/* already enough popups on screen, just dump it to stderr */
	fprintf(stderr, "%s: %s\n", my_msg_map[type].window_title, msg_buf);
	/* Note: If a mad function continues to open popups, this will
	 * stop after MAX_POPUPS, but open a new window for each
	 * window the user pops down. Maybe we ought to do something
	 * about this.
	 */
	return NULL;
    }
    else {
	/* mark it as non-free */
	g_popup_array[my_popup_num] = 1;
    }
#if DEBUG
    fprintf(stderr, "first free position in g_popup_array: %d\n", my_popup_num);
#endif

    /* just to make sure ... */
    if (parent == NULL)
	parent = globals.widgets.top_level;

    /* create a new set of widgets for the additional popup. */
    ret = create_dialogs(size, parent,
			 my_popup_num,
			 helptext,
			 pre_cb, arg,
			 yes_button, yes_cb, yes_arg,
			 no_button, no_cb, no_arg,
			 cancel_button, cancel_cb, cancel_arg);
#ifdef MOTIF
    XtVaSetValues(popup_window[my_popup_num], XmNtitle,
	    my_msg_map[type].window_title, NULL);
    XtVaSetValues(dialog[my_popup_num], XmNdialogType,
	    my_msg_map[type].motif_msg_type, NULL);
    { /* wrap message at space before MSG_WRAP_LEN */
	char *testwrap = msg_buf;
	int ctr;
	for (ctr = 0; *testwrap++; ctr++) {
	    if (*testwrap == '\n') {
		ctr = 0;
	    }
	    else if (ctr > MSG_WRAP_LEN) {
		size_t before_len = 0, after_len = 0;
		char *before_ptr, *after_ptr;
		before_ptr = after_ptr = testwrap;
		/* try to find shortest sequence before or after point to wrap at;
		   this seems to give the most pleasing results.
		*/
		while (before_ptr > msg_buf && !isspace((int)*--before_ptr)) {
		    before_len++;
		}
		while (*after_ptr != '\0' && !isspace((int)*++after_ptr)) {
		    after_len++;
		}

		if (before_len < after_len && isspace((int)*before_ptr)) {
		    /* use last in sequence of multiple spaces */
		    while (isspace((int)*++before_ptr)) { ; }
		    /* back up, and wrap */
		    *--before_ptr = '\n';
		    ctr = 0;
		}
		else if (isspace((int)*after_ptr)) {
		    /* use last in sequence of multiple spaces */
		    while (isspace((int)*++after_ptr)) { ; }
		    /* back up, and wrap */
		    *--after_ptr = '\n';
		    ctr = 0;
		}
	    }
	}
    }
    str = XmStringCreateLtoR((char *)msg_buf, G_charset);
    XtVaSetValues(dialog[my_popup_num],
		  XmNmessageString, str,
		  XmNtraversalOn, True,
		  XmNhighlightOnEnter, True,
		  NULL);
    XmStringFree(str);

    XtManageChild(dialog[my_popup_num]);
    
    if (x_coord > 0 && y_coord > 0) {
	position_window(XtParent(dialog[my_popup_num]), (Position)x_coord, (Position)y_coord);
    }
    
    XtPopup(XtParent(dialog[my_popup_num]), XtGrabNone);
    /*      XtPopup(XtParent(dialog[my_popup_num]), XtGrabExclusive); */

#else /* MOTIF */

    /* add a binding of xaw_ret_action_str to <Return> to relevant widgets.
       The callbacks (xaw_ret_action_str) are responsible for parsing the
       passed arguments (pointers, or empty arguments).       
    */
    if (xaw_ret_action_str != NULL) {
	XtTranslations xlats;
	char *translation_str;

	if (yes_arg != NULL)
	    translation_str = get_string_va("<Key>Return:close-popup(%d)%s(%p)",
					    my_popup_num, xaw_ret_action_str, yes_arg);
	else
	    translation_str = get_string_va("<Key>Return:close-popup(%d)%s()",
					    my_popup_num, xaw_ret_action_str);
	
	xlats = XtParseTranslationTable(translation_str);
	free(translation_str);
	XtOverrideTranslations(popup_window[my_popup_num], xlats);
	XtOverrideTranslations(message_paned[my_popup_num], xlats);
	XtOverrideTranslations(message_text[my_popup_num], xlats);
    }
    
    XtVaSetValues(popup_window[my_popup_num], XtNtitle,
	    my_msg_map[type].window_title, NULL);
    XtVaSetValues(message_text[my_popup_num], XtNstring, msg_buf, NULL);
    XtRealizeWidget(popup_window[my_popup_num]);

    XSetWMProtocols(XtDisplay(popup_window[my_popup_num]), XtWindow(popup_window[my_popup_num]),
		    &WM_DELETE_WINDOW, 1);

    if (x_coord <= 0 || y_coord <= 0)
	center_window(popup_window[my_popup_num], parent);
    else
	position_window(popup_window[my_popup_num], (Position)x_coord, (Position)y_coord);
    
    if (my_popup_num > 0) {
	/* some window managers position new windows exactly above the
	   existing one; to prevent this, move it with some offset
	   from the previous one: */
	Position x = 0, y = 0;
	XtVaGetValues(popup_window[my_popup_num-1], XtNx, &x, XtNy, &y, NULL);
	XtVaSetValues(popup_window[my_popup_num], XtNx, x + POPUP_OFFSET, XtNy, y + POPUP_OFFSET, NULL);

    }
    XtPopup(popup_window[my_popup_num], XtGrabNone);
    /*      XtPopup(XtParent(popup_window[my_popup_num]), XtGrabExclusive); */
    if (XtIsManaged(message_not_ok[my_popup_num]) && XtIsManaged(message_help[my_popup_num])) {
	/* center the help button. This is something of a sham, since it won't
	   survive resizing; but in general most users won't resize dialogs ;-) */
	Position x1, x2, bw;
	int w, dist;
	
	XtVaGetValues(message_ok[my_popup_num], XtNx, &x1, XtNwidth, &w, XtNborderWidth, &bw, NULL);
	XtVaGetValues(message_help[my_popup_num], XtNx, &x2, NULL);
	/* following formula is measured, not calculated -
	   I have no idea why it's e.g. 2 * w, not 1.5 * w ... */
	dist = (x2 - x1 - 2 * w) / 2 - 2 * bw;
	XtVaSetValues(message_not_ok[my_popup_num], XtNhorizDistance, dist, NULL);
    }
    
#endif /* MOTIF */
    return ret;
}
示例#8
0
static GtkWidget *
create_label_window (MateRRLabeler *labeler, MateRROutputInfo *output, GdkColor *color)
#endif
{
	GtkWidget *window;
	GtkWidget *widget;
	char *str;
	const char *display_name;
#if GTK_CHECK_VERSION (3, 0, 0)
	GdkRGBA black = { 0., 0., 0., 1. };
#else
	GdkColor black = { 0, 0, 0, 0 };
#endif
	int x,y;

	window = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_widget_set_app_paintable (window, TRUE);

	gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);

	/* This is semi-dangerous.  The color is part of the labeler->palette
	 * array.  Note that in mate_rr_labeler_finalize(), we are careful to
	 * free the palette only after we free the windows.
	 */
	g_object_set_data (G_OBJECT (window), "color", color);

#if GTK_CHECK_VERSION (3, 0, 0)
	g_signal_connect (window, "draw",
			  G_CALLBACK (label_window_draw_event_cb), labeler);
#else
	g_signal_connect (window, "expose-event",
			  G_CALLBACK (label_window_expose_event_cb), labeler);
#endif

	if (mate_rr_config_get_clone (labeler->priv->config)) {
		/* Keep this string in sync with mate-control-center/capplets/display/xrandr-capplet.c:get_display_name() */

		/* Translators:  this is the feature where what you see on your laptop's
		 * screen is the same as your external monitor.  Here, "Mirror" is being
		 * used as an adjective, not as a verb.  For example, the Spanish
		 * translation could be "Pantallas en Espejo", *not* "Espejar Pantallas".
		 */
		display_name = g_strdup_printf (_("Mirror Screens"));
		str = g_strdup_printf ("<b>%s</b>", display_name);
	} else {
		display_name = g_strdup_printf ("<b>%s</b>\n<small>%s</small>", mate_rr_output_info_get_display_name (output), mate_rr_output_info_get_name (output));
		str = g_strdup_printf ("%s", display_name);
	}
	g_free (display_name);

	widget = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (widget), str);
	g_free (str);

	/* Make the label explicitly black.  We don't want it to follow the
	 * theme's colors, since the label is always shown against a light
	 * pastel background.  See bgo#556050
	 */
#if GTK_CHECK_VERSION (3, 0, 0)
	gtk_widget_override_color(widget, gtk_widget_get_state_flags (widget), &black);
#else
	gtk_widget_modify_fg (widget, gtk_widget_get_state (widget), &black);
#endif

	gtk_container_add (GTK_CONTAINER (window), widget);

	/* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
	mate_rr_output_info_get_geometry (output, &x, &y, NULL, NULL);
	position_window (labeler, window, x, y);

	gtk_widget_show_all (window);

	return window;
}
static GtkWidget *
create_label_window (CcRRLabeler *labeler, GnomeRROutputInfo *output, GdkRGBA *rgba)
{
	GtkWidget *window;
	GtkWidget *widget;
	char *str;
	const char *display_name;
	GdkRGBA black = { 0, 0, 0, 1.0 };
	int x, y;
	GdkScreen *screen;
	GdkVisual *visual;

	window = gtk_window_new (GTK_WINDOW_POPUP);
	gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
	gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
	gtk_widget_set_app_paintable (window, TRUE);
	screen = gtk_widget_get_screen (window);
	visual = gdk_screen_get_rgba_visual (screen);

	if (visual != NULL)
		gtk_widget_set_visual (window, visual);

	gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);

	/* This is semi-dangerous.  The color is part of the labeler->palette
	 * array.  Note that in cc_rr_labeler_finalize(), we are careful to
	 * free the palette only after we free the windows.
	 */
	g_object_set_data (G_OBJECT (window), "rgba", rgba);

	g_signal_connect (window, "draw",
			  G_CALLBACK (label_window_draw_event_cb), labeler);
	g_signal_connect (window, "realize",
			  G_CALLBACK (label_window_realize_cb), labeler);
	g_signal_connect (window, "composited-changed",
			  G_CALLBACK (label_window_composited_changed_cb), labeler);

	if (gnome_rr_config_get_clone (labeler->priv->config)) {
		/* Keep this string in sync with gnome-control-center/capplets/display/xrandr-capplet.c:get_display_name() */

		/* Translators:  this is the feature where what you see on your
		 * laptop's screen is the same as your external projector.
		 * Here, "Mirrored" is being used as an adjective.  For example,
		 * the Spanish translation could be "Pantallas en Espejo".
		 */
		display_name = _("Mirrored Displays");
	} else
		display_name = gnome_rr_output_info_get_display_name (output);

	str = g_strdup_printf ("<b>%s</b>", display_name);
	widget = gtk_label_new (NULL);
	gtk_label_set_markup (GTK_LABEL (widget), str);
	g_free (str);

	/* Make the label explicitly black.  We don't want it to follow the
	 * theme's colors, since the label is always shown against a light
	 * pastel background.  See bgo#556050
	 */
	gtk_widget_override_color (widget,
				   gtk_widget_get_state_flags (widget),
				   &black);

	gtk_container_add (GTK_CONTAINER (window), widget);

	/* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
	gnome_rr_output_info_get_geometry (output, &x, &y, NULL, NULL);
	position_window (labeler, window, x, y);

	gtk_widget_show_all (window);

	return window;
}
示例#10
0
static void
moo_position_window_real (GtkWidget  *window,
                          GtkWidget  *parent,
                          gboolean    at_mouse,
                          gboolean    at_coords,
                          int         x,
                          int         y)
{
    GtkWidget *toplevel = NULL;

    g_return_if_fail (GTK_IS_WINDOW (window));

    if (parent)
        toplevel = gtk_widget_get_toplevel (parent);
    if (toplevel && !GTK_IS_WINDOW (toplevel))
        toplevel = NULL;

    if (toplevel)
    {
        gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (toplevel));
#ifdef __WIN32__
        g_signal_handlers_disconnect_by_func (window, (gpointer) on_hide, NULL);
        g_signal_connect (window, "unmap", G_CALLBACK (on_hide), NULL);
#endif
    }

    if (toplevel && GTK_WINDOW(toplevel)->group)
        gtk_window_group_add_window (GTK_WINDOW(toplevel)->group, GTK_WINDOW (window));

    if (!at_mouse && !at_coords && parent && GTK_WIDGET_REALIZED (parent))
    {
        if (GTK_IS_WINDOW (parent))
        {
            gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);
        }
        else
        {
            GdkWindow *parent_window = gtk_widget_get_parent_window (parent);
            gdk_window_get_origin (parent_window, &x, &y);
            x += parent->allocation.x;
            y += parent->allocation.y;
            x += parent->allocation.width / 2;
            y += parent->allocation.height / 2;
            at_coords = TRUE;
        }
    }

    if (at_mouse)
    {
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
    }
    else if (at_coords)
    {
        GdkPoint *coord = g_new (GdkPoint, 1);
        coord->x = x;
        coord->y = y;
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_NONE);
        g_object_set_data_full (G_OBJECT (window), "moo-coords", coord, g_free);

        if (!GTK_WIDGET_REALIZED (window))
        {
            g_signal_handlers_disconnect_by_func (window, (gpointer) position_window, NULL);
            g_signal_connect (window, "realize",
                              G_CALLBACK (position_window),
                              NULL);
        }
        else
        {
            position_window (GTK_WINDOW (window));
        }
    }
}
示例#11
0
int main()
{
    /* Setup Allegro/AllegroGL */

	if (allegro_init())
		return 1;

	if (install_allegro_gl())
		return 1;

    if (install_keyboard() < 0)
    {
        allegro_message("Unable to install keyboard\n");
        return 1;
    }

    if (install_mouse() == -1)
    {
        allegro_message("Unable to install mouse\n");
        return 1;
    }

    if (install_timer() < 0)
    {
        allegro_message("Unable to install timers\n");
        return 1;
    }

    /* lock timer */
    LOCK_VARIABLE(rotation_counter);
    LOCK_FUNCTION(rotation_counter_handler);


    /* set desktop resolution */
    DESKTOP_W = GetSystemMetrics(SM_CXVIRTUALSCREEN);
    DESKTOP_H = GetSystemMetrics(SM_CYVIRTUALSCREEN);

    /* get monitor resolution/count */
    int monitor_count;
    MONITOR *monitors = get_monitors(&monitor_count);


    /* generate point data */
    PLACE places[POINT_COUNT];
    int c;
    for (c = 1; c < POINT_COUNT - 1; c++)
    {
        places[c].x = sin((M_PI * (GLfloat)c) / 10.0f) * 200.0f;
        places[c].y = cos((M_PI * (GLfloat)c) / 10.0f) * 200.0f;
    }
    places[0].x = 0.01;
    places[0].y = 200.0f;
    places[POINT_COUNT - 1].x = 0.01;
    places[POINT_COUNT - 1].y = -200.0f;


    /* setup display */
    allegro_gl_set(AGL_Z_DEPTH, 8);
	allegro_gl_set(AGL_COLOR_DEPTH, 16);
	allegro_gl_set(AGL_SUGGEST, AGL_Z_DEPTH | AGL_COLOR_DEPTH);
    glDepthFunc(GL_LEQUAL);

	if (set_gfx_mode(GFX_OPENGL_WINDOWED_BORDERLESS, DESKTOP_W, DESKTOP_H, 0, 0)) {
		set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
		allegro_message("Unable to set graphic mode\n%s\n", allegro_error);
		return 1;
	}

    /* move window so it covers the desktop */
    position_window(0, 0);


    /* fake information to use if only 1 monitor */
    MONITOR fake = {0, 512, 512, 512};

    /* setup lighting model */
    glShadeModel(GL_FLAT);
    glEnable(GL_LIGHT0);
    glEnable(GL_COLOR_MATERIAL);
    GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    GLfloat ambient[] = { 0.1f, 0.1f, 0.1f };
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);


    int selected = -1; /* the point currently being moved */
    GLfloat rotation[3] = {0, 0, 0}; /* the rotation of the mesh */

    install_int(rotation_counter_handler, 20); /* install the rotation handler */

    /* enter main program loop */
    while(!key[KEY_ESC])
    {
        while (rotation_counter > 0)
        {
            /* rotate the mesh */
            rotation[0] += M_PI / 24.0f;
            rotation[1] += M_PI / 16.0f;
            rotation[2] += M_PI /  8.0f;
            rotation_counter--;
        }


        /* clear the buffers */
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        /* process monitor 0 */
        MONITOR *m = &monitors[0];

        /* adjust mouse so its relative to the monitor */
        int mx = (mouse_x - m->x) - (m->w / 2);
        int my = (mouse_y - m->y) - (m->h / 2);

        /* if the left mouse is pushed, find a close point */
        if (mouse_b & 1)
        {
            if (selected == -1)
            {
                GLfloat distance = 10;
                for (c = 0; c < POINT_COUNT; c++)
                {
                    GLfloat dx = mx - places[c].x;
                    GLfloat dy = my - places[c].y;
                    GLfloat d = sqrt(dx * dx + dy * dy);
                    if (d < distance)
                    {
                        distance = d;
                        selected = c;
                    }
                }
            }
        }
        else
            selected = -1;

        /* move selected point */
        if (selected >= 0)
        {
            places[selected].x = mx;
            places[selected].y = my;
        }

        /* center the viewport on monitor */
        glViewport(m->x, DESKTOP_H - m->h - m->y, m->w, m->h);

        /* setup viewport projection */
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluOrtho2D(-m->w / 2, m->w / 2, m->h / 2, -m->h / 2);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        /* draw points */
        glColor3ub(0, 255, 0);
        glBegin(GL_LINE_STRIP);
        for (c = 0; c < POINT_COUNT; c++)
        {
            glVertex2f(places[c].x, places[c].y);
        }
        glEnd();

        glColor3ub(255, 255, 255);
        for (c = 0; c < POINT_COUNT; c++)
        {
            draw_square(places[c].x, places[c].y, 10);
        }

        /* draw vertical line */
        glBegin(GL_LINE_STRIP);
        glVertex2f(0.0f, -m->h);
        glVertex2f(0.0f, m->h);
        glEnd();


        /* draw the mouse */
        glColor3ub(255, 255, 255);
        draw_square(mx, my, 20);



        /* process viewport 1 */

        /* select second monitor */
        if (monitor_count > 1)
        {
            /* if 2nd monitor exists use it */
            m = &monitors[1];
        }
        else
        {
            /* use fake monitor */
            m = &fake;
        }

        /* adjust mouse so its relative to the monitor*/
        mx = (mouse_x - m->x) - (m->w / 2);
        my = (mouse_y - m->y) - (m->h / 2);

        /* center the viewport on the monitor*/
        glViewport(m->x, DESKTOP_H - m->h - m->y, m->w, m->h);

        /* setup viewport projection */
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(45.0f, (float)m->w / (float)m->h, 0.1f, 2000.0f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        /* turn on lighting and depth testing */
        glEnable(GL_LIGHTING);
        glEnable(GL_DEPTH_TEST);

        /* move mesh so its visible */
        glTranslatef(0.0f, 0.0f, -1000.0f);
        /* rotate mesh */
        glRotatef(rotation[0], 1.0f, 0.0f, 0.0f);
        glRotatef(rotation[1], 0.0f, 1.0f, 0.0f);
        glRotatef(rotation[2], 0.0f, 0.0f, 1.0f);

        GLfloat p1[3] = {0, 0, 0};
        GLfloat p2[3] = {0, 0, 0};
        GLfloat p3[3] = {0, 0, 0};
        GLfloat p4[3] = {0, 0, 0};
        GLfloat vec1[3];
        GLfloat vec2[3];
        GLfloat normal[3];


        /* draw mesh to screen */
        glColor3ub(0, 255, 0);
        for (c = 0; c < (POINT_COUNT - 1); c++)
        {

            GLfloat a1 = 0;
            GLfloat a2 = M_PI / 16.0f;
            GLfloat d1 = places[c].x;
            GLfloat d2 = places[c + 1].x;

            p1[0] = sin(a1) * d1;  p1[1] = places[c].y;     p1[2] = cos(a1) * d1;
            p2[0] = sin(a2) * d1;  p2[1] = places[c].y;     p2[2] = cos(a2) * d1;
            p3[0] = sin(a2) * d2;  p3[1] = places[c + 1].y; p3[2] = cos(a2) * d2;
            p4[0] = sin(a1) * d2;  p4[1] = places[c + 1].y; p4[2] = cos(a1) * d2;

            buildVector(vec1, p1, p2);
            buildVector(vec2, p1, p4);
            cross_product_f(vec2[0], vec2[1], vec2[2], vec1[0], vec1[1], vec1[2], &normal[0], &normal[1], &normal[2]);
            normalize_vector_f(&normal[0], &normal[1], &normal[2]);


            glBegin(GL_QUAD_STRIP);
            glNormal3fv(normal);
            glVertex3fv(p1);
            glVertex3fv(p4);

            int s = 0;
            for (s = 1; s < 32; s++)
            {
                a2 = (M_PI * (GLfloat)(s + 1)) / 16.0f;
                d1 = places[c].x;
                d2 = places[c + 1].x;

                copyPoint(p1, p2);
                copyPoint(p4, p3);
                p2[0] = sin(a2) * d1;  p2[1] = places[c].y;     p2[2] = cos(a2) * d1;
                p3[0] = sin(a2) * d2;  p3[1] = places[c + 1].y; p3[2] = cos(a2) * d2;

                buildVector(vec1, p1, p2);
                buildVector(vec2, p1, p4);
                cross_product_f(vec2[0], vec2[1], vec2[2], vec1[0], vec1[1], vec1[2], &normal[0], &normal[1], &normal[2]);
                normalize_vector_f(&normal[0], &normal[1], &normal[2]);

                glNormal3fv(normal);
                glVertex3fv(p2);
                glVertex3fv(p3);
            }
            glEnd();
        }

        /* turn off lighting and depth testing */
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);

        /* if not using the fake monitor */
        if (m != &fake)
        {

            /* setup viewport projection */
            glMatrixMode(GL_PROJECTION);
            glLoadIdentity();
            gluOrtho2D(-m->w / 2, m->w / 2, m->h / 2, -m->h / 2);
            glMatrixMode(GL_MODELVIEW);
            glLoadIdentity();

            /* draw the mouse */
            glColor3ub(255, 255, 255);
            draw_square(mx, my, 20);
        }

        /* flip the contents to the screen */
        allegro_gl_flip();
    }


    free(monitors);

    return 0;
}