예제 #1
11
QList<QAction*> ScreenSaver::availableActions()
{
    QList<QAction*> ret;
    QAction * act;

    act = new QAction(XdgIcon::fromTheme("system-lock-screen"), tr("Lock Screen"), this);
    connect(act, SIGNAL(triggered()), this, SLOT(lockScreen()));
    ret.append(act);

    return ret;
}
예제 #2
0
PanelScreenSaver::PanelScreenSaver(const ILxQtPanelPluginStartupInfo &startupInfo) :
    QObject(),
    ILxQtPanelPlugin(startupInfo)
{
    mSaver = new LxQt::ScreenSaver(this);

    QList<QAction*> actions = mSaver->availableActions();
    if (!actions.empty())
        mButton.setDefaultAction(actions.first());
    //mButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    mShortcutKey = GlobalKeyShortcut::Client::instance()->addAction(QString(), QString("/panel/%1/lock").arg(settings()->group()), tr("Lock Screen"), this);
    if (mShortcutKey)
    {
        connect(mShortcutKey, SIGNAL(activated()), mSaver, SLOT(lockScreen()));

        if (mShortcutKey->shortcut().isEmpty())
        {
            mShortcutKey->changeShortcut(DEFAULT_SHORTCUT);
            if (mShortcutKey->shortcut().isEmpty())
            {
                LxQt::Notification::notify(tr("Panel Screensaver: Global shortcut '%1' cannot be registered").arg(DEFAULT_SHORTCUT));
            }
        }
    }
}
예제 #3
0
int main(int argc, char **argv)
{
	if (argc == 2 && !strcmp(argv[1], "off")) {
		unlockScreen();
	} else if (argc == 3 && !strcmp(argv[1], "on")) {
		CFStringRef str =
			CFStringCreateWithCString(NULL,
			                          argv[2],
			                          kCFStringEncodingUTF8);
		lockScreen(str, NULL);
		CFRelease(str);
	} else if (argc == 2 && !strcmp(argv[1], "on")) {
		lockScreen(NULL, NULL);
	} else {
		printf("usage: %s on [MESSAGE]\n", argv[0]);
		printf("       %s off\n", argv[0]);
		return 1;
	}

	return 0;
}
IOReturn NoSleepExtension::clamshellEventInterestHandler(UInt32 messageType, IOService * provider,
                                                         void * messageArgument, vm_size_t argSize)
{
    if(messageType == kIOPMMessageClamshellStateChange)
    {
#ifdef DEBUG
        IOLog("%s[%p]::%s(%u, %p, %p, %lu)\n", getName(), this, __FUNCTION__,
              (unsigned int)messageType, provider, messageArgument, (long unsigned int)argSize);
#endif
        
        clamshellState = (bool)(((uintptr_t)messageArgument) & kClamshellStateBit);
        clamshellShouldSleep = (bool)(((uintptr_t)messageArgument) & kClamshellSleepBit);
        isClamshellStateInitialized = true;
        
        if((getCurrentSleepSuppressionState() == kNoSleepStateEnabled)) {
            setUserSleepDisabled(true);
            
            UInt64 deadline;
            clock_interval_to_deadline(10, kSecondScale, &deadline);
            thread_call_enter_delayed(delayTimer, deadline);
            
            if(clamshellShouldSleep) {
                pRootDomain->receivePowerNotification(kIOPMDisableClamshell);
            }

            // Lock screen when lid closed
            if(clamshellState == true && oldClamshellState == false) {
                lockScreen();
                //notify_
                //notify_post("com.apple.loginwindow.notify");
                //mach_port_t bp = bootstrap_port;
                //task_get_bootstrap_port(bootstrap_port, &bp);
            }
        }
        
        oldClamshellState = clamshellState;
    } 
    
    return kIOReturnSuccess;
}
예제 #5
0
void TopLevelWindowManager::slotScreenLocked(int state)
{
	switch (state) {
	case LockWindow::ScreenUnlocked: {
		// notify the WindowServer that the other layers should be visible again
		Q_EMIT signalScreenLockStatusChanged(false);
		unlockScreen();
	}
	break;
	
	case LockWindow::ScreenLocking: {
		lockScreen();
	}
	break;
	
	case LockWindow::ScreenLocked: {
		// notify the WindowServer that all other layers should be made invisible
		Q_EMIT signalScreenLockStatusChanged(true);
	}
	break;
	
	}
}
예제 #6
0
파일: tihos.c 프로젝트: dforsi/tihos
/* Main program and UI creation */
int main (int argc, char *argv[]) {
    g_type_init();
    gtk_init(&argc, &argv);

    bindtextdomain("tihos", PACKAGE_LOCALE_DIR);
    bind_textdomain_codeset("tihos", "UTF-8");
    textdomain("tihos");

    createUI();
    updateBattery();
    refreshWindowList();

    /* Check if to start with screen lock */
    if (argc > 1) {
        if (strcmp(argv[1], "--lock") == 0) {
            lockScreen(NULL, NULL);
        }
    }
 
    /* Key grabbing and looping depending on where we are */
    while (1) {
        if (isLocked()) {
            while (gtk_events_pending()) {
                gtk_main_iteration();
            }
            handleX();
        }
        else if (isMainVisible()) {
            while (gtk_events_pending()) {
                gtk_main_iteration();
            }
        }
        else {
            handleX();
        }
    }
}
예제 #7
0
int aboutMenu()
{
	aboutBg = sf2d_create_texture_mem_RGBA8(about_img.pixel_data, about_img.width, about_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	highlight = sf2d_create_texture_mem_RGBA8(highlight_img.pixel_data, highlight_img.width, highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(aboutBg, 0, 0);
		
		sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][0]);
		sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][1]);
		sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][2]);
		//sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		sftd_draw_textf(roboto, 20, 168, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][5]);
		//sftd_draw_textf(roboto, 20, 183, RGBA8(0, 0, 0, 255), 12, "NinjaHax version: NULL");
		
		if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 58 && touch.py <= 105)
		{
			sf2d_draw_texture(highlight, 0, 56);
			sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS Updates");
			sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "Click for, view or isntall available updates");
		}
		else if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 106 && touch.py <= 157)
		{
			sf2d_draw_texture(highlight, 0, 105);
			sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS version: 0.01-20151019-UNOFFICIAL");
			sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		}
		 
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1);
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	sf2d_free_texture(aboutBg);
	sf2d_free_texture(highlight);

	return 0;
}
예제 #8
0
int settingsMenu()
{
	settingsBg = sf2d_create_texture_mem_RGBA8(settings_img.pixel_data, settings_img.width, settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	about_highlight = sf2d_create_texture_mem_RGBA8(about_highlight_img.pixel_data, about_highlight_img.width, about_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	display_highlight = sf2d_create_texture_mem_RGBA8(display_highlight_img.pixel_data, display_highlight_img.width, display_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	developeroptions_highlight = sf2d_create_texture_mem_RGBA8(developeroptions_highlight_img.pixel_data, developeroptions_highlight_img.width, developeroptions_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	performance_highlight = sf2d_create_texture_mem_RGBA8(performance_highlight_img.pixel_data, performance_highlight_img.width, performance_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	security_highlight = sf2d_create_texture_mem_RGBA8(security_highlight_img.pixel_data, security_highlight_img.width, security_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	wifi_highlight = sf2d_create_texture_mem_RGBA8(wifi_highlight_img.pixel_data, wifi_highlight_img.width, wifi_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);

	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(settingsBg, 0, 0);
		
		sftd_draw_textf(roboto, 48, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][0]);
		sftd_draw_textf(roboto, 48, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][1]);
		sftd_draw_textf(roboto, 48, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][2]);
		sftd_draw_textf(roboto, 250, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][3]);
		sftd_draw_textf(roboto, 250, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][4]);
		sftd_draw_textf(roboto, 250, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][5]);
		
		settingsHighlight();
		
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1); 
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			settingsUnload();
			appDrawer();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			settingsUnload();
			appDrawer();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			settingsUnload();
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	settingsUnload();
	
	return 0;
}
예제 #9
0
void BaseBackend::fillScreen(uint32 col) {
	Graphics::Surface *screen = lockScreen();
	if (screen && screen->getPixels())
		memset(screen->getPixels(), col, screen->h * screen->pitch);
	unlockScreen();
}
예제 #10
0
int home()
{
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));

	ic_allapps_pressed = sf2d_create_texture_mem_RGBA8(ic_allapps_pressed_img.pixel_data, ic_allapps_pressed_img.width, ic_allapps_pressed_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	ic_launcher_browser = sf2d_create_texture_mem_RGBA8(ic_launcher_browser_img.pixel_data, ic_launcher_browser_img.width, ic_launcher_browser_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_messenger = sf2d_create_texture_mem_RGBA8(ic_launcher_messenger_img.pixel_data, ic_launcher_messenger_img.width, ic_launcher_messenger_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_apollo = sf2d_create_texture_mem_RGBA8(ic_launcher_apollo_img.pixel_data, ic_launcher_apollo_img.width, ic_launcher_apollo_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_settings = sf2d_create_texture_mem_RGBA8(ic_launcher_settings_img.pixel_data, ic_launcher_settings_img.width, ic_launcher_settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	// Main loop
	while (aptMainLoop())
	{

		//Scan all the inputs. This should be done once for each frame
		hidScanInput();
		
		//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
		u32 kDown = hidKeysDown();
		//hidKeysUp returns information about which buttons have been just released
		//u32 kUp = hidKeysUp();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(background, 0, 0);
		
		sf2d_draw_texture(ic_launcher_browser, 49, 145);
		sf2d_draw_texture(ic_launcher_messenger, 114, 145);
		sf2d_draw_texture(ic_launcher_apollo, 241, 145);
		sf2d_draw_texture(ic_launcher_settings, 306, 145);
		appDrawerIcon();

		dayNightWidget();
		
		navbarControls(0); //Displays navbar
		digitalTime(350, 2); //Displays digital time
		batteryStatus(316, 2); //Displays battery status
		cursorController();
		
		sf2d_end_frame();
		
		if ((touch.px  >= 170 && touch.px  <= 210 && touch.py >= 148 && touch.py <= 190) && (kDown & KEY_A))
		{
			sf2d_free_texture(ic_allapps_pressed);
			appDrawer(); //Open app drawer
		}
		
		if ((touch.px  >= 306 && touch.px  <= 351 && touch.py >= 145 && touch.py <= 190) && (kDown & KEY_A))
		{
			sf2d_free_texture(ic_allapps_pressed);
			settingsMenu(); //Open settings menu
		}
		
		if (kDown & KEY_Y)
			powerMenu(); //Open power menu
		
		if (kDown & KEY_L)
			lockScreen(); //Locks the screen

		// Flush and swap framebuffers
		sf2d_swapbuffers();
	}

	sf2d_free_texture(ic_allapps_pressed);
	
	return 0;
}
예제 #11
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;
}