Diff

Differences From Artifact [58d0bd8c65]:

To Artifact [3ac07673b0]:


77
78
79
80
81
82
83

84
85
86
87
88
89
90
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91







+







    void *logctx;
    int exited;
    struct unicode_data ucsdata;
    Config cfg;
    void *eventlogstuff;
    char *progname, **gtkargvstart;
    int ngtkargs;
    guint32 input_event_time; /* Timestamp of the most recent input event. */
};

struct draw_ctx {
    GdkGC *gc;
    struct gui_data *inst;
};

443
444
445
446
447
448
449



450
451
452
453
454
455
456
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460







+
+
+







gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;
    char output[32];
    wchar_t ucsoutput[2];
    int ucsval, start, end, special, use_ucsoutput;

    /* Remember the timestamp. */
    inst->input_event_time = event->time;

    /* By default, nothing is generated. */
    end = start = 0;
    special = use_ucsoutput = FALSE;

    /*
     * If Alt is being released after typing an Alt+numberpad
     * sequence, we should generate the code that was typed.
1017
1018
1019
1020
1021
1022
1023



1024
1025
1026
1027
1028
1029
1030
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037







+
+
+







}

gint button_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;
    int shift, ctrl, alt, x, y, button, act;

    /* Remember the timestamp. */
    inst->input_event_time = event->time;

    show_mouseptr(inst, 1);

    if (event->button == 4 && event->type == GDK_BUTTON_PRESS) {
	term_scroll(inst->term, 0, -5);
	return TRUE;
    }
    if (event->button == 5 && event->type == GDK_BUTTON_PRESS) {
1073
1074
1075
1076
1077
1078
1079



1080
1081
1082
1083
1084
1085
1086
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096







+
+
+







}

gint motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;
    int shift, ctrl, alt, x, y, button;

    /* Remember the timestamp. */
    inst->input_event_time = event->time;

    show_mouseptr(inst, 1);

    shift = event->state & GDK_SHIFT_MASK;
    ctrl = event->state & GDK_CONTROL_MASK;
    alt = event->state & GDK_MOD1_MASK;
    if (event->state & GDK_BUTTON1_MASK)
	button = MBT_LEFT;
1387
1388
1389
1390
1391
1392
1393
1394

1395
1396
1397
1398
1399
1400
1401
1397
1398
1399
1400
1401
1402
1403

1404
1405
1406
1407
1408
1409
1410
1411







-
+







	inst->pasteout_data = NULL;
    } else {
	inst->pasteout_data =
	    sresize(inst->pasteout_data, inst->pasteout_data_len, char);
    }

    if (gtk_selection_owner_set(inst->area, GDK_SELECTION_PRIMARY,
				GDK_CURRENT_TIME)) {
				inst->input_event_time)) {
	gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				 GDK_SELECTION_TYPE_STRING, 1);
	if (inst->pasteout_data_ctext)
	    gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				     compound_text_atom, 1);
	if (inst->pasteout_data_utf8)
	    gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
1423
1424
1425
1426
1427
1428
1429

1430
1431
1432
1433
1434
1435
1436
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447







+







			       inst->pasteout_data, inst->pasteout_data_len);
}

gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
		     gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;

    term_deselect(inst->term);
    if (inst->pasteout_data)
	sfree(inst->pasteout_data);
    if (inst->pasteout_data_ctext)
	sfree(inst->pasteout_data_ctext);
    if (inst->pasteout_data_utf8)
	sfree(inst->pasteout_data_utf8);
1457
1458
1459
1460
1461
1462
1463
1464


1465
1466
1467
1468
1469
1470
1471


1472
1473
1474
1475
1476
1477
1478
1468
1469
1470
1471
1472
1473
1474

1475
1476
1477
1478
1479
1480
1481
1482

1483
1484
1485
1486
1487
1488
1489
1490
1491







-
+
+






-
+
+







	 * First we attempt to retrieve the selection as a UTF-8
	 * string (which we will convert to the correct code page
	 * before sending to the session, of course). If that
	 * fails, selection_received() will be informed and will
	 * fall back to an ordinary string.
	 */
	gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			      utf8_string_atom, GDK_CURRENT_TIME);
			      utf8_string_atom,
			      inst->input_event_time);
    } else {
	/*
	 * If we're in direct-to-font mode, we disable UTF-8
	 * pasting, and go straight to ordinary string data.
	 */
	gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			      GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
			      GDK_SELECTION_TYPE_STRING,
			      inst->input_event_time);
    }
}

gint idle_paste_func(gpointer data);   /* forward ref */

void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
			guint time, gpointer data)
1487
1488
1489
1490
1491
1492
1493
1494


1495
1496
1497
1498
1499
1500
1501
1502
1503
1504


1505
1506
1507
1508
1509
1510
1511
1500
1501
1502
1503
1504
1505
1506

1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517

1518
1519
1520
1521
1522
1523
1524
1525
1526







-
+
+









-
+
+








    if (seldata->target == utf8_string_atom && seldata->length <= 0) {
	/*
	 * Failed to get a UTF-8 selection string. Try compound
	 * text next.
	 */
	gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			      compound_text_atom, GDK_CURRENT_TIME);
			      compound_text_atom,
			      inst->input_event_time);
	return;
    }

    if (seldata->target == compound_text_atom && seldata->length <= 0) {
	/*
	 * Failed to get UTF-8 or compound text. Try an ordinary
	 * string.
	 */
	gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			      GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
			      GDK_SELECTION_TYPE_STRING,
			      inst->input_event_time);
	return;
    }

    /*
     * Any other failure should just go foom.
     */
    if (seldata->length <= 0 ||
1525
1526
1527
1528
1529
1530
1531
1532


1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546

1547
1548
1549
1550
1551
1552
1553
1554
1555







-
+
+







	tp.nitems = seldata->length;
	ret = Xutf8TextPropertyToTextList(GDK_DISPLAY(), &tp, &list, &count);
	if (ret != 0 || count != 1) {
	    /*
	     * Compound text failed; fall back to STRING.
	     */
	    gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
				  GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
				  GDK_SELECTION_TYPE_STRING,
				  inst->input_event_time);
	    return;
	}
	text = list[0];
	length = strlen(list[0]);
	charset = CS_UTF8;
	free_list_required = 1;
    } else {