Exemplo n.º 1
0
void
draw_dot (int x, int y)
{
    set_foreground (5);
	XDrawPoint (dd, tb.win, fore_gc, x, y);
    set_foreground (4);
	XDrawPoint (dd, tb.win, fore_gc, x + 1, y + 1);
}
Exemplo n.º 2
0
void
gui_draw_vline (int x)
{
	set_foreground (5);
	draw_line (x, 0, x, WINHEIGHT);
	set_foreground (4);
	draw_line (x + 1, 0, x + 1, WINHEIGHT);
}
Exemplo n.º 3
0
void mode(SCREEN_Screen* scr, int x)
{
    switch (x) {
        case 0: exit_attribute_mode(scr); break;
        case 1: enter_bold_mode(scr); break;
        case 7: enter_reverse_mode(scr); break;
        case 10: break;
        case 22: exit_bold_mode(scr); break;
        case 30: set_foreground(scr, SCREEN_COLOR_BLACK); break;
        case 31: set_foreground(scr, SCREEN_COLOR_RED); break;
        case 32: set_foreground(scr, SCREEN_COLOR_GREEN); break;
        case 33: set_foreground(scr, SCREEN_COLOR_YELLOW); break;
        case 34: set_foreground(scr, SCREEN_COLOR_BLUE); break;
        case 35: set_foreground(scr, SCREEN_COLOR_MAGENTA); break;
        case 36: set_foreground(scr, SCREEN_COLOR_CYAN); break;
        case 37: set_foreground(scr, SCREEN_COLOR_WHITE); break;
        case 39: set_foreground(scr, SCREEN_COLOR_WHITE); break;
        case 40: set_background(scr, SCREEN_COLOR_BLACK); break;
        case 41: set_background(scr, SCREEN_COLOR_RED); break;
        case 42: set_background(scr, SCREEN_COLOR_GREEN); break;
        case 43: set_background(scr, SCREEN_COLOR_YELLOW); break;
        case 44: set_background(scr, SCREEN_COLOR_BLUE); break;
        case 45: set_background(scr, SCREEN_COLOR_MAGENTA); break;
        case 46: set_background(scr, SCREEN_COLOR_CYAN); break;
        case 47: set_background(scr, SCREEN_COLOR_WHITE); break;
        case 49: set_background(scr, SCREEN_COLOR_BLACK); break;
        default: 
            fprintf(stderr, "uknown mode parameter: %i\n", x);
            break;
    }
}
Exemplo n.º 4
0
void
draw_box (int x, int width)
{
    set_foreground (5);		  /* mid gray */
	fill_rect (x + 3, 2, width - 2, WINHEIGHT - 4);

	set_foreground (5);		  /* white */
	draw_line (x + 3, WINHEIGHT - 2, x + width - 1, WINHEIGHT - 2);
	draw_line (x + width - 1, 1, x + width - 1, WINHEIGHT - 2);

	set_foreground (5);		  /* darkest gray */
	draw_line (x + 3, 1, x + width - 1, 1);
	draw_line (x + 3, 2, x + 3, WINHEIGHT - 3);
}
Exemplo n.º 5
0
Arquivo: color.c Projeto: Brybry/wTerm
static void
reset_test_colors(void)
{
  /* Now, set the background again just in case there's a glitch */
  set_foreground(COLOR_WHITE);
  set_background(COLOR_BLACK);
}
Exemplo n.º 6
0
void Screen::init_control (Control* par) {
    set_background (C_SCREEN_BACKGROUND);
    set_foreground (C_FOREGROUND);
    set_font_color (C_FOREGROUND);
    set_frame (0);
    reinitialize ();
}
Exemplo n.º 7
0
	void stop()
	{
		set_foreground(frame_producer::empty());

		background_			= background_;
		frame_number_		= 0;
		auto_play_delta_	= -1;

		is_paused_			= false;
	}
Exemplo n.º 8
0
Arquivo: color.c Projeto: Brybry/wTerm
/*
 * VT220 and higher implement the 22, 24, 25 and 27 codes.
 * VT510 implements concealed text.
 *
 * ISO 6429 specifies additional SGR codes so that one needn't use SGR 0
 * to reset everything before switching, e.g., set/clear pairs are
 * bold      1/22
 * faint     2/22
 * italics   3/23
 * underline 4/24
 * blink     5/25
 * inverse   7/27
 * concealed 8/28
 */
