char*
prof_pre_room_message_display(const char * const room, const char * const nick, const char *message)
{
    create_win();

    char *str = "fired -> prof_pre_room_message_display: ";
    char buf[strlen(str) + strlen(room) + 2 + strlen(nick) + 2 + strlen(message) + 1];
    sprintf(buf, "%s%s, %s, %s", str, room, nick, message);
    prof_win_show(plugin_win, buf);

    return NULL;
}
char*
prof_pre_chat_message_send(const char * const jid, const char *message)
{
    create_win();

    char *str = "fired -> prof_pre_chat_message_send: ";
    char buf[strlen(str) + strlen(jid) + 2 + strlen(message) + 1];
    sprintf(buf, "%s%s, %s", str, jid, message);
    prof_win_show(plugin_win, buf);

    return NULL;
}
/* App init */
int app_create(void *data)
{
	Evas_Object *win;
	struct appdata *ad = data;

	/* create window */
	win = create_win(PACKAGE);
	if (win == NULL)
		return -1;

	ad->win_main = win;

	return 0;

}
Exemple #4
0
int main (int argc, char **argv)
{
    Display *dpy;
    int xi_opcode, event, error;
    Window win;
    XEvent ev;

    dpy = XOpenDisplay(NULL);

    if (!dpy) {
        fprintf(stderr, "Failed to open display.\n");
        return -1;
    }

    if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error)) {
           printf("X Input extension not available.\n");
              return -1;
    }

    if (!has_xi2(dpy))
        return -1;

    /* Create a simple window */
    win = create_win(dpy);

    /* select for XI2 events */
    select_events(dpy, win);

    while(1) {
        XGenericEventCookie *cookie = &ev.xcookie;

        XNextEvent(dpy, &ev);

        if (cookie->type != GenericEvent ||
            cookie->extension != xi_opcode)
            continue;

        if (XGetEventData(dpy, cookie))
        {
            printf("Event type %d received\n", cookie->evtype);
            XFreeEventData(dpy, &ev.xcookie);
        }
    }

    return 0;
}
/* App init */
int app_create(void *data)
{

	Evas_Object *win;
	struct appdata *ad = data;

	/* Create window (Reqd for sys-popup) */
	win = create_win(PACKAGE);
	if (win == NULL)
		return -1;

	ad->win_main = win;

	elm_theme_overlay_add(NULL,EDJ_NAME); 

	return 0;
}
Exemple #6
0
// Shows the inventory
void
show_inventory(void)
{
  WINDOW * w_inv;
  COORDS co;
  int t_freeze;

  w_inv = create_win(0, 0, 0, 0, 1, CP_WHITEBLUE);
  co = get_geometry(w_inv);
  set_winstr(w_inv, (co.x - (int) strlen("INVENTORY")) / 2, 1, A_BOLD,
             CP_WHITEBLUE, "INVENTORY");

  t_freeze = pause_game();
  set_inputmode(IM_KEYPRESS);
  getch();
  rm_win(w_inv);
  resume_game(t_freeze);
}
Exemple #7
0
int main(int argc, char **argv)
{
	if (signal(SIGINT, sig_handler) == SIG_ERR)
		printf("\ncan't catch SIGINT\n");
	if (signal(SIGUSR1, sig_handler) == SIG_ERR)
		printf("\ncan't catch SIGUSR1\n");
	
	setlocale(LC_ALL, "");
	uint8_t RAMVPointer = 3;	// Позиция отображаемого участка памяти
	uint8_t PROVPointer = 0;
	int ActiveWindow = WIN_REG;	// Активное окно
	int EditMode = False;		// Режим редактора
	int cx, cy;					// Координаты курсора
	
	Memory = sc_memoryInit(MaxMemory);
	if (NULL == Memory)
	{
		perror("Память не выделена\n");
		goto TERMINATE;
	}
	

	
	
	WINDOW *winRAM;
	WINDOW *winREG;
	WINDOW *winTerminal;
	WINDOW *winProgram;
	initscr();
	start_color();
	init_pair(1, COLOR_WHITE, COLOR_BLUE);
	init_pair(2, COLOR_BLUE, COLOR_CYAN);
	init_pair(3, COLOR_WHITE, COLOR_BLACK);
	keypad(stdscr, TRUE);		
	refresh();
	noecho();
	
	//curs_set(1);
	curs_set(0);//FIXME
	
	winREG = create_win(0, 0, 11, 15);
	winTerminal = create_win(0, 15, 11, 65);
	winRAM = create_win(18, 0, 6, 80);
	winProgram = create_win(11, 0, 7, 19);
	
	mvwprintw(winREG, 0, 1, "РЕГИСТРЫ");
	mvwprintw(winTerminal, 0, 1, "ТЕРМИНАЛ");
	mvwprintw(winRAM, 0, 1, "ПАМЯТЬ");
	mvwprintw(winProgram, 0, 1, "ПРОГРАММА");
	
	wbkgd(winREG, COLOR_PAIR(3));
	wbkgd(winTerminal, COLOR_PAIR(3));
	
	mvwprintw(winREG, 1, 1, "A:     0x0000");
	mvwprintw(winREG, 2, 1, "IC:      0x00");
//	mvwprintw(winREG, 3, 1, " FLAGS: 0x00");
//	mvwprintw(winREG, 4, 1, " V Z E P C");
//	mvwprintw(winREG, 5, 1, " 0 0 0 0 0");
	mvwprintw(winREG, 3, 1, "F: 0b00000000");
	mvwprintw(winREG, 4, 1, "        VZEPC");

	
	loadbios(Memory);
	viewprog(winProgram, Memory, 0, 0);
	
	
	
	//sc_memorySet(Memory, 17, 5);
	
	
//	sc_memorySave(Memory, (char*)"caca");
	sc_memoryLoad(Memory, (char*)"caca");
	
	viewram(winRAM, RAMVPointer, 0);//fixme
	
	wrefresh(winREG);
	wrefresh(winTerminal);
	wrefresh(winRAM);
	wrefresh(winProgram);
	refresh();

	move(1, 1);
	paintbox(winREG, 1);
	
	int ch;
	while (1)
	{
		ch = getch();
		switch (ActiveWindow)
		{
			case WIN_MEM:
			{
				if (ch == KEY_F(3))
				{
					if (EditMode)
					{
						EditMode = False;
						curs_set(0);
					}
					else
					{
						EditMode = True;
						curs_set(1);
						move(19, 8);
						cx = 8;
						cy = 1;
					}
				}
				if (!(EditMode))
				{
					switch (ch)
					{
						case KEY_DOWN:
							RAMVPointer = viewram(winRAM, RAMVPointer, 1);
							wrefresh(winRAM);
							break;
						case KEY_UP:
							RAMVPointer = viewram(winRAM, RAMVPointer, -1);
							wrefresh(winRAM);
							break;
						case KEY_TAB:
							//goto TERMINATE;
							ActiveWindow = WIN_REG;
							paintbox(winRAM, 3);
							paintbox(winREG, 1);
							ActiveWindow = WIN_REG;
							break;
					}
				}
				else
				{
					int dig = 0, t;
					switch (ch)
					{
						// MAXIMUM MAGIC!
						case 'a' ... 'f':				//case 97 ... 102:
							dig -= 'a' - 'A';			//	dig -= 32;
						case 'A' ... 'F':				//case 65 ... 70:
							--dig;
						case '0' ... '9':				//case 48 ... 57:
							dig += ch - '0';			//	dig += ch - 48
							if ('9' < ch)				//	if (57 < ch)
								dig -= 1 + 'f' - 'a';	//		dig -= 6;
						if (cx < 31)
							t = (cx - 8) % 3;
						else
							t = ((cx - 8) % 3) - 1;	
						Memory[16 * (RAMVPointer - (4 - cy)) + ((cx - 8) / 3)] = ((dig * 0x10 | (Memory[16 * (RAMVPointer - (4 - cy)) + ((cx - 8) / 3)] & 0x0f)) & (!t * 0xff)) + ((dig | (Memory[16 * (RAMVPointer - (4 - cy)) + ((cx - 8) / 3)] & 0xf0)) & (t * 0xff));
						viewram(winRAM, RAMVPointer, 0);
						case KEY_RIGHT:
						{
							if (cx < 31)
							{
								if (cx % 3)
									++cx;
								else
									cx += 2;
								if (cx == 32)
									++cx;
							}
							else
							{
								if (cx % 3)
									cx += 2;
								else
									++cx;
							}
							wmove(winRAM, cy, cx);
							wrefresh (winRAM);//fixme
							if (cx < 57)
								break;
							else
								cx = 8;//FIXME В самом конце
						}
						case KEY_DOWN:
						{
							if (cy > 3)
								RAMVPointer = viewram(winRAM, RAMVPointer, 1);
							else
								++cy;
							wmove(winRAM, cy, cx);
							wrefresh (winRAM);//fixme
						}
						break;
						case KEY_LEFT:
						{
							if (cx > 31)
							{
								if (cx % 3)
									--cx;
								else
									cx -= 2;
								if (cx == 31)
									--cx;
							}
							else
							{
								if (cx % 3)
									cx -= 2;
								else
									--cx;
							}
							wmove(winRAM, cy,cx);
							wrefresh (winRAM);//fixme
							if (cx > 7)
								break;
							else
								if (RAMVPointer == 3)
									cx = 8;
								else
									cx = 55;
						}
						case KEY_UP:
						{
							if (cy <= 1)
								RAMVPointer = viewram(winRAM, RAMVPointer, -1);
							else
								--cy;
							wmove(winRAM, cy, cx);
							wrefresh (winRAM);//fixme
						}
						break;
					}
				}
			}
			break;
			case WIN_PRO:
			{
				
				switch (ch)
				{
					case KEY_UP:
						PROVPointer = viewprog(winProgram, Memory, PROVPointer, -1);
						wrefresh(winProgram);
						break;
					case KEY_DOWN:
						PROVPointer = viewprog(winProgram, Memory, PROVPointer, 1);
						wrefresh(winProgram);
						break;
					case KEY_TAB://FIXME смена активного окна
						//goto TERMINATE;
						ActiveWindow = WIN_MEM;
						paintbox(winProgram, 3);
						paintbox(winRAM, 1);
						ActiveWindow = WIN_MEM;
						break;
				}
			}
			break;
			case WIN_REG:
			{
				switch (ch)
				{
					case KEY_TAB:
					paintbox(winREG, 3);
					paintbox(winTerminal, 1);
					ActiveWindow = WIN_TER;
					
					goto TERMINATE;
					break;
				}
			}
			break;

			case WIN_TER:
			{
				switch (ch)
				{
					case KEY_TAB:
					paintbox(winTerminal, 3);
					paintbox(winProgram, 1);
					ActiveWindow = WIN_PRO;
					break;
				}
			}
			break;
			
			
			
		}
	}
	
	
TERMINATE:
	free(Memory);
	delwin(winRAM);
	delwin(winREG);
	delwin(winTerminal);
//	refresh();
	endwin();
//	sc_regSet(4,1);
//	sc_regSet(1,1);
	
	
	mt_clrscr();
	//bc_printA("\n");

	
	//bc_setbigcharpos(r[3],0,0,0b10000001);
	


int bcint0 [2] = {1717976064, 3958374};	//0b01100110011001100011110000000000, 0b00000000001111000110011001100110
int bcint1 [2] = {1010315264, 3158064};	//0b00111100001110000011000000000000, 0b00000000001100000011000000110000
int bcint2 [2] = {1010842624, 8258050};	//0b00111100010000000011110000000000, 0b00000000011111100000001000000010
int bcint3 [2] = {2120252928, 8282238};	//0b01111110011000000111111000000000, 0b00000000011111100110000001111110
int bcint4 [2] = {2120640000, 6316158};	//0b01111110011001100110011000000000, 0b00000000011000000110000001111110
int bcint5 [2] = {1040350720, 4079680};	//0b00111110000000100111111000000000, 0b00000000001111100100000001000000
int bcint6 [2] = {35789824, 1974814};	//0b00000010001000100001110000000000, 0b00000000000111100010001000011110
int bcint7 [2] = {811630080, 396312};	//0b00110000011000000111111000000000, 0b00000000000001100000110000011000
int bcint8 [2] = {1013332992, 3958374};	//0b00111100011001100011110000000000, 0b00000000001111000110011001100110;
int bcint9 [2] = {2087074816, 3956832};	//0b01111100011001100011110000000000, 0b00000000001111000110000001100000
int bcintA [2] = {2118269952, 4342338};	//0b01111110010000100011110000000000, 0b00000000010000100100001001000010
int bcintB [2] = {1044528640, 4080194};	//0b00111110010000100011111000000000, 0b00000000001111100100001001000010
int bcintC [2] = {37895168, 3949058};	//0b00000010010000100011110000000000, 0b00000000001111000100001000000010
int bcintD [2] = {1111637504, 4080194};	//0b01000010010000100011111000000000, 0b00000000001111100100001001000010
int bcintE [2] = {2114092544, 8258050};	//0b01111110000000100111111000000000, 0b00000000011111100000001000000010
int bcintF [2] = {33717760, 131646};	//0b00000010000000100111111000000000, 0b00000000000000100000001000111110
int bcintp [2] = {2115508224, 1579134};	//0b01111110000110000001100000000000, 0b00000000000110000001100001111110
/*
	
	bc_printbigchar(bcintp, 5, 5, cl_blue, cl_red);
	
	bc_box(2, 1, 50, 20);
*/

	int a;
	rk_readkey(&a);
	printf("%d\n", a);
	return 0;
}
Exemple #8
0
int main(int argc, char *argv[])
{
	//initialize global variable
	index1=0; // index of movie list
	index2=0; // index of smi list
	index_inside_movie=TRUE;

	// initialize varables
	int ch;
	WIN win;	
	WIN win2;
	WINDOW *popup_win;
	
	// init ncurses window
	initscr();
	cbreak();
	//raw();
	keypad(stdscr, TRUE);
	noecho();
	curs_set(0);
	if(has_colors() == FALSE) { endwin();
		printf("Your terminal does not support color\n");
		exit(1);
	}
	start_color();
	init_pair(1, COLOR_BLACK, COLOR_WHITE);
	init_pair(2, COLOR_BLACK, COLOR_YELLOW);

	// print headline
	int start_line_number = print_headline();

	// load local files.
	loadFiles(".");

	// sorting
	std::sort(vMovieFiles.begin(), vMovieFiles.end(), sortOp);
	std::sort(vSmiFiles.begin(), vSmiFiles.end(), sortOp);

	// listFiles return 0 when no error
	if(listFiles() == 0)
	{

	init_win_params(&win, start_line_number+2, 0, 0, vMovieFiles.size() + 1);
	init_win_params(&win2, start_line_number+3+vMovieFiles.size()+3, 0, 0, vSmiFiles.size() + 1);
	create_box(&win, TRUE,1);
	create_box2(&win2, TRUE,1);

	while( (ch = getch()) != 'q')
	{
		switch(ch)
		{

			case 'j':
			case KEY_DOWN:
				{
					create_box(&win, FALSE,1);
					create_box(&win2, FALSE,1);

					if(index_inside_movie == TRUE) {
						if(index1 == vMovieFiles.size()-1) {
							index1 = 0;
						} else
						{
							index1++;
						}
					} else {
						if(index2 == vSmiFiles.size()-1) {
							index2 =0;
						} else
						{
							index2++;
						}
					}
					create_box(&win, TRUE,1);
					create_box2(&win2, TRUE,1);
					break;
				}
				
			case 'k':
			case KEY_UP:
				{
					create_box(&win, FALSE,1);
					create_box(&win2, FALSE,1);

					if(index_inside_movie == TRUE) {
						if(index1 == 0) {
							index1 = vMovieFiles.size()-1;
						} else
						{
							index1--;
						}
					} else {
						if(index2 == 0) {
							index2 = vSmiFiles.size()-1;
						} else
						{
							index2--;
						}
					}
					create_box(&win, TRUE,1);
					create_box2(&win2, TRUE,1);
					break;
				}

			case '\t':
			case KEY_BTAB:
				{
					index_inside_movie = !index_inside_movie; 
					create_box(&win, TRUE,1);
					create_box2(&win2, TRUE,1);
					break;
				}
			case 'd':
				{
					std::string popup_msg = "delete?(d/esc)";
					popup_win = create_win(3, popup_msg.length()+3, start_line_number+5,(int)COLS/2-popup_msg.length(),popup_msg);
					wrefresh(popup_win);
					
					int ch2;
					while( (ch2=getch()) != 'e')
					{
						switch(ch2)
						{
							case 'd':
							{
								if(index_inside_movie)
								{
									std::vector<std::string>::iterator iter1=vMovieFiles.begin();
								if(vMovieFiles.size()!=1){
									if(index1 == vMovieFiles.size()-1){
										vMovieFiles.erase(iter1 + index1);
										index1--;
									} else
										vMovieFiles.erase(iter1 + index1);
								}
								start_line_number = print_headline();
								init_win_params(&win, start_line_number+2, 0, 0, vMovieFiles.size() + 1);
								init_win_params(&win2, start_line_number+3+vMovieFiles.size()+3, 0, 0, vSmiFiles.size() + 1);

								} else
								{
									std::vector<std::string>::iterator iter2=vSmiFiles.begin();
								if(vSmiFiles.size()!=1){
									if(index2 == vSmiFiles.size()-1){
										vSmiFiles.erase(iter2 + index2);
										index2--;
									} else
										vSmiFiles.erase(iter2 + index2);
								}
								start_line_number = print_headline();
								init_win_params(&win, start_line_number+2, 0, 0, vMovieFiles.size() + 1);
								init_win_params(&win2, start_line_number+3+vMovieFiles.size()+3, 0, 0, vSmiFiles.size() + 1);

								}
								break;
							}
							case 'e':
							{
								delwin(popup_win);
								break;
							}
						} // switch
						if(ch2 == 'd')
							break;
					} //while

					clear();
					int start_line_number = print_headline();
					create_box(&win, TRUE,1);
					create_box2(&win2, TRUE,1);

					break;
				} // case d

			case ' ': //case space for selection to move
				{
					
					create_box(&win, TRUE,2);
					create_box2(&win2, TRUE,2);
					wrefresh(stdscr);

					std::string popup_msg = "down/up/esc?(j/k/e)";
					popup_win = create_win(3, popup_msg.length()+3, start_line_number+5,(int)COLS/2-popup_msg.length()/2,popup_msg);
					wrefresh(popup_win);
					
					int ch3;
					while( (ch3=getch()) != 'e')
					{
						switch(ch3)
						{
							case 'j':
							case KEY_DOWN:
							{
								swapVector(true);
								break;
							}
							case 'k':
							case KEY_UP:
							{
								swapVector(false);
								break;
							}
							case 'e':
							{
								delwin(popup_win);
								break;
							}
						} // end of switch	
						
					if(ch3 == 'j' || ch3 == 'k' || ch3 == KEY_DOWN || ch3 == KEY_UP)
						break;
					} // while

					clear();
					int start_line_number = print_headline();
					create_box(&win, TRUE,1);
					create_box2(&win2, TRUE,1);

					break; //end of case space
				} // case space

			case 'y':
				{

					// if counts are mismatched
					if(vMovieFiles.size() != vSmiFiles.size())
					{
						std::string popup_msg = "Mismatch Error! (e)";
						popup_win = create_win(3, popup_msg.length()+3, start_line_number+5,(int)COLS/2-popup_msg.length()/2,popup_msg);
						wrefresh(popup_win);

						int ch5;
						while ( (ch5=getch()) != 'e')
						{
							switch(ch5)
							{
								case 'e':
								{
									delwin(popup_win);
									break;
								}
							}
							if(ch5 == 'e')
								break;
						}

						clear();
						int start_line_number = print_headline();
						create_box(&win, TRUE,1);
						create_box2(&win2, TRUE,1);
						break;
					} // end of if statement = counts are mismatched

					std::string popup_msg = "confirm?(m)ovies (s)ubtitle(m/s/e)";
					popup_win = create_win(3, popup_msg.length()+3, start_line_number+5,(int)COLS/2-popup_msg.length()/2,popup_msg);
					wrefresh(popup_win);
					
					int ch4;
					while( (ch4=getch()) != 'e')
					{
						switch(ch4)
						{
							case 'm':
							{
								int err = renameSmiFiles();
								std::cout << "err: " << err << std::endl;
								break;
							}
							case 's':
							{
								int err = renameAviFiles();
								std::cout << "err: " << err << std::endl;
								break;
							}
							case 'e':
							{
								delwin(popup_win);
								break;
							}
						} // end of switch	
					if(ch4 == 'm' || ch4 == 's')
						break;
					} // while

					// rename it then files reloading
					// load local files.
					loadFiles(".");

					// sorting
					std::sort(vMovieFiles.begin(), vMovieFiles.end(), sortOp);
					std::sort(vSmiFiles.begin(), vSmiFiles.end(), sortOp);

					clear();
					init_win_params(&win, start_line_number+2, 0, 0, vMovieFiles.size() + 1);
					init_win_params(&win2, start_line_number+3+vMovieFiles.size()+3, 0, 0, vSmiFiles.size() + 1);
					int start_line_number = print_headline();
					create_box(&win, TRUE,1);
					create_box2(&win2, TRUE,1);

					break; // end of case y
				} // case y
		} // switch
	} // while
		
	}
	else
	{
		endwin();
		std::cout << "You don't have No relative files... Bye..." << std::endl;	
		return 1;
	}
	
	// delete ncurses window
	endwin();

	return 0;
} //end of main
int ompi_attr_create_predefined(void)
{
    int ret;
    char *univ_size;
    int usize;

    /* Create all the keyvals */

    /* DO NOT CHANGE THE ORDER OF CREATING THESE KEYVALS!  This order
       strictly adheres to the order in mpi.h.  If you change the
       order here, you must change the order in mpi.h as well! */

    if (OMPI_SUCCESS != (ret = create_comm(MPI_TAG_UB, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_HOST, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_IO, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_WTIME_IS_GLOBAL, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_APPNUM, true)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_LASTUSEDCODE, false)) ||
        OMPI_SUCCESS != (ret = create_comm(MPI_UNIVERSE_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_BASE)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_SIZE)) ||
        OMPI_SUCCESS != (ret = create_win(MPI_WIN_DISP_UNIT)) ||