static int
test_iso_6429_sgr(MENU_ARGS)
{
  set_test_colors();

  ed(2);
  /* *INDENT-OFF* */
  cup( 1,20); printf("Extended/Graphic rendition test pattern:");
  cup( 4, 1); c_sgr("0");            printf("vanilla");
  cup( 4,40); c_sgr("0;1");          printf("bold");
  cup( 6, 6); c_sgr("22;4");         printf("underline");
  cup( 6,45); c_sgr("24;1;4");       printf("bold underline");
  cup( 8, 1); c_sgr("22;24;5");      printf("blink");
  cup( 8,40); c_sgr("25;5;1");       printf("bold blink");
  cup(10, 6); c_sgr("22;4;5");       printf("underline blink");
  cup(10,45); c_sgr("24;25;1;4;5");  printf("bold underline blink");
  cup(12, 1); c_sgr("22;24;25;7");   printf("negative");
  cup(12,40); c_sgr("1");            printf("bold negative");
  cup(14, 6); c_sgr("22;4;7");       printf("underline negative");
  cup(14,45); c_sgr("1;4;7");        printf("bold underline negative");
  cup(16, 1); c_sgr("22;24;5;7");    printf("blink negative");
  cup(16,40); c_sgr("1");            printf("bold blink negative");
  cup(18, 6); c_sgr("22;4");         printf("underline blink negative");
  cup(18,45); c_sgr("1");            printf("bold underline blink negative");
  cup(20, 6); c_sgr(""); set_foreground(9); printf("original foreground");
  cup(20,45); c_sgr(""); set_background(9); printf("original background");
  cup(22, 1); c_sgr(";8");           printf("concealed");
  cup(22,40); c_sgr("8;7");          printf("concealed negative");
  /* *INDENT-ON* */

  c_sgr("");    /* same as c_sgr("0") */
  printf(" <- concealed text");

  decscnm(FALSE);   /* Inverse video off */
  cup(max_lines - 1, 1);
  el(0);
  printf("Dark background. ");
  holdit();

  decscnm(TRUE);  /* Inverse video */
  cup(max_lines - 1, 1);
  el(0);
  printf("Light background. ");
  holdit();

  decscnm(FALSE);
  cup(max_lines - 1, 1);
  el(0);
  printf("Dark background. ");
  holdit();

  reset_colors();
  return MENU_NOHOLD;
}
Exemplo n.º 9
0
void
pager_draw_button (int x, int num)
{
	char label;
#ifdef XFT
	XftColor col;
#endif

	if (num == tb.my_desktop)
	{
		/* current desktop */
		draw_box (x, PAGER_BUTTON_WIDTH);
	} else
	{
		set_foreground (5);
		fill_rect (x, 1, PAGER_BUTTON_WIDTH+1, WINHEIGHT - 2);
	}

	label = '1' + num;

#ifdef XFT
	col.color.alpha = 0xffff;
	col.color.red = cols[5].red;
	col.color.green = cols[5].green;
	col.color.blue = cols[5].blue;
	XftDrawString8 (xftdraw, &col, xfs, x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2), text_y, &label, 1);
#else
    if (num == tb.my_desktop)
    {
        set_foreground (6);
    }
    else
    {
        set_foreground (4);
    }
	XDrawString (dd, tb.win, fore_gc,
	x + ((PAGER_BUTTON_WIDTH - PAGER_DIGIT_WIDTH) / 2) - 1, text_y, &label, 1);
#endif
}
Exemplo n.º 10
0
int read_config_file(char *config_filename)
{
	FILE *fd;
	char *p;
	char textline[LINEBUFFER];
	int ret;

	if ((fd = fopen(config_filename, "r")) == NULL)
		return 1;

	while (fgets(textline, LINEBUFFER - 1, fd) != NULL) {
		/* We ignore blank lines and comments */
		if (textline[0] == '\n' || textline[0] == '#')
			continue;	

		p = strtok(textline, " \t\n");

		if (strncasecmp("server", p, 4) == 0) {
			int ret;
			p = strtok(NULL, " \t\n");
			ret = set_server(p);
			if (ret) {
				/* error */
				fflush(stderr);
				fflush(stdout);
				fprintf(stderr, "Server IP unknown.\n");
				exit(1);
			}
		} else if (strncasecmp("logfile", p, 7) == 0) {
			p = strtok(NULL, " \t\n");
			open_log(p);
		} else if (strncasecmp("background", p, 10) == 0) {
			p = strtok(NULL, " \t\n");
			set_background(p);
		} else if (strncasecmp("logo", p, 4) == 0) {
			p = strtok(NULL, " \t\n");
			set_logo(p);
		} else if (strncasecmp("foreground", p, 10) == 0) {
			p = strtok(NULL, " \t\n");
			set_foreground(p);
		} else if (strncasecmp("port", p, 4) == 0) {
			p = strtok(NULL, " \t\n");
			set_listen_port(p);
		}
	}
	ret = fclose(fd);
	return ret;

}
Exemplo n.º 11
0
	void play()
	{			
		if(background_ != frame_producer::empty())
		{
			background_->set_leading_producer(foreground_);
			
			set_foreground(background_);

			background_			= frame_producer::empty();
			frame_number_		= 0;
			auto_play_delta_	= -1;	
		}

		is_paused_			= false;
	}
Exemplo n.º 12
0
void ui_display_tape_control_status(int control)
{
    GdkColor *color;
    int status = 0;
#if !defined(HAVE_CAIRO)
    GdkGC *app_gc = get_toplevel();
#endif

    DBG(("ui_display_tape_control_status (%d) motor:%d image:%d\n", control, tape_motor_status, tape_image_status));

    if (control < 0) {
        control = tape_control_status;
    } else {
        tape_control_status = control;
    }

#if !defined(HAVE_CAIRO)
    if (app_gc == NULL) {
        DBG(("ui_display_tape_control_status skipped\n"));
        return;
    }
#endif

    /* Set background color */
    color = (tape_image_status == 1) ? &drive_led_on_green_pixel : &drive_led_on_red_pixel;
    set_background(color);

    /* set foreground color for tape-button */
    color = (tape_motor_status == 1) ? &motor_running_pixel : &tape_control_pixel;
    switch (control) {
        case DATASETTE_CONTROL_START:
            status = 1;
            break;
        case DATASETTE_CONTROL_FORWARD:
            status = 2;
            break;
        case DATASETTE_CONTROL_REWIND:
            status = 3;
            break;
        case DATASETTE_CONTROL_RECORD:
            status = 4;
            break;
    }
    set_foreground(color, status);
    gdk_flush();
}
Exemplo n.º 13
0
void
gui_draw_taskbar (void)
{
	task *tk;
	int x, width, taskw;

#ifdef PAGER
	pager_draw ();
#else
	pager_size = GRILL_WIDTH;
#endif

	width = WINWIDTH - (pager_size + GRILL_WIDTH + GRILL_WIDTH);
	x = pager_size + 2;

	if (tb.num_tasks == 0)
		goto clear;

	taskw = width / tb.num_tasks;
	if (taskw > MAX_TASK_WIDTH)
		taskw = MAX_TASK_WIDTH;

	tk = tb.task_list;
	while (tk)
	{
		tk->pos_x = x;
		tk->width = taskw - 1;
		gui_draw_task (tk);
		x += taskw;
		tk = tk->next;
	}

	if (x < (width + pager_size + 2))
	{
clear:
		gui_draw_vline (x);
		set_foreground (5);
		fill_rect (x + 2, 0, WINWIDTH, WINHEIGHT);
	}

	gui_draw_vline (8);
	gui_draw_vline (WINWIDTH - 8);

	draw_grill (2);
	draw_grill (WINWIDTH - 6);
}
Exemplo n.º 14
0
void
scale_icon (task *tk)
{
	int xx, yy, x, y, w, h, d, bw;
	Pixmap pix, mk = None;
	XGCValues gcv;
	GC mgc;

	XGetGeometry (dd, tk->icon, &pix, &x, &y, &w, &h, &bw, &d);
	pix = XCreatePixmap (dd, tk->win, ICONWIDTH, ICONHEIGHT, scr_depth);

	if (tk->mask != None)
	{
		mk = XCreatePixmap (dd, tk->win, ICONWIDTH, ICONHEIGHT, 1);
		gcv.subwindow_mode = IncludeInferiors;
		gcv.graphics_exposures = False;
		mgc = XCreateGC (dd, mk, GCGraphicsExposures | GCSubwindowMode, &gcv);
	}

	set_foreground (5);

	/* this is my simple & dirty scaling routine */
	for (y = ICONHEIGHT - 1; y >= 0; y--)
	{
		yy = (y * h) / ICONHEIGHT;
		for (x = ICONWIDTH - 1; x >= 0; x--)
		{
			xx = (x * w) / ICONWIDTH;
			if (d != scr_depth)
				XCopyPlane (dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y, 1);
			else
				XCopyArea (dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y);
			if (mk != None)
				XCopyArea (dd, tk->mask, mk, mgc, xx, yy, 1, 1, x, y);
		}
	}

	if (mk != None)
	{
		XFreeGC (dd, mgc);
		tk->mask = mk;
	}

	tk->icon = pix;
}
Exemplo n.º 15
0
Arquivo: color.c Projeto: Brybry/wTerm
/* Graphic rendition requires special handling with color, since SGR-0
 * is supposed to reset the colors as well.
 */