#if 0
        /* JMS For when we implement IMPI */
        OMPI_SUCCESS != (ret = create_comm(IMPI_CLIENT_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_CLIENT_COLOR, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_HOST_SIZE, true)) ||
        OMPI_SUCCESS != (ret = create_comm(IMPI_HOST_COLOR, true)) ||
#endif
        0) {
        return ret;
    }

    /* Set default values for everything except MPI_UNIVERSE_SIZE */

    if (OMPI_SUCCESS != (ret = set_f(MPI_TAG_UB, mca_pml.pml_max_tag)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_HOST, MPI_PROC_NULL)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_IO, MPI_ANY_SOURCE)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_WTIME_IS_GLOBAL, 0)) ||
        OMPI_SUCCESS != (ret = set_f(MPI_LASTUSEDCODE,
                                     ompi_mpi_errcode_lastused)) ||
#if 0
        /* JMS For when we implement IMPI */
        OMPI_SUCCESS != (ret = set(IMPI_CLIENT_SIZE,
                                   &attr_impi_client_size)) ||
        OMPI_SUCCESS != (ret = set(IMPI_CLIENT_COLOR,
                                   &attr_impi_client_color)) ||
        OMPI_SUCCESS != (ret = set(IMPI_HOST_SIZE,
                                   &attr_impi_host_size)) ||
        OMPI_SUCCESS != (ret = set(IMPI_HOST_COLOR,
                                   &attr_impi_host_color)) ||