static void
show_graphic_rendition(void)
{
  ed(2);
  /* *INDENT-OFF* */
  cup( 1,20); printf("Color/Graphic rendition test pattern:");
  cup( 4, 1); c_sgr("0");            printf("vanilla");
  cup( 4,40); c_sgr("0;1");          printf("bold");
  cup( 6, 6); c_sgr(";4");           printf("underline");
  cup( 6,45); c_sgr(";1");c_sgr("4");printf("bold underline");
  cup( 8, 1); c_sgr("0;5");          printf("blink");
  cup( 8,40); c_sgr("0;5;1");        printf("bold blink");
  cup(10, 6); c_sgr("0;4;5");        printf("underline blink");
  cup(10,45); c_sgr("0;1;4;5");      printf("bold underline blink");
  cup(12, 1); c_sgr("1;4;5;0;7");    printf("negative");
  cup(12,40); c_sgr("0;1;7");        printf("bold negative");
  cup(14, 6); c_sgr("0;4;7");        printf("underline negative");
  cup(14,45); c_sgr("0;1;4;7");      printf("bold underline negative");
  cup(16, 1); c_sgr("1;4;;5;7");     printf("blink negative");
  cup(16,40); c_sgr("0;1;5;7");      printf("bold blink negative");
  cup(18, 6); c_sgr("0;4;5;7");      printf("underline blink negative");
  cup(18,45); c_sgr("0;1;4;5;7");    printf("bold underline blink negative");
  cup(20, 6); c_sgr(""); set_foreground(9); printf("original foreground");
  cup(20,45); c_sgr(""); set_background(9); printf("original background");
  /* *INDENT-ON* */

  c_sgr("");    /* same as c_sgr("0") */

  decscnm(FALSE);   /* Inverse video off */
  cup(max_lines - 1, 1);
  el(0);
  printf("Dark background. ");
  holdit();

  decscnm(TRUE);  /* Inverse video */
  cup(max_lines - 1, 1);
  el(0);
  printf("Light background. ");
  holdit();

  decscnm(FALSE);
}
Exemplo n.º 16
0
	safe_ptr<basic_frame> receive(int hints)
	{		
		try
		{
			monitor_subject_ << monitor::message("/paused") % is_paused_;

			if(is_paused_)
			{
				if(foreground_->last_frame() == basic_frame::empty())
					foreground_->receive(frame_producer::NO_HINT);

				return disable_audio(foreground_->last_frame());
			}

			auto foreground = foreground_;

			auto frame = receive_and_follow(foreground, hints);

			if(foreground != foreground_)
				set_foreground(foreground);

			if(frame == core::basic_frame::late())
				return foreground_->last_frame();

			auto frames_left = static_cast<int64_t>(foreground_->nb_frames()) - static_cast<int64_t>(++frame_number_) - static_cast<int64_t>(auto_play_delta_);
			if(auto_play_delta_ > -1 && frames_left < 1)
			{
				play();
				return receive(hints);
			}
				
			return frame;
		}
		catch(...)
		{
			CASPAR_LOG_CURRENT_EXCEPTION();
			stop();
			return core::basic_frame::empty();
		}
	}