#endif
        0) {
        return ret;
    }

    /* If the universe size is set, then use it. Otherwise default
     * to the size of MPI_COMM_WORLD */
    univ_size = getenv("OMPI_UNIVERSE_SIZE");
    if (NULL == univ_size || (usize = strtol(univ_size, NULL, 0)) <= 0) {
        ret = set_f(MPI_UNIVERSE_SIZE, ompi_comm_size(MPI_COMM_WORLD));
    } else {
        ret = set_f(MPI_UNIVERSE_SIZE, usize);
    }
    if (OMPI_SUCCESS != ret) {
        return ret;
    }
    
    /* check the app_num - if it was set, then define it - otherwise, don't */
    if (orte_process_info.app_num >= 0) {
        ret = set_f(MPI_APPNUM, orte_process_info.app_num);
    }
    
    return ret;
}
Exemple #10
0
/*
*点击登陆按钮时执行
*/
void on_login(GtkWidget *button, gpointer data)
{
    create_win();
}
Exemple #11
0
int xinput_init()
{
  int ret = 0;
  int event, error;
  int m_num = 0;
  int k_num = 0;

  memset(devices, 0x00, sizeof(devices));
  nb_devices = 0;

  unsigned int i;
  for(i=0; i<sizeof(device_index)/sizeof(*device_index); ++i)
  {
    device_index[i] = -1;
  }

  dpy = XOpenDisplay(NULL);

  if (!dpy)
  {
    fprintf(stderr, "Failed to open display.\n");
    return -1;
  }

  if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error))
  {
    fprintf(stderr, "X Input extension not available.\n");
    return -1;
  }

  win = create_win(dpy);

  int nxdevices;
  XIDeviceInfo *xdevices, *xdevice;

  xdevices = XIQueryDevice(dpy, XIAllDevices, &nxdevices);

  for (i = 0; nxdevices > 0 && i < (unsigned int) nxdevices; i++)
  {
      xdevice = &xdevices[i];

      if(xdevice->deviceid >= GE_MAX_DEVICES)
      {
        continue;
      }

      device_index[xdevice->deviceid] = nb_devices;

      switch(xdevice->use) {
         case XISlaveKeyboard:
           devices[nb_devices].type = DEVTYPE_KEYBOARD;
           devices[nb_devices].id = k_num;
           ++k_num;
           break;
         case XISlavePointer:
           devices[nb_devices].type = DEVTYPE_MOUSE;
           devices[nb_devices].id = m_num;
           ++m_num;
           break;
      }

      if(devices[nb_devices].type)
      {
        devices[nb_devices].name = strdup(xdevice->name);
        ++nb_devices;
      }
  }

  XIFreeDeviceInfo(xdevices);

  ev_register_source(ConnectionNumber(dpy), i, &xinput_process_events, NULL, &xinput_close);

  XEvent xevent;

  /* get info about current pointer position */
  XQueryPointer(dpy, DefaultRootWindow(dpy),
  &xevent.xbutton.root, &xevent.xbutton.window,
  &xevent.xbutton.x_root, &xevent.xbutton.y_root,
  &xevent.xbutton.x, &xevent.xbutton.y,
  &xevent.xbutton.state);

  mouse_coordinates.x = xevent.xbutton.x;
  mouse_coordinates.y = xevent.xbutton.y;

  return ret;
}
Exemple #12
0
int
test_xi2(Display	*display,
         int	argc,
         char	*argv[],
         char	*name,
         char	*desc)
{
    XIEventMask mask[2];
    XIEventMask *m;
    Window win;
    int deviceid = -1;
    int use_root = 0;
    int rc;

    setvbuf(stdout, NULL, _IOLBF, 0);

    if (argc >= 1 && strcmp(argv[0], "--root") == 0) {
        use_root = 1;

        argc--;
        argv++;
    }

    rc = list(display, argc, argv, name, desc);
    if (rc != EXIT_SUCCESS)
        return rc;

    if (use_root)
        win = DefaultRootWindow(display);
    else
        win = create_win(display);

    if (argc >= 1) {
        XIDeviceInfo *info;
        info = xi2_find_device_info(display, argv[0]);
        deviceid = info->deviceid;
    }

    /* Select for motion events */
    m = &mask[0];
    m->deviceid = (deviceid == -1) ? XIAllDevices : deviceid;
    m->mask_len = XIMaskLen(XI_LASTEVENT);
    m->mask = calloc(m->mask_len, sizeof(char));
    XISetMask(m->mask, XI_ButtonPress);
    XISetMask(m->mask, XI_ButtonRelease);
    XISetMask(m->mask, XI_KeyPress);
    XISetMask(m->mask, XI_KeyRelease);
    XISetMask(m->mask, XI_Motion);
    XISetMask(m->mask, XI_DeviceChanged);
    XISetMask(m->mask, XI_Enter);
    XISetMask(m->mask, XI_Leave);
    XISetMask(m->mask, XI_FocusIn);
    XISetMask(m->mask, XI_FocusOut);
#ifdef HAVE_XI22
    XISetMask(m->mask, XI_TouchBegin);
    XISetMask(m->mask, XI_TouchUpdate);
    XISetMask(m->mask, XI_TouchEnd);
#endif
    if (m->deviceid == XIAllDevices)
        XISetMask(m->mask, XI_HierarchyChanged);
    XISetMask(m->mask, XI_PropertyEvent);

    m = &mask[1];
    m->deviceid = (deviceid == -1) ? XIAllMasterDevices : deviceid;
    m->mask_len = XIMaskLen(XI_LASTEVENT);
    m->mask = calloc(m->mask_len, sizeof(char));
    XISetMask(m->mask, XI_RawKeyPress);
    XISetMask(m->mask, XI_RawKeyRelease);
    XISetMask(m->mask, XI_RawButtonPress);
    XISetMask(m->mask, XI_RawButtonRelease);
    XISetMask(m->mask, XI_RawMotion);
#ifdef HAVE_XI22
    XISetMask(m->mask, XI_RawTouchBegin);
    XISetMask(m->mask, XI_RawTouchUpdate);
    XISetMask(m->mask, XI_RawTouchEnd);
#endif

    XISelectEvents(display, win, &mask[0], use_root ? 2 : 1);
    if (!use_root) {
        XISelectEvents(display, DefaultRootWindow(display), &mask[1], 1);
        XMapWindow(display, win);
    }
    XSync(display, False);

    free(mask[0].mask);
    free(mask[1].mask);

    if (!use_root) {
        XEvent event;
        XMaskEvent(display, ExposureMask, &event);
        XSelectInput(display, win, 0);
    }

    /*
    test_sync_grab(display, win);
    */

    while(1)
    {
        XEvent ev;
        XGenericEventCookie *cookie = (XGenericEventCookie*)&ev.xcookie;
        XNextEvent(display, (XEvent*)&ev);

        if (XGetEventData(display, cookie) &&
                cookie->type == GenericEvent &&
                cookie->extension == xi_opcode)
        {
            printf("EVENT type %d (%s)\n", cookie->evtype, type_to_name(cookie->evtype));
            switch (cookie->evtype)
            {
            case XI_DeviceChanged:
                print_devicechangedevent(display, cookie->data);
                break;
            case XI_HierarchyChanged:
                print_hierarchychangedevent(cookie->data);
                break;
            case XI_RawKeyPress:
            case XI_RawKeyRelease:
            case XI_RawButtonPress:
            case XI_RawButtonRelease:
            case XI_RawMotion:
            case XI_RawTouchBegin:
            case XI_RawTouchUpdate:
            case XI_RawTouchEnd:
                print_rawevent(cookie->data);
                break;
            case XI_Enter:
            case XI_Leave:
            case XI_FocusIn:
            case XI_FocusOut:
                print_enterleave(cookie->data);
                break;
            case XI_PropertyEvent:
                print_propertyevent(display, cookie->data);
                break;
            default:
                print_deviceevent(cookie->data);
                break;
            }
        }

        XFreeEventData(display, cookie);
    }

    XDestroyWindow(display, win);

    return EXIT_SUCCESS;
}
void
cmd_ctest(char **args)
{
    if (strcmp(args[0], "consalert") == 0) {
        create_win();
        prof_win_focus(plugin_win);
        prof_cons_alert();
        prof_win_show(plugin_win, "called -> prof_cons_alert");
    } else if (strcmp(args[0], "consshow") == 0) {
        if (args[1]) {
            create_win();
            prof_win_focus(plugin_win);
            prof_cons_show(args[1]);
            char *str = "called -> prof_cons_show: ";
            char buf[strlen(str) + strlen(args[1])];
            sprintf(buf, "%s%s", str, args[1]);
            prof_win_show(plugin_win, buf);
        } else {
            prof_cons_bad_cmd_usage("/c-test");
        }
    } else if (strcmp(args[0], "consshow_t") == 0) {
        if (args[1] == NULL || args[2] == NULL || args[3] == NULL || args[4] == NULL) {
            prof_cons_bad_cmd_usage("/c-test");
        } else {
            char *group = strcmp(args[1], "none") == 0 ? NULL : args[1];
            char *key = strcmp(args[2], "none") == 0 ? NULL : args[2];
            char *def = strcmp(args[3], "none") == 0 ? NULL : args[3];
            char *message = args[4];
            create_win();
            prof_win_focus(plugin_win);
            prof_cons_show_themed(group, key, def, message);
            char *str = "called -> prof_cons_show_themed: ";
            char buf[strlen(str) + strlen(args[1]) + 2 + strlen(args[2]) + 2 + strlen(args[3]) + 2 + strlen(args[4])];
            sprintf(buf, "%s%s, %s, %s, %s", str, args[1], args[2], args[3], args[4]);
            prof_win_show(plugin_win, buf);
        }
    } else if (strcmp(args[0], "constest") == 0) {
        int res = prof_current_win_is_console();
        create_win();
        prof_win_focus(plugin_win);
        if (res) {
            prof_win_show(plugin_win, "called -> prof_current_win_is_console: true");
        } else {
            prof_win_show(plugin_win, "called -> prof_current_win_is_console: false");
        }
    } else if (strcmp(args[0], "winshow") == 0) {
        if (args[1]) {
            create_win();
            prof_win_focus(plugin_win);
            prof_win_show(plugin_win, args[1]);
            char *str = "called -> prof_win_show: ";
            char buf[strlen(str) + strlen(args[1])];
            sprintf(buf, "%s%s", str, args[1]);
            prof_win_show(plugin_win, buf);
        } else {
            prof_cons_bad_cmd_usage("/c-test");
        }
    } else if (strcmp(args[0], "winshow_t") == 0) {
        if (args[1] == NULL || args[2] == NULL || args[3] == NULL || args[4] == NULL) {
            prof_cons_bad_cmd_usage("/c-test");
        } else {
            char *group = strcmp(args[1], "none") == 0 ? NULL : args[1];
            char *key = strcmp(args[2], "none") == 0 ? NULL : args[2];
            char *def = strcmp(args[3], "none") == 0 ? NULL : args[3];
            char *message = args[4];
            create_win();
            prof_win_focus(plugin_win);
            prof_win_show_themed(plugin_win, group, key, def, message);
            char *str = "called -> prof_win_show_themed: ";
            char buf[strlen(str) + strlen(args[1]) + 2 + strlen(args[2]) + 2 + strlen(args[3]) + 2 + strlen(args[4])];
            sprintf(buf, "%s%s, %s, %s, %s", str, args[1], args[2], args[3], args[4]);
            prof_win_show(plugin_win, buf);
        }
    } else if (strcmp(args[0], "sendline") == 0) {
        if (args[1]) {
            create_win();
            prof_win_focus(plugin_win);
            prof_send_line(args[1]);
            char *str = "called -> prof_send_line: ";
            char buf[strlen(str) + strlen(args[1])];
            sprintf(buf, "%s%s", str, args[1]);
            prof_win_show(plugin_win, buf);
        } else {
            prof_cons_bad_cmd_usage("/c-test");
        }
    } else if (strcmp(args[0], "notify") == 0) {
        if (args[1]) {
            create_win();
            prof_win_focus(plugin_win);
            prof_notify(args[1], 5000, "c-test plugin");
            char *str = "called -> prof_notify: ";
            char buf[strlen(str) + strlen(args[1])];
            sprintf(buf, "%s%s", str, args[1]);
            prof_win_show(plugin_win, buf);
        } else {
            prof_cons_bad_cmd_usage("/c-test");
        }
    } else if (strcmp(args[0], "get") == 0) {
        if (!args[1]) {
            prof_cons_bad_cmd_usage("/c-test");
        } else if (strcmp(args[1], "recipient") == 0) {
            create_win();
            char *recipient = prof_get_current_recipient();
            if (recipient) {
                prof_win_focus(plugin_win);
                char *str = "called -> prof_get_current_recipient: ";
                char buf[strlen(str) + strlen(recipient)];
                sprintf(buf, "%s%s", str, recipient);
                prof_win_show(plugin_win, buf);
            } else {
                prof_win_focus(plugin_win);
                prof_win_show(plugin_win, "called -> prof_get_current_recipient: <none>");
            }
        } else if (strcmp(args[1], "room") == 0) {
            create_win();
            char *room = prof_get_current_muc();
            if (room) {
                prof_win_focus(plugin_win);
                char *str = "called -> prof_get_current_muc: ";
                char buf[strlen(str) + strlen(room)];
                sprintf(buf, "%s%s", str, room);
                prof_win_show(plugin_win, buf);
            } else {
                prof_win_focus(plugin_win);
                prof_win_show(plugin_win, "called -> prof_get_current_muc: <none>");
            }
        } else {
            prof_cons_bad_cmd_usage("/c-test");
        }
    } else if (strcmp(args[0], "log") == 0) {
        if (!args[1]) {
            prof_cons_bad_cmd_usage("/c-test");
        } else if (strcmp(args[1], "debug") == 0) {
            if (!args[2]) {
                prof_cons_bad_cmd_usage("/c-test");
            } else {
                create_win();
                prof_win_focus(plugin_win);
                prof_log_debug(args[2]);
                char *str = "called -> prof_log_debug: ";
                char buf[strlen(str) + strlen(args[2])];
                sprintf(buf, "%s%s", str, args[2]);
                prof_win_show(plugin_win, buf);
            }
        } else if (strcmp(args[1], "info") == 0) {
            if (!args[2]) {
                prof_cons_bad_cmd_usage("/c-test");
            } else {
                create_win();
                prof_win_focus(plugin_win);
                prof_log_info(args[2]);
                char *str = "called -> prof_log_info: ";
                char buf[strlen(str) + strlen(args[2])];
                sprintf(buf, "%s%s", str, args[2]);
                prof_win_show(plugin_win, buf);
            }
        } else if (strcmp(args[1], "warning") == 0) {
            if (!args[2]) {
                prof_cons_bad_cmd_usage("/c-test");
            } else {
                create_win();
                prof_win_focus(plugin_win);
                prof_log_warning(args[2]);
                char *str = "called -> prof_log_warning: ";
                char buf[strlen(str) + strlen(args[2])];
                sprintf(buf, "%s%s", str, args[2]);
                prof_win_show(plugin_win, buf);
            }
        } else if (strcmp(args[1], "error") == 0) {
            if (!args[2]) {
                prof_cons_bad_cmd_usage("/c-test");
            } else {
                create_win();
                prof_win_focus(plugin_win);
                prof_log_error(args[2]);
                char *str = "called -> prof_log_error: ";
                char buf[strlen(str) + strlen(args[2])];
                sprintf(buf, "%s%s", str, args[2]);
                prof_win_show(plugin_win, buf);
            }
        } else {
            prof_cons_bad_cmd_usage("/c-test");
        }
    } else if (strcmp(args[0], "count") == 0) {
        create_win();
        prof_win_focus(plugin_win);
        char buf[100];
        sprintf(buf, "Count: %d", count);
        prof_win_show(plugin_win, buf);
    } else {
        prof_cons_bad_cmd_usage("/c-test");
    }
}
void
prof_on_shutdown(void)
{
    create_win();
    prof_win_show(plugin_win, "fired -> prof_on_shutdown");
}
void
prof_on_start(void)
{
    create_win();
    prof_win_show(plugin_win, "fired -> prof_on_start");
}
void
timed_callback(void)
{
    create_win();
    prof_win_show(plugin_win, "timed -> timed_callback called");
}