Exemplo n.º 17
0
int main(int argc, char *argv[])
{
	/* getopt */
	int next_option;

	int ret;
	int will_block = 0;

	/*! short options. See man getopt */
	const char *const short_options = "hc:l:L:b:f:xp:s:";
	/*! the array for the long options. */
	const struct option long_options[] = {
		{"help", 0, NULL, 'h'},
		{"config", 1, NULL, 'c'},
		{"logfile", 1, NULL, 'L'},
		{"background", 1, NULL, 'b'},
		{"foreground", 1, NULL, 'f'},
		{"logo", 1, NULL, 'l'},
		{"blocked", 0, NULL, 'x'},
		{"port", 1, NULL, 'p'},
		{"server", 1, NULL, 's'},
		{NULL, 0, NULL, 0}
	};

	/* Initializing exit function */
	if (atexit(f_atexit) != 0) {
		fprintf(stderr, "failed to register f_atexit() exit function\n");
		exit(EXIT_FAILURE);
	}
	if (signal(SIGINT, sig_ctrlc) == SIG_ERR) {
		fprintf(stderr, "Warning - Could not set CTRL-C handler\n");
	}

	/* First, set defaults */
	set_listen_port(PORT);
	set_foreground(FOREGROUND_IMAGE);
	set_logo(LOGO_IMAGE);
	/* Second, read entries from default config file. 
	 * They will eventually be replaced by command line settings. */
	read_config_file(CONFIGFILE);

	/* Then, overwrite with command line options... */
	do {
		next_option = getopt_long(argc, argv, short_options, long_options, NULL);
		switch (next_option) {
		case 'h':	/* -h or --help */
			print_usage();
			exit(1);

		case 'c':/* -c or --config */
			/* Things like "mdclient -p 7000 -c /etc/mymedusa.conf" 
			 * when port is set to a different value in /etc/mymedusa.conf
			 * may result in an unpredictable value for listen_port. Just don't do that. */
			read_config_file(strdup(optarg));
			break;

		case 'p': /* -p or --port */
			set_listen_port(strdup(optarg));
			break;

		case 'x': /* -x or --blocked */
			will_block = 1;
			break;

		case 'b': /* -b or --background */
			set_background(strdup(optarg));
			break;

		case 'l': /* -l or --logo */
			set_logo(strdup(optarg));
			break;

		case 'f': /* -f or --foreground */
			set_foreground(strdup(optarg));
			break;

		case 'L': /* -L or --logfile */
			close_log();
			open_log(strdup(optarg));
			break;
		case 's': /* -s or --server */
			ret = set_server(strdup(optarg));
			if (ret) {
				/* error */
				fflush(stderr);
				fflush(stdout);
				fprintf(stderr, "Server IP unknown.\n");
				exit(1);
			}
			break;

		case '?':/* The user specified an invalid option */
			/* Write usage info on the screen   */
			print_usage();
			exit(1);

		case -1: /* No more options */
			break;

		default: /* Garbage */
			abort();
		}
 } while (next_option != -1);

 if (will_block) {
  if (lockScreen() < 0) {
   write_log_fmt("Could not open display.\n");
			exit(EXIT_FAILURE);
		}
	}
				
	write_log_fmt("Starting...\n");
	listen_network();
	close_log();
	return 0;
}
Exemplo n.º 18
0
int main(int argc, char* argv[]) {
    FILE* command_file = stdin;
    int quiet = 0;

    // Check for '-q' option: be quiet (print no prompts)
    if (argc > 1 && strcmp(argv[1], "-q") == 0) {
        quiet = 1;
        --argc, ++argv;
    }

    // Check for filename option: read commands from file
    if (argc > 1) {
        command_file = fopen(argv[1], "rb");
        if (!command_file) {
            perror(argv[1]);
            exit(1);
        }
    }

    // - Put the shell into the foreground
    // - Ignore the SIGTTOU signal, which is sent when the shell is put back
    //   into the foreground
    set_foreground(0);
    handle_signal(SIGTTOU, SIG_IGN);

    char buf[BUFSIZ];
    int bufpos = 0;
    int needprompt = 1;

    while (!feof(command_file)) {
        // Print the prompt at the beginning of the line
        if (needprompt && !quiet) {
            printf("sh61[%d]$ ", getpid());
            fflush(stdout);
            needprompt = 0;
        }

        // Read a string, checking for error or EOF
        if (fgets(&buf[bufpos], BUFSIZ - bufpos, command_file) == NULL) {
            if (ferror(command_file) && errno == EINTR) {
                // ignore EINTR errors
                clearerr(command_file);
                buf[bufpos] = 0;
            } else {
                if (ferror(command_file))
                    perror("sh61");
                break;
            }
        }

        // If a complete command line has been provided, run it
        bufpos = strlen(buf);
        if (bufpos == BUFSIZ - 1 || (bufpos > 0 && buf[bufpos - 1] == '\n')) {
            eval_line(buf);
            bufpos = 0;
            needprompt = 1;
        }

        // Handle zombie processes and/or interrupt requests
        // Your code here!
    }

    return 0;
}
Exemplo n.º 19
0
static void test_foregroundwindow(void)
{
    HWND hwnd, hwnd_test, partners[2], hwnds[2];
    HDESK hdesks[2];
    int thread_desk_id, input_desk_id, hwnd_id;
    WNDCLASSA wclass;
    wnd_param param;
    DWORD ret, timeout, timeout_old;
    char win_text[1024];

#define DESKTOPS 2

    memset( &wclass, 0, sizeof(wclass) );
    wclass.lpszClassName = "test_class";
    wclass.lpfnWndProc   = WndProc;
    RegisterClassA(&wclass);
    param.wnd_name = "win_name";

    hdesks[0] = GetThreadDesktop(GetCurrentThreadId());
    ok(hdesks[0] != NULL, "OpenDesktop failed!\n");
    SetLastError(0xdeadbeef);
    hdesks[1] = CreateDesktopA("desk2", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL);
    ret = GetLastError();
    ok(hdesks[1] != NULL || ret == ERROR_ACCESS_DENIED, "CreateDesktop failed (%u)\n", ret);
    if(!hdesks[1])
    {
        win_skip("Not enough privileges for CreateDesktop\n");
        return;
    }

    ret = SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout_old, 0);
    if(!ret)
    {
        win_skip("Skip tests on NT4\n");
        CloseDesktop(hdesks[1]);
        return;
    }
    trace("old timeout %d\n", timeout_old);
    timeout = 0;
    ret = SystemParametersInfoA(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
    ok(ret, "set foreground lock timeout failed!\n");
    ret = SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout, 0);
    ok(ret, "get foreground lock timeout failed!\n");
    ok(timeout == 0, "unexpected timeout %d\n", timeout);

    for (thread_desk_id = 0; thread_desk_id < DESKTOPS; thread_desk_id++)
    {
        param.hdesk = hdesks[thread_desk_id];
        param.hevent = CreateEventA(NULL, TRUE, FALSE, NULL);
        CreateThread(NULL, 0, create_window, &param, 0, NULL);
        ret = WaitForSingleObject(param.hevent, INFINITE);
        ok(ret == WAIT_OBJECT_0, "wait failed!\n");
        hwnds[thread_desk_id] = param.hwnd;
    }

    for (thread_desk_id = 0; thread_desk_id < DESKTOPS; thread_desk_id++)
    {
        param.hdesk = hdesks[thread_desk_id];
        param.hevent = CreateEventA(NULL, TRUE, FALSE, NULL);
        CreateThread(NULL, 0, create_window, &param, 0, NULL);
        ret = WaitForSingleObject(param.hevent, INFINITE);
        ok(ret == WAIT_OBJECT_0, "wait failed!\n");
        partners[thread_desk_id] = param.hwnd;
    }

    trace("hwnd0 %p hwnd1 %p partner0 %p partner1 %p\n", hwnds[0], hwnds[1], partners[0], partners[1]);

    for (hwnd_id = 0; hwnd_id < DESKTOPS; hwnd_id++)
        for (thread_desk_id = 0; thread_desk_id < DESKTOPS; thread_desk_id++)
            for (input_desk_id = 0; input_desk_id < DESKTOPS; input_desk_id++)
            {
                trace("testing thread_desk %d input_desk %d hwnd %d\n",
                        thread_desk_id, input_desk_id, hwnd_id);
                hwnd_test = hwnds[hwnd_id];
                ret = SetThreadDesktop(hdesks[thread_desk_id]);
                ok(ret, "set thread desktop failed!\n");
                ret = SwitchDesktop(hdesks[input_desk_id]);
                ok(ret, "switch desktop failed!\n");
                set_foreground(partners[0]);
                set_foreground(partners[1]);
                hwnd = GetForegroundWindow();
                ok(hwnd != hwnd_test, "unexpected foreground window %p\n", hwnd);
                ret = set_foreground(hwnd_test);
                hwnd = GetForegroundWindow();
                GetWindowTextA(hwnd, win_text, 1024);
                trace("hwnd %p name %s\n", hwnd, win_text);
                if (input_desk_id == hwnd_id)
                {
                    if (input_desk_id == thread_desk_id)
                    {
                        ok(ret, "SetForegroundWindow failed!\n");
                        ok(hwnd == hwnd_test , "unexpected foreground window %p\n", hwnd);
                    }
                    else
                    {
                        todo_wine ok(ret, "SetForegroundWindow failed!\n");
                        todo_wine ok(hwnd == 0, "unexpected foreground window %p\n", hwnd);
                    }
                }
                else
                {
                    if (input_desk_id == thread_desk_id)
                    {
                        ok(!ret, "SetForegroundWindow should fail!\n");
                        ok(hwnd == partners[input_desk_id] , "unexpected foreground window %p\n", hwnd);
                    }
                    else
                    {
                        todo_wine ok(!ret, "SetForegroundWindow should fail!\n");
                        todo_wine ok(hwnd == 0, "unexpected foreground window %p\n", hwnd);
                    }
                }
            }

    /* Clean up */

    for (thread_desk_id = DESKTOPS - 1; thread_desk_id >= 0; thread_desk_id--)
    {
        ret = SetThreadDesktop(hdesks[thread_desk_id]);
        ok(ret, "set thread desktop failed!\n");
        SendMessageA(hwnds[thread_desk_id], WM_DESTROY, 0, 0);
        SendMessageA(partners[thread_desk_id], WM_DESTROY, 0, 0);
    }

    ret = SwitchDesktop(hdesks[0]);
    ok(ret, "switch desktop failed!\n");
    CloseDesktop(hdesks[1]);

    ret = SystemParametersInfoA(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UlongToPtr(timeout_old), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
    ok(ret, "set foreground lock timeout failed!\n");
    ret = SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout, 0);
    ok(ret, "get foreground lock timeout failed!\n");
    ok(timeout == timeout_old, "unexpected timeout %d\n", timeout);
}
Exemplo n.º 20
0
void
gui_draw_task (task *tk)
{
	int len;
	int x = tk->pos_x;
	int taskw = tk->width;
#ifdef XFT
	XGlyphInfo ext;
	XftColor col;
#endif

	if (!tk->name)
		return;

	gui_draw_vline (x);

	if (tk->focused)
	{
		draw_box (x, taskw);
	} else
	{
		set_foreground (5);		  /* mid gray */
		fill_rect (x + 2, 0, taskw - 1, WINHEIGHT);
	}

	{
		register int text_x = x + TEXTPAD + TEXTPAD + ICONWIDTH;
#ifdef XFT

		/* check how many chars can fit */
		len = strlen (tk->name);
		while (len > 0)
		{
			XftTextExtents8 (dd, xfs, tk->name, len, &ext);
			if (ext.width < taskw - (text_x - x) - 2)
				break;
			len--;
		}

		col.color.alpha = 0xffff;

		if (tk->iconified)
		{
			/* draw task's name dark (iconified) */
			col.color.red = cols[3].red;
			col.color.green = cols[3].green;
			col.color.blue = cols[3].blue;
			XftDrawString8 (xftdraw, &col, xfs, text_x, text_y + 1, tk->name, len);
			col.color.red = cols[3].red;
			col.color.green = cols[3].green;
			col.color.blue = cols[3].blue;
		} else
		{
			col.color.red = cols[3].red;
			col.color.green = cols[3].green;
			col.color.blue = cols[3].blue;
		}

		/* draw task's name here */
		XftDrawString8 (xftdraw, &col, xfs, text_x, text_y, tk->name, len);

#else

		/* check how many chars can fit */
		len = strlen (tk->name);

		while (XTextWidth (xfs, tk->name, len) >= taskw - (text_x - x) - 2
				 && len > 0)
			len--;

		if (tk->iconified)
		{
			/* draw task's name dark (iconified) */
		    set_foreground (4);
			XDrawString (dd, tb.win, fore_gc, text_x, text_y + 1, tk->name, len);
			set_foreground (3);
		} else if (tk->focused)
		{
        	set_foreground (7);
		}
        else
        {
            set_foreground (4);
        }

		/* draw task's name here */
		XDrawString (dd, tb.win, fore_gc, text_x, text_y, tk->name, len);
#endif
	}

#ifndef HAVE_XPM
	if (!tk->icon)
		return;
#endif

	/* draw the task's icon */
	XSetClipMask (dd, fore_gc, tk->mask);
	XSetClipOrigin (dd, fore_gc, x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
	XCopyArea (dd, tk->icon, tb.win, fore_gc, 0, 0, ICONWIDTH, ICONHEIGHT,
				  x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2);
	XSetClipMask (dd, fore_gc, None);
}